qbash 0.4.8 → 0.5.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: bbe9e9fc160187a9aa6cbb353cc4d7679fc256b1a58a5443f6100cf0a234d656
4
- data.tar.gz: 0d7996f3b77055ae4b5cb0f9124ff90b05c720200d4e7b5a26a69cc531fee6da
3
+ metadata.gz: 9e872574e62d1c8a6c104b3073529e89aef6bb4cbf0e72d96c464b91e82d96ee
4
+ data.tar.gz: 020a400a253c7467a8d4bf5fcd7bcab4991174ba500b792e5afb2cb80214c2f7
5
5
  SHA512:
6
- metadata.gz: 0ed1097373b8757f1b2482d81dd8159f71f70f87520bbe06b1f62c0a090b99892f0525c9b0b2d247f34c1a5ac1c0aae0497179d6a203bfabfe7fa153602de6f6
7
- data.tar.gz: 0dc6ed420d59e2b8c1892f13318aec97b33a2e2c57eff0a8bbe5a7eb9ff8beacfa3487822caf270ca708b631ea0ce845e71e95b10ec525edc3fbd482da750680
6
+ metadata.gz: c104aba85b47d33cac8a92acf3d6c917dc40a9c813e04c65dec7c2d694860d9ae34118e3042f9d37f0fd596162b7e647074bd2c7275409b8abb0aefbd3cfa68e
7
+ data.tar.gz: 76a9724d3477772a856ede1693668b665afc53b07d442e01b9380d1a6a7e90a163f1d88991a9232f9aa4b062c62e5006df5bdb805939c6d73a3b735abcca4744
data/Gemfile CHANGED
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  source 'https://rubygems.org'
7
7
  gemspec
8
8
 
9
9
  gem 'cucumber', '~>10.0', require: false
10
- gem 'minitest', '~>5.25', require: false
10
+ gem 'minitest', '~>6.0', require: false
11
11
  gem 'minitest-reporters', '~>1.7', require: false
12
12
  gem 'net-ping', '~>2.0', require: false
13
13
  gem 'rake', '~>13.2', require: false
14
14
  gem 'random-port', '~>0.0', require: false
15
- gem 'rdoc', '~>6.13', require: false
15
+ gem 'rdoc', '~>7.0', require: false
16
16
  gem 'rubocop', '~>1.73', require: false
17
17
  gem 'rubocop-minitest', '~>0.38', require: false
18
18
  gem 'rubocop-performance', '~>1.25', require: false
data/Gemfile.lock CHANGED
@@ -21,22 +21,22 @@ GEM
21
21
  crack (1.0.1)
22
22
  bigdecimal
23
23
  rexml
24
- cucumber (10.1.1)
24
+ cucumber (10.2.0)
25
25
  base64 (~> 0.2)
26
26
  builder (~> 3.2)
27
- cucumber-ci-environment (> 9, < 11)
27
+ cucumber-ci-environment (> 9, < 12)
28
28
  cucumber-core (> 15, < 17)
29
- cucumber-cucumber-expressions (> 17, < 19)
30
- cucumber-html-formatter (> 20.3, < 22)
29
+ cucumber-cucumber-expressions (> 17, < 20)
30
+ cucumber-html-formatter (> 21, < 23)
31
31
  diff-lcs (~> 1.5)
32
32
  logger (~> 1.6)
33
33
  mini_mime (~> 1.1)
34
34
  multi_test (~> 1.1)
35
35
  sys-uname (~> 1.3)
36
36
  cucumber-ci-environment (10.0.1)
37
- cucumber-core (15.3.0)
38
- cucumber-gherkin (> 27, < 35)
39
- cucumber-messages (> 26, < 30)
37
+ cucumber-core (15.4.0)
38
+ cucumber-gherkin (> 27, < 40)
39
+ cucumber-messages (> 26, < 33)
40
40
  cucumber-tag-expressions (> 5, < 9)
41
41
  cucumber-cucumber-expressions (18.0.1)
42
42
  bigdecimal
@@ -45,14 +45,14 @@ GEM
45
45
  cucumber-html-formatter (21.15.1)
46
46
  cucumber-messages (> 19, < 28)
47
47
  cucumber-messages (27.2.0)
