Class: LookbookVisualTester::ScenarioFinder
- Defined in:
- lib/lookbook_visual_tester/scenario_finder.rb
Instance Attribute Summary collapse
-
#fuzze ⇒ Object
readonly
Returns the value of attribute fuzze.
-
#previews ⇒ Object
readonly
Returns the value of attribute previews.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(search, fuzzy: true, previews: Lookbook.previews) ⇒ ScenarioFinder
constructor
A new instance of ScenarioFinder.
- #matched_previews ⇒ Object
- #regex ⇒ Object
Methods inherited from Service
Constructor Details
#initialize(search, fuzzy: true, previews: Lookbook.previews) ⇒ ScenarioFinder
Returns a new instance of ScenarioFinder.
8 9 10 11 12 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 8 def initialize(search, fuzzy: true, previews: Lookbook.previews) @search = search @fuzzy = fuzzy @previews = previews end |
Instance Attribute Details
#fuzze ⇒ Object (readonly)
Returns the value of attribute fuzze.
6 7 8 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 6 def fuzze @fuzze end |
#previews ⇒ Object (readonly)
Returns the value of attribute previews.
6 7 8 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 6 def previews @previews end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
6 7 8 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 6 def search @search end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 22 def call return nil if search.nil? || search == '' || previews.empty? previews.each do |preview| preview.scenarios.each do |scenario| return ScenarioRun.new(scenario) if scenario.name.downcase.include?(search.downcase) end end nil end |
#matched_previews ⇒ Object
18 19 20 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 18 def matched_previews @matched_previews ||= previews.select { |preview| regex.match?(preview.name.downcase) } end |
#regex ⇒ Object
14 15 16 |
# File 'lib/lookbook_visual_tester/scenario_finder.rb', line 14 def regex @regex = Regexp.new(search.chars.join('.*'), Regexp::IGNORECASE) end |