Class: JSLint
- Inherits:
-
Object
- Object
- JSLint
- Defined in:
- lib/js_lint.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ JSLint
constructor
A new instance of JSLint.
- #tree ⇒ Object
Constructor Details
#initialize(source) ⇒ JSLint
Returns a new instance of JSLint.
6 7 8 |
# File 'lib/js_lint.rb', line 6 def initialize source @source = source end |
Instance Method Details
#tree ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/js_lint.rb', line 10 def tree Rhino::Context.open do |context| ["fulljslint", "options", "json2"].each do |file_name| context.load(File.join(File.dirname(__FILE__),"#{file_name}.js")) end context['source'] = @source code = " JSLINT(source.toString(), options);\n JSON.stringify(JSLINT.tree, ['value', 'arity', 'name', 'first', 'second', 'third', 'block', 'else'], 4);\n" JSON.parse(context.eval(code).to_str, :max_nesting => 100) end end |