qbash 0.5.0 → 0.6.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +36 -36
  3. data/lib/qbash.rb +13 -2
  4. data/qbash.gemspec +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e872574e62d1c8a6c104b3073529e89aef6bb4cbf0e72d96c464b91e82d96ee
4
- data.tar.gz: 020a400a253c7467a8d4bf5fcd7bcab4991174ba500b792e5afb2cb80214c2f7
3
+ metadata.gz: 76514b64336276e5a7a6f930cdde69aa8f92a368385e661b8b930fcf56b74269
4
+ data.tar.gz: 551650cc2ab252c771d99b6cf7a1e57a432d24b13b660df5c80549e1156a12c1
5
5
  SHA512:
6
- metadata.gz: c104aba85b47d33cac8a92acf3d6c917dc40a9c813e04c65dec7c2d694860d9ae34118e3042f9d37f0fd596162b7e647074bd2c7275409b8abb0aefbd3cfa68e
7
- data.tar.gz: 76a9724d3477772a856ede1693668b665afc53b07d442e01b9380d1a6a7e90a163f1d88991a9232f9aa4b062c62e5006df5bdb805939c6d73a3b735abcca4744
6
+ metadata.gz: b0b790b282910bc8730657f264042caddaf3d960933be65ef5a9541277ca8d0f7e0d1f5371643eadee77f3f9b367f67db744ad99a6edbdf2a89c55b9ec0e63df
7
+ data.tar.gz: 904d66cdf396205812115e1f45d90a903fe65fa9bdc9bc66c62f410beb521261f3dd830f87831996dc650ade478d0a7601e29ccb390d7dc3b29dd1b2a156a86c
data/Gemfile.lock CHANGED
@@ -10,13 +10,13 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.8.7)
14
- public_suffix (>= 2.0.2, < 7.0)
13
+ addressable (2.8.8)
14
+ public_suffix (>= 2.0.2, < 8.0)
15
15
  ansi (1.5.0)
16
16
  ast (2.4.3)
17
17
  backtrace (0.4.1)
18
18
  base64 (0.3.0)
19
- bigdecimal (3.3.1)
19
+ bigdecimal (4.0.1)
20
20
  builder (3.3.0)
21
21
  crack (1.0.1)
22
22
  bigdecimal
@@ -33,33 +33,33 @@ GEM
33
33
  mini_mime (~> 1.1)
34
34
  multi_test (~> 1.1)
35
35
  sys-uname (~> 1.3)
36
- cucumber-ci-environment (10.0.1)
37
- cucumber-core (15.4.0)
38
- cucumber-gherkin (> 27, < 40)
39
- cucumber-messages (> 26, < 33)
40
- cucumber-tag-expressions (> 5, < 9)
36
+ cucumber-ci-environment (11.0.0)
37
+ cucumber-core (16.1.1)
38
+ cucumber-gherkin (> 36, < 40)
39
+ cucumber-messages (> 31, < 33)
40
+ cucumber-tag-expressions (> 6, < 9)
41
41
  cucumber-cucumber-expressions (18.0.1)
42
42
  bigdecimal
43
- cucumber-gherkin (34.0.0)
44
- cucumber-messages (> 25, < 29)
45
- cucumber-html-formatter (21.15.1)
46
- cucumber-messages (> 19, < 28)
47
- cucumber-messages (27.2.0)
43
+ cucumber-gherkin (37.0.1)
44
+ cucumber-messages (>= 31, < 32)
45
+ cucumber-html-formatter (22.3.0)
46
+ cucumber-messages (> 23, < 33)
47
+ cucumber-messages (31.2.0)
48
48
  cucumber-tag-expressions (8.1.0)
49
49
  date (3.5.1)
50
50
  diff-lcs (1.6.2)
51
51
  docile (1.4.1)
52
- elapsed (0.2.0)
52
+ elapsed (0.2.2)
53
53
  loog (~> 0.6)
54
54
  tago (~> 0.1)
55
55
  erb (6.0.1)
56
- ffi (1.17.2-aarch64-linux-gnu)
57
- ffi (1.17.2-arm-linux-gnu)
58
- ffi (1.17.2-arm64-darwin)
59
- ffi (1.17.2-x64-mingw-ucrt)
60
- ffi (1.17.2-x86-linux-gnu)
61
- ffi (1.17.2-x86_64-darwin)
62
- ffi (1.17.2-x86_64-linux-gnu)
56
+ ffi (1.17.3-aarch64-linux-gnu)
57
+ ffi (1.17.3-arm-linux-gnu)
58
+ ffi (1.17.3-arm64-darwin)
59
+ ffi (1.17.3-x64-mingw-ucrt)
60
+ ffi (1.17.3-x86-linux-gnu)
61
+ ffi (1.17.3-x86_64-darwin)
62
+ ffi (1.17.3-x86_64-linux-gnu)
63
63
  hashdiff (1.2.1)
64
64
  json (2.18.0)
65
65
  language_server-protocol (3.17.0.5)
@@ -79,36 +79,36 @@ GEM
79
79
  ruby-progressbar
80
80
  multi_test (1.1.0)
81
81
  net-ping (2.0.8)
82
- nokogiri (1.18.10)
82
+ nokogiri (1.19.0)
83
83
  mini_portile2 (~> 2.8.2)
84
84
  racc (~> 1.4)
