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



61
62
63
# File 'lib/inploy/helper.rb', line 61

def bundle_cmd
  "bundle install #{bundler_opts || '--deployment --without development test cucumber'}"
end

#bundle_installObject



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_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
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

#hostObject



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

def host
  hosts.first
end

#install_gemsObject



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

Returns:

  • (Boolean)


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

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

#migrate_databaseObject



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_relicObject



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

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



57
58
59
# File 'lib/inploy/helper.rb', line 57

def tasks
  `rake -T`
end

#update_crontabObject



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