Module: Lkml
- Defined in:
- lib/lkml.rb,
lib/lkml/cli.rb,
lib/lkml/keys.rb,
lib/lkml/tree.rb,
lib/lkml/lexer.rb,
lib/lkml/utils.rb,
lib/lkml/parser.rb,
lib/lkml/simple.rb,
lib/lkml/tokens.rb,
lib/lkml/version.rb,
lib/lkml/visitors.rb
Defined Under Namespace
Modules: CLI, Keys, Simple, Tokens, Tree, Utils, Visitors
Classes: AttributeError, CommaSeparatedValues, Lexer, Parser
Constant Summary
collapse
- DELIMITER =
". "
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.dump(obj, io: nil) ⇒ Object
Also known as:
generate
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/lkml.rb', line 38
def dump(obj, io: nil)
tree = Simple::DictParser.new.parse(obj)
result = tree.to_s
if io
io.write(result)
nil
else
result
end
end
|
.load(stream) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/lkml.rb', line 24
def load(stream)
text =
case stream
when String then stream
else
raise TypeError, "Input stream must be a string or file object." unless stream.respond_to?(:read)
stream.read
end
tree = parse(text)
Simple::DictVisitor.new.visit(tree)
end
|
.parse(text) ⇒ Object
18
19
20
21
22
|
# File 'lib/lkml.rb', line 18
def parse(text)
lexer = Lexer.new(text)
tokens = lexer.scan
Parser.new(tokens).parse
end
|