ruby-ssh 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/ruby-ssh/result.rb +10 -0
- data/lib/ruby-ssh/session.rb +16 -0
- data/lib/ruby-ssh/shell_runner.rb +32 -0
- data/lib/ruby-ssh/version.rb +3 -0
- data/lib/ruby-ssh.rb +16 -0
- data/ruby-ssh.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e81e278215379b5b8cc8771a869e5e30a56985b2
|
4
|
+
data.tar.gz: fe632baf81715780f53ca88b989e3113ca337dab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c48a393fbe770891c2513a17890c72975193063ef366736c78f2a262313923094088fbea31cc479b69930b7795d15587a5268ad3f0adf481aaacf16d7c8b43a6
|
7
|
+
data.tar.gz: eb68f3c5109d9ccf7a141cdf64c9121006e3c6134a8a0d7288b24c266d004b5e9bddd3a601559ca0a723c67a5ae77e361c48eb1d1e6078cec4686a10c9f35f30
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Ruby::Ssh
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby/ssh`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruby-ssh'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruby-ssh
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/ruby-ssh/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby/ssh"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Net
|
2
|
+
module SSH
|
3
|
+
module Connection
|
4
|
+
class Session
|
5
|
+
# Provides a convenient way to initialize a shell given a Net::SSH
|
6
|
+
# session. Yields the new shell if a block is given. Returns the shell
|
7
|
+
# instance.
|
8
|
+
def shell_runner
|
9
|
+
runner = RubySSH::ShellRunner.new(self)
|
10
|
+
yield runner if block_given?
|
11
|
+
runner
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RubySSH
|
2
|
+
class ShellRunner
|
3
|
+
def initialize(session)
|
4
|
+
@session = session
|
5
|
+
end
|
6
|
+
|
7
|
+
def exec(script)
|
8
|
+
stdout, exit_status = nil
|
9
|
+
@session.open_channel do |channel|
|
10
|
+
channel.on_data do |ch, data|
|
11
|
+
stdout = data
|
12
|
+
end
|
13
|
+
|
14
|
+
channel.send_channel_request 'shell' do |ch, success|
|
15
|
+
if success
|
16
|
+
ch.send_data(script)
|
17
|
+
ch.process
|
18
|
+
ch.eof!
|
19
|
+
else
|
20
|
+
p "channel request error"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
channel.on_request "exit-status" do |ch, data|
|
25
|
+
exit_status = data.read_long
|
26
|
+
end
|
27
|
+
end
|
28
|
+
@session.loop
|
29
|
+
RubySSH::Result.new(stdout: stdout, exit_status: exit_status)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ruby-ssh.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
require "ruby-ssh/version"
|
3
|
+
require "ruby-ssh/session"
|
4
|
+
require "ruby-ssh/shell_runner"
|
5
|
+
require "ruby-ssh/result"
|
6
|
+
|
7
|
+
=begin
|
8
|
+
module RubySSH
|
9
|
+
def self.start(host, user, options = {}, &block)
|
10
|
+
Net::SSH::start(host, user, options) do |ssh|
|
11
|
+
p ssh.exec!('ls ~')
|
12
|
+
#yield
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
=end
|
data/ruby-ssh.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruby-ssh/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby-ssh"
|
8
|
+
spec.version = RubySSH::VERSION
|
9
|
+
spec.authors = ["a.harada"]
|
10
|
+
spec.email = ["mbl.atc.1hydrogen@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ A simple library ssh access. }
|
13
|
+
spec.description = %q{ A simple library ssh access. }
|
14
|
+
spec.homepage = "https://github.com/mofmof"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "net-ssh", "~> 2.0"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-ssh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- a.harada
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-ssh
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: " A simple library ssh access. "
|
70
|
+
email:
|
71
|
+
- mbl.atc.1hydrogen@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- bin/console
|
81
|
+
- bin/setup
|
82
|
+
- lib/ruby-ssh.rb
|
83
|
+
- lib/ruby-ssh/result.rb
|
84
|
+
- lib/ruby-ssh/session.rb
|
85
|
+
- lib/ruby-ssh/shell_runner.rb
|
86
|
+
- lib/ruby-ssh/version.rb
|
87
|
+
- ruby-ssh.gemspec
|
88
|
+
homepage: https://github.com/mofmof
|
89
|
+
licenses: []
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.5
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: A simple library ssh access.
|
111
|
+
test_files: []
|
112
|
+
has_rdoc:
|