85
- nokogiri (1.18.10-aarch64-linux-gnu)
85
+ nokogiri (1.19.0-aarch64-linux-gnu)
86
86
  racc (~> 1.4)
87
- nokogiri (1.18.10-arm-linux-gnu)
87
+ nokogiri (1.19.0-arm-linux-gnu)
88
88
  racc (~> 1.4)
89
- nokogiri (1.18.10-arm64-darwin)
89
+ nokogiri (1.19.0-arm64-darwin)
90
90
  racc (~> 1.4)
91
- nokogiri (1.18.10-x64-mingw-ucrt)
91
+ nokogiri (1.19.0-x64-mingw-ucrt)
92
92
  racc (~> 1.4)
93
- nokogiri (1.18.10-x86_64-darwin)
93
+ nokogiri (1.19.0-x86_64-darwin)
94
94
  racc (~> 1.4)
95
- nokogiri (1.18.10-x86_64-linux-gnu)
95
+ nokogiri (1.19.0-x86_64-linux-gnu)
96
96
  racc (~> 1.4)
97
97
  parallel (1.27.0)
98
- parser (3.3.10.0)
98
+ parser (3.3.10.1)
99
99
  ast (~> 2.4.1)
100
100
  racc
101
- prism (1.6.0)
101
+ prism (1.8.0)
102
102
  psych (5.3.1)
103
103
  date
104
104
  stringio
105
- public_suffix (6.0.2)
105
+ public_suffix (7.0.2)
106
106
  racc (1.8.1)
107
107
  rainbow (3.1.1)
108
108
  rake (13.3.1)
109
109
  random-port (0.7.6)
110
110
  tago (~> 0.0)
111
- rdoc (7.0.3)
111
+ rdoc (7.1.0)
112
112
  erb
113
113
  psych (>= 4.0.0)
114
114
  tsort
@@ -125,9 +125,9 @@ GEM
125
125
  rubocop-ast (>= 1.48.0, < 2.0)
126
126
  ruby-progressbar (~> 1.7)
127
127
  unicode-display_width (>= 2.4.0, < 4.0)
128
- rubocop-ast (1.48.0)
128
+ rubocop-ast (1.49.0)
129
129
  parser (>= 3.3.7.2)
130
- prism (~> 1.4)
130
+ prism (~> 1.7)
131
131
  rubocop-minitest (0.38.2)
132
132
  lint_roller (~> 1.1)
133
133
  rubocop (>= 1.75.0, < 2.0)
@@ -153,11 +153,11 @@ GEM
153
153
  sys-uname (1.4.1)
154
154
  ffi (~> 1.1)
155
155
  memoist3 (~> 1.0.0)
156
- tago (0.3.0)
156
+ tago (0.6.0)
157
157
  tsort (0.2.0)
158
158
  unicode-display_width (3.2.0)
159
159
  unicode-emoji (~> 4.1)
160
- unicode-emoji (4.1.0)
160
+ unicode-emoji (4.2.0)
161
161
  w3c_validators (1.3.7)
162
162
  json (>= 1.8)
163
163
  nokogiri (~> 1.6)
data/lib/qbash.rb CHANGED
@@ -67,6 +67,14 @@ module Kernel
67
67
  # # Process will be terminated when block exits
68
68
  # end
69
69
  #
70
+ # == Changing Working Directory
71
+ #
72
+ # # Execute command in a specific directory
73
+ # files = qbash('ls -la', chdir: '/tmp')
74
+ #
75
+ # # Useful for commands that operate on the current directory
76
+ # qbash('git status', chdir: '/path/to/repo')
77
+ #
70
78
  # For command with multiple arguments, you can use +Shellwords.escape()+ to
71
79
  # properly escape each argument. Stderr automatically merges with stdout.
72
80
  #
@@ -80,8 +88,10 @@ module Kernel
80
88
  # @param [Array] accept List of accepted exit codes (accepts all if the list is +nil+)
81
89
  # @param [Boolean] both If set to TRUE, the function returns an array +(stdout, code)+
82
90
  # @param [Integer] level Logging level (use +Logger::DEBUG+, +Logger::INFO+, +Logger::WARN+, or +Logger::ERROR+)
91
+ # @param [String] chdir Directory to change to before running the command (or +nil+ to use current directory)
83
92
  # @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)
93
+ def qbash(*cmd, opts: [], stdin: '', env: {}, log: Loog::NULL, accept: [0], both: false, level: Logger::DEBUG,
94
+ chdir: nil)
85
95
  env.each { |k, v| raise "env[#{k}] is nil" if v.nil? }
86
96
  cmd = cmd.reject { |a| a.nil? || (a.is_a?(String) && a.empty?) }.join(' ')
87
97
  logit =
@@ -112,7 +122,8 @@ module Kernel
112
122
  e = 1
113
123
  start = Time.now
114
124
  bash = ['/bin/bash'] + opts + ['-c', cmd]
115
- Open3.popen2e(env, *bash) do |sin, sout, ctrl|
125
+ popen = chdir.nil? ? [env, *bash] : [env, *bash, { chdir: }]
126
+ Open3.popen2e(*popen) do |sin, sout, ctrl|
116
127
  pid = ctrl.pid
117
128
  logit["+ #{cmd} /##{pid}"]
118
129
  consume =
data/qbash.gemspec CHANGED
@@ -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.5.0'
12
+ s.version = '0.6.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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko