Class: Fitting::Report::Actions
- Inherits:
-
Object
- Object
- Fitting::Report::Actions
- Defined in:
- lib/fitting/report/actions.rb
Instance Method Summary collapse
- #cram_into_the_appropriate_action(test) ⇒ Object
- #details(prefix) ⇒ Object
-
#initialize(prefix, tomogram_json_path) ⇒ Actions
constructor
A new instance of Actions.
- #is_there_a_suitable_action?(test) ⇒ Boolean
- #join(tests) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(prefix, tomogram_json_path) ⇒ Actions
Returns a new instance of Actions.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fitting/report/actions.rb', line 6 def initialize(prefix, tomogram_json_path) actions = Tomograph::Tomogram.new( prefix: prefix, tomogram_json_path: tomogram_json_path ) @actions = [] actions.to_a.map do |action| @actions.push(Fitting::Report::Action.new(action)) end end |
Instance Method Details
#cram_into_the_appropriate_action(test) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/fitting/report/actions.rb', line 38 def cram_into_the_appropriate_action(test) @actions.map do |action| if test.method == action.method && action.path_match(test.path) action.add_test(test) return end end end |
#details(prefix) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fitting/report/actions.rb', line 47 def details(prefix) { tests_without_actions: prefix.tests.without_actions, actions_details: @actions.map { |a| {method: a.method, path: a.path, tests_size: a.tests.size, responses: a.details} } } end |
#is_there_a_suitable_action?(test) ⇒ Boolean
30 31 32 33 34 35 36 |
# File 'lib/fitting/report/actions.rb', line 30 def is_there_a_suitable_action?(test) @actions.map do |action| return true if test.method == action.method && action.path_match(test.path) end false end |
#join(tests) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fitting/report/actions.rb', line 21 def join(tests) tests.to_a.map do |test| if is_there_a_suitable_action?(test) cram_into_the_appropriate_action(test) test.mark_action end end end |
#to_a ⇒ Object
17 18 19 |
# File 'lib/fitting/report/actions.rb', line 17 def to_a @actions end |