magic_recipes 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/magic_recipes.rb CHANGED
@@ -19,6 +19,8 @@ module MagicRecipes
19
19
  default_run_options[:pty] = true
20
20
  ssh_options[:forward_agent] = true
21
21
 
22
+ set_default :use_rvm, false # => no_rvm
23
+
22
24
  def template(from, to)
23
25
  erb = File.read(File.expand_path("../magic_recipes/templates/#{from}", __FILE__))
24
26
  put ERB.new(erb).result(binding), to
@@ -44,30 +44,25 @@ module MagicRecipes
44
44
  set :asset_env, "RAILS_GROUPS=assets"
45
45
  DESC
46
46
  task :precompile, :roles => assets_role, :except => { :no_release => true } do
47
- run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
47
+ # run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
48
48
  if make_pulbic_folder_public
49
49
  chmod
50
50
  end
51
- # run <<-CMD
52
- # source '/usr/local/rvm/scripts/rvm' &&
53
- # rvm use 1.9.3 &&
54
- # cd #{latest_release} &&
55
- # #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile &&
56
- # #{sudo} chmod -R 777 public/ &&
57
- # #{sudo} chmod -R 777 tmp/
58
- # CMD
51
+ if use_rvm
52
+ run <<-CMD
53
+ source '#{rvm_path}/scripts/rvm' &&
54
+ rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} &&
55
+ cd #{latest_release} &&
56
+ #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile
57
+ CMD
58
+ else
59
+ run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile"
60
+ end
59
61
  end
60
62
 
61
63
  desc "make the public folder public for all (777)"
62
64
  task :chmod, :roles => assets_role, :except => { :no_release => true } do
63
65
  run "cd #{latest_release} && #{sudo} chmod -R 777 public/ && #{sudo} chmod -R 777 tmp/"
64
- # run <<-CMD
65
- # source '/usr/local/rvm/scripts/rvm' &&
66
- # rvm use 1.9.3 &&
67
- # cd #{latest_release} &&
68
- # #{sudo} chmod -R 777 public/ &&
69
- # #{sudo} chmod -R 777 tmp/
70
- # CMD
71
66
  end
72
67
 
73
68
  desc <<-DESC
@@ -8,22 +8,30 @@ module MagicRecipes
8
8
 
9
9
  desc "seed the database"
10
10
  task :seed do
11
- run <<-CMD
12
- source '/usr/local/rvm/scripts/rvm' &&
13
- rvm use 1.9.3 &&
14
- cd #{latest_release} &&
11
+ if use_rvm
12
+ run <<-CMD
13
+ source '#{rvm_path}/scripts/rvm' &&
14
+ rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} &&
15
+ cd #{latest_release} &&
15
16
  #{rake} db:seed RAILS_ENV=#{rails_env}
16
17
  CMD
18
+ else
19
+ run "cd #{latest_release} && #{rake} db:seed RAILS_ENV=#{rails_env}"
20
+ end
17
21
  end
18
22
 
19
23
  desc "migrate the database"
20
24
  task :migrate do
21
- run <<-CMD
22
- source '/usr/local/rvm/scripts/rvm' &&
23
- rvm use 1.9.3 &&
24
- cd #{latest_release} &&
25
+ if use_rvm
26
+ run <<-CMD
27
+ source '#{rvm_path}/scripts/rvm' &&
28
+ rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} &&
29
+ cd #{latest_release} &&
25
30
  #{rake} db:migrate RAILS_ENV=#{rails_env}
26
31
  CMD
32
+ else
33
+ run "cd #{latest_release} && #{rake} db:migrate RAILS_ENV=#{rails_env}"
34
+ end
27
35
  end
28
36
 
29
37
  end
@@ -36,13 +36,22 @@ module MagicRecipes
36
36
 
37
37
  desc "start private_pub server"
38
38
  task :start, roles: :app do
39
+ if use_rvm
40
+ run <<-CMD
41
+ source '#{rvm_path}/scripts/rvm' &&
42
+ rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} &&
43
+ cd #{current_path} &&
44
+ RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -p #{private_pub_port} -o #{server_ip} -D
45
+ CMD
46
+ else
47
+ run "cd #{current_path} && RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -p #{private_pub_port} -o #{server_ip} -D"
48
+ end
39
49
  # => run <<-CMD
40
50
  # => source '/usr/local/rvm/scripts/rvm' &&
41
51
  # => rvm use 1.9.3 &&
42
52
  # => cd #{current_path} &&
43
53
  # => RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -p #{private_pub_port} -o #{server_ip} -D
44
54
  # => CMD
45
- run "cd #{current_path} && RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production -p #{private_pub_port} -o #{server_ip} -D"
46
55
  end
47
56
 
48
57
 
@@ -19,14 +19,15 @@ module MagicRecipes
19
19
  set :rvm_bin_path, "#{rvm_path}/bin"
20
20
  set :rvm_lib_path, "#{rvm_path}/lib"
21
21
  set :remote_bin_path, "#{rvm_path}/gems/ruby-#{rvm_ruby}-#{rvm_patch}/bin/"
22
+ set :use_rvm, true
22
23
 
23
- set :default_environment, {
24
- 'PATH' => "#{rvm_path}/gems/ruby/1.9.1/bin:#{rvm_bin_path}/bin:#{remote_bin_path}:$PATH",
25
- 'RUBY_VERSION' => "#{rvm_ruby}",
26
- 'GEM_HOME' => "#{rvm_path}/gems/#{rvm_ruby_string}",
27
- 'GEM_PATH' => "#{rvm_path}/gems/#{rvm_ruby_string}",
28
- 'BUNDLE_PATH' => "#{rvm_path}/gems/#{rvm_ruby_string}"
29
- }
24
+ # => set :default_environment, {
25
+ # => 'PATH' => "#{rvm_path}/gems/ruby/1.9.1/bin:#{rvm_bin_path}/bin:#{remote_bin_path}:$PATH",
26
+ # => 'RUBY_VERSION' => "#{rvm_ruby}",
27
+ # => 'GEM_HOME' => "#{rvm_path}/gems/#{rvm_ruby_string}",
28
+ # => 'GEM_PATH' => "#{rvm_path}/gems/#{rvm_ruby_string}",
29
+ # => 'BUNDLE_PATH' => "#{rvm_path}/gems/#{rvm_ruby_string}"
30
+ # => }
30
31
 
31
32
  set :bundle_dir, "#{rvm_path}/gems/#{rvm_ruby_string}"
32
33
  set :bundle_flags, "--deployment --verbose"
@@ -20,12 +20,16 @@ module MagicRecipes
20
20
  desc "#{command} thin"
21
21
  task command, roles: :app do
22
22
  reconf
23
- # => run <<-CMD
24
- # => source '/usr/local/rvm/scripts/rvm' &&
25
- # => rvm use 1.9.3 && cd #{current_path} &&
26
- # => bundle exec thin #{command} -C config/thin_app.yml
27
- # => CMD
28
- run "bundle exec thin #{command} -C config/thin_app.yml"
23
+ if use_rvm
24
+ run <<-CMD
25
+ source '#{rvm_path}/scripts/rvm' &&
26
+ rvm use #{rvm_ruby}-#{rvm_patch}@#{rvm_gemset} &&
27
+ cd #{current_path} &&
28
+ bundle exec thin #{command} -C config/thin_app.yml
29
+ CMD
30
+ else
31
+ run "bundle exec thin #{command} -C config/thin_app.yml"
32
+ end
29
33
  end
30
34
  # before "nginx:#{command}", "thin:#{command}"
31
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: