capistrano 3.6.0 → 3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dffc85194d6ad3db0812f96e216fe5d95a508e9
4
- data.tar.gz: f93a202158ed81afecc72d6d19db46b9c965fdad
3
+ metadata.gz: 1948ef0e60f92eb2ca3eee3f5a67e96e5c0e0612
4
+ data.tar.gz: 8b16bda549777df3faadb59ed76cebc58dec095d
5
5
  SHA512:
6
- metadata.gz: 07cb65b0395968f71258ab6e0f6886d658f5c5f6a87e1780537474855f19453c2c09e77fc7b6d7d11ce062133aca191dc1be4e19ad9f21b22c37d82a86925e55
7
- data.tar.gz: 65d563a1ae4fce777c70c225f2f5d711d4c5e68493b3254215a372ba72f06fb4cf410637ab82758af6d2ac91d91ec8c11c8648da4c5a57deec7800838b30a6c4
6
+ metadata.gz: e2f8bdbc484772a5d54a40449dd4f2b5480fb76c906d55d57c1dbe593072487a0f717dfc00702b16aa308ada41d9df3543601179a5bc4c9cd53abe55e4de355c
7
+ data.tar.gz: c7312872efddec76244ee17dffa32da76108a7073c326654f207437806f86693bacac9fd0a55546e13f5004ac13046f4b26a11af3e7c17ad57ad87a8895130da
@@ -4,10 +4,20 @@ Reverse Chronological Order:
4
4
 
5
5
  ## master
6
6
 
7
- https://github.com/capistrano/capistrano/compare/v3.6.0...HEAD
7
+ https://github.com/capistrano/capistrano/compare/v3.6.1...HEAD
8
8
 
9
9
  * Your contribution here!
10
10
 
