sshkit-interactive 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 85a367dc3b5b858208966b608522f5cfa5437184
4
- data.tar.gz: dbade21d2bfb2b0e4e438ccff779f4d998f1d5cc
2
+ SHA256:
3
+ metadata.gz: 51e9cecfe07a2b9b600c7399e0c33ffc2e916ac28badd117948bdc20d9878ad1
4
+ data.tar.gz: cf9cea1f88cb5868630f1c2aebe2e0f35faa7db2fe3ded186243e405f97ffc90
5
5
  SHA512:
6
- metadata.gz: aa2aedd29c8f938e711165aacee63d03869e523bbe39950d99aa189fc210a1d567fabe882d8a2270dae8f1b90e04f332f2d8e3c43bc9b5f141fba431a08d1315
7
- data.tar.gz: 41adf32334b6ea3abe35eaa6a52a2970547366af9821fbd6a69c884b9d37a4039511d18e22073f5c833fc490cc7bd7c11a331cc7e5b9e089e6e773e17a0f3a94
6
+ metadata.gz: b9228c6782fbc0d77a97e2f32e45791147add79e785e4bced6225c7aab4170e74cad1eb40ae41e9312416266a2221112b38c822e379fd9577ed2b31b7cd9073d
7
+ data.tar.gz: 9b78d748aa11d9f9a9296e3b73ee2c1086133cc4b15ae274d24dca98ef89b55ef048fe0bc331225aba5c2a0a24c99502ef29ed7fda982c9fa356e0eb67bda319
@@ -3,11 +3,12 @@ sudo: false
3
3
  language: ruby
4
4
 
5
5
  rvm:
6
- - ruby-2.2.7
7
- - ruby-2.3.4
8
- - ruby-2.4.1
6
+ - ruby-2.2.9
7
+ - ruby-2.3.6
8
+ - ruby-2.4.3
9
+ - ruby-2.5.0
9
10
  - jruby-1.7
10
- - jruby-9.1.12.0
11
+ - jruby-9.1.15.0
11
12
 
12
13
  gemfile:
13
14
  - spec/gemfiles/net-ssh2_8.gemfile
@@ -17,6 +18,7 @@ gemfile:
17
18
  - spec/gemfiles/net-ssh3_2.gemfile
18
19
  - spec/gemfiles/net-ssh4_0.gemfile
19
20
  - spec/gemfiles/net-ssh4_1.gemfile
21
+ - spec/gemfiles/net-ssh4_2.gemfile
20
22
 
21
23
  matrix:
22
24
  exclude:
@@ -30,5 +32,7 @@ matrix:
30
32
  gemfile: spec/gemfiles/net-ssh4_0.gemfile
31
33
  - rvm: jruby-1.7
32
34
  gemfile: spec/gemfiles/net-ssh4_1.gemfile
35
+ - rvm: jruby-1.7
36
+ gemfile: spec/gemfiles/net-ssh4_2.gemfile
33
37
 
34
38
  script: bundle exec rake spec
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.3.0 (2018-02-03)
4
+ ### Feature
5
+ - allow to set shell
6
+
3
7
  ## 0.2.3 (2017-09-03)
4
8
  ### Fix
