Project

jsdj

0.0
No commit activity in last 3 years
No release in over 3 years
A unix tool to execute javascript on a headless browser
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 0.1
~> 10.3
~> 3.2
~> 1.3

Runtime

 Project Readme

jsdj: Remix your javascript

Gem Version Build Status Bitdeli Badge License

What is this?

Jsdj was purpose built for Flok to allow for macros within javascript code that look like traditional javascript code.

How to use it

djc = Jsdj.new do |dj|
  #When ever the function puts(...) is written in javascript,
  #It will be replaced by what ever is returned within this
  #block. i.e. makes the function call an inlined macro
  dj.function :puts do |params|
    raise "must have one function argument" if params.length != 1
    raise "argument must be a string literal" if params[0].class != Jsdj::JSStringLiteral
  end
end

#Given a js src string, jsdj will return a js src string
#that contains modifications
result = djc.compile(src)

Create a function macro

Jsdj can parse javascript and take any function calls of a certain name and replace them with your specified macro. When you get arguments for a function in Jsdj, the arguments have a type. E.g. JSStringLiteral

dj.function :puts do |params|
  raise "argument must be a string literal" if params[0].class != Jsdj::JSStringLiteral
end
  • Supported Types
    • JSStringLiteral - A javascript string literal in quotes (single or double), e.g. foo("bar")
      • value contains the full string as a ruby string
    • JSNumber - A number
      • value contains the value as a number
    • JSOther - Some other kind of expression, either mixed, hash, etc.
  • Unsupported Types
    • anonymous functions - Attempting to use an anonymous function will result in undefined behavior. Anonymous functions can be contained within a hash. Expression

Supported platforms

  • iOS 8 (iPhone)
  • HTML5

Docs

Requirements

  • Modern nix (FreeBSD, Mac, or Linux)
  • Ruby 2.1 or Higher

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

RVM users: Run gem install jsdj

System ruby installation? Run sudo gem install jsdj


FAQ


Creator

License

flok is released under the MIT license. See LICENSE for details.