Module: Inploy::Helper
- Included in:
- Deploy
- Defined in:
- lib/inploy/helper.rb
Instance Method Summary collapse
- #application_folder ⇒ Object
- #application_path ⇒ Object
- #bundle_cmd ⇒ Object
- #bundle_install ⇒ Object
- #camelize(string) ⇒ Object
- #clear_cache ⇒ Object
- #configuration_file ⇒ Object
- #copy_sample_files ⇒ Object
- #host ⇒ Object
- #install_gems ⇒ Object
- #jammit_is_installed? ⇒ Boolean
- #migrate_database ⇒ Object
- #notify_new_relic ⇒ Object
- #skip_step?(step) ⇒ Boolean
- #skip_steps_cmd ⇒ Object
- #tasks ⇒ Object
- #update_crontab ⇒ Object
Instance Method Details
#application_folder ⇒ Object
39 40 41 |
# File 'lib/inploy/helper.rb', line 39 def application_folder app_folder.nil? ? application : "#{application}/#{app_folder}" end |
#application_path ⇒ Object
35 36 37 |
# File 'lib/inploy/helper.rb', line 35 def application_path app_folder.nil? ? "#{path}/#{application}" : "#{path}/#{application}/#{app_folder}" end |
#bundle_cmd ⇒ Object
61 62 63 |
# File 'lib/inploy/helper.rb', line 61 def bundle_cmd "bundle install #{bundler_opts || '--deployment --without development test cucumber'}" end |
#bundle_install ⇒ Object
65 66 67 |
# File 'lib/inploy/helper.rb', line 65 def bundle_install run bundle_cmd unless skip_step?('bundle_install') end |
#camelize(string) ⇒ Object
31 32 33 |
# File 'lib/inploy/helper.rb', line 31 def camelize(string) string.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } end |
#clear_cache ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/inploy/helper.rb', line 15 def clear_cache unless skip_step?('clear_cache') cache_dirs.each do |dir| run "rm -R -f #{dir}" end end end |
#configuration_file ⇒ Object
3 4 5 |
# File 'lib/inploy/helper.rb', line 3 def configuration_file File.open("config/deploy.rb") rescue File.open("deploy.rb") rescue nil end |
#copy_sample_files ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/inploy/helper.rb', line 43 def copy_sample_files unless skip_step?('copy_sample_files') ["example", "sample", "template"].each do |extension| Dir.glob("config/*.#{extension}*").each do |file| secure_copy file, file.gsub(".#{extension}", '') end end end end |
#host ⇒ Object
27 28 29 |
# File 'lib/inploy/helper.rb', line 27 def host hosts.first end |
#install_gems ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/inploy/helper.rb', line 69 def install_gems if using_bundler? bundle_install else rake "gems:install RAILS_ENV=#{environment}" unless skip_step?('install_gems') end end |
#jammit_is_installed? ⇒ Boolean
23 24 25 |
# File 'lib/inploy/helper.rb', line 23 def jammit_is_installed? file_exists?("config/assets.yml") end |
#migrate_database ⇒ Object
53 54 55 |
# File 'lib/inploy/helper.rb', line 53 def migrate_database rake "db:migrate RAILS_ENV=#{environment}" unless skip_step?('migrate_database') end |
#notify_new_relic ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/inploy/helper.rb', line 81 def notify_new_relic if file_exists? "vendor/plugins/newrelic_rpm/bin/newrelic_cmd" run "ruby vendor/plugins/newrelic_rpm/bin/newrelic_cmd deployments" elsif file_exists? "config/newrelic.yml" run "newrelic_cmd deployments" end end |
#skip_step?(step) ⇒ Boolean
7 8 9 |
# File 'lib/inploy/helper.rb', line 7 def skip_step?(step) skip_steps and skip_steps.include?(step) end |
#skip_steps_cmd ⇒ Object
11 12 13 |
# File 'lib/inploy/helper.rb', line 11 def skip_steps_cmd " skip_steps=#{skip_steps.join(',')}" unless skip_steps.nil? end |
#tasks ⇒ Object
57 58 59 |
# File 'lib/inploy/helper.rb', line 57 def tasks `rake -T` end |
#update_crontab ⇒ Object
77 78 79 |
# File 'lib/inploy/helper.rb', line 77 def update_crontab run "whenever --update-crontab #{application} --set 'environment=#{environment}'" if file_exists?("config/schedule.rb") unless skip_step?('update_crontab') end |