cape 1.6.0 → 1.6.1
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/.rspec +2 -0
- data/Gemfile +1 -1
- data/Guardfile +4 -1
- data/History.markdown +4 -0
- data/License.markdown +1 -1
- data/README.markdown +9 -4
- data/Rakefile +3 -3
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace.feature +40 -0
- data/features/dsl/mirror_rake_tasks/with_defined_namespace_argument.feature +23 -53
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options.feature +39 -0
- data/features/dsl/mirror_rake_tasks/with_defined_task_and_valid_options_arguments_and_environment_variables.feature +6 -186
- data/features/dsl/mirror_rake_tasks/with_defined_task_argument.feature +11 -26
- data/features/dsl/mirror_rake_tasks/with_defined_task_argument_and_environment_variables.feature +43 -0
- data/features/dsl/mirror_rake_tasks/with_environment_variables.feature +29 -0
- data/features/dsl/mirror_rake_tasks/with_undefined_argument.feature +3 -17
- data/features/dsl/mirror_rake_tasks/with_valid_options_argument.feature +2 -67
- data/features/dsl/mirror_rake_tasks/with_valid_options_arguments_and_environment_variables.feature +26 -0
- data/features/dsl/mirror_rake_tasks/without_arguments.feature +5 -2
- data/lib/cape/capistrano.rb +9 -6
- data/lib/cape/core_ext/hash.rb +1 -0
- data/lib/cape/core_ext/symbol.rb +1 -0
- data/lib/cape/dsl.rb +29 -13
- data/lib/cape/hash_list.rb +80 -0
- data/lib/cape/rake.rb +12 -7
- data/lib/cape/util.rb +3 -1
- data/lib/cape/version.rb +1 -1
- data/spec/cape/capistrano_spec.rb +1 -0
- data/spec/cape/core_ext/hash_spec.rb +1 -0
- data/spec/cape/core_ext/symbol_spec.rb +1 -0
- data/spec/cape/dsl_spec.rb +1 -1
- data/spec/cape/hash_list_spec.rb +48 -0
- data/spec/cape/rake_spec.rb +5 -2
- data/spec/cape/util_spec.rb +1 -0
- data/spec/cape/version_spec.rb +1 -0
- data/spec/cape_spec.rb +1 -0
- data/spec/spec_helper.rb +18 -3
- metadata +92 -80
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_namespace_argument.feature +0 -110
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_defined_task_argument.feature +0 -60
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/with_undefined_argument.feature +0 -35
- data/features/dsl/mirror_rake_tasks/inside_capistrano_namespace/without_arguments.feature +0 -290
@@ -9,7 +9,7 @@ Feature: The #mirror_rake_tasks DSL method with an argument of a defined task
|
|
9
9
|
And a Capfile with:
|
10
10
|
"""
|
11
11
|
Cape do
|
12
|
-
mirror_rake_tasks
|
12
|
+
mirror_rake_tasks :with_period
|
13
13
|
end
|
14
14
|
"""
|
15
15
|
When I run `cap -vT`
|
@@ -17,38 +17,23 @@ Feature: The #mirror_rake_tasks DSL method with an argument of a defined task
|
|
17
17
|
"""
|
18
18
|
cap with_period # Ends with period.
|
19
19
|
"""
|
20
|
-
And the output should not contain "
|
20
|
+
And the output should not contain "without_period"
|
21
21
|
|
22
|
-
Scenario: mirror Rake task
|
22
|
+
Scenario: mirror the matching Rake task with its implementation
|
23
23
|
Given a full-featured Rakefile
|
24
24
|
And a Capfile with:
|
25
25
|
"""
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
"""
|
30
|
-
When I run `cap -e with_period`
|
31
|
-
Then the output should contain exactly:
|
32
|
-
"""
|
33
|
-
------------------------------------------------------------
|
34
|
-
cap with_period
|
35
|
-
------------------------------------------------------------
|
36
|
-
Ends with period.
|
26
|
+
set :current_path, '/path/to/current/deployed/application'
|
27
|
+
set :rails_env, 'production'
|
37
28
|
|
38
|
-
|
39
|
-
"""
|
40
|
-
|
41
|
-
Scenario: do not mirror Rake task 'without_period'
|
42
|
-
Given a full-featured Rakefile
|
43
|
-
And a Capfile with:
|
44
|
-
"""
|
45
29
|
Cape do
|
46
|
-
mirror_rake_tasks
|
30
|
+
mirror_rake_tasks 'with_period'
|
47
31
|
end
|
48
32
|
"""
|
49
|
-
When I run `cap
|
50
|
-
Then the output should contain
|
33
|
+
When I run `cap with_period`
|
34
|
+
Then the output should contain:
|
51
35
|
"""
|
52
|
-
|
53
|
-
|
36
|
+
* executing `with_period'
|
37
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
|
38
|
+
`with_period' is only run for servers matching {}, but no servers matched
|
54
39
|
"""
|
data/features/dsl/mirror_rake_tasks/with_defined_task_argument_and_environment_variables.feature
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with an argument of a defined task, and with environment variables
|
2
|
+
|
3
|
+
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
|
+
As a developer using Cape,
|
5
|
+
I want to use the Cape DSL.
|
6
|
+
|
7
|
+
Scenario: mirror only the matching Rake task
|
8
|
+
Given a full-featured Rakefile
|
9
|
+
And a Capfile with:
|
10
|
+
"""
|
11
|
+
Cape do
|
12
|
+
mirror_rake_tasks :with_period do |env|
|
13
|
+
env['RAILS_ENV'] = rails_env
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I run `cap -vT`
|
18
|
+
Then the output should contain:
|
19
|
+
"""
|
20
|
+
cap with_period # Ends with period.
|
21
|
+
"""
|
22
|
+
And the output should not contain "without_period"
|
23
|
+
|
24
|
+
Scenario: mirror the matching Rake task with its implementation
|
25
|
+
Given a full-featured Rakefile
|
26
|
+
And a Capfile with:
|
27
|
+
"""
|
28
|
+
set :current_path, '/path/to/current/deployed/application'
|
29
|
+
set :rails_env, 'production'
|
30
|
+
|
31
|
+
Cape do
|
32
|
+
mirror_rake_tasks 'with_period' do |env|
|
33
|
+
env['RAILS_ENV'] = rails_env
|
34
|
+
end
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
When I run `cap with_period`
|
38
|
+
Then the output should contain:
|
39
|
+
"""
|
40
|
+
* executing `with_period'
|
41
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"production\""
|
42
|
+
`with_period' is only run for servers matching {}, but no servers matched
|
43
|
+
"""
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with environment variables
|
2
|
+
|
3
|
+
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
|
+
As a developer using Cape,
|
5
|
+
I want to use the Cape DSL.
|
6
|
+
|
7
|
+
Scenario: mirror a Rake task with its implementation
|
8
|
+
Given a full-featured Rakefile
|
9
|
+
And a Capfile with:
|
10
|
+
"""
|
11
|
+
set :current_path, '/path/to/current/deployed/application'
|
12
|
+
set :rails_env, 'production'
|
13
|
+
|
14
|
+
Cape do
|
15
|
+
mirror_rake_tasks do |env|
|
16
|
+
env['RAILS_ENV'] = rails_env
|
17
|
+
env[nil] = 'foo'
|
18
|
+
env['FOO'] = nil
|
19
|
+
env['SOME_OTHER'] = 'var'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
"""
|
23
|
+
When I run `cap with_period`
|
24
|
+
Then the output should contain:
|
25
|
+
"""
|
26
|
+
* executing `with_period'
|
27
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"production\" SOME_OTHER=\"var\""
|
28
|
+
`with_period' is only run for servers matching {}, but no servers matched
|
29
|
+
"""
|
@@ -5,17 +5,6 @@ Feature: The #mirror_rake_tasks DSL method with an undefined argument
|
|
5
5
|
I want to use the Cape DSL.
|
6
6
|
|
7
7
|
Scenario: do not mirror any Rake tasks
|
8
|
-
Given a full-featured Rakefile
|
9
|
-
And a Capfile with:
|
10
|
-
"""
|
11
|
-
Cape do
|
12
|
-
mirror_rake_tasks 'this_does_not_exist'
|
13
|
-
end
|
14
|
-
"""
|
15
|
-
When I run `cap -vT`
|
16
|
-
Then the output should not contain "cap with_period"
|
17
|
-
|
18
|
-
Scenario: do not mirror Rake task 'with_period'
|
19
8
|
Given a full-featured Rakefile
|
20
9
|
And a Capfile with:
|
21
10
|
"""
|
@@ -23,9 +12,6 @@ Feature: The #mirror_rake_tasks DSL method with an undefined argument
|
|
23
12
|
mirror_rake_tasks :this_does_not_exist
|
24
13
|
end
|
25
14
|
"""
|
26
|
-
When I run `cap -
|
27
|
-
Then the output should contain
|
28
|
-
|
29
|
-
The task `with_period' does not exist.
|
30
|
-
|
31
|
-
"""
|
15
|
+
When I run `cap -vT`
|
16
|
+
Then the output should not contain "cap this_does_not_exist"
|
17
|
+
And the output should not contain "cap with_period"
|
@@ -1,75 +1,10 @@
|
|
1
|
-
Feature: The #mirror_rake_tasks DSL method with
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with an argument of valid options
|
2
2
|
|
3
3
|
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
4
|
As a developer using Cape,
|
5
5
|
I want to use the Cape DSL.
|
6
6
|
|
7
|
-
Scenario: mirror
|
8
|
-
Given a full-featured Rakefile
|
9
|
-
And a Capfile with:
|
10
|
-
"""
|
11
|
-
Cape do
|
12
|
-
mirror_rake_tasks :roles => :app
|
13
|
-
end
|
14
|
-
"""
|
15
|
-
When I run `cap -vT`
|
16
|
-
Then the output should contain:
|
17
|
-
"""
|
18
|
-
cap with_period # Ends with period.
|
19
|
-
"""
|
20
|
-
And the output should contain:
|
21
|
-
"""
|
22
|
-
cap without_period # Ends without period.
|
23
|
-
"""
|
24
|
-
And the output should contain:
|
25
|
-
"""
|
26
|
-
cap long # My long task -- it has a ve...
|
27
|
-
"""
|
28
|
-
And the output should contain:
|
29
|
-
"""
|
30
|
-
cap with_one_arg # My task with one argument.
|
31
|
-
"""
|
32
|
-
And the output should contain:
|
33
|
-
"""
|
34
|
-
cap my_namespace # A task that shadows a names...
|
35
|
-
"""
|
36
|
-
And the output should contain:
|
37
|
-
"""
|
38
|
-
cap my_namespace:in_a_namespace # My task in a namespace.
|
39
|
-
"""
|
40
|
-
And the output should contain:
|
41
|
-
"""
|
42
|
-
cap my_namespace:my_nested_namespace:in_a_nested_namespace # My task in a nested namespace.
|
43
|
-
"""
|
44
|
-
And the output should contain:
|
45
|
-
"""
|
46
|
-
cap with_two_args # My task with two arguments.
|
47
|
-
"""
|
48
|
-
And the output should contain:
|
49
|
-
"""
|
50
|
-
cap with_three_args # My task with three arguments.
|
51
|
-
"""
|
52
|
-
|
53
|
-
Scenario: mirror Rake task 'with_period' with its description
|
54
|
-
Given a full-featured Rakefile
|
55
|
-
And a Capfile with:
|
56
|
-
"""
|
57
|
-
Cape do
|
58
|
-
mirror_rake_tasks :roles => :app
|
59
|
-
end
|
60
|
-
"""
|
61
|
-
When I run `cap -e with_period`
|
62
|
-
Then the output should contain exactly:
|
63
|
-
"""
|
64
|
-
------------------------------------------------------------
|
65
|
-
cap with_period
|
66
|
-
------------------------------------------------------------
|
67
|
-
Ends with period.
|
68
|
-
|
69
|
-
|
70
|
-
"""
|
71
|
-
|
72
|
-
Scenario: mirror Rake task 'with_period' with its implementation
|
7
|
+
Scenario: mirror a Rake task with its implementation
|
73
8
|
Given a full-featured Rakefile
|
74
9
|
And a Capfile with:
|
75
10
|
"""
|
data/features/dsl/mirror_rake_tasks/with_valid_options_arguments_and_environment_variables.feature
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: The #mirror_rake_tasks DSL method with an argument of valid options, and with environment variables
|
2
|
+
|
3
|
+
In order to include Rake tasks with descriptions in my Capistrano recipes,
|
4
|
+
As a developer using Cape,
|
5
|
+
I want to use the Cape DSL.
|
6
|
+
|
7
|
+
Scenario: mirror a Rake task with its implementation
|
8
|
+
Given a full-featured Rakefile
|
9
|
+
And a Capfile with:
|
10
|
+
"""
|
11
|
+
set :current_path, '/path/to/current/deployed/application'
|
12
|
+
set :rails_env, 'production'
|
13
|
+
|
14
|
+
Cape do
|
15
|
+
mirror_rake_tasks :roles => :app do |env|
|
16
|
+
env['RAILS_ENV'] = rails_env
|
17
|
+
end
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
When I run `cap with_period`
|
21
|
+
Then the output should contain:
|
22
|
+
"""
|
23
|
+
* executing `with_period'
|
24
|
+
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period RAILS_ENV=\"production\""
|
25
|
+
`with_period' is only run for servers matching {:roles=>:app}, but no servers matched
|
26
|
+
"""
|
@@ -84,6 +84,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
84
84
|
"""
|
85
85
|
* executing `with_period'
|
86
86
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_period"
|
87
|
+
`with_period' is only run for servers matching {}, but no servers matched
|
87
88
|
"""
|
88
89
|
|
89
90
|
Scenario: mirror Rake task 'without_period' with its description
|
@@ -181,6 +182,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
181
182
|
"""
|
182
183
|
* executing `my_namespace'
|
183
184
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake my_namespace"
|
185
|
+
`my_namespace' is only run for servers matching {}, but no servers matched
|
184
186
|
"""
|
185
187
|
|
186
188
|
Scenario: mirror Rake task 'my_namespace:in_a_namespace' with its description
|
@@ -236,6 +238,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
236
238
|
"""
|
237
239
|
* executing `my_namespace:my_nested_namespace:in_a_nested_namespace'
|
238
240
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake my_namespace:my_nested_namespace:in_a_nested_namespace"
|
241
|
+
`my_namespace:my_nested_namespace:in_a_nested_namespace' is only run for servers matching {}, but no servers matched
|
239
242
|
"""
|
240
243
|
|
241
244
|
Scenario: mirror Rake task 'with_two_args' with its description
|
@@ -297,7 +300,7 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
297
300
|
"""
|
298
301
|
* executing `with_three_args'
|
299
302
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[\"a value for an_arg1\",\"a value for an_arg2\",\"a value for an_arg3\"]"
|
300
|
-
|
303
|
+
`with_three_args' is only run for servers matching {}, but no servers matched
|
301
304
|
"""
|
302
305
|
|
303
306
|
Scenario: mirror Rake task 'with_three_args' with its implementation not enforcing arguments
|
@@ -315,5 +318,5 @@ Feature: The #mirror_rake_tasks DSL method without arguments
|
|
315
318
|
"""
|
316
319
|
* executing `with_three_args'
|
317
320
|
* executing "cd /path/to/current/deployed/application && /usr/bin/env `/usr/bin/env bundle check >/dev/null 2>&1; case $? in 0|1 ) echo bundle exec ;; esac` rake with_three_args[,\"a value for an_arg2\",]"
|
318
|
-
|
321
|
+
`with_three_args' is only run for servers matching {}, but no servers matched
|
319
322
|
"""
|
data/lib/cape/capistrano.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cape/hash_list'
|
1
2
|
require 'cape/rake'
|
2
3
|
require 'cape/util'
|
3
4
|
|
@@ -10,6 +11,8 @@ module Cape
|
|
10
11
|
attr_accessor :rake
|
11
12
|
|
12
13
|
# Constructs a new Capistrano object with the specified _attributes_.
|
14
|
+
#
|
15
|
+
# @param [Hash] attributes attribute values
|
13
16
|
def initialize(attributes={})
|
14
17
|
attributes.each do |name, value|
|
15
18
|
send "#{name}=", value
|
@@ -44,7 +47,7 @@ module Cape
|
|
44
47
|
#
|
45
48
|
# @note Any parameters that the Rake task has are integrated via environment variables, since Capistrano does not support recipe parameters per se.
|
46
49
|
#
|
47
|
-
# @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/
|
50
|
+
# @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/actions/invocation.rb#L99-L144 Valid Capistrano ‘task’ method options
|
48
51
|
def define_rake_wrapper(task, named_arguments, &block)
|
49
52
|
unless (binding = named_arguments[:binding])
|
50
53
|
raise ::ArgumentError, ':binding named argument is required'
|
@@ -54,13 +57,13 @@ module Cape
|
|
54
57
|
options = named_arguments.reject do |key, value|
|
55
58
|
key == :binding
|
56
59
|
end
|
57
|
-
describe
|
60
|
+
describe task, capistrano_context
|
58
61
|
implement(task, capistrano_context, options, &block)
|
59
62
|
end
|
60
63
|
|
61
64
|
private
|
62
65
|
|
63
|
-
def build_capistrano_description(task
|
66
|
+
def build_capistrano_description(task)
|
64
67
|
return nil unless task[:description]
|
65
68
|
|
66
69
|
description = [task[:description]]
|
@@ -85,8 +88,8 @@ Set environment #{noun} #{parameters_list} if you want to pass #{noun_phrase}.
|
|
85
88
|
description.join
|
86
89
|
end
|
87
90
|
|
88
|
-
def describe(task, capistrano_context
|
89
|
-
if (description = build_capistrano_description(task
|
91
|
+
def describe(task, capistrano_context)
|
92
|
+
if (description = build_capistrano_description(task))
|
90
93
|
capistrano_context.desc description
|
91
94
|
end
|
92
95
|
self
|
@@ -110,7 +113,7 @@ Set environment #{noun} #{parameters_list} if you want to pass #{noun_phrase}.
|
|
110
113
|
else
|
111
114
|
arguments = "[#{arguments.join ','}]"
|
112
115
|
end
|
113
|
-
env_hash =
|
116
|
+
env_hash = HashList.new
|
114
117
|
env_block.call(env_hash) if env_block
|
115
118
|
env_hash.reject! do |var_name, var_value|
|
116
119
|
var_name.nil? || var_value.nil?
|
data/lib/cape/core_ext/hash.rb
CHANGED
data/lib/cape/core_ext/symbol.rb
CHANGED
@@ -8,6 +8,7 @@ module Cape
|
|
8
8
|
# Compares the String representation of the Symbol to that of another.
|
9
9
|
#
|
10
10
|
# @param [Symbol] other
|
11
|
+
#
|
11
12
|
# @return [0] the Symbol is equal to _other_
|
12
13
|
# @return [-1] the Symbol is lesser than _other_
|
13
14
|
# @return [1] the Symbol is greater than _other_
|
data/lib/cape/dsl.rb
CHANGED
@@ -9,7 +9,7 @@ module Cape
|
|
9
9
|
# Enumerates Rake tasks.
|
10
10
|
#
|
11
11
|
# @param [String, Symbol] task_expression the full name of a task or
|
12
|
-
# namespace to filter
|
12
|
+
# namespace to filter
|
13
13
|
# @param [Proc] block a block that processes tasks
|
14
14
|
#
|
15
15
|
# @yield [task] a block that processes tasks
|
@@ -27,7 +27,8 @@ module Cape
|
|
27
27
|
# # Do something interesting with this hash:
|
28
28
|
# # * t[:name] -- the full name of the task
|
29
29
|
# # * t[:parameters] -- the names of task arguments
|
30
|
-
# # * t[:description] -- documentation on the task, including
|
30
|
+
# # * t[:description] -- documentation on the task, including
|
31
|
+
# # parameters
|
31
32
|
# end
|
32
33
|
# end
|
33
34
|
#
|
@@ -41,7 +42,8 @@ module Cape
|
|
41
42
|
# # Do something interesting with this hash:
|
42
43
|
# # * t[:name] -- the full name of the task
|
43
44
|
# # * t[:parameters] -- the names of task arguments
|
44
|
-
# # * t[:description] -- documentation on the task, including
|
45
|
+
# # * t[:description] -- documentation on the task, including
|
46
|
+
# # parameters
|
45
47
|
# end
|
46
48
|
# end
|
47
49
|
def each_rake_task(task_expression=nil, &block)
|
@@ -61,6 +63,7 @@ module Cape
|
|
61
63
|
# Sets the command used to run Rake on the local computer.
|
62
64
|
#
|
63
65
|
# @param [String] value the command used to run Rake on the local computer
|
66
|
+
#
|
64
67
|
# @return [String] _value_
|
65
68
|
#
|
66
69
|
# @example Changing the local Rake executable
|
@@ -68,7 +71,8 @@ module Cape
|
|
68
71
|
#
|
69
72
|
# Cape do
|
70
73
|
# self.local_rake_executable = '/path/to/rake'
|
71
|
-
# $stdout.puts
|
74
|
+
# $stdout.puts 'We changed the local Rake executable to ' +
|
75
|
+
# "#{local_rake_executable.inspect}."
|
72
76
|
# end
|
73
77
|
def local_rake_executable=(value)
|
74
78
|
rake.local_executable = value
|
@@ -80,6 +84,7 @@ module Cape
|
|
80
84
|
# @param [Symbol, String] method the method called
|
81
85
|
# @param [Array] args the arguments passed to _method_
|
82
86
|
# @param [Proc] block the block passed to _method_
|
87
|
+
#
|
83
88
|
# @return the result of the forwarded method call
|
84
89
|
def method_missing(method, *args, &block)
|
85
90
|
@outer_self.send(method, *args, &block)
|
@@ -91,7 +96,7 @@ module Cape
|
|
91
96
|
# Defines Rake tasks as Capistrano recipes.
|
92
97
|
#
|
93
98
|
# @param [String, Symbol] task_expression the full name of a Rake task or
|
94
|
-
# namespace to filter
|
99
|
+
# namespace to filter
|
95
100
|
#
|
96
101
|
# @yield [env] a block that defines environment variables for the Rake
|
97
102
|
# task; optional
|
@@ -132,7 +137,7 @@ module Cape
|
|
132
137
|
#
|
133
138
|
# @note Any parameters that the Rake tasks have are integrated via environment variables, since Capistrano does not support recipe parameters per se.
|
134
139
|
#
|
135
|
-
# @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/
|
140
|
+
# @see http://github.com/capistrano/capistrano/blob/master/lib/capistrano/configuration/actions/invocation.rb#L99-L144 Valid Capistrano ‘task’ method options
|
136
141
|
#
|
137
142
|
# @example Mirroring all Rake tasks
|
138
143
|
# # config/deploy.rb
|
@@ -143,22 +148,31 @@ module Cape
|
|
143
148
|
# mirror_rake_tasks
|
144
149
|
# end
|
145
150
|
#
|
146
|
-
# @example Mirroring
|
151
|
+
# @example Mirroring some Rake tasks, but not others
|
147
152
|
# # config/deploy.rb
|
148
153
|
#
|
149
154
|
# require 'cape'
|
150
155
|
#
|
151
156
|
# Cape do
|
152
|
-
#
|
157
|
+
# # Create Capistrano recipes for the Rake task 'foo' and/or for the
|
158
|
+
# # tasks in the 'foo' namespace.
|
159
|
+
# mirror_rake_tasks :foo
|
153
160
|
# end
|
154
161
|
#
|
155
|
-
# @example Mirroring
|
162
|
+
# @example Mirroring Rake tasks that require Capistrano recipe options and/or environment variables
|
156
163
|
# # config/deploy.rb
|
157
164
|
#
|
158
165
|
# require 'cape'
|
159
166
|
#
|
160
167
|
# Cape do
|
161
|
-
#
|
168
|
+
# # Display defined Rails routes on application server remote machines
|
169
|
+
# # only.
|
170
|
+
# mirror_rake_tasks :routes, :roles => :app
|
171
|
+
#
|
172
|
+
# # Execute database migration on application server remote machines
|
173
|
+
# # only, and set the 'RAILS_ENV' environment variable to the value of
|
174
|
+
# # the Capistrano variable 'rails_env'.
|
175
|
+
# mirror_rake_tasks 'db:migrate', :roles => :app do |env|
|
162
176
|
# env['RAILS_ENV'] = rails_env
|
163
177
|
# end
|
164
178
|
# end
|
@@ -178,8 +192,8 @@ module Cape
|
|
178
192
|
options = arguments.last.is_a?(Hash) ? arguments.pop.dup : {}
|
179
193
|
unless arguments.length <= 1
|
180
194
|
raise ::ArgumentError,
|
181
|
-
"wrong number of arguments (#{arguments_count} for 0 or 1,
|
182
|
-
|
195
|
+
("wrong number of arguments (#{arguments_count} for 0 or 1, " +
|
196
|
+
'plus an options hash)')
|
183
197
|
end
|
184
198
|
|
185
199
|
task_expression = arguments.first
|
@@ -202,6 +216,7 @@ module Cape
|
|
202
216
|
# Sets the command used to run Rake on remote computers.
|
203
217
|
#
|
204
218
|
# @param [String] value the command used to run Rake on remote computers
|
219
|
+
#
|
205
220
|
# @return [String] _value_
|
206
221
|
#
|
207
222
|
# @example Changing the remote Rake executable
|
@@ -209,7 +224,8 @@ module Cape
|
|
209
224
|
#
|
210
225
|
# Cape do
|
211
226
|
# self.remote_rake_executable = '/path/to/rake'
|
212
|
-
# $stdout.puts
|
227
|
+
# $stdout.puts 'We changed the remote Rake executable to ' +
|
228
|
+
# "#{remote_rake_executable.inspect}."
|
213
229
|
# end
|
214
230
|
def remote_rake_executable=(value)
|
215
231
|
rake.remote_executable = value
|