Class: SnowyOwl::OwlField
- Inherits:
-
Object
- Object
- SnowyOwl::OwlField
- Defined in:
- lib/snowy_owl/owl_field.rb
Instance Method Summary collapse
- #play(*args, &block) ⇒ Object
- #plots_scope(candidate_plots, expression) ⇒ Object
- #sequence_run(candidate_play_books) ⇒ Object
- #sequence_run_from_starting_point(candidate_plots, plots_range) ⇒ Object
Instance Method Details
#play(*args, &block) ⇒ Object
3 4 5 |
# File 'lib/snowy_owl/owl_field.rb', line 3 def play(*args, &block) instance_exec *args, &block end |
#plots_scope(candidate_plots, expression) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/snowy_owl/owl_field.rb', line 7 def plots_scope(candidate_plots, expression) return candidate_plots if expression.nil? || expression.empty? SnowyOwl.is_recovering = true plots_range = expression.match /(.*)(\.{2})(.*)/ if plots_range.nil? scope = expression.split("\n") candidate_plots.select do |plot| in_scope = scope.include?(plot['plot_name']) || scope.include?(plot['digest']) plot['is_recovering'] = in_scope in_scope end else sequence_run_from_starting_point candidate_plots, plots_range end end |
#sequence_run(candidate_play_books) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/snowy_owl/owl_field.rb', line 40 def sequence_run(candidate_play_books) candidate_plots = SnowyOwl::Plays.build_plays(candidate_play_books) expression = ENV['PLOTS_SCOPE'] candidate_plots = plots_scope(candidate_plots, expression) candidate_plots.each do |plot| plot_name = plot['plot_name'] digest = plot['digest'] is_recovering = plot['is_recovering'] SnowyOwl::Persist.recover_state digest if SnowyOwl.is_recovering && is_recovering SnowyOwl::Persist.persist_state digest if SnowyOwl.is_persisting instance_exec plot_name, &SnowyOwl::Plots.plot(plot_name) end end |
#sequence_run_from_starting_point(candidate_plots, plots_range) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/snowy_owl/owl_field.rb', line 23 def sequence_run_from_starting_point(candidate_plots, plots_range) starting_point = plots_range[1] range_type = plots_range[2] ending_point = plots_range[3] in_scope = false candidate_plots.each_with_object([]) do |plot, acc| plot_name = plot['plot_name'] plot_digest = plot['digest'] in_scope = true if plot_name == starting_point || plot_digest == starting_point if in_scope plot['is_recovering'] = acc.size == 0 acc << plot end in_scope = false if plot_name == ending_point || plot_digest == ending_point end end |