48
- cucumber-tag-expressions (8.0.0)
49
- date (3.4.1)
48
+ cucumber-tag-expressions (8.1.0)
49
+ date (3.5.1)
50
50
  diff-lcs (1.6.2)
51
51
  docile (1.4.1)
52
52
  elapsed (0.2.0)
53
53
  loog (~> 0.6)
54
54
  tago (~> 0.1)
55
- erb (5.1.3)
55
+ erb (6.0.1)
56
56
  ffi (1.17.2-aarch64-linux-gnu)
57
57
  ffi (1.17.2-arm-linux-gnu)
58
58
  ffi (1.17.2-arm64-darwin)
@@ -61,7 +61,7 @@ GEM
61
61
  ffi (1.17.2-x86_64-darwin)
62
62
  ffi (1.17.2-x86_64-linux-gnu)
63
63
  hashdiff (1.2.1)
64
- json (2.15.2)
64
+ json (2.18.0)
65
65
  language_server-protocol (3.17.0.5)
66
66
  lint_roller (1.1.0)
67
67
  logger (1.7.0)
@@ -70,7 +70,8 @@ GEM
70
70
  memoist3 (1.0.0)
71
71
  mini_mime (1.1.5)
72
72
  mini_portile2 (2.8.9)
73
- minitest (5.26.2)
73
+ minitest (6.0.1)
74
+ prism (~> 1.5)
74
75
  minitest-reporters (1.7.1)
75
76
  ansi
76
77
  builder
@@ -98,7 +99,7 @@ GEM
98
99
  ast (~> 2.4.1)
99
100
  racc
100
101
  prism (1.6.0)
101
- psych (5.2.6)
102
+ psych (5.3.1)
102
103
  date
103
104
  stringio
104
105
  public_suffix (6.0.2)
@@ -107,13 +108,13 @@ GEM
107
108
  rake (13.3.1)
108
109
  random-port (0.7.6)
109
110
  tago (~> 0.0)
110
- rdoc (6.15.1)
111
+ rdoc (7.0.3)
111
112
  erb
112
113
  psych (>= 4.0.0)
113
114
  tsort
114
115
  regexp_parser (2.11.3)
115
116
  rexml (3.4.4)
116
- rubocop (1.81.7)
117
+ rubocop (1.82.1)
117
118
  json (~> 2.3)
118
119
  language_server-protocol (~> 3.17.0.2)
119
120
  lint_roller (~> 1.1.0)
@@ -121,10 +122,10 @@ GEM
121
122
  parser (>= 3.3.0.2)
122
123
  rainbow (>= 2.2.2, < 4.0)
123
124
  regexp_parser (>= 2.9.3, < 3.0)
124
- rubocop-ast (>= 1.47.1, < 2.0)
125
+ rubocop-ast (>= 1.48.0, < 2.0)
125
126
  ruby-progressbar (~> 1.7)
126
127
  unicode-display_width (>= 2.4.0, < 4.0)
127
- rubocop-ast (1.47.1)
128
+ rubocop-ast (1.48.0)
128
129
  parser (>= 3.3.7.2)
129
130
  prism (~> 1.4)
130
131
  rubocop-minitest (0.38.2)
@@ -148,7 +149,7 @@ GEM
148
149
  simplecov (~> 0.19)
149
150
  simplecov-html (0.13.2)
150
151
  simplecov_json_formatter (0.1.4)
151
- stringio (3.1.8)
152
+ stringio (3.2.0)
152
153
  sys-uname (1.4.1)
153
154
  ffi (~> 1.1)
154
155
  memoist3 (~> 1.0.0)
@@ -165,7 +166,7 @@ GEM
165
166
  addressable (>= 2.8.0)
166
167
  crack (>= 0.3.2)
167
168
  hashdiff (>= 0.4.0, < 2.0.0)
168
- yard (0.9.37)
169
+ yard (0.9.38)
169
170
 
170
171
  PLATFORMS
171
172
  aarch64-linux
@@ -179,13 +180,13 @@ PLATFORMS
179
180
 
180
181
  DEPENDENCIES
181
182
  cucumber (~> 10.0)
182
- minitest (~> 5.25)
183
+ minitest (~> 6.0)
183
184
  minitest-reporters (~> 1.7)
184
185
  net-ping (~> 2.0)
185
186
  qbash!
186
187
  rake (~> 13.2)
