aleksi-rush 0.6.6 → 0.6.7
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.
- data/VERSION +1 -1
- data/lib/rush/commands.rb +16 -9
- data/lib/rush/local.rb +4 -4
- data/spec/commands_spec.rb +8 -0
- data/spec/local_spec.rb +3 -3
- metadata +18 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.7
|
data/lib/rush/commands.rb
CHANGED
@@ -8,6 +8,11 @@
|
|
8
8
|
# box['/etc/'].search /localhost/ # entire directory
|
9
9
|
# box['/etc/**/*.conf'].search /localhost/ # arbitrary list
|
10
10
|
module Rush::Commands
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(Rush::ExternalCommands)
|
13
|
+
Rush::ExternalCommands::COMMANDS_TO_ADD.each { |command| base.add_command(command) }
|
14
|
+
end
|
15
|
+
|
11
16
|
# The entries command must return an array of Rush::Entry items. This
|
12
17
|
# varies by class that it is mixed in to.
|
13
18
|
def entries
|
@@ -41,15 +46,17 @@ module Rush::Commands
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
|
-
|
45
|
-
def vi(*args)
|
46
|
-
names = entries.map { |f| f.quoted_path }.join(' ')
|
47
|
-
system "vim #{names} #{args.join(' ')}"
|
48
|
-
end
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
module Rush::ExternalCommands
|
52
|
+
COMMANDS_TO_ADD = [:vim, :mate, :kate, :gedit]
|
53
|
+
|
54
|
+
def add_command(command)
|
55
|
+
if system("which #{command} > /dev/null 2>&1")
|
56
|
+
define_method(command) do |*args|
|
57
|
+
names = entries.map { |f| f.quoted_path }.join(' ')
|
58
|
+
system("#{command} #{args.join(' ')} #{names}")
|
59
|
+
end
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|
data/lib/rush/local.rb
CHANGED
@@ -349,7 +349,7 @@ class Rush::Connection::Local
|
|
349
349
|
def close_all_descriptors(keep_open = [])
|
350
350
|
3.upto(256) do |fd|
|
351
351
|
next if keep_open.include?(fd)
|
352
|
-
IO::new(fd).close rescue nil
|
352
|
+
IO::new(fd, "r").close rescue nil
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
@@ -370,10 +370,10 @@ class Rush::Connection::Local
|
|
370
370
|
when 'destroy' then destroy(params[:full_path])
|
371
371
|
when 'purge' then purge(params[:full_path])
|
372
372
|
when 'create_dir' then create_dir(params[:full_path])
|
373
|
-
when 'rename' then rename(params[:path], params[:name], params[:new_name], params[:force])
|
374
|
-
when 'copy' then copy(params[:src], params[:dst], params[:force])
|
373
|
+
when 'rename' then rename(params[:path], params[:name], params[:new_name], !!params[:force])
|
374
|
+
when 'copy' then copy(params[:src], params[:dst], !!params[:force])
|
375
375
|
when 'read_archive' then read_archive(params[:full_path])
|
376
|
-
when 'write_archive' then write_archive(params[:payload], params[:dir], params[:force])
|
376
|
+
when 'write_archive' then write_archive(params[:payload], params[:dir], !!params[:force])
|
377
377
|
when 'index' then index(params[:base_path], params[:glob]).join("\n") + "\n"
|
378
378
|
when 'stat' then YAML.dump(stat(params[:full_path]))
|
379
379
|
when 'set_access' then set_access(params[:full_path], Rush::Access.from_hash(params))
|
data/spec/commands_spec.rb
CHANGED
@@ -44,4 +44,12 @@ describe Rush::Commands do
|
|
44
44
|
it "counts lines of the contained files" do
|
45
45
|
@dir.files.line_count.should == 2
|
46
46
|
end
|
47
|
+
|
48
|
+
it "adds external commands when mixed-in" do
|
49
|
+
class SomeNewClass; include Rush::Commands; end
|
50
|
+
obj = SomeNewClass.new
|
51
|
+
Rush::ExternalCommands::COMMANDS_TO_ADD.each do |command|
|
52
|
+
obj.should respond_to(command) if system("which #{command} > /dev/null 2>&1")
|
53
|
+
end
|
54
|
+
end
|
47
55
|
end
|
data/spec/local_spec.rb
CHANGED
@@ -43,12 +43,12 @@ describe Rush::Connection::Local do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "receive -> rename(path, name, new_name)" do
|
46
|
-
@con.should_receive(:rename).with('path', 'name', 'new_name')
|
46
|
+
@con.should_receive(:rename).with('path', 'name', 'new_name', false)
|
47
47
|
@con.receive(:action => 'rename', :path => 'path', :name => 'name', :new_name => 'new_name')
|
48
48
|
end
|
49
49
|
|
50
50
|
it "receive -> copy(src, dst)" do
|
51
|
-
@con.should_receive(:copy).with('src', 'dst')
|
51
|
+
@con.should_receive(:copy).with('src', 'dst', false)
|
52
52
|
@con.receive(:action => 'copy', :src => 'src', :dst => 'dst')
|
53
53
|
end
|
54
54
|
|
@@ -58,7 +58,7 @@ describe Rush::Connection::Local do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "receive -> write_archive(archive, dir)" do
|
61
|
-
@con.should_receive(:write_archive).with('archive', 'dir')
|
61
|
+
@con.should_receive(:write_archive).with('archive', 'dir', false)
|
62
62
|
@con.receive(:action => 'write_archive', :dir => 'dir', :payload => 'archive')
|
63
63
|
end
|
64
64
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 7
|
9
|
+
version: 0.6.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adam Wiggins, Aleksey Palazhchenko
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-04 00:00:00 +04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -119,24 +119,24 @@ signing_key:
|
|
119
119
|
specification_version: 3
|
120
120
|
summary: A Ruby replacement for bash+ssh.
|
121
121
|
test_files:
|
122
|
-
- spec/
|
123
|
-
- spec/box_spec.rb
|
124
|
-
- spec/entry_spec.rb
|
125
|
-
- spec/shell_spec.rb
|
126
|
-
- spec/process_spec.rb
|
127
|
-
- spec/process_set_spec.rb
|
128
|
-
- spec/local_spec.rb
|
129
|
-
- spec/file_spec.rb
|
122
|
+
- spec/access_spec.rb
|
130
123
|
- spec/array_ext_spec.rb
|
124
|
+
- spec/base.rb
|
125
|
+
- spec/box_spec.rb
|
126
|
+
- spec/commands_spec.rb
|
131
127
|
- spec/config_spec.rb
|
132
128
|
- spec/dir_spec.rb
|
133
|
-
- spec/base.rb
|
134
|
-
- spec/fixnum_ext_spec.rb
|
135
|
-
- spec/ssh_tunnel_spec.rb
|
136
|
-
- spec/access_spec.rb
|
137
|
-
- spec/find_by_spec.rb
|
138
129
|
- spec/embeddable_shell_spec.rb
|
130
|
+
- spec/entry_spec.rb
|
131
|
+
- spec/file_spec.rb
|
132
|
+
- spec/find_by_spec.rb
|
133
|
+
- spec/fixnum_ext_spec.rb
|
134
|
+
- spec/local_spec.rb
|
135
|
+
- spec/process_set_spec.rb
|
136
|
+
- spec/process_spec.rb
|
139
137
|
- spec/remote_spec.rb
|
140
|
-
- spec/commands_spec.rb
|
141
|
-
- spec/search_results_spec.rb
|
142
138
|
- spec/rush_spec.rb
|
139
|
+
- spec/search_results_spec.rb
|
140
|
+
- spec/shell_spec.rb
|
141
|
+
- spec/ssh_tunnel_spec.rb
|
142
|
+
- spec/string_ext_spec.rb
|