qbash 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/copyrights.yml +1 -1
- data/.github/workflows/rake.yml +1 -1
- data/Gemfile +5 -5
- data/Gemfile.lock +37 -37
- data/lib/qbash.rb +21 -5
- data/qbash.gemspec +1 -1
- data/test/test_qbash.rb +15 -0
- 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: 010ab8ee65105e6dd7d463e0f86a93ab0816c85d390de47c0e146fdf3d101cb4
|
4
|
+
data.tar.gz: 1fa31fc03e965c1a41c435b0722443ef4836455febe350e7a129402965a1df69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19933d40b4ac18a7d9db6d9328fd09d303971aa113bbff8a4c655db4cdbed14b682e95487134e33cb5e443dcf826996ffc8d39065cecfc6c1dd1bb57147abf47
|
7
|
+
data.tar.gz: 33a7904018b3b781a1efdebf39cb6fdfc96e6ec578803948a1b446b116ccc4e53630939ad63e3de2ba0c38f8cae4695f1e1f9b665196720dc5ed0b6473179a48
|
data/.github/workflows/rake.yml
CHANGED
data/Gemfile
CHANGED
@@ -24,15 +24,15 @@ source 'https://rubygems.org'
|
|
24
24
|
gemspec
|
25
25
|
|
26
26
|
gem 'cucumber', '9.2.0', require: false
|
27
|
-
gem 'minitest', '5.25.
|
27
|
+
gem 'minitest', '5.25.4', require: false
|
28
28
|
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.0
|
33
|
-
gem 'rubocop', '1.
|
34
|
-
gem 'rubocop-performance', '1.
|
35
|
-
gem 'rubocop-rspec', '3.
|
32
|
+
gem 'rspec-rails', '7.1.0', require: false
|
33
|
+
gem 'rubocop', '1.69.2', require: false
|
34
|
+
gem 'rubocop-performance', '1.23.0', require: false
|
35
|
+
gem 'rubocop-rspec', '3.3.0', require: false
|
36
36
|
gem 'simplecov', '0.22.0', require: false
|
37
37
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
38
38
|
gem 'w3c_validators', '1.3.7', require: false
|
data/Gemfile.lock
CHANGED
@@ -10,9 +10,9 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionpack (7.2.
|
14
|
-
actionview (= 7.2.
|
15
|
-
activesupport (= 7.2.
|
13
|
+
actionpack (7.2.2)
|
14
|
+
actionview (= 7.2.2)
|
15
|
+
activesupport (= 7.2.2)
|
16
16
|
nokogiri (>= 1.8.5)
|
17
17
|
racc
|
18
18
|
rack (>= 2.2.4, < 3.2)
|
@@ -21,14 +21,15 @@ GEM
|
|
21
21
|
rails-dom-testing (~> 2.2)
|
22
22
|
rails-html-sanitizer (~> 1.6)
|
23
23
|
useragent (~> 0.16)
|
24
|
-
actionview (7.2.
|
25
|
-
activesupport (= 7.2.
|
24
|
+
actionview (7.2.2)
|
25
|
+
activesupport (= 7.2.2)
|
26
26
|
builder (~> 3.1)
|
27
27
|
erubi (~> 1.11)
|
28
28
|
rails-dom-testing (~> 2.2)
|
29
29
|
rails-html-sanitizer (~> 1.6)
|
30
|
-
activesupport (7.2.
|
30
|
+
activesupport (7.2.2)
|
31
31
|
base64
|
32
|
+
benchmark (>= 0.3)
|
32
33
|
bigdecimal
|
33
34
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
34
35
|
connection_pool (>= 2.2.5)
|
@@ -44,6 +45,7 @@ GEM
|
|
44
45
|
ast (2.4.2)
|
45
46
|
backtrace (0.4.0)
|
46
47
|
base64 (0.2.0)
|
48
|
+
benchmark (0.4.0)
|
47
49
|
bigdecimal (3.1.8)
|
48
50
|
builder (3.3.0)
|
49
51
|
concurrent-ruby (1.3.4)
|
@@ -98,15 +100,15 @@ GEM
|
|
98
100
|
irb (1.14.1)
|
99
101
|
rdoc (>= 4.0.0)
|
100
102
|
reline (>= 0.4.2)
|
101
|
-
json (2.
|
103
|
+
json (2.9.0)
|
102
104
|
language_server-protocol (3.17.0.3)
|
103
105
|
logger (1.6.1)
|
104
|
-
loofah (2.
|
106
|
+
loofah (2.23.1)
|
105
107
|
crass (~> 1.0.2)
|
106
108
|
nokogiri (>= 1.12.0)
|
107
109
|
loog (0.6.0)
|
108
110
|
mini_mime (1.1.5)
|
109
|
-
minitest (5.25.
|
111
|
+
minitest (5.25.4)
|
110
112
|
minitest-reporters (1.7.1)
|
111
113
|
ansi
|
112
114
|
builder
|
@@ -129,21 +131,20 @@ GEM
|
|
129
131
|
nokogiri (1.16.7-x86_64-linux)
|
130
132
|
racc (~> 1.4)
|
131
133
|
parallel (1.26.3)
|
132
|
-
parser (3.3.
|
134
|
+
parser (3.3.6.0)
|
133
135
|
ast (~> 2.4.1)
|
134
136
|
racc
|
135
|
-
psych (5.
|
137
|
+
psych (5.2.0)
|
136
138
|
stringio
|
137
139
|
public_suffix (6.0.1)
|
138
140
|
racc (1.8.1)
|
139
|
-
rack (3.1.
|
141
|
+
rack (3.1.8)
|
140
142
|
rack-session (2.0.0)
|
141
143
|
rack (>= 3.0.0)
|
142
144
|
rack-test (2.1.0)
|
143
145
|
rack (>= 1.3)
|
144
|
-
rackup (2.
|
146
|
+
rackup (2.2.0)
|
145
147
|
rack (>= 3)
|
146
|
-
webrick (~> 1.8)
|
147
148
|
rails-dom-testing (2.2.0)
|
148
149
|
activesupport (>= 5.0.0)
|
149
150
|
minitest
|
@@ -151,9 +152,9 @@ GEM
|
|
151
152
|
rails-html-sanitizer (1.6.0)
|
152
153
|
loofah (~> 2.21)
|
153
154
|
nokogiri (~> 1.14)
|
154
|
-
railties (7.2.
|
155
|
-
actionpack (= 7.2.
|
156
|
-
activesupport (= 7.2.
|
155
|
+
railties (7.2.2)
|
156
|
+
actionpack (= 7.2.2)
|
157
|
+
activesupport (= 7.2.2)
|
157
158
|
irb (~> 1.13)
|
158
159
|
rackup (>= 1.0.0)
|
159
160
|
rake (>= 12.2)
|
@@ -164,19 +165,19 @@ GEM
|
|
164
165
|
random-port (0.7.1)
|
165
166
|
rdoc (6.7.0)
|
166
167
|
psych (>= 4.0.0)
|
167
|
-
regexp_parser (2.9.
|
168
|
-
reline (0.5.
|
168
|
+
regexp_parser (2.9.3)
|
169
|
+
reline (0.5.11)
|
169
170
|
io-console (~> 0.5)
|
170
171
|
rexml (3.3.8)
|
171
|
-
rspec-core (3.13.
|
172
|
+
rspec-core (3.13.2)
|
172
173
|
rspec-support (~> 3.13.0)
|
173
174
|
rspec-expectations (3.13.3)
|
174
175
|
diff-lcs (>= 1.2.0, < 2.0)
|
175
176
|
rspec-support (~> 3.13.0)
|
176
|
-
rspec-mocks (3.13.
|
177
|
+
rspec-mocks (3.13.2)
|
177
178
|
diff-lcs (>= 1.2.0, < 2.0)
|
178
179
|
rspec-support (~> 3.13.0)
|
179
|
-
rspec-rails (7.0
|
180
|
+
rspec-rails (7.1.0)
|
180
181
|
actionpack (>= 7.0)
|
181
182
|
activesupport (>= 7.0)
|
182
183
|
railties (>= 7.0)
|
@@ -185,22 +186,22 @@ GEM
|
|
185
186
|
rspec-mocks (~> 3.13)
|
186
187
|
rspec-support (~> 3.13)
|
187
188
|
rspec-support (3.13.1)
|
188
|
-
rubocop (1.
|
189
|
+
rubocop (1.69.2)
|
189
190
|
json (~> 2.3)
|
190
191
|
language_server-protocol (>= 3.17.0)
|
191
192
|
parallel (~> 1.10)
|
192
193
|
parser (>= 3.3.0.2)
|
193
194
|
rainbow (>= 2.2.2, < 4.0)
|
194
|
-
regexp_parser (>= 2.
|
195
|
-
rubocop-ast (>= 1.
|
195
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
196
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
196
197
|
ruby-progressbar (~> 1.7)
|
197
|
-
unicode-display_width (>= 2.4.0, <
|
198
|
-
rubocop-ast (1.
|
198
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
199
|
+
rubocop-ast (1.36.2)
|
199
200
|
parser (>= 3.3.1.0)
|
200
|
-
rubocop-performance (1.
|
201
|
+
rubocop-performance (1.23.0)
|
201
202
|
rubocop (>= 1.48.1, < 2.0)
|
202
203
|
rubocop-ast (>= 1.31.1, < 2.0)
|
203
|
-
rubocop-rspec (3.
|
204
|
+
rubocop-rspec (3.3.0)
|
204
205
|
rubocop (~> 1.61)
|
205
206
|
ruby-progressbar (1.13.0)
|
206
207
|
securerandom (0.3.1)
|
@@ -213,7 +214,7 @@ GEM
|
|
213
214
|
simplecov (~> 0.19)
|
214
215
|
simplecov-html (0.13.1)
|
215
216
|
simplecov_json_formatter (0.1.4)
|
216
|
-
stringio (3.1.
|
217
|
+
stringio (3.1.2)
|
217
218
|
sys-uname (1.3.0)
|
218
219
|
ffi (~> 1.1)
|
219
220
|
tago (0.0.2)
|
@@ -230,9 +231,8 @@ GEM
|
|
230
231
|
addressable (>= 2.8.0)
|
231
232
|
crack (>= 0.3.2)
|
232
233
|
hashdiff (>= 0.4.0, < 2.0.0)
|
233
|
-
webrick (1.8.2)
|
234
234
|
yard (0.9.37)
|
235
|
-
zeitwerk (2.
|
235
|
+
zeitwerk (2.7.1)
|
236
236
|
|
237
237
|
PLATFORMS
|
238
238
|
aarch64-linux
|
@@ -245,16 +245,16 @@ PLATFORMS
|
|
245
245
|
|
246
246
|
DEPENDENCIES
|
247
247
|
cucumber (= 9.2.0)
|
248
|
-
minitest (= 5.25.
|
248
|
+
minitest (= 5.25.4)
|
249
249
|
minitest-reporters (= 1.7.1)
|
250
250
|
net-ping (= 2.0.8)
|
251
251
|
qbash!
|
252
252
|
rake (= 13.2.1)
|
253
253
|
random-port (~> 0.0)
|
254
|
-
rspec-rails (= 7.0
|
255
|
-
rubocop (= 1.
|
256
|
-
rubocop-performance (= 1.
|
257
|
-
rubocop-rspec (= 3.
|
254
|
+
rspec-rails (= 7.1.0)
|
255
|
+
rubocop (= 1.69.2)
|
256
|
+
rubocop-performance (= 1.23.0)
|
257
|
+
rubocop-rspec (= 3.3.0)
|
258
258
|
simplecov (= 0.22.0)
|
259
259
|
simplecov-cobertura (= 2.1.0)
|
260
260
|
w3c_validators (= 1.3.7)
|
data/lib/qbash.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
require 'backtrace'
|
24
|
+
require 'logger'
|
24
25
|
require 'loog'
|
25
26
|
require 'open3'
|
26
27
|
require 'shellwords'
|
@@ -53,11 +54,26 @@ module Kernel
|
|
53
54
|
# @param [Array] accept List of accepted exit codes (accepts all if the list is +nil+)
|
54
55
|
# @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
|
55
56
|
# @param [Integer] timeout If it's set to non-NIL, the execution will fail after this number of seconds
|
57
|
+
# @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
|
56
58
|
# @return [String] Everything that was printed to the +stdout+ by the command
|
57
|
-
def qbash(cmd, stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, timeout: nil)
|
59
|
+
def qbash(cmd, stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, timeout: nil, level: Logger::DEBUG)
|
60
|
+
env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
|
58
61
|
cmd = cmd.reject { |a| a.nil? || a.empty? }.join(' ') if cmd.is_a?(Array)
|
59
|
-
|
60
|
-
|
62
|
+
mtd =
|
63
|
+
case level
|
64
|
+
when Logger::DEBUG
|
65
|
+
:debug
|
66
|
+
when Logger::INFO
|
67
|
+
:info
|
68
|
+
when Logger::WARN
|
69
|
+
:warn
|
70
|
+
when Logger::ERROR
|
71
|
+
:error
|
72
|
+
else
|
73
|
+
raise "Unknown log level #{level}"
|
74
|
+
end
|
75
|
+
if log.respond_to?(mtd)
|
76
|
+
log.__send__(mtd, "+ #{cmd}")
|
61
77
|
else
|
62
78
|
log.print("+ #{cmd}\n")
|
63
79
|
end
|
@@ -75,8 +91,8 @@ module Kernel
|
|
75
91
|
rescue IOError => e
|
76
92
|
ln = Backtrace.new(e).to_s
|
77
93
|
end
|
78
|
-
if log.respond_to?(
|
79
|
-
log.
|
94
|
+
if log.respond_to?(mtd)
|
95
|
+
log.__send__(mtd, ln)
|
80
96
|
else
|
81
97
|
log.print("#{ln}\n")
|
82
98
|
end
|
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.0
|
29
|
+
s.version = '0.1.0'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Quick Executor of a BASH Command'
|
32
32
|
s.description =
|
data/test/test_qbash.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
require 'minitest/autorun'
|
24
24
|
require 'tmpdir'
|
25
25
|
require 'loog'
|
26
|
+
require 'logger'
|
26
27
|
require 'shellwords'
|
27
28
|
require_relative 'test__helper'
|
28
29
|
require_relative '../lib/qbash'
|
@@ -48,10 +49,20 @@ class TestQbash < Minitest::Test
|
|
48
49
|
qbash('echo Hello world!', log: $stdout)
|
49
50
|
end
|
50
51
|
|
52
|
+
def test_log_to_loog
|
53
|
+
[Logger::DEBUG, Logger::INFO, Logger::WARN, Logger::ERROR].each do |level|
|
54
|
+
qbash('echo Hello world!', log: Loog::NULL, level:)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
def test_skip_nil
|
52
59
|
assert_equal('Hi!', qbash(['printf', nil, 'Hi!', '']))
|
53
60
|
end
|
54
61
|
|
62
|
+
def test_accept_zero
|
63
|
+
qbash('echo hi', accept: nil)
|
64
|
+
end
|
65
|
+
|
55
66
|
def test_with_stdin
|
56
67
|
Dir.mktmpdir do |home|
|
57
68
|
f = File.join(home, 'a b c.txt')
|
@@ -77,6 +88,10 @@ class TestQbash < Minitest::Test
|
|
77
88
|
end
|
78
89
|
end
|
79
90
|
|
91
|
+
def test_fails_when_nil_env
|
92
|
+
assert_raises { qbash('echo hi', env: { a: nil }) }
|
93
|
+
end
|
94
|
+
|
80
95
|
def test_ignore_errors
|
81
96
|
Dir.mktmpdir do |home|
|
82
97
|
qbash("cat #{Shellwords.escape(File.join(home, 'b.txt'))}", accept: nil)
|
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.0
|
4
|
+
version: 0.1.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: 2024-
|
11
|
+
date: 2024-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|