187
188
  random-port (~> 0.0)
188
- rdoc (~> 6.13)
189
+ rdoc (~> 7.0)
189
190
  rubocop (~> 1.73)
190
191
  rubocop-minitest (~> 0.38)
191
192
  rubocop-performance (~> 1.25)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2024-2025 Yegor Bugayenko
3
+ Copyright (c) 2024-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/LICENSES/MIT.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2024-2025 Yegor Bugayenko
3
+ Copyright (c) 2024-2026 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/README.md CHANGED
@@ -13,9 +13,10 @@
13
13
 
14
14
  How do you execute a new shell command from Ruby?
15
15
  There are [many ways][so-question].
16
- None of them offers a one-liner that would execute a command, print
17
- its output to the console or a logger, and then raise an exception if
18
- the exit code is not zero. This small gem offers exactly this one-liner.
16
+ None of them offers a one-liner that would execute a command,
17
+ print its output to the console or a logger, and then raise an exception if
18
+ the exit code is not zero.
19
+ This small gem offers exactly this one-liner.
19
20
 
20
21
  First, install it:
21
22
 
@@ -23,17 +24,17 @@ First, install it:
23
24
  gem install qbash
24
25
  ```
25
26
 
26
- Then, you can use [qbash][qbash] global function:
27
+ Then, you can use [qbash] global function:
27
28
 
28
29
  ```ruby
29
30
  require 'qbash'
30
31
  stdout = qbash('echo "Hello, world!"', log: $stdout)
31
32
  ```
32
33
 
33
- If the command fails, an exception will be raised.
34
+ If the command fails, an exception is raised.
34
35
 
35
36
  The function automatically merges `stderr` with `stdout`
36
- (you can't change this).
37
+ (you can't change this).
37
38
 
38
39
  It's possible to provide the standard input and environment variables:
39
40
 
@@ -41,28 +42,28 @@ It's possible to provide the standard input and environment variables:
41
42
  stdout = qbash('cat > $FILE', env: { 'FILE' => 'a.txt' }, stdin: 'Hello!')
42
43
  ```
43
44
 
44
- It's possible to configure the logging facility too, for example, with the help
45
- of the [loog](https://github.com/yegor256/loog) gem (the output
46
- will be returned _and_ printed to the logger):
45
+ It's possible to configure the logging facility too, for example,
46
+ with the help of the [loog] gem
47
+ (the output is returned _and_ printed to the logger):
47
48
 
48
49
  ```ruby
49
50
  require 'loog'
50
51
  qbash('echo "Hello, world!"', log: Loog::VERBOSE)
51
52
  ```
52
53
 
53
- You can also make it return both stdout and exit code, with the help
54
- of the `both` option set to `true`:
54
+ You can also make it return both stdout and exit code,
55
+ with the help of the `both` option set to `true`:
55
56
 
56
57
  ```ruby
57
58
  stdout, code = qbash('cat a.txt', both: true, accept: [])
58
59
  ```
59
60
 
60
61
  Here, the `accept` param contains the list of exit codes that are "acceptable"
61
- and won't lead to runtime failures. When the list is empty, all exists are
62
- acceptable (there will be no failures ever).
62
+ and won't lead to runtime failures.
63
+ When the list is empty, all exits are acceptable (no failures occur).
63
64
 
64
- The command may be provided as an array, which automatically will be
65
- converted to a string by joining all items with spaces between them.
65
+ The command may be provided as an array, which is automatically
66
+ converted to a string by joining all items with spaces between them.
66
67
 
67
68
  ```ruby
68
69
  qbash(
@@ -74,9 +75,19 @@ qbash(
74
75
  )
75
76
  ```
76
77
 
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]:
78
+ Even simpler:
79
+
80
+ ```ruby
81
+ qbash(
82
+ 'echo "Hello, world!"',
83
+ '&& echo "How are you?"',
84
+ '&& cat /etc/passwd'
85
+ )
86
+ ```
87
+
88
+ If a block is given to `qbash`, it runs the command in background mode,
89
+ waiting for the block to finish.
90
+ Once finished, the command is terminated via the `TERM` [signal]:
80
91
 
81
92
  ```ruby
82
93
  qbash('sleep 9999') do |pid|
@@ -85,18 +96,17 @@ end
85
96
  ```
86
97
 
