Class: RailsClone::Runner
- Inherits:
-
Thor
- Object
- Thor
- RailsClone::Runner
- Includes:
- Thor::Actions
- Defined in:
- lib/rails_clone/runner.rb
Instance Method Summary collapse
Instance Method Details
#change_name(from, name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_clone/runner.rb', line 23 def change_name(from, name) %w( app/views/layouts/application.html.erb config/application.rb app.json ) .each do |file| gsub_file(file, from.classify) {|match| name.classify } end %w( config/database.yml config/initializers/session_store.rb ) .each do |file| gsub_file(file, from.camelize) {|match| name.camelize } end end |
#clone(from, name, branch) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rails_clone/runner.rb', line 5 def clone(from, name, branch) branches = `git branch` unless branches.match(branch) say "Cannot find branch #{branch}" say "Available:\n#{branches}" exit(1) end dir = File.("../#{name}_#{branch}", destination_root) say "Archiving current app into #{dir}" empty_directory dir `git archive #{branch} --format tar --output #{branch}.tar && tar -xf #{branch}.tar -C #{dir} && rm #{branch}.tar` inside dir do change_name(from, name) end end |