Class: Inspec::Input::Event
- Inherits:
-
Object
- Object
- Inspec::Input::Event
- Defined in:
- lib/inspec/input.rb
Overview
TODO: break this out to its own file under inspec/input? Information about how the input obtained its value. Each time it changes, an Input::Event is added to the #events array.
Constant Summary collapse
- EVENT_PROPERTIES =
[ :action, # :create, :set, :fetch :provider, # Name of the plugin :priority, # Priority of this plugin for resolving conflicts. 1-100, higher numbers win. :value, # New value, if provided. :file, # File containing the input-changing action, if known :line, # Line in file containing the input-changing action, if known :hit, # if action is :fetch, true if the remote source had the input ].freeze
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #diagnostic_string ⇒ Object
-
#initialize(properties = {}) ⇒ Event
constructor
A new instance of Event.
- #to_h ⇒ Object
- #value_has_been_set? ⇒ Boolean
Constructor Details
#initialize(properties = {}) ⇒ Event
Returns a new instance of Event.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/inspec/input.rb', line 62 def initialize(properties = {}) @value_has_been_set = false properties.each do |prop_name, prop_value| if EVENT_PROPERTIES.include? prop_name # OK, save the property send((prop_name.to_s + "=").to_sym, prop_value) else raise "Unrecognized property to Input::Event: #{prop_name}" end end end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
60 61 62 |
# File 'lib/inspec/input.rb', line 60 def value @value end |
Class Method Details
.probe_stack ⇒ Object
94 95 96 97 98 |
# File 'lib/inspec/input.rb', line 94 def self.probe_stack frames = caller_locations(2, 40) frames.reject! { |f| f.path && f.path.include?("/lib/inspec/") } frames.first end |
Instance Method Details
#diagnostic_string ⇒ Object
84 85 86 |
# File 'lib/inspec/input.rb', line 84 def diagnostic_string to_h.reject { |_, val| val.nil? }.to_a.map { |pair| "#{pair[0]}: '#{pair[1]}'" }.join(", ") end |
#to_h ⇒ Object
88 89 90 91 92 |
# File 'lib/inspec/input.rb', line 88 def to_h EVENT_PROPERTIES.each_with_object({}) do |prop, hash| hash[prop] = send(prop) end end |
#value_has_been_set? ⇒ Boolean
80 81 82 |
# File 'lib/inspec/input.rb', line 80 def value_has_been_set? @value_has_been_set end |