Class: InspecRspecJson

Inherits:
InspecRspecMiniJson show all
Defined in:
lib/inspec/rspec_json_formatter.rb

Overview

rubocop:disable Metrics/ClassLength

Direct Known Subclasses

InspecRspecCli, InspecRspecJUnit

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from InspecRspecMiniJson

#dump_summary

Constructor Details

#initialize(*args) ⇒ InspecRspecJson

Returns a new instance of InspecRspecJson.



113
114
115
116
117
118
# File 'lib/inspec/rspec_json_formatter.rb', line 113

def initialize(*args)
  super(*args)
  @profiles = []
  @profiles_info = nil
  @backend = nil
end

Instance Attribute Details

#backend=(value) ⇒ Object (writeonly)

Sets the attribute backend

Parameters:

  • value

    the value to set the attribute backend to.



111
112
113
# File 'lib/inspec/rspec_json_formatter.rb', line 111

def backend=(value)
  @backend = value
end

Instance Method Details

#add_profile(profile) ⇒ Object

Called by the runner during example collection.



121
122
123
# File 'lib/inspec/rspec_json_formatter.rb', line 121

def add_profile(profile)
  @profiles.push(profile)
end

#stop(notification) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/inspec/rspec_json_formatter.rb', line 125

def stop(notification)
  super(notification)

  @output_hash[:other_checks] = examples_without_controls
  @output_hash[:profiles] = profiles_info
  @output_hash[:platform] = {
    name: os(:name),
    release: os(:release),
  }

  examples_with_controls.each do |example|
    control = example2control(example)
    move_example_into_control(example, control)
  end
end