Sha256: 2f6df0cd6ce680da1af3a7b297c7c512f83f2e43d9971f887e51298e78df0b28

Contents?: true

Size: 1.43 KB

Versions: 11

Compression:

Stored size: 1.43 KB

Contents

module Specinfra
  module Configuration
    class << self
      VALID_OPTIONS_KEYS = [
        :backend,
        :env,
        :path,
        :shell,
        :pre_command,
        :stdout,
        :stderr,
        :exit_status,
        :sudo_path,
        :disable_sudo,
        :sudo_options,
        :docker_image,
        :docker_url,
        :lxc,
        :request_pty,
        :ssh_options,
        :dockerfile_finalizer,
        :telnet_options,
      ].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 Helpet::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
          ret = instance_variable_get("@#{key}")
        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

11 entries across 11 versions & 1 rubygems

Version Path
specinfra-2.17.1 lib/specinfra/configuration.rb
specinfra-2.17.0 lib/specinfra/configuration.rb
specinfra-2.16.0 lib/specinfra/configuration.rb
specinfra-2.15.2 lib/specinfra/configuration.rb
specinfra-2.15.1 lib/specinfra/configuration.rb
specinfra-2.15.0 lib/specinfra/configuration.rb
specinfra-2.14.4 lib/specinfra/configuration.rb
specinfra-2.14.3 lib/specinfra/configuration.rb
specinfra-2.14.2 lib/specinfra/configuration.rb
specinfra-2.14.1 lib/specinfra/configuration.rb
specinfra-2.14.0 lib/specinfra/configuration.rb