lib/cupper/environment.rb in cupper-0.1.3 vs lib/cupper/environment.rb in cupper-0.2.0

- old
+ new

@@ -1,9 +1,10 @@ +require 'colorize' require "pathname" require "cupper/cupperfile" require "cupper/version" -require 'colorize' +require "cupper/errors" module Cupper class Environment # The `cwd` that this environment represents attr_reader :cwd @@ -31,10 +32,11 @@ def check_env(ex, root_path) begin raise ex if !root_path rescue ex => ex puts "#{ex.message}".red + exit end end # Initializes a new environment with the given options. The options # is a hash where the main available key is `cwd`, which defines where @@ -99,24 +101,10 @@ # @return [String] def inspect "#<#{self.class}: #{@cwd}>".encode('external') end - def config_loader - return @config_loader if @config_loader - - root_cupperfile = nil - if root_path - root_cupperfile = find_cupperfile(root_path, @cupperfile_name) - end - - @config_loader = Config::Loader.new( - Config::VERSIONS, Config::VERSIONS_ORDER) - @config_loader.set(:root, root_cupperfile) if root_cupperfile - @config_loader - end - def environment(cupperfile, **opts) path = File.expand_path(cupperfile, root_path) file = File.basename(path) path = File.dirname(path) @@ -158,14 +146,14 @@ def unload hook(:environment_unload) end def cupperfile - @cupperfile ||= cupperfile.new(config_loader, [:home, :root]) + @cupperfile ||= Cupper::Cupperfile.new(find_cupperfile(@root_path)) end def find_cupperfile(search_path, filenames=nil) - filenames ||= ["cupperfile", "cupperfile"] + filenames ||= ["Cupperfile", "cupperfile"] filenames.each do |cupperfile| current_path = search_path.join(cupperfile) return current_path if current_path.file? end