Created
January 31, 2013 01:44
-
-
Save mockra/4679199 to your computer and use it in GitHub Desktop.
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
namespace :ember do | |
task :update do | |
[['~/.ember', 'git://github.com/emberjs/ember.js.git', 'ember.js'], | |
['~/.ember-data', 'git://github.com/emberjs/data.git', 'ember-data.js'] | |
].each { |i| EmberBuild.new(*i).update } | |
end | |
end | |
class EmberBuild | |
attr_reader :ember_dir, :repo, :file_name, :gem_file | |
def initialize root, repo, file_name | |
@ember_dir = File.expand_path root | |
@gem_file = File.join ember_dir, 'Gemfile' | |
@repo, @file_name = repo, file_name | |
end | |
def update | |
download_latest_version | |
build_dist | |
copy_to_vendor_assets | |
end | |
def update_repo | |
Dir.chdir ember_dir do | |
system 'git fetch origin && git reset origin/master --hard' | |
end | |
end | |
def clone_repo | |
system "git clone #{repo} '#{ember_dir}'" | |
end | |
def download_latest_version | |
File.exist?(ember_dir) ? update_repo : clone_repo | |
end | |
def build_dist | |
Dir.chdir ember_dir do | |
Bundler.with_clean_env do | |
system "bundle --gemfile #{gem_file}" | |
system "BUNDLE_GEMFILE='#{gem_file}' bundle exec rake dist" | |
end | |
end | |
end | |
def copy_to_vendor_assets | |
system "cp #{ember_dir}/dist/#{file_name} vendor/assets/javascripts" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment