capistrano-windows-server 0.4.5 → 0.4.6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capistrano-windows-server}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Edward Anderson"]
@@ -20,8 +20,20 @@ configuration.load do
20
20
  end
21
21
 
22
22
  # We can't run ruby commands directly, because the rake script searches for ruby based on windows paths that aren't valid in this environment
23
- def ruby_cmd(gem, cmd=gem)
24
- "PATH=\"#{File.dirname ruby_exe_path}:$PATH\" #{ruby_exe_path} -e \"require 'rubygems'; gem '#{gem}', '>= 0'; load Gem.bin_path('#{gem}', '#{cmd}', '>= 0')\""
23
+ def ruby_cmd(cmd, gem_name=cmd)
24
+ %Q(PATH="#{File.dirname ruby_exe_path}:$PATH" #{ruby_exe_path} -e "require 'rubygems'; gem '#{gem_name}', '>= 0'; load Gem.bin_path('#{gem_name}', '#{cmd}', '>= 0')")
25
+ end
26
+
27
+ def run_ruby_cmd(cmd, args='', gem_name=cmd)
28
+ run "cd #{current_path} && #{ruby_cmd cmd, gem_name} #{args}"
29
+ end
30
+
31
+ def bundle_exec(cmd, args='', gem_name=cmd)
32
+ if gemfile_present?
33
+ run_ruby_cmd 'bundle', "exec #{cmd} #{args}", 'bundler'
34
+ else
35
+ run_ruby_cmd cmd, args, gem_name
36
+ end
25
37
  end
26
38
 
27
39
  def rubygems_cmd
@@ -31,6 +43,10 @@ configuration.load do
31
43
  def application_server
32
44
  app_server rescue :mongrel
33
45
  end
46
+
47
+ def gemfile_present?
48
+ File.exists? "Gemfile"
49
+ end
34
50
 
35
51
  namespace :deploy do
36
52
  desc "Update the code on the server by doing a git reset --hard <ref> in the current/ directory"
@@ -73,7 +89,7 @@ configuration.load do
73
89
  end
74
90
 
75
91
  # Clear out tasks that are not appropriate on Windows
76
- %w(finalize_update symlink cleanup).each do |removed_task|
92
+ %w(finalize_update create_symlink symlink cleanup).each do |removed_task|
77
93
  task removed_task do; end
78
94
  end
79
95
  namespace :rollback do
@@ -84,7 +100,7 @@ configuration.load do
84
100
 
85
101
  desc "Run pending migrations"
86
102
  task :migrate do
87
- run "cd #{current_path} && #{ruby_cmd 'rake'} db:migrate RAILS_ENV=#{rails_env}"
103
+ bundle_exec 'rake', "db:migrate RAILS_ENV=#{rails_env}"
88
104
  end
89
105
 
90
106
  desc "Start mongrel"
@@ -118,7 +134,7 @@ configuration.load do
118
134
  return unless application_server == :mongrel
119
135
  mongrel_instances.each do |n|
120
136
  run "mkdir -p #{current_path}/{tmp,log}" # These are often not under version control, but their absence keeps mongrel from recognizing the rails app
121
- run "cd #{current_path} && #{ruby_cmd 'mongrel', 'mongrel_rails'} service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true"
137
+ bundle_exec 'mongrel_rails', "service::install -e #{rails_env} -N #{mongrel_instance_prefix}#{n} -p #{base_port + n - mongrel_instances.first}; true", 'mongrel'
122
138
  run %Q(sc.exe config "#{mongrel_instance_prefix}#{n}" start= auto type= interact type= own; true)
123
139
  end
124
140
  end
@@ -126,7 +142,7 @@ configuration.load do
126
142
  desc "Remove mongrel services"
127
143
  task :remove do
128
144
  mongrel_instances.each do |n|
129
- run "#{ruby_cmd 'mongrel', 'mongrel_rails'} service::remove -N #{mongrel_instance_prefix}#{n}; true"
145
+ bundle_exec 'mongrel_rails', "service::remove -N #{mongrel_instance_prefix}#{n}; true", 'mongrel'
130
146
  end
131
147
  end
132
148
 
@@ -137,7 +153,7 @@ configuration.load do
137
153
  desc "Run a rake command in COMMAND"
138
154
  task :rake do
139
155
  raise "Specify the command with COMMAND='some:task with_arguments'" unless ENV['COMMAND']
140
- run "cd #{current_path} && #{ruby_cmd 'rake'} #{ENV['COMMAND']} RAILS_ENV=#{rails_env}"
156
+ bundle_exec 'rake', "#{ENV['COMMAND']} RAILS_ENV=#{rails_env}"
141
157
  end
142
158
 
143
159
  desc "Run a rubygems (gem) command in COMMAND"
@@ -157,13 +173,16 @@ configuration.load do
157
173
  namespace :bundle do
158
174
  desc "Install gems with bundler"
159
175
  task :install do
160
- run "cd #{current_path} && #{ruby_cmd 'bundler', 'bundle'} install --without test development --path #{strip_cygdrive deploy_to}/bundle"
176
+ raise "No Gemfile detected" unless gemfile_present?
177
+ run_ruby_cmd 'bundle', "install --without test development --path #{strip_cygdrive deploy_to}/bundle", 'bundler'
161
178
  end
162
179
 
163
180
  desc "Execute a COMMAND with bundle exec"
164
181
  task :execute do
182
+ raise "No Gemfile detected" unless gemfile_present?
165
183
  raise "Specify the command with COMMAND. eg: COMMAND='rake db:migrate'" unless ENV['COMMAND']
166
- run "cd #{current_path} && #{ruby_cmd 'bundler', 'bundle'} exec #{ENV['COMMAND']}"
184
+ args = ENV['COMMAND'].split
185
+ bundle_exec args.shift, args.join(' ')
167
186
  end
168
187
  end
169
188
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-windows-server
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 5
10
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Edward Anderson