Class: Gurke::Builder
- Inherits:
-
Object
- Object
- Gurke::Builder
- Defined in:
- lib/gurke/builder.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
Instance Method Summary collapse
- #background(raw) ⇒ Object
- #eof ⇒ Object
- #feature(raw) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #load(files) ⇒ Object
- #scenario(raw) ⇒ Object
- #step(raw) ⇒ Object
- #uri(raw) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gurke/builder.rb', line 7 def initialize # @options = options # @files = files.map do |file| # split = file.split(':') # [split[0], split[1..-1].map{|l| Integer(l) }] # end @language = 'en' @parser = Gherkin::Parser::Parser.new( self, true, 'root', false, @language) end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
5 6 7 |
# File 'lib/gurke/builder.rb', line 5 def features @features end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
5 6 7 |
# File 'lib/gurke/builder.rb', line 5 def keywords @keywords end |
Instance Method Details
#background(raw) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/gurke/builder.rb', line 57 def background(raw) @context = Background.new @file, raw.line, raw @type = nil @feature.backgrounds << @context end |
#eof ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/gurke/builder.rb', line 81 def eof(*) @features.reject!{|f| f.scenarios.empty? } @feature = nil @scenario = nil @context = nil @type = nil @file = nil end |
#feature(raw) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/gurke/builder.rb', line 47 def feature(raw) = raw..map{|t| Tag.new @file, t.line, t } @feature = Feature.new(@file, raw.line, , raw) @scenario = nil @type = nil features << @feature end |
#load(files) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gurke/builder.rb', line 31 def load(files) FeatureList.new.tap do |fl| @features = fl files.each do |file| @parser.parse File.read(file), file, 0 end @features = nil end end |
#scenario(raw) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gurke/builder.rb', line 64 def scenario(raw) = raw..map{|t| Tag.new @file, t.line, t } += features.last. @scenario = Scenario.new @feature, @file, raw.line, , raw @context = @scenario @type = nil @feature.scenarios << @scenario #unless filtered?(@scenario) end |
#step(raw) ⇒ Object
75 76 77 78 79 |
# File 'lib/gurke/builder.rb', line 75 def step(raw) @type = lookup_type raw.keyword.strip @context.steps << Step.new(@file, raw.line, @type, raw) end |
#uri(raw) ⇒ Object
43 44 45 |
# File 'lib/gurke/builder.rb', line 43 def uri(raw) @file = raw.to_s end |