class Inspec::DescribeBase

Public Class Methods

new(action) click to toggle source
# File lib/inspec/describe_base.rb, line 8
def initialize(action)
  @action = action
  @checks = []
end

Public Instance Methods

describe(*args, &block) click to toggle source
# File lib/inspec/describe_base.rb, line 37
def describe(*args, &block)
  @checks.push(["describe", args, block])
end
input(input_name, options = {}) click to toggle source
# File lib/inspec/describe_base.rb, line 25
def input(input_name, options = {})
  input_with_profile_id(__profile_id, input_name, options)
end
input_object(name) click to toggle source
# File lib/inspec/describe_base.rb, line 29
def input_object(name)
  Inspec::InputRegistry.find_or_register_input(name, __profile_id)
end
method_missing(method_name, *arguments) click to toggle source
# File lib/inspec/describe_base.rb, line 33
def method_missing(method_name, *arguments)
  Inspec::DSL.method_missing_resource(inspec, method_name, *arguments)
end
one(&block) click to toggle source

Evaluate the given block and collect all checks. These will be registered with the callback function under the 'describe.one' name.

@param [Proc] ruby block containing checks (e.g. via describe) @return [nil]

# File lib/inspec/describe_base.rb, line 18
def one(&block)
  return unless block_given?

  instance_eval(&block)
  @action.call("describe.one", @checks, nil)
end

Private Instance Methods

__profile_id() click to toggle source

While this is marked private, it gets consumed during an instance_eval, so it is fully visible. The double underscore is there to discourage use - this is a private API.

# File lib/inspec/describe_base.rb, line 46
def __profile_id
  # Excavate the profile ID. The action is a Method calling __add_check on
  # a Rule whose profile ID we want
  @action.receiver.instance_variable_get(:@__profile_id)
end