Class: Totem::ShellCmds::New
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Totem::ShellCmds::Base
Instance Method Details
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/totem/shell_cmds/new.rb', line 6 def run if @args[0].nil? puts 'ERROR: You must provide a name for the new project.' return end root_path = @args[0] puts 'Creating project root directory...' Dir.mkdir(root_path) puts puts 'Creating sub-directories...' %w(app config log tmp).each do |dir| puts " #{dir}..." Dir.mkdir(root_path + '/' + dir) end puts template_path = File.(File.dirname(__FILE__) + '/../../../templates') puts 'Creating Gemfile...' input = File.read(template_path + '/Gemfile.erb') output = ERB.new(input).result(binding) File.open(root_path + '/Gemfile', 'w') { |f| f.write(output) } puts puts 'Creating config/environment.rb...' input = File.read(template_path + '/config/environment.rb.erb') output = ERB.new(input).result(binding) File.open(root_path + '/config/environment.rb', 'w') { |f| f.write(output) } puts puts 'Creating app/loader.rb...' input = File.read(template_path + '/app/loader.rb.erb') output = ERB.new(input).result(binding) File.open(root_path + '/app/loader.rb', 'w') { |f| f.write(output) } puts puts 'Finished! You must now run "bundle update" inside your project directory.' end |