qbash 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/qbash.rb +2 -3
- data/qbash.gemspec +1 -1
- data/test/test_qbash.rb +0 -6
- 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: 39244de3b00f6094ec91699c5a7eb8f0e2e7cf53670233dfb21d5df3a05d00fc
|
4
|
+
data.tar.gz: 8f17ae0148d5a5426ca7754bc12f1746b57b0f9c82fd4a48f0611dee186dc760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ea302ab3a7094e337b55367c8c10db61465d7ac24187e2691346f25ca1db4ec587c4f6a72b3c9d9c148f9347beabcb6a6f8fb16cd07e09ffd5b12af6521fd3a
|
7
|
+
data.tar.gz: 3c56561a93b211904ac4482df6cf1f3dd31b989792f984e691259d7374f7a51bdf091354149324ddb3460efc7769c3f6db4f489e413d59af7e20d7ae916049d7
|
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
|
-
|
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
|
-
|
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
|
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,9 @@ 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,
|
58
|
+
def qbash(cmd, stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, level: Logger::DEBUG)
|
60
59
|
env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
|
61
60
|
cmd = cmd.reject { |a| a.nil? || a.empty? }.join(' ') if cmd.is_a?(Array)
|
62
61
|
mtd =
|
@@ -104,7 +103,7 @@ module Kernel
|
|
104
103
|
end
|
105
104
|
end
|
106
105
|
end
|
107
|
-
|
106
|
+
thread.join
|
108
107
|
return [buf, e] if both
|
109
108
|
buf
|
110
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.
|
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
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.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-12-
|
11
|
+
date: 2024-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|