Module: SyntaxTree::JSON

Defined in:
lib/syntax_tree/json.rb,
lib/syntax_tree/json/ast.rb,
lib/syntax_tree/json/format.rb,
lib/syntax_tree/json/parser.rb,
lib/syntax_tree/json/version.rb,
lib/syntax_tree/json/visitor.rb,
lib/syntax_tree/json/pretty_print.rb

Defined Under Namespace

Modules: AST Classes: Format, Parser, PrettyPrint, Visitor

Constant Summary collapse

VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.format(source, maxwidth = 80) ⇒ Object



17
18
19
20
21
# File 'lib/syntax_tree/json.rb', line 17

def format(source, maxwidth = 80)
  PrettierPrint.format(+"", maxwidth) do |q|
    parse(source).accept(Format.new(q))
  end
end

.parse(source) ⇒ Object



23
24
25
# File 'lib/syntax_tree/json.rb', line 23

def parse(source)
  Parser.new(source).parse
end

.read(filepath) ⇒ Object



27
28
29
# File 'lib/syntax_tree/json.rb', line 27

def read(filepath)
  File.read(filepath)
end