Sha256: 8f2170875a9357d1add0293c6df88d462066eba0fbd3b62813901b1d46d233ce

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require "ember-cli/engine" if defined?(Rails)

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"

  def configure
    yield configuration
  end

  def configuration
    Configuration.instance
  end

  def get_app(name)
    configuration.apps[name]
  end

  def prepare!
    @prepared ||= begin
      Rails.configuration.assets.paths << root.join("assets").to_s
      at_exit{ cleanup }
      true
    end
  end

  def enable!
    prepare!

    if Helpers.use_middleware?
      Rails.configuration.middleware.use Middleware
    end
  end

  def install_dependencies!
    prepare!
    each_app &:install_dependencies
  end

  def run!
    prepare!
    each_app &:run
  end

  def run_tests!
    prepare!
    each_app &:run_tests
  end

  def compile!
    prepare!
    each_app &:compile
  end

  def stop!
    each_app &:stop
  end

  def wait!
    each_app &:wait
  end

  def root
    @root ||= Rails.root.join("tmp", "ember-cli-#{uid}")
  end

  private

  def uid
    @uid ||= SecureRandom.uuid
  end

  def cleanup
    root.rmtree if root.exist?
  end

  def each_app
    configuration.apps.each{ |name, app| yield app }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ember-cli-rails-0.1.12 lib/ember-cli-rails.rb
ember-cli-rails-0.1.11 lib/ember-cli-rails.rb
ember-cli-rails-0.1.10 lib/ember-cli-rails.rb
ember-cli-rails-0.1.9 lib/ember-cli-rails.rb
ember-cli-rails-0.1.8 lib/ember-cli-rails.rb
ember-cli-rails-0.1.7 lib/ember-cli-rails.rb