rush2 0.7.1 → 0.8.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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rush2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Smagin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-13 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: session
@@ -156,7 +156,6 @@ files:
156
156
  - lib/rush/local.rb
157
157
  - lib/rush/process.rb
158
158
  - lib/rush/process_set.rb
159
- - lib/rush/remote.rb
160
159
  - lib/rush/search_results.rb
161
160
  - lib/rush/shell.rb
162
161
  - lib/rush/shell/completion.rb
@@ -176,7 +175,6 @@ files:
176
175
  - spec/local_spec.rb
177
176
  - spec/process_set_spec.rb
178
177
  - spec/process_spec.rb
179
- - spec/remote_spec.rb
180
178
  - spec/rush_spec.rb
181
179
  - spec/search_results_spec.rb
182
180
  - spec/shell_spec.rb
@@ -202,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
200
  version: '0'
203
201
  requirements: []
204
202
  rubyforge_project:
205
- rubygems_version: 2.2.2
203
+ rubygems_version: 2.4.5
206
204
  signing_key:
207
205
  specification_version: 4
208
206
  summary: A Ruby replacement for bash+ssh.
@@ -1,33 +0,0 @@
1
- require 'net/ssh'
2
-
3
- module Rush
4
- # wrapper of command
5
- # sshfs '-o idmap=user <user_name>@<server_address>:<path> <local_path>'
6
- #
7
- class Connection::Remote
8
- attr_reader :local_path, :full_remote_path, :remote_path, :remote_server, :remote_user
9
-
10
- def initialize(full_remote_path, local_path)
11
- local_path = local_path.full_path if local_path.respond_to?(:full_path)
12
- @full_remote_path = full_remote_path
13
- @local_path = Rush::Dir.new(local_path)
14
- @local_path.create unless @local_path.exists?
15
- @remote_user, server_and_path = *full_remote_path.split('@', 2)
16
- @remote_server, @remote_address = *server_and_path.split(':', 2)
17
- end
18
-
19
- def connect
20
- system "sshfs -o idmap=user #{full_remote_path} #{local_path}"
21
- end
22
- alias_method :mount, :connect
23
-
24
- def disconnect
25
- system "fusermount -u #{local_path.full_path}"
26
- end
27
- alias_method :umount, :disconnect
28
-
29
- def method_missing(meth, *args, &block)
30
- @local_path.send(meth, *args, &block)
31
- end
32
- end
33
- end
@@ -1,140 +0,0 @@
1
- require_relative 'base'
2
-
3
- describe Rush::Connection::Local do
4
- before do
5
- @sandbox_dir = "/tmp/rush_spec.#{Process.pid}"
6
- system "rm -rf #{@sandbox_dir}; mkdir -p #{@sandbox_dir}"
7
-
8
- @con = Rush::Connection::Remote.new('spec.example.com')
9
- end
10
-
11
- after do
12
- system "rm -rf #{@sandbox_dir}"
13
- end
14
-
15
- it "transmits write_file" do
16
- @con.should_receive(:transmit).with(:action => 'write_file', :full_path => 'file', :payload => 'contents')
17
- @con.write_file('file', 'contents')
18
- end
19
-
20
- it "transmits append_to_file" do
21
- @con.should_receive(:transmit).with(:action => 'append_to_file', :full_path => 'file', :payload => 'contents')
22
- @con.append_to_file('file', 'contents')
23
- end
24
-
25
- it "transmits file_contents" do
26
- @con.should_receive(:transmit).with(:action => 'file_contents', :full_path => 'file').and_return('contents')
27
- @con.file_contents('file').should == 'contents'
28
- end
29
-
30
- it "transmits destroy" do
31
- @con.should_receive(:transmit).with(:action => 'destroy', :full_path => 'file')
32
- @con.destroy('file')
33
- end
34
-
35
- it "transmits purge" do
36
- @con.should_receive(:transmit).with(:action => 'purge', :full_path => 'dir')
37
- @con.purge('dir')
38
- end
39
-
40
- it "transmits create_dir" do
41
- @con.should_receive(:transmit).with(:action => 'create_dir', :full_path => 'file')
42
- @con.create_dir('file')
43
- end
44
-
45
- it "transmits rename" do
46
- @con.should_receive(:transmit).with(:action => 'rename', :path => 'path', :name => 'name', :new_name => 'new_name')
47
- @con.rename('path', 'name', 'new_name')
48
- end
49
-
50
- it "transmits copy" do
51
- @con.should_receive(:transmit).with(:action => 'copy', :src => 'src', :dst => 'dst')
52
- @con.copy('src', 'dst')
53
- end
54
-
55
- it "transmits read_archive" do
56
- @con.should_receive(:transmit).with(:action => 'read_archive', :full_path => 'full_path').and_return('archive data')
57
- @con.read_archive('full_path').should == 'archive data'
58
- end
59
-
60
- it "transmits write_archive" do
61
- @con.should_receive(:transmit).with(:action => 'write_archive', :dir => 'dir', :payload => 'archive')
62
- @con.write_archive('archive', 'dir')
63
- end
64
-
65
- it "transmits index" do
66
- @con.should_receive(:transmit).with(:action => 'index', :base_path => 'base_path', :glob => '*').and_return("1\n2\n")
67
- @con.index('base_path', '*').should == %w(1 2)
68
- end
69
-
70
- it "transmits stat" do
71
- @con.should_receive(:transmit).with(:action => 'stat', :full_path => 'full_path').and_return(YAML.dump(1 => 2))
72
- @con.stat('full_path').should == { 1 => 2 }
73
- end
74
-
75
- it "transmits set_access" do
76
- @con.should_receive(:transmit).with(:action => 'set_access', :full_path => 'full_path', :user => 'joe', :user_read => 1)
77
- @con.set_access('full_path', :user => 'joe', :user_read => 1)
78
- end
79
-
80
- it "transmits size" do
81
- @con.should_receive(:transmit).with(:action => 'size', :full_path => 'full_path').and_return("123")
82
- @con.size('full_path').should == 123
83
- end
84
-
85
- it "transmits processes" do
86
- @con.should_receive(:transmit).with(:action => 'processes').and_return(YAML.dump([ { :pid => 1 } ]))
87
- @con.processes.should == [ { :pid => 1 } ]
88
- end
89
-
90
- it "transmits process_alive" do
91
- @con.should_receive(:transmit).with(:action => 'process_alive', :pid => 123).and_return(true)
92
- @con.process_alive(123).should == true
93
- end
94
-
95
- it "transmits kill_process" do
96
- @con.should_receive(:transmit).with(:action => 'kill_process', :pid => 123, :payload => YAML.dump(:wait => 10))
97
- @con.kill_process(123, :wait => 10)
98
- end
99
-
100
- it "transmits bash" do
101
- @con.should_receive(:transmit).with(:action => 'bash', :payload => 'cmd', :user => 'user', :background => 'bg', :reset_environment => false).and_return('output')
102
- @con.bash('cmd', 'user', 'bg', false).should == 'output'
103
- end
104
-
105
- it "an http result code of 401 raises NotAuthorized" do
106
- lambda { @con.process_result("401", "") }.should raise_error(Rush::NotAuthorized)
107
- end
108
-
109
- it "an http result code of 400 raises the exception passed in the result body" do
110
- @con.stub(:parse_exception).and_return(Rush::DoesNotExist, "message")
111
- lambda { @con.process_result("400", "") }.should raise_error(Rush::DoesNotExist)
112
- end
113
-
114
- it "an http result code of 501 (or anything other than the other defined codes) raises FailedTransmit" do
115
- lambda { @con.process_result("501", "") }.should raise_error(Rush::FailedTransmit)
116
- end
117
-
118
- it "parse_exception takes the class from the first line and the message from the second" do
119
- @con.parse_exception("Rush::DoesNotExist\nthe message\n").should == [ Rush::DoesNotExist, "the message" ]
120
- end
121
-
122
- it "parse_exception rejects unrecognized exceptions" do
123
- lambda { @con.parse_exception("NotARushException\n") }.should raise_error
124
- end
125
-
126
- it "passes through ensure_tunnel" do
127
- @con.tunnel.should_receive(:ensure_tunnel)
128
- @con.ensure_tunnel
129
- end
130
-
131
- it "is alive if the box is responding to commands" do
132
- @con.should_receive(:index).and_return(:dummy)
133
- @con.should be_alive
134
- end
135
-
136
- it "not alive if an attempted command throws an exception" do
137
- @con.should_receive(:index).and_raise(RuntimeError)
138
- @con.should_not be_alive
139
- end
140
- end