lib/ember-cli-rails.rb in ember-cli-rails-0.1.13 vs lib/ember-cli-rails.rb in ember-cli-rails-0.2.0

- old
+ new

@@ -3,28 +3,32 @@ module EmberCLI extend self autoload :App, "ember-cli/app" autoload :Configuration, "ember-cli/configuration" - autoload :ViewHelpers, "ember-cli/view_helpers" autoload :Helpers, "ember-cli/helpers" autoload :Middleware, "ember-cli/middleware" + autoload :PathSet, "ember-cli/path_set" def configure yield configuration end def configuration Configuration.instance end - def get_app(name) - configuration.apps[name] + def app(name) + apps.fetch(name) do + fail KeyError, "#{name.inspect} app is not defined" + end end + alias_method :[], :app + def skip? - ENV["SKIP_EMBER"] + ENV["SKIP_EMBER"].present? end def prepare! @prepared ||= begin Rails.configuration.assets.paths << root.join("assets").to_s @@ -33,14 +37,11 @@ end end def enable! prepare! - - if Helpers.use_middleware? - Rails.configuration.middleware.use Middleware - end + append_middleware unless env.production? end def install_dependencies! prepare! each_app &:install_dependencies @@ -71,10 +72,16 @@ def root @root ||= Rails.root.join("tmp", "ember-cli-#{uid}") end + def env + @env ||= Helpers.current_environment.inquiry + end + + delegate :apps, to: :configuration + private def uid @uid ||= SecureRandom.uuid end @@ -82,8 +89,12 @@ def cleanup root.rmtree if root.exist? end def each_app - configuration.apps.each{ |name, app| yield app } + apps.each{ |name, app| yield app } + end + + def append_middleware + Rails.configuration.middleware.use Middleware end end