Skip to content

Commit

Permalink
Introduce lib/ember_cli.rb
Browse files Browse the repository at this point in the history
So that the files and tests follow Ruby's naming idioms, move the
contents of `lib/ember-cli-rails.rb` to `lib/ember_cli.rb`, to match the
constant that the file contains.
  • Loading branch information
seanpdoyle committed Jul 14, 2017
1 parent 1089254 commit c11588e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 67 deletions.
68 changes: 1 addition & 67 deletions lib/ember-cli-rails.rb
Original file line number Diff line number Diff line change
@@ -1,69 +1,3 @@
require "fileutils"
require "ember-cli-rails-assets"
require "ember_cli/engine"
require "ember_cli/configuration"
require "ember_cli/helpers"
require "ember_cli/errors"

module EmberCli
extend self

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

def build(name)
app(name).build
end

alias_method :[], :app

def skip?
ENV["SKIP_EMBER"].present?
end

def install_dependencies!
each_app(&:install_dependencies)
end

def test!
each_app(&:test)
end

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

def root
@root ||= Rails.root.join("tmp", "ember-cli").tap(&:mkpath)
end

def env
@env ||= Helpers.current_environment
end

delegate :apps, to: :configuration

private

def cleanup!
root.children.each { |tmp_file| FileUtils.rm_rf(tmp_file) }
end

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

EmberCLI = EmberCli
67 changes: 67 additions & 0 deletions lib/ember_cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
require "fileutils"
require "ember-cli-rails-assets"
require "ember_cli/engine"
require "ember_cli/configuration"
require "ember_cli/helpers"
require "ember_cli/errors"

module EmberCli
extend self

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

def build(name)
app(name).build
end

alias_method :[], :app

def skip?
ENV["SKIP_EMBER"].present?
end

def install_dependencies!
each_app(&:install_dependencies)
end

def test!
each_app(&:test)
end

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

def root
@root ||= Rails.root.join("tmp", "ember-cli").tap(&:mkpath)
end

def env
@env ||= Helpers.current_environment
end

delegate :apps, to: :configuration

private

def cleanup!
root.children.each { |tmp_file| FileUtils.rm_rf(tmp_file) }
end

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

0 comments on commit c11588e

Please sign in to comment.