class InspecPlugins::TKInfo::Input
Attributes
Public Instance Methods
fetch(_profile_name, input)
click to toggle source
Fetch method used for Input
plugins
# File lib/inspec-tkinfo/input.rb, line 20 def fetch(_profile_name, input) return nil unless valid_plugin_input?(input) raise "Plugin can only be run via TestKitchen" unless inside_testkitchen? case input when "KITCHEN_INSTANCE_NAME" kitchen_instance.name when "KITCHEN_SUITE_NAME" kitchen_instance.suite.name when "KITCHEN_PLATFORM_NAME" kitchen_instance.platform.name end end
kitchen_instance()
click to toggle source
# File lib/inspec-tkinfo/input.rb, line 10 def kitchen_instance require "binding_of_caller" @kitchen_instance ||= binding.callers.find { |b| b.frame_description == "verify_action" }.receiver end
Private Instance Methods
inside_testkitchen?()
click to toggle source
Check if this is called from within TestKitchen
# File lib/inspec-tkinfo/input.rb, line 50 def inside_testkitchen? !! defined?(::Kitchen) end
valid_plugin_input?(input)
click to toggle source
Verify if input is valid for this plugin
# File lib/inspec-tkinfo/input.rb, line 41 def valid_plugin_input?(input) %w{ KITCHEN_INSTANCE_NAME KITCHEN_SUITE_NAME KITCHEN_PLATFORM_NAME }.include? input end