lib/berkshelf.rb in berkshelf-2.0.0.beta vs lib/berkshelf.rb in berkshelf-2.0.0

- old
+ new

@@ -1,9 +1,10 @@ require 'active_support/core_ext' require 'archive/tar/minitar' require 'celluloid' require 'chozo/core_ext' +require 'digest/md5' require 'forwardable' require 'hashie' require 'json' require 'pathname' require 'ridley' @@ -13,41 +14,19 @@ require 'uri' require 'zlib' require 'berkshelf/core_ext' require 'berkshelf/errors' -require 'berkshelf/test' if ENV['RUBY_ENV'] == 'test' -require 'berkshelf/version' require 'thor/monkies' JSON.create_id = nil module Berkshelf DEFAULT_FILENAME = 'Berksfile'.freeze - autoload :BaseGenerator, 'berkshelf/base_generator' - autoload :Berksfile, 'berkshelf/berksfile' - autoload :CachedCookbook, 'berkshelf/cached_cookbook' - autoload :Chef, 'berkshelf/chef' - autoload :Cli, 'berkshelf/cli' - autoload :CommunityREST, 'berkshelf/community_rest' - autoload :Config, 'berkshelf/config' - autoload :CookbookGenerator, 'berkshelf/cookbook_generator' - autoload :CookbookSource, 'berkshelf/cookbook_source' - autoload :CookbookStore, 'berkshelf/cookbook_store' - autoload :Downloader, 'berkshelf/downloader' - autoload :Git, 'berkshelf/git' - autoload :InitGenerator, 'berkshelf/init_generator' - autoload :Lockfile, 'berkshelf/lockfile' - autoload :Logger, 'berkshelf/logger' - autoload :Mixin, 'berkshelf/mixin' - autoload :Resolver, 'berkshelf/resolver' - autoload :UI, 'berkshelf/ui' - - require 'berkshelf/location' - class << self + require 'berkshelf/mixin/logging' include Berkshelf::Mixin::Logging attr_accessor :ui attr_writer :cookbook_store @@ -68,21 +47,34 @@ # can be overridden by specifying a value for the ENV variable # 'BERKSHELF_PATH'. # # @return [String] def berkshelf_path - ENV["BERKSHELF_PATH"] || File.expand_path("~/.berkshelf") + ENV['BERKSHELF_PATH'] || File.expand_path('~/.berkshelf') end + # The Chef configuration file. + # + # @return [Berkshelf::Chef::Config] + def chef_config + @chef_config ||= Berkshelf::Chef::Config.load + end + + # Set the Chef configuration file. + # + # @param [Berkshelf::Chef::Config] new_config + # the new configuration file to use + attr_writer :chef_config + # @return [Logger] def logger Celluloid.logger end # @return [String] def tmp_dir - File.join(berkshelf_path, "tmp") + File.join(berkshelf_path, 'tmp') end # Creates a temporary directory within the Berkshelf path # # @return [String] @@ -91,11 +83,11 @@ FileUtils.mkdir_p(tmp_dir) Dir.mktmpdir(nil, tmp_dir) end def cookbooks_dir - File.join(berkshelf_path, "cookbooks") + File.join(berkshelf_path, 'cookbooks') end # @return [Berkshelf::CookbookStore] def cookbook_store @cookbook_store ||= CookbookStore.new(cookbooks_dir) @@ -147,6 +139,26 @@ end end end end -require 'berkshelf/formatters' +require_relative 'berkshelf/base_generator' +require_relative 'berkshelf/berksfile' +require_relative 'berkshelf/cached_cookbook' +require_relative 'berkshelf/chef' +require_relative 'berkshelf/cli' +require_relative 'berkshelf/community_rest' +require_relative 'berkshelf/cookbook_generator' +require_relative 'berkshelf/cookbook_source' +require_relative 'berkshelf/cookbook_store' +require_relative 'berkshelf/config' +require_relative 'berkshelf/downloader' +require_relative 'berkshelf/formatters' +require_relative 'berkshelf/git' +require_relative 'berkshelf/init_generator' +require_relative 'berkshelf/location' +require_relative 'berkshelf/lockfile' +require_relative 'berkshelf/logger' +require_relative 'berkshelf/resolver' +require_relative 'berkshelf/test' if ENV['RUBY_ENV'] == 'test' +require_relative 'berkshelf/ui' +require_relative 'berkshelf/version'