Module: Inploy::Helper

Included in:
Deploy
Defined in:
lib/inploy/helper.rb

Instance Method Summary collapse

Instance Method Details

#application_folderObject



39
40
41
# File 'lib/inploy/helper.rb', line 39

def application_folder
  app_folder.nil? ? application : "#{application}/#{app_folder}"
end

#application_pathObject



35
36
37
# File 'lib/inploy/helper.rb', line 35

def application_path
  app_folder.nil? ? "#{path}/#{application}" : "#{path}/#{application}/#{app_folder}"
end

#bundle_cmdObject



59
60
61
# File 'lib/inploy/helper.rb', line 59

def bundle_cmd
  "bundle install --path ~/.bundle --without development test cucumber"
end

#bundle_installObject



63
64
65
# File 'lib/inploy/helper.rb', line 63

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_cacheObject



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_fileObject



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_filesObject



43
44
45
46
47
48
49
# File 'lib/inploy/helper.rb', line 43

def copy_sample_files
  ["example", "sample"].each do |extension|
    Dir.glob("config/*.#{extension}").each do |file|
      secure_copy file, file.gsub(".#{extension}", '')
    end
  end
end

#hostObject



27
28
29
# File 'lib/inploy/helper.rb', line 27

def host
  hosts.first
end

#install_gemsObject



67
68
69
70
71
72
73
# File 'lib/inploy/helper.rb', line 67

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

Returns:

  • (Boolean)


23
24
25
# File 'lib/inploy/helper.rb', line 23

def jammit_is_installed?
  file_exists?("config/assets.yml")
end

#migrate_databaseObject



51
52
53
# File 'lib/inploy/helper.rb', line 51

def migrate_database
  rake "db:migrate RAILS_ENV=#{environment}" unless skip_step?('migrate_database')
end

#notify_new_relicObject



79
80
81
82
83
84
85
# File 'lib/inploy/helper.rb', line 79

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

Returns:

  • (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_cmdObject



11
12
13
# File 'lib/inploy/helper.rb', line 11

def skip_steps_cmd
  " skip_steps=#{skip_steps.join(',')}" unless skip_steps.nil?
end

#tasksObject



55
56
57
# File 'lib/inploy/helper.rb', line 55

def tasks
  `rake -T`
end

#update_crontabObject



75
76
77
# File 'lib/inploy/helper.rb', line 75

def update_crontab
  run "whenever --update-crontab #{application} --set 'environment=#{environment}'" if file_exists?("config/schedule.rb") unless skip_step?('update_crontab')
end