Class: Inploy::Deploy
- Inherits:
-
Object
- Object
- Inploy::Deploy
- Defined in:
- lib/inploy/deploy.rb
Instance Attribute Summary collapse
-
#app_folder ⇒ Object
Returns the value of attribute app_folder.
-
#application ⇒ Object
Returns the value of attribute application.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#bundler_opts ⇒ Object
Returns the value of attribute bundler_opts.
-
#cache_dirs ⇒ Object
Returns the value of attribute cache_dirs.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#login_shell ⇒ Object
Returns the value of attribute login_shell.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#skip_steps ⇒ Object
Returns the value of attribute skip_steps.
-
#ssh_opts ⇒ Object
Returns the value of attribute ssh_opts.
-
#sudo ⇒ Object
Returns the value of attribute sudo.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #configure ⇒ Object
- #configure_from(file) ⇒ Object
-
#initialize ⇒ Deploy
constructor
A new instance of Deploy.
- #local_setup ⇒ Object
- #local_update ⇒ Object
- #remote_install(opts) ⇒ Object
- #remote_rake(task) ⇒ Object
- #remote_reset(params) ⇒ Object
- #remote_setup ⇒ Object
- #remote_update ⇒ Object
- #server=(server) ⇒ Object
- #template=(template) ⇒ Object
- #update_code ⇒ Object
Methods included from DSL
#callback, #create_folder, #create_folders, #file_exists?, included, #load_module, #login_shell_wrap, #rake, #rake_if_included, #remote_run, #ruby_if_exists, #run, #say, #secure_copy, #sudo_if_should, #using_bundler?
Methods included from Helper
#application_folder, #application_path, #bundle_cmd, #bundle_install, #camelize, #clear_cache, #configuration_file, #copy_sample_files, #host, #install_gems, #jammit_is_installed?, #migrate_database, #notify_new_relic, #skip_step?, #skip_steps_cmd, #tasks, #update_crontab
Constructor Details
#initialize ⇒ Deploy
Returns a new instance of Deploy.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/inploy/deploy.rb', line 10 def initialize self.server = :passenger @cache_dirs = %w(public/cache) @branch = 'master' @environment = 'production' @user = "deploy" @path = "/var/local/apps" @app_folder = nil configure end |
Instance Attribute Details
#app_folder ⇒ Object
Returns the value of attribute app_folder.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def app_folder @app_folder end |
#application ⇒ Object
Returns the value of attribute application.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def application @application end |
#branch ⇒ Object
Returns the value of attribute branch.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def branch @branch end |
#bundler_opts ⇒ Object
Returns the value of attribute bundler_opts.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def bundler_opts @bundler_opts end |
#cache_dirs ⇒ Object
Returns the value of attribute cache_dirs.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def cache_dirs @cache_dirs end |
#environment ⇒ Object
Returns the value of attribute environment.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def environment @environment end |
#hosts ⇒ Object
Returns the value of attribute hosts.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def hosts @hosts end |
#login_shell ⇒ Object
Returns the value of attribute login_shell.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def login_shell @login_shell end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def port @port end |
#repository ⇒ Object
Returns the value of attribute repository.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def repository @repository end |
#skip_steps ⇒ Object
Returns the value of attribute skip_steps.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def skip_steps @skip_steps end |
#ssh_opts ⇒ Object
Returns the value of attribute ssh_opts.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def ssh_opts @ssh_opts end |
#sudo ⇒ Object
Returns the value of attribute sudo.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def sudo @sudo end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/inploy/deploy.rb', line 6 def user @user end |
Instance Method Details
#configure ⇒ Object
29 30 31 |
# File 'lib/inploy/deploy.rb', line 29 def configure configure_from configuration_file if configuration_file end |
#configure_from(file) ⇒ Object
33 34 35 36 |
# File 'lib/inploy/deploy.rb', line 33 def configure_from(file) deploy = self eval file.read + ';local_variables.each { |variable| deploy.send "#{variable}=", eval(variable.to_s) rescue nil }' end |
#local_setup ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/inploy/deploy.rb', line 46 def local_setup create_folders 'public', 'tmp/pids', 'db' callback :after_git copy_sample_files rake "db:create RAILS_ENV=#{environment}" run "./init.sh" if file_exists?("init.sh") after_update_code callback :after_setup end |
#local_update ⇒ Object
70 71 72 73 |
# File 'lib/inploy/deploy.rb', line 70 def local_update update_code after_update_code end |
#remote_install(opts) ⇒ Object
38 39 40 |
# File 'lib/inploy/deploy.rb', line 38 def remote_install(opts) remote_run "bash < <(wget -O- #{opts[:from]})" end |
#remote_rake(task) ⇒ Object
60 61 62 |
# File 'lib/inploy/deploy.rb', line 60 def remote_rake(task) remote_run "cd #{application_path} && rake #{task} RAILS_ENV=#{environment}" end |
#remote_reset(params) ⇒ Object
64 65 66 67 68 |
# File 'lib/inploy/deploy.rb', line 64 def remote_reset(params) callback :before_git remote_run "cd #{application_path} && git reset --hard #{params[:to]}" callback :after_git end |
#remote_setup ⇒ Object
42 43 44 |
# File 'lib/inploy/deploy.rb', line 42 def remote_setup remote_run "cd #{path} && #{sudo_if_should}git clone --depth 1 #{repository} #{application} && cd #{application_folder} #{checkout}#{bundle} && #{sudo_if_should}rake inploy:local:setup RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" end |
#remote_update ⇒ Object
56 57 58 |
# File 'lib/inploy/deploy.rb', line 56 def remote_update remote_run "cd #{application_path} && #{sudo_if_should}rake inploy:local:update RAILS_ENV=#{environment} environment=#{environment}#{skip_steps_cmd}" end |
#server=(server) ⇒ Object
25 26 27 |
# File 'lib/inploy/deploy.rb', line 25 def server=(server) load_module "servers/#{server}" end |
#template=(template) ⇒ Object
21 22 23 |
# File 'lib/inploy/deploy.rb', line 21 def template=(template) load_module "templates/#{template}" end |
#update_code ⇒ Object
75 76 77 78 79 |
# File 'lib/inploy/deploy.rb', line 75 def update_code callback :before_git raise "ERROR: git pull failed with error status = #{$?}" unless run "git pull origin #{branch}" callback :after_git end |