forked from emberjs/ember-rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a basic generator to install into your project. Also ability to…
… install from HEAD
- Loading branch information
Showing
9 changed files
with
115 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module EmberRails | ||
VERSION = "0.2.3" | ||
EMBER_VERSION = "0.9.4" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'rails' | ||
require 'bundler' | ||
|
||
module EmberRails | ||
module Generators | ||
class InstallGenerator < ::Rails::Generators::Base | ||
|
||
FILES = [ "ember.js", "ember-dev.js", "ember-runtime.js", "ember-runtime-dev.js" ] | ||
|
||
desc "This generator installs Ember.js #{EmberRails::EMBER_VERSION}" | ||
class_option :head, :type => :boolean, :default => false, :desc => "Download latest Ember.js from GitHub and copy it into your project" | ||
|
||
def remove_ember | ||
FILES.each do |name| | ||
remove_file "vendor/assets/javascripts/#{name}" | ||
end | ||
end | ||
|
||
def copy_ember | ||
if options.head? | ||
git_root = File.expand_path "../../../../../vendor/ember", __FILE__ | ||
gem_file = File.join git_root, "Gemfile" | ||
self.class.source_root git_root | ||
|
||
Dir.chdir git_root do | ||
say_status("downloading", "Ember.js (HEAD)", :green) | ||
cmd "git fetch --force --quiet --tags" | ||
cmd "git reset --hard" | ||
say_status("building", "", :green) | ||
|
||
Bundler.with_clean_env do | ||
cmd "bundle --gemfile #{gem_file}" | ||
cmd %{BUNDLE_GEMFILE="#{gem_file}" bundle exec rake} | ||
end | ||
end | ||
|
||
Dir[File.join(git_root, "dist", "*.js")].each do |file| | ||
name = File.basename file | ||
if name.match /\.min/ | ||
name.gsub! /\.min/, '' | ||
else | ||
name.gsub! /\.js/, '-dev.js' | ||
end | ||
copy_file file, "vendor/assets/javascripts/#{name}" | ||
end | ||
else | ||
self.class.source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__) | ||
|
||
say_status("copying", "Ember.js (#{EmberRails::EMBER_VERSION})", :green) | ||
|
||
FILES.each do |name| | ||
copy_file name, "vendor/assets/javascripts/#{name}" | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def cmd(command) | ||
out = %x{#{command}} | ||
|
||
if $?.exitstatus != 0 | ||
raise "Command error: command `#{command}` in directory #{Dir.pwd} has failed." | ||
end | ||
out | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters