lib/ember_cli/app.rb in ember-cli-rails-0.6.1 vs lib/ember_cli/app.rb in ember-cli-rails-0.7.0

- old
+ new

@@ -1,19 +1,20 @@ -require "ember_cli/shell" require "html_page/renderer" +require "ember_cli/path_set" +require "ember_cli/shell" require "ember_cli/build_monitor" +require "ember_cli/deploy/file" module EmberCli class App attr_reader :name, :options, :paths def initialize(name, **options) @name = name.to_s @options = options @paths = PathSet.new( app: self, - configuration: EmberCli.configuration, environment: Rails.env, rails_root: Rails.root, ember_cli_root: EmberCli.root, ) @shell = Shell.new( @@ -40,35 +41,29 @@ true end end def build - if development? - build_and_watch - elsif test? - compile - end + unless EmberCli.skip? + if development? + build_and_watch + elsif test? + compile + end - @build.wait! + @build.wait! + end end def index_html(head:, body:) - if index_file.exist? - html = HtmlPage::Renderer.new( - head: head, - body: body, - content: index_file.read, - ) + html = HtmlPage::Renderer.new( + head: head, + body: body, + content: deploy.index_html, + ) - html.render - else - @build.check! - - raise BuildError.new <<-MSG - EmberCLI failed to generate an `index.html` file. - MSG - end + html.render end def install_dependencies @shell.install end @@ -77,18 +72,42 @@ prepare @shell.test end + def check_for_errors! + @build.check! + end + private - delegate :development?, :test?, to: :env + def development? + env.to_s == "development" + end - def index_file - paths.index_file + def test? + env.to_s == "test" end + def deploy + deploy_strategy.new(self) + end + + def deploy_strategy + strategy = options.fetch(:deploy, {}) + + if strategy.respond_to?(:fetch) + strategy.fetch(rails_env, EmberCli::Deploy::File) + else + strategy + end + end + + def rails_env + Rails.env.to_s.to_sym + end + def env EmberCli.env end def build_and_watch @@ -102,10 +121,10 @@ true end end def excluded_ember_deps - Array.wrap(options[:exclude_ember_deps]).join(?,) + Array.wrap(options[:exclude_ember_deps]).join("?") end def env_hash ENV.to_h.tap do |vars| vars["RAILS_ENV"] = Rails.env