rush2 0.8.0 → 0.9.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 +4 -4
- data/Gemfile.lock +22 -22
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/rush.rb +1 -0
- data/lib/rush/box.rb +6 -0
- data/lib/rush/commands.rb +31 -32
- data/lib/rush/config.rb +6 -6
- data/lib/rush/dir.rb +5 -12
- data/lib/rush/entry.rb +3 -5
- data/lib/rush/local.rb +6 -2
- data/lib/rush/path.rb +9 -0
- data/lib/rush/shell.rb +4 -1
- data/lib/rush/shell/completion.rb +4 -6
- data/lib/rush/string_ext.rb +17 -0
- data/spec/dir_spec.rb +6 -6
- data/spec/local_spec.rb +3 -5
- data/spec/path_spec.rb +13 -0
- data/spec/process_spec.rb +22 -8
- data/spec/shell_spec.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57b0055c6516f9185ac3b4b5d742cbdc46430e3d
|
4
|
+
data.tar.gz: d7d7ea8dec9c9bd665e1f7a6446b2300840e0f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b63d0a3b8858907d0c2642f088801825eadff80075fd2fe1b24e776288af93e7ba67c0709b42a6bac7255a78157ef206d77a501925f322d130ebfb5e64baf79
|
7
|
+
data.tar.gz: a26460bb88e642c1fa0e447ab8f8548dd078fc17ddd49628f3a934708280edbe1ebfe5c7319b8a1bb5cb92a51b21219b9412e5d7adf122d8e23d4726436fcc7a
|
data/Gemfile.lock
CHANGED
@@ -9,19 +9,19 @@ GEM
|
|
9
9
|
descendants_tracker (0.0.4)
|
10
10
|
thread_safe (~> 0.3, >= 0.3.1)
|
11
11
|
diff-lcs (1.2.5)
|
12
|
-
faraday (0.9.
|
12
|
+
faraday (0.9.2)
|
13
13
|
multipart-post (>= 1.2, < 3)
|
14
14
|
git (1.2.9.1)
|
15
|
-
github_api (0.12.
|
15
|
+
github_api (0.12.4)
|
16
16
|
addressable (~> 2.3)
|
17
17
|
descendants_tracker (~> 0.0.4)
|
18
18
|
faraday (~> 0.8, < 0.10)
|
19
|
-
hashie (>= 3.
|
19
|
+
hashie (>= 3.4)
|
20
20
|
multi_json (>= 1.7.5, < 2.0)
|
21
|
-
nokogiri (~> 1.6.
|
21
|
+
nokogiri (~> 1.6.6)
|
22
22
|
oauth2
|
23
|
-
hashie (3.4.
|
24
|
-
highline (1.7.
|
23
|
+
hashie (3.4.2)
|
24
|
+
highline (1.7.8)
|
25
25
|
jeweler (2.0.1)
|
26
26
|
builder
|
27
27
|
bundler (>= 1.0)
|
@@ -31,13 +31,13 @@ GEM
|
|
31
31
|
nokogiri (>= 1.5.10)
|
32
32
|
rake
|
33
33
|
rdoc
|
34
|
-
jwt (1.
|
34
|
+
jwt (1.5.1)
|
35
35
|
method_source (0.8.2)
|
36
36
|
mini_portile (0.6.2)
|
37
|
-
multi_json (1.11.
|
37
|
+
multi_json (1.11.2)
|
38
38
|
multi_xml (0.5.5)
|
39
39
|
multipart-post (2.0.0)
|
40
|
-
net-ssh (
|
40
|
+
net-ssh (3.0.1)
|
41
41
|
nokogiri (1.6.6.2)
|
42
42
|
mini_portile (~> 0.6.0)
|
43
43
|
oauth2 (1.0.0)
|
@@ -46,26 +46,26 @@ GEM
|
|
46
46
|
multi_json (~> 1.3)
|
47
47
|
multi_xml (~> 0.5)
|
48
48
|
rack (~> 1.2)
|
49
|
-
pry (0.10.
|
49
|
+
pry (0.10.3)
|
50
50
|
coderay (~> 1.1.0)
|
51
51
|
method_source (~> 0.8.1)
|
52
52
|
slop (~> 3.4)
|
53
|
-
rack (1.6.
|
53
|
+
rack (1.6.4)
|
54
54
|
rake (10.4.2)
|
55
55
|
rdoc (4.2.0)
|
56
|
-
rspec (3.
|
57
|
-
rspec-core (~> 3.
|
58
|
-
rspec-expectations (~> 3.
|
59
|
-
rspec-mocks (~> 3.
|
60
|
-
rspec-core (3.
|
61
|
-
rspec-support (~> 3.
|
62
|
-
rspec-expectations (3.
|
56
|
+
rspec (3.3.0)
|
57
|
+
rspec-core (~> 3.3.0)
|
58
|
+
rspec-expectations (~> 3.3.0)
|
59
|
+
rspec-mocks (~> 3.3.0)
|
60
|
+
rspec-core (3.3.2)
|
61
|
+
rspec-support (~> 3.3.0)
|
62
|
+
rspec-expectations (3.3.1)
|
63
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
-
rspec-support (~> 3.
|
65
|
-
rspec-mocks (3.2
|
64
|
+
rspec-support (~> 3.3.0)
|
65
|
+
rspec-mocks (3.3.2)
|
66
66
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.
|
68
|
-
rspec-support (3.
|
67
|
+
rspec-support (~> 3.3.0)
|
68
|
+
rspec-support (3.3.0)
|
69
69
|
session (3.2.0)
|
70
70
|
slop (3.6.0)
|
71
71
|
thread_safe (0.3.5)
|
data/README.rdoc
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
rush is a unix integration library and an interactive shell which uses pure Ruby syntax. Walk directory trees; create, copy, search, and destroy files; find and kill processes - everything you'd normally do with shell commands, now in the strict and elegant world of Ruby.
|
4
4
|
|
5
|
-
{<img src="https://
|
5
|
+
{<img src="https://drone.io/github.com/s-mage/rush/status.png" alt="Build Status" />}[https://drone.io/github.com/s-mage/rush]
|
6
6
|
|
7
7
|
|
8
8
|
== Install
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
data/lib/rush.rb
CHANGED
@@ -74,6 +74,7 @@ require_relative 'rush/exceptions'
|
|
74
74
|
require_relative 'rush/config'
|
75
75
|
require_relative 'rush/commands'
|
76
76
|
require_relative 'rush/access'
|
77
|
+
require_relative 'rush/path'
|
77
78
|
require_relative 'rush/entry'
|
78
79
|
require_relative 'rush/file'
|
79
80
|
require_relative 'rush/dir'
|
data/lib/rush/box.rb
CHANGED
data/lib/rush/commands.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# The commands module contains operations against Rush::File entries, and is
|
2
|
-
# mixed in to Rush::Entry and Array.
|
2
|
+
# mixed in to Rush::Entry and Array.
|
3
|
+
# This means you can run these commands against a single
|
3
4
|
# file, a dir full of files, or an arbitrary list of files.
|
4
5
|
#
|
5
6
|
# Examples:
|
@@ -7,11 +8,12 @@
|
|
7
8
|
# box['/etc/hosts'].search /localhost/ # single file
|
8
9
|
# box['/etc/'].search /localhost/ # entire directory
|
9
10
|
# box['/etc/**/*.conf'].search /localhost/ # arbitrary list
|
11
|
+
#
|
10
12
|
module Rush::Commands
|
11
13
|
# The entries command must return an array of Rush::Entry items. This
|
12
14
|
# varies by class that it is mixed in to.
|
13
15
|
def entries
|
14
|
-
|
16
|
+
fail 'must define me in class mixed in to for command use'
|
15
17
|
end
|
16
18
|
|
17
19
|
# Search file contents for a regular expression. A Rush::SearchResults
|
@@ -45,21 +47,6 @@ module Rush::Commands
|
|
45
47
|
open_with ENV['EDITOR'], *args
|
46
48
|
end
|
47
49
|
|
48
|
-
# Invoke vi on one or more files - only works locally.
|
49
|
-
def vi(*args)
|
50
|
-
if self.class == Rush::Dir
|
51
|
-
system "cd #{full_path}; vim"
|
52
|
-
else
|
53
|
-
open_with('vim', *args)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
alias_method :vim, :vi
|
57
|
-
|
58
|
-
# Invoke TextMate on one or more files - only works locally.
|
59
|
-
def mate(*args)
|
60
|
-
open_with('mate', *args)
|
61
|
-
end
|
62
|
-
|
63
50
|
# Open file with xdg-open.
|
64
51
|
# Usage:
|
65
52
|
# home.locate('mai_failz').open
|
@@ -71,24 +58,36 @@ module Rush::Commands
|
|
71
58
|
# Usage:
|
72
59
|
# home.locate('timetable').open_with :vim
|
73
60
|
# home['.vimrc'].vim { other: '+55', x: true, u: 'other_vimrc', cmd: 'ls' }
|
74
|
-
|
75
|
-
|
61
|
+
# home['my_app'].rails :c, env: { rails_env: 'test' } # environment vars
|
62
|
+
def open_with(app, *args)
|
63
|
+
system(*open_command(app, *args))
|
76
64
|
end
|
77
65
|
|
78
|
-
def output_of(app, *args
|
79
|
-
`#{open_command(app, *args
|
66
|
+
def output_of(app, *args)
|
67
|
+
`#{open_command(app, *args)}`
|
80
68
|
end
|
81
69
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
70
|
+
def opt_to_s(k, v)
|
71
|
+
key = k.size == 1 ? "-#{k}" : "--#{k}"
|
72
|
+
case
|
73
|
+
when v == true then key
|
74
|
+
when k == 'other' || k == :other then v
|
75
|
+
else "#{key} #{v}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def open_command(app, *args)
|
80
|
+
opts = args.last.is_a?(Hash) ? args.pop : {}
|
81
|
+
names = dir? ? '' : entries.map { |x| Rush.quote x.to_s }.join(' ')
|
82
|
+
options = opts
|
83
|
+
.reject { |k, _| k == :env }
|
84
|
+
.map { |k, v| opt_to_s(k, v) }
|
85
|
+
.join(' ')
|
86
|
+
dir = Rush.quote dirname.to_s
|
87
|
+
cmd = "cd #{dir}; #{app} #{names} #{options} #{args.join(' ')}"
|
88
|
+
if vars = opts[:env]
|
89
|
+
env = vars.inject({}) { |r, (k, v)| r.merge(k.to_s.upcase => v.to_s) }
|
90
|
+
end
|
91
|
+
vars ? [env, cmd] : cmd
|
93
92
|
end
|
94
93
|
end
|
data/lib/rush/config.rb
CHANGED
@@ -6,7 +6,7 @@ class Rush::Config
|
|
6
6
|
|
7
7
|
# By default, reads from the dir ~/.rush, but an optional parameter allows
|
8
8
|
# using another location.
|
9
|
-
def initialize(location=nil)
|
9
|
+
def initialize(location = nil)
|
10
10
|
@dir = Rush::Dir.new(location || "#{ENV['HOME']}/.rush")
|
11
11
|
@dir.create
|
12
12
|
end
|
@@ -67,7 +67,7 @@ class Rush::Config
|
|
67
67
|
|
68
68
|
def passwords
|
69
69
|
passwords_file.lines_or_empty.inject({}) do |result, line|
|
70
|
-
user, password = line.split(
|
70
|
+
user, password = line.split(':', 2)
|
71
71
|
result.merge user => password
|
72
72
|
end
|
73
73
|
end
|
@@ -80,7 +80,7 @@ class Rush::Config
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def credentials
|
83
|
-
credentials_file.lines.first.split(
|
83
|
+
credentials_file.lines.first.split(':', 2)
|
84
84
|
end
|
85
85
|
|
86
86
|
def save_credentials(user, password)
|
@@ -96,7 +96,7 @@ class Rush::Config
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def ensure_credentials_exist
|
99
|
-
generate_credentials if credentials_file.contents_or_blank ==
|
99
|
+
generate_credentials if credentials_file.contents_or_blank == ''
|
100
100
|
end
|
101
101
|
|
102
102
|
def generate_credentials
|
@@ -118,7 +118,7 @@ class Rush::Config
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def secret_characters
|
121
|
-
[
|
121
|
+
[('a'..'z'), ('1'..'9')].inject([]) do |chars, range|
|
122
122
|
chars += range.to_a
|
123
123
|
end
|
124
124
|
end
|
@@ -138,7 +138,7 @@ class Rush::Config
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def save_tunnels(hash)
|
141
|
-
string =
|
141
|
+
string = ''
|
142
142
|
hash.each do |host, port|
|
143
143
|
string += "#{host}:#{port}\n"
|
144
144
|
end
|
data/lib/rush/dir.rb
CHANGED
@@ -23,7 +23,7 @@ class Rush::Dir < Rush::Entry
|
|
23
23
|
|
24
24
|
# Entries contained within this dir - not recursive.
|
25
25
|
def contents
|
26
|
-
find_by_glob('*')
|
26
|
+
find_by_glob('*') + find_by_glob('.[!.]*')
|
27
27
|
end
|
28
28
|
|
29
29
|
# Files contained in this dir only.
|
@@ -49,7 +49,7 @@ class Rush::Dir < Rush::Entry
|
|
49
49
|
alias_method :/, :[]
|
50
50
|
|
51
51
|
def locate(path)
|
52
|
-
located = bash("locate #{path}").split("\n").
|
52
|
+
located = bash("locate -i #{path}").split("\n").
|
53
53
|
map { |x| x.dir? ? Rush::Dir.new(x) : Rush::File.new(x) }
|
54
54
|
located.size == 1 ? located.first : located
|
55
55
|
end
|
@@ -137,16 +137,9 @@ class Rush::Dir < Rush::Entry
|
|
137
137
|
end
|
138
138
|
|
139
139
|
# Text output of dir listing, equivalent to the regular unix shell's ls command.
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
out << " #{dir.name}/"
|
144
|
-
end
|
145
|
-
nonhidden_files.each do |file|
|
146
|
-
out << " #{file.name}"
|
147
|
-
end
|
148
|
-
out.join("\n")
|
149
|
-
end
|
140
|
+
def ls(*args)
|
141
|
+
output_of 'ls', *args
|
142
|
+
end
|
150
143
|
|
151
144
|
# Run rake within this dir.
|
152
145
|
def rake(*args)
|
data/lib/rush/entry.rb
CHANGED
@@ -22,9 +22,7 @@ class Rush::Entry
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def executables
|
25
|
-
|
26
|
-
.map { |x| Rush::Dir.new(x).entries.map(&:name) }
|
27
|
-
.flatten
|
25
|
+
Rush::Path.executables
|
28
26
|
end
|
29
27
|
|
30
28
|
# The factory checks to see if the full path has a trailing slash for
|
@@ -41,7 +39,7 @@ class Rush::Entry
|
|
41
39
|
|
42
40
|
def to_s # :nodoc:
|
43
41
|
if box.host == 'localhost'
|
44
|
-
|
42
|
+
full_path
|
45
43
|
else
|
46
44
|
inspect
|
47
45
|
end
|
@@ -61,7 +59,7 @@ class Rush::Entry
|
|
61
59
|
end
|
62
60
|
|
63
61
|
def full_path
|
64
|
-
"#{
|
62
|
+
"#{path}/#{name}"
|
65
63
|
end
|
66
64
|
|
67
65
|
def quoted_path
|
data/lib/rush/local.rb
CHANGED
@@ -142,7 +142,11 @@ class Rush::Connection::Local
|
|
142
142
|
# Fetch the size of a dir, since a standard file stat does not include the
|
143
143
|
# size of the contents.
|
144
144
|
def size(full_path)
|
145
|
-
|
145
|
+
if RUBY_PLATFORM.match(/darwin/)
|
146
|
+
`find #{Rush.quote(full_path)} -print0 | xargs -0 stat -f%z`.split(/\n/).map(&:to_i).reduce(:+)
|
147
|
+
else
|
148
|
+
`du -sb #{Rush.quote(full_path)}`.match(/(\d+)/)[1].to_i
|
149
|
+
end
|
146
150
|
end
|
147
151
|
|
148
152
|
# Get the list of processes as an array of hashes.
|
@@ -153,7 +157,7 @@ class Rush::Connection::Local
|
|
153
157
|
windows_processes
|
154
158
|
else
|
155
159
|
os_x_processes
|
156
|
-
end
|
160
|
+
end.uniq
|
157
161
|
end
|
158
162
|
|
159
163
|
# Process list on Linux using /proc.
|
data/lib/rush/path.rb
ADDED
data/lib/rush/shell.rb
CHANGED
@@ -25,6 +25,7 @@ module Rush
|
|
25
25
|
load_custom_commands
|
26
26
|
set_readline
|
27
27
|
@multiline_cmd = '' # Multiline commands should be stored somewhere
|
28
|
+
$last_backtrace = '' # Backtrace should too.
|
28
29
|
end
|
29
30
|
|
30
31
|
def set_readline
|
@@ -75,7 +76,9 @@ module Rush
|
|
75
76
|
@multiline_cmd = ''
|
76
77
|
rescue ::Exception => e
|
77
78
|
puts "Exception #{e.class} -> #{e.message}"
|
78
|
-
e.backtrace
|
79
|
+
$last_backtrace = e.backtrace
|
80
|
+
.map { |t| "\t#{::File.expand_path(t)}" }
|
81
|
+
.join("\n")
|
79
82
|
@multiline_cmd = ''
|
80
83
|
end
|
81
84
|
|
@@ -50,13 +50,13 @@ module Rush
|
|
50
50
|
method: :complete_method
|
51
51
|
},
|
52
52
|
path: {
|
53
|
-
regexp: /^(\w|_
|
53
|
+
regexp: /^(\w|_|.|:| )+[\[\/][\'\"].*$/,
|
54
54
|
method: :complete_path
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
58
|
def complete_constant(input)
|
59
|
-
Object.constants.map(&:to_s).select { |x| x.start_with? input }
|
59
|
+
Object.constants.map(&:to_s).select { |x| x.start_with? input }.sort
|
60
60
|
end
|
61
61
|
|
62
62
|
def complete_object_constant(input)
|
@@ -64,7 +64,7 @@ module Rush
|
|
64
64
|
eval(receiver, pure_binding).constants
|
65
65
|
.map(&:to_s)
|
66
66
|
.select { |x| x.start_with? const_part }
|
67
|
-
.map
|
67
|
+
.map { |x| receiver + delimiter + x }
|
68
68
|
end
|
69
69
|
|
70
70
|
def complete_global_method(input)
|
@@ -89,9 +89,7 @@ module Rush
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def executables
|
92
|
-
|
93
|
-
.map { |x| Rush::Dir.new(x).entries.map(&:name) }
|
94
|
-
.flatten
|
92
|
+
Rush::Path.executables
|
95
93
|
end
|
96
94
|
|
97
95
|
def complete_path(input)
|
data/lib/rush/string_ext.rb
CHANGED
@@ -13,4 +13,21 @@ class String
|
|
13
13
|
def locate
|
14
14
|
Rush::Dir.new(ENV['HOME']).locate self
|
15
15
|
end
|
16
|
+
|
17
|
+
def open_with(meth, *args, &block)
|
18
|
+
if executables.include? meth.to_s
|
19
|
+
system [meth.to_s, *args, self].join(' ')
|
20
|
+
else
|
21
|
+
raise 'No such executable. Maybe something wrong with PATH?'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
alias_method :e, :open_with
|
25
|
+
|
26
|
+
def |(meth, *args, &block)
|
27
|
+
Open3.capture2(meth, stdin_data: self).first
|
28
|
+
end
|
29
|
+
|
30
|
+
def executables
|
31
|
+
Rush::Path.executables
|
32
|
+
end
|
16
33
|
end
|
data/spec/dir_spec.rb
CHANGED
@@ -130,12 +130,12 @@ describe Rush::Dir do
|
|
130
130
|
expect(@dir.nonhidden_dirs).to eq @dir.make_entries(%(show/))
|
131
131
|
end
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
133
|
+
it "knows its size in bytes, which includes its contents recursively" do
|
134
|
+
@dir.create_file('a').write('1234')
|
135
|
+
# on OSX fs stat's size is 102, even though blksize=4096
|
136
|
+
# on Linux size is 4096
|
137
|
+
expect(@dir.size).to eq(::File.stat(@dir.path).size + 4)
|
138
|
+
end
|
139
139
|
|
140
140
|
it "can destroy itself when empty" do
|
141
141
|
@dir.destroy
|
data/spec/local_spec.rb
CHANGED
@@ -260,11 +260,9 @@ describe Rush::Connection::Local do
|
|
260
260
|
@con.set_access('/some/path', access)
|
261
261
|
end
|
262
262
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
expect(@con.size(@sandbox_dir)).to eq (4096*3 + 5)
|
267
|
-
end
|
263
|
+
it "size gives size of a directory and all its contents recursively" do
|
264
|
+
system "mkdir -p #{@sandbox_dir}/a/b/; echo 1234 > #{@sandbox_dir}/a/b/c"
|
265
|
+
expect(@con.size(@sandbox_dir)).to eq (::File.stat(@sandbox_dir).size*3 + 5)
|
268
266
|
end
|
269
267
|
|
270
268
|
it "parses ps output on os x" do
|
data/spec/path_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
require_relative '../lib/rush/path'
|
3
|
+
|
4
|
+
describe Rush::Path do
|
5
|
+
it 'works' do
|
6
|
+
expect(Rush::Path.executables).to be_kind_of Array
|
7
|
+
end
|
8
|
+
|
9
|
+
it "doesn't fail with non-existent directories in PATH" do
|
10
|
+
expect(ENV).to receive(:[]).with("PATH").and_return("/foobar")
|
11
|
+
expect(Rush::Path.executables).to eq []
|
12
|
+
end
|
13
|
+
end
|
data/spec/process_spec.rb
CHANGED
@@ -1,22 +1,36 @@
|
|
1
1
|
require_relative 'base'
|
2
2
|
|
3
3
|
describe Rush::Process do
|
4
|
+
let!(:pid_file) { "/tmp/rush_rspec_#{Process.pid}" }
|
5
|
+
|
4
6
|
before do
|
5
|
-
@
|
7
|
+
@parent_pid = fork do
|
8
|
+
# OSX includes checking `ps` process into current Process#children
|
9
|
+
# as such isolate parent from the main thread
|
10
|
+
# but the instance_valriabes are unavailable since #fork - use fs
|
11
|
+
@pid = fork do
|
12
|
+
sleep 999
|
13
|
+
end
|
14
|
+
::File.write(pid_file, @pid)
|
6
15
|
sleep 999
|
7
16
|
end
|
17
|
+
|
18
|
+
# wait parent to tell child's pid
|
19
|
+
sleep 0.3
|
20
|
+
|
21
|
+
@pid = ::File.read(pid_file).to_i
|
8
22
|
@process = Rush::Process.all.detect { |p| p.pid == @pid }
|
9
23
|
end
|
10
24
|
|
11
25
|
after do
|
26
|
+
::File.unlink(pid_file) if ::File.exists?(pid_file)
|
12
27
|
system "kill -9 #{@pid}"
|
28
|
+
system "kill -9 #{@parent_pid}"
|
13
29
|
end
|
14
30
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
expect(parent.children).to eq [@process]
|
19
|
-
end
|
31
|
+
it 'knows all its child processes' do
|
32
|
+
parent = Rush::Process.all.detect { |p| p.pid == @parent_pid }
|
33
|
+
expect(parent.children).to eq [@process]
|
20
34
|
end
|
21
35
|
|
22
36
|
it 'gets the list of all processes' do
|
@@ -50,12 +64,12 @@ describe Rush::Process do
|
|
50
64
|
end
|
51
65
|
|
52
66
|
it 'knows the parent process pid' do
|
53
|
-
expect(@process.parent_pid).to eq
|
67
|
+
expect(@process.parent_pid).to eq @parent_pid
|
54
68
|
end
|
55
69
|
|
56
70
|
it 'knows the parent process' do
|
57
71
|
this = Rush::Box.new.processes
|
58
|
-
.select { |p| p.pid ==
|
72
|
+
.select { |p| p.pid == @parent_pid }
|
59
73
|
.first
|
60
74
|
expect(@process.parent).to eq this
|
61
75
|
end
|
data/spec/shell_spec.rb
CHANGED
@@ -21,8 +21,9 @@ describe Rush::Shell do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'Complete method names' do
|
24
|
+
# rbx has additional Rush.method_table, Rush.method_table=
|
24
25
|
expect(@shell.complete('Rush.meth')).
|
25
|
-
to
|
26
|
+
to include("Rush.method_part", "Rush.method_defined?", "Rush.methods", "Rush.method")
|
26
27
|
expect(@shell.complete('Rush.methods.inc')).to include "Rush.methods.include?"
|
27
28
|
end
|
28
29
|
|
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.
|
4
|
+
version: 0.9.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:
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: session
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/rush/fixnum_ext.rb
|
155
155
|
- lib/rush/head_tail.rb
|
156
156
|
- lib/rush/local.rb
|
157
|
+
- lib/rush/path.rb
|
157
158
|
- lib/rush/process.rb
|
158
159
|
- lib/rush/process_set.rb
|
159
160
|
- lib/rush/search_results.rb
|
@@ -173,6 +174,7 @@ files:
|
|
173
174
|
- spec/find_by_spec.rb
|
174
175
|
- spec/fixnum_ext_spec.rb
|
175
176
|
- spec/local_spec.rb
|
177
|
+
- spec/path_spec.rb
|
176
178
|
- spec/process_set_spec.rb
|
177
179
|
- spec/process_spec.rb
|
178
180
|
- spec/rush_spec.rb
|
@@ -200,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
202
|
version: '0'
|
201
203
|
requirements: []
|
202
204
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.5.0
|
204
206
|
signing_key:
|
205
207
|
specification_version: 4
|
206
208
|
summary: A Ruby replacement for bash+ssh.
|