11
+ ## `3.6.1` (2016-08-23)
12
+
13
+ https://github.com/capistrano/capistrano/compare/v3.6.0...v3.6.1
14
+
15
+ ### Fixes:
16
+
17
+ * Restore compatibility with older versions of Rake (< 11.0.0) (@troelskn)
18
+ * Fix `NoMethodError: undefined method gsub` when setting `:application` to a Proc. The original fix released in 3.6.0 worked for values specified with blocks, but not for those specified with procs or lambdas (the latter syntax is much more common). [#1681](https://github.com/capistrano/capistrano/issues/1681)
19
+ * Fix a bug where deploy would fail if `:local_user` contained a space; spaces are now replaced with dashes when computing the git-ssh suffix. (@will_in_wi)
20
+
11
21
  ## `3.6.0` (2016-07-26)
12
22
 
13
23
  https://github.com/capistrano/capistrano/compare/v3.5.0...v3.6.0
@@ -7,9 +7,9 @@ module Capistrano
7
7
  # user-supplied validation rules. Each rule for a given key is invoked
8
8
  # immediately whenever `set` is called with a value for that key.
9
9
  #
10
- # If `set` is called with a block, validation is not performed immediately.
11
- # Instead, the validation rules are invoked the first time `fetch` is used
12
- # to access the value.
10
+ # If `set` is called with a callable value or a block, validation is not
11
+ # performed immediately. Instead, the validation rules are invoked the first
12
+ # time `fetch` is used to access the value.
13
13
  #
14
14
  # A rule is simply a block that accepts two arguments: key and value. It is
15
15
  # up to the rule to raise an exception when it deems the value is invalid
@@ -31,10 +31,17 @@ module Capistrano
31
31
 
32
32
  # Decorate Variables#set to add validation behavior.
33
33
  def set(key, value=nil, &block)
34
- if value.nil? && callable_without_parameters?(block)
35
- super(key, nil, &assert_valid_later(key, &block))
34
+ assert_value_or_block_not_both(value, block)
35
+
36
+ # Skip validation behavior if no validators are registered for this key
37
+ return super unless validators.key?(key)
38
+
39
+ value_to_evaluate = block || value
40
+
41
+ if callable_without_parameters?(value_to_evaluate)
42
+ super(key, assert_valid_later(key, value_to_evaluate), &nil)
36
43
  else
37
- assert_valid_now(key, block || value)
44
+ assert_valid_now(key, value_to_evaluate)
38
45
  super
39
46
  end
40
47
  end
@@ -50,26 +57,55 @@ module Capistrano
50
57
 
51
58
  attr_reader :validators
52
59
 
53
- # Wrap a block with a proc that validates the value of the block. This
54
- # allows us to defer validation until the time the value is requested.
55
- def assert_valid_later(key)
56
- lambda do
57
- value = yield
60
+ # Given a callable that provides a value, wrap the callable with another
61
+ # object that responds to `call`. This new object will perform validation
62
+ # and then return the original callable's value.
63
+ #
64
+ # If the callable is a `Question`, the object returned by this method will
65
+ # also be a `Question` (a `ValidatedQuestion`, to be precise). This
66
+ # ensures that `is_a?(Question)` remains true even after the validation
67
+ # wrapper is applied. This is needed so that `Configuration#is_question?`
68
+ # works as expected.
69
+ #
70
+ def assert_valid_later(key, callable)
71
+ validation_callback = lambda do
72
+ value = callable.call
58
73
  assert_valid_now(key, value)
59
74
  value
60
75
  end
76
+
77
+ if callable.is_a?(Question)
78
+ ValidatedQuestion.new(validation_callback)
79
+ else
80
+ validation_callback
81
+ end
61
82
  end
62
83
 
63
84
  # Runs all validation rules registered for the given key against the
64
85
  # user-supplied value for that variable. If no validator raises an
65
86
  # exception, the value is assumed to be valid.
66
87
  def assert_valid_now(key, value)
67
- return unless validators.key?(key)
68
-
69
88
  validators[key].each do |validator|
70
89
  validator.call(key, value)
71
90
  end
72
91
  end
92
+
93
+ def assert_value_or_block_not_both(value, block)
94
+ unless value.nil? || block.nil?
95
+ raise Capistrano::ValidationError,
96
+ "Value and block both passed to Configuration#set"
97
+ end
98
+ end
99
+
100
+ class ValidatedQuestion < Question
101
+ def initialize(validator)
102
+ @validator = validator
103
+ end
104
+
105
+ def call
106
+ @validator.call
107
+ end
108
+ end
73
109
  end
74
110
  end
75
111
  end
@@ -35,7 +35,6 @@ module Capistrano
35
35
  end
36
36
 
37
37
  def set(key, value=nil, &block)
38
- assert_value_or_block_not_both(value, block)
39
38
  @trusted_keys << key if trusted?
40
39
  remember_location(key)
41
40
  values[key] = block || value
@@ -104,13 +103,6 @@ module Capistrano
104
103
  (locations[key] ||= []) << location
105
104
  end
106
105
 
107
- def assert_value_or_block_not_both(value, block)
108
- unless value.nil? || block.nil?
109
- raise Capistrano::ValidationError,
110
- "Value and block both passed to Configuration#set"
111
- end
112
- end
113
-
114
106
  def trace_set(key)
115
107
  return unless fetch(:print_config_variables, false)
116
108
  puts "Config variable set: #{key.inspect} => #{values[key].inspect}"
@@ -13,7 +13,8 @@ module Capistrano
13
13
 
14
14
  def invoke(task_name, *args)
15
15
  task = Rake::Task[task_name]
16
- if task && task.already_invoked
16
+ # NOTE: We access instance variable since the accessor was only added recently. Once Capistrano depends on rake 11+, we can revert the following line
17
+ if task && task.instance_variable_get(:@already_invoked)
17
18
  file, line, = caller.first.split(":")
18
19
  colors = SSHKit::Color.new($stderr)
19
20
  $stderr.puts colors.colorize("Skipping task `#{task_name}'.", :yellow)
@@ -6,7 +6,7 @@ namespace :git do
6
6
  set :git_wrapper_path, lambda {
7
7
  # Try to avoid permissions issues when multiple users deploy the same app
8
8
  # by using different file names in the same dir for each deployer and stage.
9
- suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-")
9
+ suffix = [:application, :stage, :local_user].map { |key| fetch(key).to_s }.join("-").gsub(/\s+/, "-")
10
10
  "#{fetch(:tmp_dir)}/git-ssh-#{suffix}.sh"
11
11
  }
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Capistrano
2
- VERSION = "3.6.0".freeze
2
+ VERSION = "3.6.1".freeze
3
3
  end
@@ -154,19 +154,29 @@ module Capistrano
154
154
  config.set(:key, "longer_value")
155
155
  end
156
156
 
157
- it "validates proc without error" do
157
+ it "validates block without error" do
158
158
  config.set(:key) { "longer_value" }
159
159
  expect(config.fetch(:key)).to eq "longer_value"
160
160
  end
161
161
 
162
+ it "validates lambda without error" do
163
+ config.set :key, -> { "longer_value" }
164
+ expect(config.fetch(:key)).to eq "longer_value"
165
+ end
166
+
162
167
  it "raises an exception on invalid string" do
163
168
  expect { config.set(:key, "sho") }.to raise_error(Capistrano::ValidationError)
164
169
  end
165
170
 
166
- it "raises an exception on invalid string provided by proc" do
171
+ it "raises an exception on invalid string provided by block" do
167
172
  config.set(:key) { "sho" }
168
173
  expect { config.fetch(:key) }.to raise_error(Capistrano::ValidationError)
169
174
  end
175
+
176
+ it "raises an exception on invalid string provided by lambda" do
177
+ config.set :key, -> { "sho" }
178
+ expect { config.fetch(:key) }.to raise_error(Capistrano::ValidationError)
179
+ end
170
180
  end
171
181
 
172
182
  context "appending" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Clements
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-26 00:00:00.000000000 Z
12
+ date: 2016-08-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: airbrussh