87
98
  It is very much recommended to escape all command-line values with the help
88
- of the [Shellwords.escape()][shellwords] utility method, for example:
99
+ of the [Shellwords.escape()][shellwords] utility method, for example:
89
100
 
90
101
  ```ruby
91
102
  file = '/tmp/test.txt'
92
103
  qbash("cat #{Shellwords.escape(file)}")
93
104
  ```
94
105
 
95
- Without such an escaping, in this example, a space inside the `file`
96
- will lead to an unpredictable result of the execution.
106
+ Without such escaping, a space inside the `file` variable
107
+ leads to an unpredictable result.
97
108
 
98
- If you want to stop sooner than the command finishes, use
99
- [timeout] gem:
109
+ If you want to stop sooner than the command finishes, use [timeout] gem:
100
110
 
101
111
  ```ruby
102
112
  require 'timeout'
@@ -105,17 +115,15 @@ Timeout.timeout(5) do
105
115
  end
106
116
  ```
107
117
 
108
- This command will raise `Timeout::Error` exception after five seconds
109
- of waiting for the `sleep` to finish.
118
+ This raises a `Timeout::Error` exception after five seconds
119
+ of waiting for `sleep` to finish.
110
120
 
111
121
  ## How to contribute
112
122
 
113
- Read
114
- [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
115
- Make sure your build is green before you contribute
116
- your pull request. You will need to have
117
- [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
118
- [Bundler](https://bundler.io/) installed. Then:
123
+ Read [these guidelines][guidelines].
124
+ Make sure your build is green before you contribute your pull request.
125
+ You need [Ruby] 3.0+ and [Bundler] installed.
126
+ Then:
119
127
 
120
128
  ```bash
121
129
  bundle update
@@ -124,8 +132,12 @@ bundle exec rake
124
132
 
125
133
  If it's clean and you don't see any error messages, submit your pull request.
126
134
 
127
- [shellwords]: https://ruby-doc.org/stdlib-3.0.1/libdoc/shellwords/rdoc/Shellwords.html
135
+ [Bundler]: https://bundler.io/
136
+ [guidelines]: https://www.yegor256.com/2014/04/15/github-guidelines.html
137
+ [loog]: https://github.com/yegor256/loog
128
138
  [qbash]: https://rubydoc.info/github/yegor256/qbash/master/Kernel#qbash-instance_method
139
+ [Ruby]: https://www.ruby-lang.org/en/
140
+ [shellwords]: https://ruby-doc.org/stdlib-3.0.1/libdoc/shellwords/rdoc/Shellwords.html
129
141
  [signal]: https://en.wikipedia.org/wiki/Signal_(IPC)
130
- [timeout]: https://github.com/ruby/timeout
131
142
  [so-question]: https://stackoverflow.com/questions/2232/
143
+ [timeout]: https://github.com/ruby/timeout
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'rubygems'
data/lib/qbash.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'backtrace'
@@ -12,7 +12,7 @@ require 'tago'
12
12
  # Execute one bash command.
13
13
  #
14
14
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
+ # Copyright:: Copyright (c) 2024-2026 Yegor Bugayenko
16
16
  # License:: MIT
17
17
  module Kernel
18
18
  # Execute a single bash command safely with proper error handling.
@@ -81,9 +81,9 @@ module Kernel
81
81
  # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
82
82
  # @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
83
83
  # @return [String] Everything that was printed to the +stdout+ by the command
84
- def qbash(cmd, opts: [], stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, level: Logger::DEBUG)
84
+ def qbash(*cmd, opts: [], stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, level: Logger::DEBUG)
85
85
  env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
86
- cmd = cmd.reject { |a| a.nil? || (a.is_a?(String) && a.empty?) }.join(' ') if cmd.is_a?(Array)
86
+ cmd = cmd.reject { |a| a.nil? || (a.is_a?(String) && a.empty?) }.join(' ')
87
87
  logit =
88
88
  lambda do |msg|
89
89
  msg = msg.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').gsub(/\n$/, '')
data/qbash.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2026 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'English'
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
10
  s.required_ruby_version = '>=3.2'
11
11
  s.name = 'qbash'
12
- s.version = '0.4.8'
12
+ s.version = '0.5.0'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Quick Executor of a BASH Command'
15
15
  s.description =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qbash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko