Sha256: ac937a1768bee206f7938137488af6d37970394a40babd4e808b5335e048e699

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

require 'chef-config/config'
require 'chef-config/workstation_config_loader'
require 'socket'

module Ridley::Chef
  class Config
    # Create a new Chef Config object.
    #
    # @param [#to_s] path
    #   the path to the configuration file
    # @param [Hash] options
    def initialize(path, options = {})
      ChefConfig::WorkstationConfigLoader.new(path).load
      ChefConfig::Config.merge!(options)
      ChefConfig::Config.export_proxies # Set proxy settings as environment variables
    end

    # Keep defaults that aren't in ChefConfig::Config
    def cookbook_copyright(*args, &block)
      ChefConfig::Config.cookbook_copyright(*args, &block) || 'YOUR_NAME'
    end
    def cookbook_email(*args, &block)
      ChefConfig::Config.cookbook_email(*args, &block) || 'YOUR_EMAIL'
    end
    def cookbook_license(*args, &block)
      ChefConfig::Config.cookbook_license(*args, &block) || 'reserved'
    end

    # The configuration as a hash
    def to_hash
      ChefConfig::Config.save(true)
    end
    # Load from a file
    def self.from_file(file)
      new(file)
    end

    # Behave just like ChefConfig::Config in general
    def method_missing(name, *args, &block)
      ChefConfig::Config.send(name, *args, &block)
    end
    def respond_to_missing?(name)
      ChefConfig::Config.respond_to?(name)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ridley-5.1.1 lib/ridley/chef/config.rb
ridley-5.1.0 lib/ridley/chef/config.rb
ridley-5.0.0 lib/ridley/chef/config.rb
ridley-4.6.1 lib/ridley/chef/config.rb
ridley-4.6.0 lib/ridley/chef/config.rb
ridley-4.5.1 lib/ridley/chef/config.rb
ridley-4.5.0 lib/ridley/chef/config.rb
ridley-4.4.3 lib/ridley/chef/config.rb
ridley-4.4.2 lib/ridley/chef/config.rb