Class: Wally::SearchFeatures
- Inherits:
-
Object
- Object
- Wally::SearchFeatures
- Defined in:
- lib/wally/search_features.rb
Instance Method Summary collapse
- #find(query) ⇒ Object
-
#initialize(lists_features) ⇒ SearchFeatures
constructor
A new instance of SearchFeatures.
Constructor Details
#initialize(lists_features) ⇒ SearchFeatures
Returns a new instance of SearchFeatures.
5 6 7 |
# File 'lib/wally/search_features.rb', line 5 def initialize lists_features @lists_features = lists_features end |
Instance Method Details
#find(query) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wally/search_features.rb', line 9 def find(query) searchables = [] @lists_features.features.each do |feature| feature_text = feature.gherkin["name"] if feature.gherkin["tags"] feature_text += " " + feature.gherkin["tags"].map { |tag| tag["name"] }.join(" ") end if feature.gherkin["description"] feature_text += " " + feature.gherkin["description"] end feature_data = OpenStruct.new feature_data.feature = feature.gherkin feature_data.text = feature_text searchables << feature_data if feature.gherkin["elements"] feature.gherkin["elements"].each do |element| element_text = [element["name"]] if element["steps"] element_text << element["steps"].map { |s| s["name"] } end if element["tags"] element_text << element["tags"].map { |t| t["name"] } end scenario_data = OpenStruct.new scenario_data.feature = feature.gherkin scenario_data.scenario = element scenario_data.text = element_text.join(" ") searchables << scenario_data end end end searches_text = Komainu::SearchesText.new(searchables) searches_text.search(query[:query]) end |