class Gherkin::Query
Public Class Methods
new()
click to toggle source
# File lib/gherkin/query.rb, line 3 def initialize @ast_node_locations = {} end
Public Instance Methods
location(ast_node_id)
click to toggle source
# File lib/gherkin/query.rb, line 11 def location(ast_node_id) return @ast_node_locations[ast_node_id] if @ast_node_locations.has_key?(ast_node_id) raise AstNodeNotLocatedException, "No location found for #{ast_node_id} }. Known: #{@ast_node_locations.keys}" end
update(message)
click to toggle source
# File lib/gherkin/query.rb, line 7 def update(message) update_feature(message.gherkin_document.feature) if message.gherkin_document end
Private Instance Methods
store_node_location(node)
click to toggle source
# File lib/gherkin/query.rb, line 61 def store_node_location(node) @ast_node_locations[node.id] = node.location end
store_nodes_location(nodes)
click to toggle source
# File lib/gherkin/query.rb, line 57 def store_nodes_location(nodes) nodes.each { |node| store_node_location(node) } end
update_background(background)
click to toggle source
# File lib/gherkin/query.rb, line 39 def update_background(background) update_steps(background.steps) end
update_feature(feature)
click to toggle source
# File lib/gherkin/query.rb, line 18 def update_feature(feature) return if feature.nil? store_nodes_location(feature.tags) feature.children.each do |child| update_rule(child.rule) if child.rule update_background(child.background) if child.background update_scenario(child.scenario) if child.scenario end end
update_rule(rule)
click to toggle source
# File lib/gherkin/query.rb, line 29 def update_rule(rule) return if rule.nil? store_nodes_location(rule.tags) rule.children.each do |child| update_background(child.background) if child.background update_scenario(child.scenario) if child.scenario end end
update_scenario(scenario)
click to toggle source
# File lib/gherkin/query.rb, line 43 def update_scenario(scenario) store_node_location(scenario) store_nodes_location(scenario.tags) update_steps(scenario.steps) scenario.examples.each do |examples| store_nodes_location(examples.tags || []) store_nodes_location(examples.table_body || []) end end
update_steps(steps)
click to toggle source
# File lib/gherkin/query.rb, line 53 def update_steps(steps) store_nodes_location(steps) end