qbash 0.0.8 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34c417c95e1753f5500eb19887e7bb64045a8ed7888232af257a82f84ba71fa7
4
- data.tar.gz: 4614a0dfd4ce8e692590c80d5ead25a680f49deee23856ee911852f2762baf8a
3
+ metadata.gz: 39244de3b00f6094ec91699c5a7eb8f0e2e7cf53670233dfb21d5df3a05d00fc
4
+ data.tar.gz: 8f17ae0148d5a5426ca7754bc12f1746b57b0f9c82fd4a48f0611dee186dc760
5
5
  SHA512:
6
- metadata.gz: 720d1b9b3ed953125e9a68d308407ede0aa6de2b39c242eb40a31a5e916711c21dd6d57c245536182fff2c72799c7b0f86c6463a6e4d931d21c39d02f68ecf48
7
- data.tar.gz: 0f380bf249fea27cd69cfedb460c157b26be03ab3d2c944b21e8a7c09aafc23dbb4500c3bb5f3f6d1262a18bcf2ced2e44f51a0529b5310e2dc337d82109c61f
6
+ metadata.gz: 4ea302ab3a7094e337b55367c8c10db61465d7ac24187e2691346f25ca1db4ec587c4f6a72b3c9d9c148f9347beabcb6a6f8fb16cd07e09ffd5b12af6521fd3a
7
+ data.tar.gz: 3c56561a93b211904ac4482df6cf1f3dd31b989792f984e691259d7374f7a51bdf091354149324ddb3460efc7769c3f6db4f489e413d59af7e20d7ae916049d7
@@ -31,4 +31,4 @@ jobs:
31
31
  runs-on: ubuntu-24.04
32
32
  steps:
33
33
  - uses: actions/checkout@v4
34
- - uses: yegor256/copyrights-action@0.0.5
34
+ - uses: yegor256/copyrights-action@0.0.8
@@ -31,7 +31,7 @@ jobs:
31
31
  name: test
32
32
  strategy:
33
33
  matrix:
34
- os: [ubuntu-24.04, macos-12]
34
+ os: [ubuntu-24.04, macos-15]
35
35
  ruby: [3.3]
36
36
  runs-on: ${{ matrix.os }}
37
37
  steps:
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.1', require: false
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.1', require: false
33
- gem 'rubocop', '1.66.1', require: false
34
- gem 'rubocop-performance', '1.22.1', require: false
35
- gem 'rubocop-rspec', '3.1.0', require: false
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.1)
14
- actionview (= 7.2.1)
15
- activesupport (= 7.2.1)
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.1)
25
- activesupport (= 7.2.1)
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.1)
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.7.2)
103
+ json (2.9.0)
102
104
  language_server-protocol (3.17.0.3)
103
105
  logger (1.6.1)
104
- loofah (2.22.0)
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.1)
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.5.0)
134
+ parser (3.3.6.0)
133
135
  ast (~> 2.4.1)
134
136
  racc
135
- psych (5.1.2)
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.7)
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.1.0)
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.1)
155
- actionpack (= 7.2.1)
156
- activesupport (= 7.2.1)
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.2)
168
- reline (0.5.10)
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.1)
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.1)
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.1)
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.66.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.4, < 3.0)
195
- rubocop-ast (>= 1.32.2, < 2.0)
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, < 3.0)
198
- rubocop-ast (1.32.3)
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.22.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.1.0)
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.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.6.18)
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.1)
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.1)
255
- rubocop (= 1.66.1)
256
- rubocop-performance (= 1.22.1)
257
- rubocop-rspec (= 3.1.0)
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/README.md CHANGED
@@ -85,13 +85,18 @@ qbash("cat #{Shellwords.escape(file)}")
85
85
  Without such an escaping, in this example, a space inside the `file`
86
86
  will lead to an unpredicatable result of the execution.
87
87
 
88
- You can also set the maximum time for the command:
88
+ If you want to stop sooner than the command finishes, use
89
+ [`timeout`](https://github.com/ruby/timeout) gem:
89
90
 
90
91
  ```ruby
91
- qbash("sleep 100", timeout: 4)
92
+ require 'timeout'
93
+ Timeout.timeout(5) do
94
+ qbash('sleep 100')
95
+ end
92
96
  ```
93
97
 
94
- This command will raise exception after four seconds.
98
+ This command will raise `Timeout::Error` exception after five seconds
99
+ of waiting for the `sleep` to finish.
95
100
 
96
101
  ## How to contribute
97
102
 
data/lib/qbash.rb CHANGED
@@ -53,10 +53,10 @@ module Kernel
53
53
  # @param [Loog|IO] log Logging facility with +.debug()+ method (or +$stdout+)
54
54
  # @param [Array] accept List of accepted exit codes (accepts all if the list is +nil+)
55
55
  # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
56
- # @param [Integer] timeout If it's set to non-NIL, the execution will fail after this number of seconds
57
56
  # @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
58
57
  # @return [String] Everything that was printed to the +stdout+ by the command
59
- def qbash(cmd, stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, timeout: nil, level: Logger::DEBUG)
58
+ def qbash(cmd, stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, level: Logger::DEBUG)
59
+ env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
60
60
  cmd = cmd.reject { |a| a.nil? || a.empty? }.join(' ') if cmd.is_a?(Array)
61
61
  mtd =
62
62
  case level
@@ -103,7 +103,7 @@ module Kernel
103
103
  end
104
104
  end
105
105
  end
106
- raise "Execution of #{cmd} timed out in #{start.ago}" if thread.join(timeout).nil?
106
+ thread.join
107
107
  return [buf, e] if both
108
108
  buf
109
109
  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.8'
29
+ s.version = '0.2.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
@@ -72,12 +72,6 @@ class TestQbash < Minitest::Test
72
72
  end
73
73
  end
74
74
 
75
- def test_with_timeout
76
- assert_raises do
77
- qbash('sleep 100', timeout: 0.1)
78
- end
79
- end
80
-
81
75
  def test_with_special_symbols
82
76
  assert_equal("'hi'\n", qbash("echo \"'hi'\""))
83
77
  end
@@ -88,6 +82,10 @@ class TestQbash < Minitest::Test
88
82
  end
89
83
  end
90
84
 
85
+ def test_fails_when_nil_env
86
+ assert_raises { qbash('echo hi', env: { a: nil }) }
87
+ end
88
+
91
89
  def test_ignore_errors
92
90
  Dir.mktmpdir do |home|
93
91
  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.8
4
+ version: 0.2.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-10-06 00:00:00.000000000 Z
11
+ date: 2024-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace