Sha256: ad4ad2c59deea1faa06f06e5b427a9a0015c37009e8572e677b16f7801001684

Contents?: true

Size: 1.67 KB

Versions: 17

Compression:

Stored size: 1.67 KB

Contents

module Specinfra
  module Configuration
    class << self
      VALID_OPTIONS_KEYS = [
        :backend,
        :env,
        :path,
        :shell,
        :interactive_shell,
        :login_shell,
        :pre_command,
        :stdout,
        :stderr,
        :exit_status,
        :sudo_path,
        :disable_sudo,
        :sudo_options,
        :docker_container_create_options,
        :docker_container_exec_options,
        :docker_image,
        :docker_url,
        :lxc,
        :request_pty,
        :ssh_options,
        :ssh_without_env,
        :dockerfile_finalizer,
        :telnet_options,
        :jail_name,
      ].freeze

      def defaults
        VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
      end

      # Define os method explicitly to avoid stack level
      # too deep caused by Helper::DetectOS#os
      def os(value=nil)
        @os = value if value
        if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
          @os = RSpec.configuration.os
        end
        @os
      end

      def method_missing(meth, val=nil)
        key = meth.to_s
        key.gsub!(/=$/, '')
        ret = nil
        begin
          if ! val.nil?
            instance_variable_set("@#{key}", val)
            RSpec.configuration.send(:"#{key}=", val) if defined?(RSpec)
          end
          if instance_variable_defined?("@#{key}")
            ret = instance_variable_get("@#{key}")
          end
        rescue NameError
          ret = nil
        ensure
          if ret.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(key)
            ret = RSpec.configuration.send(key)
          end
        end
        ret
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
specinfra-2.82.2 lib/specinfra/configuration.rb
specinfra-2.82.1 lib/specinfra/configuration.rb
specinfra-2.82.0 lib/specinfra/configuration.rb
specinfra-2.81.0 lib/specinfra/configuration.rb
specinfra-2.80.0 lib/specinfra/configuration.rb
specinfra-2.79.0 lib/specinfra/configuration.rb
specinfra-2.78.2 lib/specinfra/configuration.rb
specinfra-2.78.1 lib/specinfra/configuration.rb
specinfra-2.78.0 lib/specinfra/configuration.rb
specinfra-2.77.3 lib/specinfra/configuration.rb
specinfra-2.77.2 lib/specinfra/configuration.rb
specinfra-2.77.1 lib/specinfra/configuration.rb
specinfra-2.77.0 lib/specinfra/configuration.rb
specinfra-2.76.9 lib/specinfra/configuration.rb
specinfra-2.76.8 lib/specinfra/configuration.rb
specinfra-2.76.7 lib/specinfra/configuration.rb
specinfra-2.76.6 lib/specinfra/configuration.rb