tabry 0.3.0 → 0.3.2

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: fb391cd439ebe097e13df65ff4a99f2911abd2d53b9c81e8283b8d5af94282b9
4
- data.tar.gz: ed3bc83d0f19fa9efee82a7cc6ec5cbd37fd34f602cb9915b78fbeeb0e0ddea9
3
+ metadata.gz: aae042ca4dc5192e4462e101ecc6f70ba6e55e428dc18791ba5735cb7d90f657
4
+ data.tar.gz: ea25d08f4cc73c799f7b2987937e6639a13976a5f65a663f30edacfd7633e533
5
5
  SHA512:
6
- metadata.gz: ee6f71b46c334b5c2a50ed46c9d6a2930d9b39d3d9dac42ed158ba5b1f94a3b850d485794169e1794f72d54333813b1f10b6d816a557c36d8830ec126524ff74
7
- data.tar.gz: fa871318216d9258fc5a9dcbe62ee9b7a9e52922cde2986a6d493025b721753b0b452b8f58ac5157925bfebcddee009289904c676a53ed6d00e2d6b6f4addf98
6
+ metadata.gz: bc7d1f309edf7c38a85cc4b46895bce5f30bf4e375777753170f970c87d17f772818cae0aea581544306c1b86fef87000b247dae2aef7587afda5d4fd163e953
7
+ data.tar.gz: a75c5a8d540a356b2d058b1c2e87aefc79139fd400cfac22965dbcf6d0acf21b908c9533d41d742570fec020065ec8bc7cbcd61a4a8381e260f12e9c117a0db8
@@ -11,6 +11,8 @@ require "json"
11
11
  # Config = Tabry::CLI::Util::Config.new('~/.mycli.yml')
12
12
  # end
13
13
 
14
+ # TODO: should probably now just remove this
15
+
14
16
  class Hash
15
17
  def to_openstruct
16
18
  JSON.parse to_json, object_class: OpenStruct
@@ -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,13 @@ module Tabry
31
33
 
32
34
  def system(*cmdline, **opts)
33
35
  cmdline = make_cmdline(*cmdline, **opts)
34
- Kernel.system cmdline if cmdline
36
+ return unless cmdline
37
+
38
+ if Gem.win_platform?
39
+ Kernel.system *SHELL_FOR_WINDOWS, cmdline
40
+ else
41
+ Kernel.system cmdline
42
+ end
35
43
  end
36
44
 
37
45
  # TODO: would be nice to get separate STDERR and STDOUT
@@ -45,7 +53,11 @@ module Tabry
45
53
 
46
54
  enoent_error = false
47
55
  begin
48
- res = `#{cmdline}`
56
+ res = if Gem.win_platform?
57
+ IO.popen([*SHELL_FOR_WINDOWS, cmdline]) { |io| io.read }
58
+ else
59
+ `#{cmdline}`
60
+ end
49
61
  rescue Errno::ENOENT
50
62
  enoent_error = true
51
63
  end
@@ -67,7 +79,7 @@ module Tabry
67
79
  end
68
80
 
69
81
  def open_web_page(url_or_urls)
70
- unless system("(%s %s 2>&1) >/dev/null", open_command, url_or_urls)
82
+ unless system("nohup %s %s 2>&1 >/dev/null &", open_command, url_or_urls)
71
83
  warn "WARNING: opening web page failed: #{make_cmdline("%s %s", open_command, url)}"
72
84
  end
73
85
  end
@@ -32,7 +32,7 @@ module Tabry
32
32
  raise ConfigError, "Unknown field(s) #{unknown_fields.inspect} for #{self.class}"
33
33
  end
34
34
 
35
- raw.each do |key, val|
35
+ raw.compact.each do |key, val|
36
36
  type, *extra = Array(self.class::FIELDS[key.to_sym])
37
37
  instance_variable_set :"@#{key}", send(:"init_field_#{type}", key, val, *extra)
38
38
  end
data/lib/tabry/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tabry
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
@@ -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
@@ -70,7 +72,7 @@ describe Tabry::CLI::Util do
70
72
  it 'uses "xdg-open" when on Linux' do
71
73
  stub_const("RUBY_PLATFORM", "x86_64-linux")
72
74
  expect(Kernel).to receive("system") do |cmdline|
73
- expect(cmdline).to include("(xdg-open ")
75
+ expect(cmdline).to include("nohup xdg-open ")
74
76
  end
75
77
  described_class.open_web_page("http://example.com")
76
78
  end
@@ -78,7 +80,7 @@ describe Tabry::CLI::Util do
78
80
  it 'uses "open" when on Darwin' do
79
81
  stub_const("RUBY_PLATFORM", "x86_64-darwin")
80
82
  expect(Kernel).to receive("system") do |cmdline|
81
- expect(cmdline).to include("(open ")
83
+ expect(cmdline).to include("nohup open ")
82
84
  end
83
85
  described_class.open_web_page("http://example.com")
84
86
  end
@@ -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
data/tabry.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = "battaglia.evan@gmail.com"
11
11
  s.homepage = "https://github.com/evanbattaglia/tabry"
12
12
  s.license = "MIT"
13
+ s.required_ruby_version = ">= 3.0"
13
14
 
14
15
  treesitter_files = %w[
15
16
  binding.gyp
data/treesitter/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ **WARNING** This is now DEPRECATED and may use VULNERABLE dependencies. Please use [tabry-rs](https://github.com/evanbattaglia/tabry-rs)
2
+
1
3
  This directory contains the compiler which compiles `*.tabry` files -- Tabry's
2
4
  mini-language for describing tab-completion/CLIs, into the JSON format used by
3
5
  the tabry gem. See the [main Tabry README](../README.md) for more info on
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Battaglia
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-28 00:00:00.000000000 Z
11
+ date: 2025-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.12'
83
- description:
83
+ description:
84
84
  email: battaglia.evan@gmail.com
85
85
  executables:
86
86
  - tabry-bash
@@ -250,7 +250,7 @@ licenses:
250
250
  - MIT
251
251
  metadata:
252
252
  rubygems_mfa_required: 'true'
253
- post_install_message:
253
+ post_install_message:
254
254
  rdoc_options: []
255
255
  require_paths:
256
256
  - lib
@@ -258,15 +258,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
258
  requirements:
259
259
  - - ">="
260
260
  - !ruby/object:Gem::Version
261
- version: '0'
261
+ version: '3.0'
262
262
  required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  requirements:
264
264
  - - ">="
265
265
  - !ruby/object:Gem::Version
266
266
  version: '0'
267
267
  requirements: []
268
- rubygems_version: 3.4.19
269
- signing_key:
268
+ rubygems_version: 3.5.22
269
+ signing_key:
270
270
  specification_version: 4
271
271
  summary: Tab completion and CLIs extraordinaire
272
272
  test_files: []