qbash 0.3.2 → 0.4.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/.rubocop.yml +0 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.md +13 -1
- data/lib/qbash.rb +26 -16
- data/qbash.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b0f67b4e45883bc237c70115187e6ab211f6fdd29da3f9f891720153ad26569
|
4
|
+
data.tar.gz: a12f5e499c7f756d71c59b52467454346c455e72d291d2bae7891f05c7e8610b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb17f8adf645e156986fcf7d08b27ee3b049fa29910b1f7b9154c51339530481167419d2a68af21b9dafae51613f81971b3e6e30f5eb175416ddafb82c87ea6b
|
7
|
+
data.tar.gz: 55c6932d3ff9a02474c33d69b3fa05f0b3ae83bf36a911468c155ef3944b603a9dceb29b13ba04eea3e9f3bd8748e90101952b0586d0e82001229a398d80c555
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -29,7 +29,7 @@ gem 'minitest-reporters', '1.7.1', require: false
|
|
29
29
|
gem 'net-ping', '2.0.8', require: false
|
30
30
|
gem 'rake', '13.2.1', require: false
|
31
31
|
gem 'random-port', '~>0.0', require: false
|
32
|
-
gem 'rspec-rails', '7.1.
|
32
|
+
gem 'rspec-rails', '7.1.1', require: false
|
33
33
|
gem 'rubocop', '1.71.2', require: false
|
34
34
|
gem 'rubocop-minitest', '0.36.0', require: false
|
35
35
|
gem 'rubocop-performance', '1.23.1', require: false
|
@@ -38,5 +38,5 @@ gem 'rubocop-rspec', '3.4.0', require: false
|
|
38
38
|
gem 'simplecov', '0.22.0', require: false
|
39
39
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
40
40
|
gem 'w3c_validators', '1.3.7', require: false
|
41
|
-
gem 'webmock', '3.
|
41
|
+
gem 'webmock', '3.25.0', require: false
|
42
42
|
gem 'yard', '0.9.37', require: false
|
data/Gemfile.lock
CHANGED
@@ -179,7 +179,7 @@ GEM
|
|
179
179
|
reline (0.6.0)
|
180
180
|
io-console (~> 0.5)
|
181
181
|
rexml (3.4.0)
|
182
|
-
rspec-core (3.13.
|
182
|
+
rspec-core (3.13.3)
|
183
183
|
rspec-support (~> 3.13.0)
|
184
184
|
rspec-expectations (3.13.3)
|
185
185
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -187,7 +187,7 @@ GEM
|
|
187
187
|
rspec-mocks (3.13.2)
|
188
188
|
diff-lcs (>= 1.2.0, < 2.0)
|
189
189
|
rspec-support (~> 3.13.0)
|
190
|
-
rspec-rails (7.1.
|
190
|
+
rspec-rails (7.1.1)
|
191
191
|
actionpack (>= 7.0)
|
192
192
|
activesupport (>= 7.0)
|
193
193
|
railties (>= 7.0)
|
@@ -245,7 +245,7 @@ GEM
|
|
245
245
|
json (>= 1.8)
|
246
246
|
nokogiri (~> 1.6)
|
247
247
|
rexml (~> 3.2)
|
248
|
-
webmock (3.
|
248
|
+
webmock (3.25.0)
|
249
249
|
addressable (>= 2.8.0)
|
250
250
|
crack (>= 0.3.2)
|
251
251
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -270,7 +270,7 @@ DEPENDENCIES
|
|
270
270
|
qbash!
|
271
271
|
rake (= 13.2.1)
|
272
272
|
random-port (~> 0.0)
|
273
|
-
rspec-rails (= 7.1.
|
273
|
+
rspec-rails (= 7.1.1)
|
274
274
|
rubocop (= 1.71.2)
|
275
275
|
rubocop-minitest (= 0.36.0)
|
276
276
|
rubocop-performance (= 1.23.1)
|
@@ -279,7 +279,7 @@ DEPENDENCIES
|
|
279
279
|
simplecov (= 0.22.0)
|
280
280
|
simplecov-cobertura (= 2.1.0)
|
281
281
|
w3c_validators (= 1.3.7)
|
282
|
-
webmock (= 3.
|
282
|
+
webmock (= 3.25.0)
|
283
283
|
yard (= 0.9.37)
|
284
284
|
|
285
285
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -74,6 +74,16 @@ qbash(
|
|
74
74
|
)
|
75
75
|
```
|
76
76
|
|
77
|
+
If a block is given to `qbash`, it will run the command in background mode,
|
78
|
+
waiting for the block to finish. Once it's finished, the command will be
|
79
|
+
terminated via the `TERM` [signal]:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
qbash('sleep 9999') do |pid|
|
83
|
+
# do something
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
77
87
|
It is very much recommended to escape all command-line values with the help
|
78
88
|
of the [Shellwords.escape()][shellwords] utility method, for example:
|
79
89
|
|
@@ -86,7 +96,7 @@ Without such an escaping, in this example, a space inside the `file`
|
|
86
96
|
will lead to an unpredicatable result of the execution.
|
87
97
|
|
88
98
|
If you want to stop sooner than the command finishes, use
|
89
|
-
[
|
99
|
+
[timeout] gem:
|
90
100
|
|
91
101
|
```ruby
|
92
102
|
require 'timeout'
|
@@ -116,3 +126,5 @@ If it's clean and you don't see any error messages, submit your pull request.
|
|
116
126
|
|
117
127
|
[shellwords]: https://ruby-doc.org/stdlib-3.0.1/libdoc/shellwords/rdoc/Shellwords.html
|
118
128
|
[qbash]: https://rubydoc.info/github/yegor256/qbash/master/Kernel#qbash-instance_method
|
129
|
+
[signal]: https://en.wikipedia.org/wiki/Signal_(IPC)
|
130
|
+
[timeout]: https://github.com/ruby/timeout
|
data/lib/qbash.rb
CHANGED
@@ -89,25 +89,35 @@ module Kernel
|
|
89
89
|
sin.write(stdin)
|
90
90
|
sin.close
|
91
91
|
if block_given?
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
92
|
+
closed = false
|
93
|
+
watch =
|
94
|
+
Thread.new do
|
95
|
+
until closed
|
96
|
+
begin
|
97
|
+
ln = sout.gets
|
98
|
+
rescue IOError => e
|
99
|
+
ln = Backtrace.new(e).to_s
|
100
|
+
end
|
101
|
+
ln = "##{thr.pid}: #{ln}"
|
102
|
+
if log.nil?
|
103
|
+
# no logging
|
104
|
+
elsif log.respond_to?(mtd)
|
105
|
+
log.__send__(mtd, ln)
|
106
|
+
else
|
107
|
+
log.print(ln)
|
108
|
+
end
|
109
|
+
buf += ln
|
98
110
|
end
|
99
|
-
ln = "##{thr.pid}: #{ln}"
|
100
|
-
if log.nil?
|
101
|
-
# no logging
|
102
|
-
elsif log.respond_to?(mtd)
|
103
|
-
log.__send__(mtd, ln)
|
104
|
-
else
|
105
|
-
log.print(ln)
|
106
|
-
end
|
107
|
-
buf += ln
|
108
111
|
end
|
112
|
+
pid = thr.pid
|
113
|
+
yield pid
|
114
|
+
begin
|
115
|
+
Process.kill('TERM', pid)
|
116
|
+
rescue Errno::ESRCH
|
117
|
+
# simply ignore it
|
109
118
|
end
|
110
|
-
|
119
|
+
closed = true
|
120
|
+
watch.join
|
111
121
|
else
|
112
122
|
until sout.eof?
|
113
123
|
begin
|
data/qbash.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
27
27
|
s.required_ruby_version = '>=3.2'
|
28
28
|
s.name = 'qbash'
|
29
|
-
s.version = '0.
|
29
|
+
s.version = '0.4.0'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Quick Executor of a BASH Command'
|
32
32
|
s.description =
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|