Sha256: 65da86e52680eef37b564538148ba6cfe3ca97d1a3257263c82147b99d80ad0b

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

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

module EmberCli
  extend self

  autoload :App,           "ember-cli/app"
  autoload :Configuration, "ember-cli/configuration"
  autoload :Helpers,       "ember-cli/helpers"
  autoload :PathSet,       "ember-cli/path_set"

  def configure
    yield configuration
  end

  def configuration
    Configuration.instance
  end

  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"].present?
  end

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

  def install_dependencies!
    enable!
    each_app(&:install_dependencies)
  end

  def test!
    enable!
    each_app(&:test)
  end

  def compile!
    enable!
    each_app(&:compile)
  end

  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

  def cleanup
    root.rmtree if root.exist?
  end

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

EmberCLI = EmberCli

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ember-cli-rails-0.5.1 lib/ember-cli-rails.rb
ember-cli-rails-0.5.0 lib/ember-cli-rails.rb