Created
August 18, 2009 10:27
-
-
Save lazyatom/169659 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
module Rip | |
module Commands | |
x "Exports an environment into a self-contained compressed archive, using tar and gzip." | |
o "export [ENVIRONMENT]" | |
def export(options={}, env=Rip::Env.active) | |
`tar c --file=#{env}.tar -C #{File.join(Rip.dir, env)} . && gzip #{env}.tar` | |
end | |
x "Imports an exported environment." | |
o "Specify --as=ENVIRONMENT to change the environment name" | |
def import(options={}, file=nil, *args) | |
ui.abort "Please provide a compressed environment to import" unless file | |
ui.abort "Cannot read #{file}" unless File.exist?(file) | |
original_env = File.basename(file).split(".").first | |
env = options[:as] || original_env | |
destination = File.join(Rip.dir, env) | |
ui.abort "Environment '#{env}' already exists!" if File.exist?(destination) | |
`mkdir -p #{destination} && tar xzf #{file} -C #{destination}` | |
`mv #{File.join(destination, original_env)}.ripenv #{File.join(destination, env)}.ripenv` unless env == original_env | |
ui.puts "Imported #{file} as #{env}" | |
end | |
x "Exports an environment into the vendor directory of the current project" | |
x "This is suitable for freezing a particular dependency set into the project for" | |
x "distribution to users who might not have rip installed." | |
o "vendor [env [directory]] (defaults to current env and 'vendor')" | |
def vendor(options={}, env=Rip::Env.active, dir='vendor') | |
`cp -r #{File.join(Rip.dir, env)} #{dir} && rm #{File.join(dir, env)}.ripenv` | |
ui.puts "Environment '#{env}' has been copied into #{dir}." | |
ui.puts "Be sure to add #{File.join(dir, 'lib')} to your application's $LOAD_PATH." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment