Class: Fitting::Debug
- Inherits:
-
Object
- Object
- Fitting::Debug
- Defined in:
- lib/fitting/debug.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#host ⇒ Object
Returns the value of attribute host.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(host, method, path, code, content_type) ⇒ Debug
constructor
A new instance of Debug.
Constructor Details
#initialize(host, method, path, code, content_type) ⇒ Debug
Returns a new instance of Debug.
5 6 7 8 9 10 11 |
# File 'lib/fitting/debug.rb', line 5 def initialize(host, method, path, code, content_type) @host = host @method = method @path = path @status = code.to_s @content_type = content_type end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
3 4 5 |
# File 'lib/fitting/debug.rb', line 3 def content_type @content_type end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/fitting/debug.rb', line 3 def host @host end |
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/fitting/debug.rb', line 3 def method @method end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/fitting/debug.rb', line 3 def path @path end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/fitting/debug.rb', line 3 def status @status end |
Class Method Details
.report(index, next_steps_first, res_logs) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fitting/debug.rb', line 25 def self.report(index, next_steps_first, res_logs) return {} if index.nil? combinations = [] next_steps_first.next_steps.each do |next_step| combinations.push( next_step.debug_report(index) ) end res_debug = { "json_schema" => next_steps_first.to_hash, "jsons" => res_logs, "valid_jsons" => next_steps_first.logs, "index_before" => next_steps_first.index_before - index, "index_medium" => next_steps_first.index_medium - index, "index_after" => next_steps_first.index_after - index, "res_before" => next_steps_first.res_before.map{|r| r ? r : "null"}[index..-1], "res_medium" => next_steps_first.res_medium.map{|r| r ? r : "null"}[index..-1], "res_after" => next_steps_first.res_after.map{|r| r ? r : "null"}[index..-1], "combinations" => combinations } end |
.save!(docs, yaml) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fitting/debug.rb', line 13 def self.save!(docs, yaml) return unless yaml['Debug'] yaml['Debug'].map do |action| debug = new(action['host'], action['method'], action['path'], action['code'], action['content-type']) res = Fitting::Doc.debug(docs, debug) index = res.next_steps.first.index_before next_steps_first = res.next_steps.first res_debug = report(index, next_steps_first, res.logs) File.open('coverage/.fitting.debug.yml', 'w') { |file| file.write(YAML.dump(res_debug)) } end end |