tabry 0.3.1 → 0.3.3
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 +4 -4
- data/lib/tabry/cli/util.rb +18 -2
- data/lib/tabry/version.rb +1 -1
- data/spec/tabry/cli/util_spec.rb +29 -0
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3e6a33f8180c72aaeb7bc05dc671a3599fe47cbb594b547a86fa988f91595ec
|
4
|
+
data.tar.gz: ca03f2d583f237102407f9f54d8b6ce528237c5bb65b5bd626bbd45f2313695a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c59e00b875e65a54a8eda61d758a5b9fbbf61d004af730ce94425d2d0d139c92ed78715e08af380a3683e2a2782dd5b851b893ad7b952c7d654d3f9ce73fcd8
|
7
|
+
data.tar.gz: c121366c38418b07790858873673f7780b4b3de357c94ca9d988f88a665770f117a4e4ba0c761a8f6f11cd30fbea338c9e751fae47ef39e6a40d93189e81eff8
|
data/lib/tabry/cli/util.rb
CHANGED
@@ -8,6 +8,8 @@ module Tabry
|
|
8
8
|
module Util
|
9
9
|
module_function
|
10
10
|
|
11
|
+
SHELL_FOR_WINDOWS = ["bash", "-c"]
|
12
|
+
|
11
13
|
def make_cmdline(cmdline, *args, echo: false, echo_only: false, merge_stderr: false)
|
12
14
|
# Allow to pass in an array, or varargs:
|
13
15
|
args = args.first if args.length == 1 && args.first.is_a?(Array)
|
@@ -31,7 +33,15 @@ module Tabry
|
|
31
33
|
|
32
34
|
def system(*cmdline, **opts)
|
33
35
|
cmdline = make_cmdline(*cmdline, **opts)
|
34
|
-
|
36
|
+
return unless cmdline
|
37
|
+
|
38
|
+
require 'rubygems'
|
39
|
+
|
40
|
+
if Gem.win_platform?
|
41
|
+
Kernel.system *SHELL_FOR_WINDOWS, cmdline
|
42
|
+
else
|
43
|
+
Kernel.system cmdline
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
# TODO: would be nice to get separate STDERR and STDOUT
|
@@ -43,9 +53,15 @@ module Tabry
|
|
43
53
|
cmdline = make_cmdline(*cmdline, **opts)
|
44
54
|
return [nil, nil] unless cmdline
|
45
55
|
|
56
|
+
require 'rubygems'
|
57
|
+
|
46
58
|
enoent_error = false
|
47
59
|
begin
|
48
|
-
res =
|
60
|
+
res = if Gem.win_platform?
|
61
|
+
IO.popen([*SHELL_FOR_WINDOWS, cmdline]) { |io| io.read }
|
62
|
+
else
|
63
|
+
`#{cmdline}`
|
64
|
+
end
|
49
65
|
rescue Errno::ENOENT
|
50
66
|
enoent_error = true
|
51
67
|
end
|
data/lib/tabry/version.rb
CHANGED
data/spec/tabry/cli/util_spec.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative "../../../lib/tabry/cli/util"
|
4
4
|
|
5
|
+
require "tempfile"
|
6
|
+
|
5
7
|
describe Tabry::CLI::Util do
|
6
8
|
describe ".make_cmdline" do
|
7
9
|
it "escapes a single string" do
|
@@ -121,5 +123,32 @@ describe Tabry::CLI::Util do
|
|
121
123
|
)
|
122
124
|
end
|
123
125
|
end
|
126
|
+
|
127
|
+
describe "on windows" do
|
128
|
+
before { expect(Gem).to receive(:win_platform?).and_return(true) }
|
129
|
+
|
130
|
+
it "uses bash" do
|
131
|
+
output = described_class.backtick_or_die("echo $BASH_VERSION")
|
132
|
+
expect(output).to match(/^[0-9]/)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "system" do
|
138
|
+
it "calls Kernel.system with the escaped code" do
|
139
|
+
expect(Kernel).to receive(:system).with("echo \\' > /dev/null")
|
140
|
+
described_class.system("echo %s > /dev/null", "'")
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "on windows" do
|
144
|
+
before { expect(Gem).to receive(:win_platform?).and_return(true) }
|
145
|
+
|
146
|
+
it "uses bash" do
|
147
|
+
Tempfile.open do |f|
|
148
|
+
described_class.system("echo $BASH_VERSION > %s", f.path)
|
149
|
+
expect(File.read(f.path)).to match(/^[0-9]/)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
124
153
|
end
|
125
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Battaglia
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: pry-byebug
|
@@ -80,7 +79,6 @@ dependencies:
|
|
80
79
|
- - "~>"
|
81
80
|
- !ruby/object:Gem::Version
|
82
81
|
version: '0.12'
|
83
|
-
description:
|
84
82
|
email: battaglia.evan@gmail.com
|
85
83
|
executables:
|
86
84
|
- tabry-bash
|
@@ -250,7 +248,6 @@ licenses:
|
|
250
248
|
- MIT
|
251
249
|
metadata:
|
252
250
|
rubygems_mfa_required: 'true'
|
253
|
-
post_install_message:
|
254
251
|
rdoc_options: []
|
255
252
|
require_paths:
|
256
253
|
- lib
|
@@ -265,8 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
262
|
- !ruby/object:Gem::Version
|
266
263
|
version: '0'
|
267
264
|
requirements: []
|
268
|
-
rubygems_version: 3.
|
269
|
-
signing_key:
|
265
|
+
rubygems_version: 3.6.7
|
270
266
|
specification_version: 4
|
271
267
|
summary: Tab completion and CLIs extraordinaire
|
272
268
|
test_files: []
|