rsh2 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/rsh/box.rb +7 -2
- data/readme.md +22 -2
- data/spec/box_spec.rb +6 -2
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/rsh/box.rb
CHANGED
@@ -132,9 +132,14 @@ module Rsh
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def bash cmd
|
135
|
-
code, stdout, stderr =
|
135
|
+
code, stdout, stderr = exec cmd
|
136
136
|
raise "can't execute '#{cmd}'!" unless code == 0
|
137
|
-
|
137
|
+
raise stderr unless stderr.empty?
|
138
|
+
stdout
|
139
|
+
end
|
140
|
+
|
141
|
+
def exec cmd
|
142
|
+
driver.exec cmd
|
138
143
|
end
|
139
144
|
|
140
145
|
protected
|
data/readme.md
CHANGED
@@ -1,4 +1,24 @@
|
|
1
|
-
|
1
|
+
# Tiny wrapper over Net::SSH and Net::SFTP
|
2
|
+
|
3
|
+
Because they are too hard to use and have terrible API design.
|
4
|
+
|
5
|
+
box = Rsh::Box.new host: 'webapp.com', ssh: {user: 'root', password: 'secret'}
|
6
|
+
|
7
|
+
stdout = box.bash 'ls /'
|
8
|
+
code, stdout, stderr = box.exec 'ls /'
|
9
|
+
|
10
|
+
box.upload_directory '/my_project', '/apps/my_project'
|
11
|
+
box.bash 'nohup /apps/my_project/server_start'
|
12
|
+
|
13
|
+
Honestly my wrapper also not very good. I would like to make API looks like the ['rush'][rush] gem (made by Adam Wiggins)
|
14
|
+
but it requires a lots of time, maybe I'll do it later.
|
15
|
+
So, for now it's just a small wrapper to do ssh/io operations not so painfull.
|
16
|
+
|
17
|
+
## TODO
|
18
|
+
|
2
19
|
- introduce Entity/Dir/File (the same as in Rush)
|
3
20
|
- allow to move files between any Boxes, not only between local and remote.
|
4
|
-
- add support for moving dirs.
|
21
|
+
- add support for moving dirs.
|
22
|
+
|
23
|
+
|
24
|
+
[rush]: http://github.com/adamwiggins/rush
|
data/spec/box_spec.rb
CHANGED
@@ -98,8 +98,12 @@ describe Rsh::Box do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
describe "shell" do
|
101
|
-
it '
|
102
|
-
@box.bash("echo 'ok'").should ==
|
101
|
+
it 'bash' do
|
102
|
+
@box.bash("echo 'ok'").should == "ok\n"
|
103
103
|
end
|
104
|
+
|
105
|
+
it "exec" do
|
106
|
+
@box.exec("echo 'ok'").should == [0, "ok\n", ""]
|
107
|
+
end
|
104
108
|
end
|
105
109
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexey Petrushin
|
@@ -79,6 +79,6 @@ rubyforge_project:
|
|
79
79
|
rubygems_version: 1.3.7
|
80
80
|
signing_key:
|
81
81
|
specification_version: 3
|
82
|
-
summary:
|
82
|
+
summary: Tiny wrapper over Net::SSH and Net::SFTP
|
83
83
|
test_files: []
|
84
84
|
|