File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ appear at the top.
32
32
and have a cleaner internal API. You can still completely disable the pool
33
33
by setting ` SSHKit::Backend::Netssh.pool.idle_timeout = 0 ` .
34
34
@mattbrictson @byroot [ PR #328 ] ( https://github.com/capistrano/sshkit/pull/328 )
35
+ * Allow command map entries (` SSHKit::CommandMap#[] ` ) to be Procs
36
+ [ PR #310 ] ((https://github.com/capistrano/sshkit/pull/310 )
37
+ @mikz
35
38
36
39
### Bug fixes
37
40
Original file line number Diff line number Diff line change @@ -31,18 +31,20 @@ def [](command)
31
31
end
32
32
end
33
33
34
+ TO_VALUE = -> ( obj ) { obj . respond_to? ( :call ) ? obj . call : obj }
35
+
34
36
def initialize ( value = nil )
35
37
@map = CommandHash . new ( value || defaults )
36
38
end
37
39
38
40
def []( command )
39
41
if prefix [ command ] . any?
40
- prefixes = prefix [ command ] . map { | prefix | prefix . respond_to? ( :call ) ? prefix . call : prefix }
42
+ prefixes = prefix [ command ] . map ( & TO_VALUE )
41
43
prefixes = prefixes . join ( " " )
42
44
43
45
"#{ prefixes } #{ command } "
44
46
else
45
- @map [ command ]
47
+ TO_VALUE . ( @map [ command ] )
46
48
end
47
49
end
48
50
Original file line number Diff line number Diff line change @@ -16,6 +16,15 @@ def test_setter
16
16
assert_equal map [ :rake ] , "/usr/local/rbenv/shims/rake"
17
17
end
18
18
19
+ def test_setter_procs
20
+ map = CommandMap . new
21
+ i = 0
22
+ map [ :rake ] = -> { i += 1 ; "/usr/local/rbenv/shims/rake#{ i } " }
23
+
24
+ assert_equal map [ :rake ] , "/usr/local/rbenv/shims/rake1"
25
+ assert_equal map [ :rake ] , "/usr/local/rbenv/shims/rake2"
26
+ end
27
+
19
28
def test_prefix
20
29
map = CommandMap . new
21
30
map . prefix [ :rake ] . push ( "/home/vagrant/.rbenv/bin/rbenv exec" )
You can’t perform that action at this time.
0 commit comments