Module: Nodex::DSL
- Included in:
- Deploy
- Defined in:
- lib/nodex/dsl.rb
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #clear_cache ⇒ Object
- #create_tmp ⇒ Object
- #install_gems ⇒ Object
- #load_module(filename) ⇒ Object
- #log(command) ⇒ Object
- #login_shell_wrap(cmd) ⇒ Object
- #migrate_database ⇒ Object
- #rake_db_create ⇒ Object
- #rake_gems_install ⇒ Object
- #rake_task(task) ⇒ Object
- #remote_run(commands) ⇒ Object
- #run(command) ⇒ Object
- #update_code ⇒ Object
Instance Method Details
#bundle_install ⇒ Object
41 42 43 |
# File 'lib/nodex/dsl.rb', line 41 def bundle_install remote_run "cd #{application_path} && #{bundle_cmd}" unless skip_step?('bundle_install') end |
#clear_cache ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/nodex/dsl.rb', line 29 def clear_cache unless skip_step?('clear_cache') cache_dirs.each do |dir| remote_run "cd #{application_path} && rm -rf #{dir}" end end end |
#create_tmp ⇒ Object
49 50 51 |
# File 'lib/nodex/dsl.rb', line 49 def create_tmp remote_run "cd #{application_path} && mkdir tmp" end |
#install_gems ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/nodex/dsl.rb', line 53 def install_gems if using_bundler? bundle_install else rake_gems_install end end |
#load_module(filename) ⇒ Object
3 4 5 6 |
# File 'lib/nodex/dsl.rb', line 3 def load_module(filename) require "nodex/#{filename}" extend eval(filename.split("/").map { |word| camelize(word) }.join("::")) end |
#log(command) ⇒ Object
20 21 22 |
# File 'lib/nodex/dsl.rb', line 20 def log(command) puts "Nodex => #{command}" end |
#login_shell_wrap(cmd) ⇒ Object
65 66 67 |
# File 'lib/nodex/dsl.rb', line 65 def login_shell_wrap(cmd) login_shell ? "\"bash -l -c '#{cmd}'\"" : "'#{cmd}'" end |
#migrate_database ⇒ Object
16 17 18 |
# File 'lib/nodex/dsl.rb', line 16 def migrate_database remote_run "cd #{application_path} && rake db:migrate RAILS_ENV=#{environment}" unless skip_step?('migrate_database') end |
#rake_db_create ⇒ Object
37 38 39 |
# File 'lib/nodex/dsl.rb', line 37 def rake_db_create rake_task "db:create" end |
#rake_gems_install ⇒ Object
45 46 47 |
# File 'lib/nodex/dsl.rb', line 45 def rake_gems_install remote_run "cd #{application_path} && #{rake_task("gems:install")}" unless skip_step?('install_gems') end |
#rake_task(task) ⇒ Object
8 9 10 |
# File 'lib/nodex/dsl.rb', line 8 def rake_task(task) "rake #{task} RAILS_ENV=#{environment}" end |
#remote_run(commands) ⇒ Object
61 62 63 |
# File 'lib/nodex/dsl.rb', line 61 def remote_run(commands) run "ssh #{user}@#{host} #{login_shell_wrap(commands)}" end |
#run(command) ⇒ Object
24 25 26 27 |
# File 'lib/nodex/dsl.rb', line 24 def run(command) log command Kernel.system "#{command}" end |
#update_code ⇒ Object
12 13 14 |
# File 'lib/nodex/dsl.rb', line 12 def update_code remote_run "cd #{application_path} && #{git_pull}" end |