5
9
  - [fix sudo with new variable expansion](https://github.com/afeld/sshkit-interactive/pull/18)
data/README.md CHANGED
@@ -63,6 +63,17 @@ namespace :rails do
63
63
  end
64
64
  ```
65
65
 
66
+ And it is possible to set the shell to be used:
67
+
68
+ ```ruby
69
+ namespace :foo do
70
+ task :bar do
71
+ run_interactively primary(:app), shell: '/bin/bash' do
72
+ ...
73
+ end
74
+ end
75
+ end
76
+
66
77
  ### Manually setting the backend
67
78
 
68
79
  Use the [interactive backend](lib/sshkit/interactive/backend.rb) and execute commands as normal:
@@ -1,6 +1,12 @@
1
1
  module SSHKit
2
2
  module Interactive
3
3
  class Backend < SSHKit::Backend::Printer
4
+ def initialize(host, options = {}, &block)
5
+ super(host, &block)
6
+
7
+ @options = options
8
+ end
9
+
4
10
  def run
5
11
  instance_exec(host, &@block)
6
12
  end
@@ -34,7 +40,7 @@ module SSHKit
34
40
  super
35
41
 
36
42
  options = args.extract_options!
37
- cmd = Command.new(host, command(args, options))
43
+ cmd = Command.new(host, command(args, options), @options)
38
44
 
39
45
  debug(cmd.to_s)
40
46
 
@@ -7,9 +7,10 @@ module SSHKit
7
7
  #
8
8
  # @param host [SSHKit::Host] the host to run `remote_command` on.
9
9
  # @param remote_command [SSHKit::Command] the command to run on `host`.
10
- def initialize(host, remote_command = nil)
10
+ def initialize(host, remote_command = nil, options = {})
11
11
  @host = host
12
12
  @remote_command = remote_command
13
+ @options = options
13
14
  end
14
15
 
15
16
  # Run the command on the remote host via SSH binary.
@@ -86,9 +87,10 @@ module SSHKit
86
87
  end
87
88
 
88
89
  def command
89
- cmd = remote_command.to_command.gsub("'", "\\\"") # replace single quotes with double quotes
90
+ cmd = remote_command.to_command.gsub("'", "\\\"") # replace single quotes with double quotes
91
+ shell = @options[:shell] || '$SHELL'
90
92
 
91
- %Q{'$SHELL -l -c \"#{cmd}\"'}
93
+ %Q{'#{shell} -l -c \"#{cmd}\"'}
92
94
  end
93
95
  end
94
96
  end
@@ -2,13 +2,13 @@ module SSHKit
2
2
  module Interactive
3
3
  module DSL
4
4
  # run commands interactively
5
- def run_interactively(host, &block)
5
+ def run_interactively(host, options = {}, &block)
6
6
  # Force setting global netssh_options on host if using capistrano
7
7
  SSHKit.config.backend.new(host) { test(:true) }.run
8
8
 
9
9
  Thread.current[:run_interactively] = true
10
10
 
11
- SSHKit::Interactive::Backend.new(host, &block).run
11
+ SSHKit::Interactive::Backend.new(host, options, &block).run
12
12
  ensure
13
13
  Thread.current[:run_interactively] = false
14
14
  end
@@ -1,5 +1,5 @@
1
1
  module SSHKit
2
2
  module Interactive
3
- VERSION = '0.2.3'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -40,6 +40,12 @@ describe SSHKit::Interactive::Backend do
40
40
  end
41
41
  end
42
42
 
43
+ it 'respects the specified shell' do
44
+ expect_system_call('ssh -t -A example.com \'/bin/bash -l -c "/usr/bin/env ls"\'')
45
+
46
+ SSHKit::Interactive::Backend.new(host, shell: '/bin/bash').execute('ls')
47
+ end
48
+
43
49
  describe 'prevents calling unsupported operations' do
44
50
  it '#upload!' do
45
51
  expect { backend.upload!(:a, :b) }.to raise_error(::SSHKit::Backend::MethodUnavailableError)
@@ -12,6 +12,14 @@ describe SSHKit::Interactive::DSL do
12
12
  end
13
13
  end
14
14
 
15
+ it 'will use specified shell' do
16
+ expect_system_call('ssh -t -A example.com \'/bin/bash -l -c "/usr/bin/env ls"\'')
17
+
18
+ run_interactively host, shell: '/bin/bash' do
19
+ execute(:ls)
20
+ end
21
+ end
22
+
15
23
  it 'does not support switching hosts' do
16
24
  expect {
17
25
  run_interactively host do
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ gem 'net-ssh', '~> 4.2.0'
5
+
6
+ # Specify your gem's dependencies in sshkit-interactive.gemspec
7
+ gemspec path: '../..'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aidan Feldman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-03 00:00:00.000000000 Z
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sshkit
@@ -82,6 +82,7 @@ files:
82
82
  - spec/gemfiles/net-ssh3_2.gemfile
83
83
  - spec/gemfiles/net-ssh4_0.gemfile
84
84
  - spec/gemfiles/net-ssh4_1.gemfile
85
+ - spec/gemfiles/net-ssh4_2.gemfile
85
86
  - spec/spec_helper.rb
86
87
  - sshkit-interactive.gemspec
87
88
  homepage: https://github.com/afeld/sshkit-interactive
@@ -104,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  version: '0'
105
106
  requirements: []
106
107
  rubyforge_project:
107
- rubygems_version: 2.6.12
108
+ rubygems_version: 2.7.3
108
109
  signing_key:
109
110
  specification_version: 4
110
111
  summary: An SSHKit backend that allows you to execute interactive commands on your
@@ -120,4 +121,5 @@ test_files:
120
121
  - spec/gemfiles/net-ssh3_2.gemfile
121
122
  - spec/gemfiles/net-ssh4_0.gemfile
122
123
  - spec/gemfiles/net-ssh4_1.gemfile
124
+ - spec/gemfiles/net-ssh4_2.gemfile
123
125
  - spec/spec_helper.rb