Class: Lucid::Parser::TDLBuilder

Inherits:
Object
  • Object
show all
Includes:
Gherkin::Rubify
Defined in:
lib/lucid/tdl_builder.rb

Overview

The TDL Builder conforms to the Gherkin event API.

Defined Under Namespace

Classes: BackgroundBuilder, Builder, FeatureBuilder, ScenarioBuilder, ScenarioOutlineBuilder, StepBuilder

Instance Method Summary collapse

Constructor Details

#initialize(path = 'UNKNOWN-FILE') ⇒ TDLBuilder

Returns a new instance of TDLBuilder.



12
13
14
# File 'lib/lucid/tdl_builder.rb', line 12

def initialize(path = 'UNKNOWN-FILE')
  @path = path
end

Instance Method Details

#background(node) ⇒ Object



33
34
35
36
37
# File 'lib/lucid/tdl_builder.rb', line 33

def background(node)
  builder = BackgroundBuilder.new(file, node)
  @feature_builder.background_builder = builder
  @current = builder
end

#eofObject



68
69
# File 'lib/lucid/tdl_builder.rb', line 68

def eof
end

#examples(examples) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/lucid/tdl_builder.rb', line 51

def examples(examples)
  examples_fields = [
    AST::Location.new(file, examples.line),
    AST::Comment.new(examples.comments.map{|comment| comment.value}.join("\n")),
    examples.keyword,
    examples.name,
    examples.description,
    matrix(examples.rows)
  ]
  @current.add_examples examples_fields, examples
end

#feature(node) ⇒ Object



29
30
31
# File 'lib/lucid/tdl_builder.rb', line 29

def feature(node)
  @feature_builder = FeatureBuilder.new(file, node)
end

#language=(language) ⇒ Object



21
22
23
# File 'lib/lucid/tdl_builder.rb', line 21

def language=(language)
  @language = language
end

#resultObject



16
17
18
19
# File 'lib/lucid/tdl_builder.rb', line 16

def result
  return nil unless @feature_builder
  @feature_builder.result(language)
end

#scenario(node) ⇒ Object



39
40
41
42
43
# File 'lib/lucid/tdl_builder.rb', line 39

def scenario(node)
  builder = ScenarioBuilder.new(file, node)
  @feature_builder.add_child builder
  @current = builder
end

#scenario_outline(node) ⇒ Object



45
46
47
48
49
# File 'lib/lucid/tdl_builder.rb', line 45

def scenario_outline(node)
  builder = ScenarioOutlineBuilder.new(file, node)
  @feature_builder.add_child builder
  @current = builder
end

#step(node) ⇒ Object



63
64
65
66
# File 'lib/lucid/tdl_builder.rb', line 63

def step(node)
  builder = StepBuilder.new(file, node)
  @current.add_child builder
end

#syntax_error(state, event, legal_events, line) ⇒ Object



71
72
73
# File 'lib/lucid/tdl_builder.rb', line 71

def syntax_error(state, event, legal_events, line)
  # raise "SYNTAX ERROR"
end

#uri(uri) ⇒ Object



25
26
27
# File 'lib/lucid/tdl_builder.rb', line 25

def uri(uri)
  @path = uri
end