Class: InspecRspecJson
- Inherits:
-
InspecRspecMiniJson
- Object
- RSpec::Core::Formatters::JsonFormatter
- InspecRspecMiniJson
- InspecRspecJson
- Defined in:
- lib/inspec/rspec_json_formatter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#backend ⇒ Object
writeonly
Sets the attribute backend.
Instance Method Summary collapse
- #add_profile(profile) ⇒ Object
- #dump_one_example(example, control) ⇒ Object
- #dump_summary(summary) ⇒ Object
-
#initialize(*args) ⇒ InspecRspecJson
constructor
A new instance of InspecRspecJson.
- #profile_info(profile) ⇒ Object
Methods inherited from InspecRspecMiniJson
Constructor Details
#initialize(*args) ⇒ InspecRspecJson
Returns a new instance of InspecRspecJson.
78 79 80 81 82 |
# File 'lib/inspec/rspec_json_formatter.rb', line 78 def initialize(*args) super(*args) @profiles = [] @backend = nil end |
Instance Attribute Details
#backend=(value) ⇒ Object (writeonly)
Sets the attribute backend
76 77 78 |
# File 'lib/inspec/rspec_json_formatter.rb', line 76 def backend=(value) @backend = value end |
Instance Method Details
#add_profile(profile) ⇒ Object
84 85 86 |
# File 'lib/inspec/rspec_json_formatter.rb', line 84 def add_profile(profile) @profiles.push(profile) end |
#dump_one_example(example, control) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/inspec/rspec_json_formatter.rb', line 88 def dump_one_example(example, control) control[:results] ||= [] example.delete(:id) example.delete(:profile_id) control[:results].push(example) end |
#dump_summary(summary) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/inspec/rspec_json_formatter.rb', line 100 def dump_summary(summary) super(summary) examples = @output_hash.delete(:controls) profiles = Hash[@profiles.map { |x| profile_info(x) }] missing = [] examples.each do |example| control = example2control(example, profiles) next missing.push(example) if control.nil? dump_one_example(example, control) end @output_hash[:profiles] = profiles @output_hash[:other_checks] = missing end |
#profile_info(profile) ⇒ Object
95 96 97 98 |
# File 'lib/inspec/rspec_json_formatter.rb', line 95 def profile_info(profile) info = profile.info.dup [info[:name], info] end |