bunchcli 1.1.4 → 1.1.10.pre
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/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/lib/bunch.rb +3 -0
- data/lib/bunch/bunchCLI.rb +24 -14
- data/lib/bunch/url_generator.rb +16 -7
- data/lib/bunch/version.rb +1 -1
- metadata +5 -6
- data/Gemfile.lock +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcda55808cd36cb2a58d47e7d6e0c0fa10772305ab8334bbd40d7f08f38949ae
|
4
|
+
data.tar.gz: 867e15277ae14bb607337e3bcba90192359bc89747450ec2abd526e441fd825f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e69c1cbb174fc1422a6480c96a016067fda4f44fb36a8a711cd3903423ee9b7a441deacd2995ff92f8fbc945c3a3b0dfd0c35e92944cb9bb4eea3713c0bb71
|
7
|
+
data.tar.gz: a7a76acbe1021ca87bad1fad48c8c06b70095d9db73b2c8368ffe157e49eff9ffc828185fa6c0b750f98fb37face66237df24f57b4ea7f79855e5cf43f8d6613
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/bunch.rb
CHANGED
data/lib/bunch/bunchCLI.rb
CHANGED
@@ -69,10 +69,11 @@ class Bunch
|
|
69
69
|
# items.push({title: 0})
|
70
70
|
def generate_bunch_list
|
71
71
|
items = []
|
72
|
-
|
72
|
+
`osascript -e 'tell app "#{TARGET_APP}" to list bunches'`.strip.split(/,/).each do |b|
|
73
|
+
b.strip!
|
73
74
|
items.push(
|
74
|
-
path:
|
75
|
-
title:
|
75
|
+
path: File.join(bunch_dir, b + '.bunch'),
|
76
|
+
title: b
|
76
77
|
)
|
77
78
|
end
|
78
79
|
items
|
@@ -80,13 +81,15 @@ class Bunch
|
|
80
81
|
|
81
82
|
def bunch_dir
|
82
83
|
@bunch_dir ||= begin
|
83
|
-
dir =
|
84
|
+
dir = `osascript -e 'tell app "#{TARGET_APP}" to get preference "Folder"'`.strip
|
85
|
+
# dir = `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist configDir`.strip
|
84
86
|
File.expand_path(dir)
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
90
|
def url_method
|
89
|
-
@url_method ||=
|
91
|
+
@url_method ||= `osascript -e 'tell app "#{TARGET_APP}" to get preference "Toggle"'`.strip == '1' ? 'toggle' : 'open'
|
92
|
+
# @url_method ||= `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist toggleBunches`.strip == '1' ? 'toggle' : 'open'
|
90
93
|
end
|
91
94
|
|
92
95
|
def bunches
|
@@ -96,15 +99,15 @@ class Bunch
|
|
96
99
|
def url(bunch)
|
97
100
|
params = "&x-success=#{@success}" if @success
|
98
101
|
if url_method == 'file'
|
99
|
-
%(
|
102
|
+
%(#{TARGET_URL}://raw?file=#{bunch}#{params})
|
100
103
|
elsif url_method == 'raw'
|
101
|
-
%(
|
104
|
+
%(#{TARGET_URL}://raw?txt=#{bunch}#{params})
|
102
105
|
elsif url_method == 'snippet'
|
103
|
-
%(
|
106
|
+
%(#{TARGET_URL}://snippet?file=#{bunch}#{params})
|
104
107
|
elsif url_method == 'setPref'
|
105
|
-
%(
|
108
|
+
%(#{TARGET_URL}://setPref?#{bunch})
|
106
109
|
else
|
107
|
-
%(
|
110
|
+
%(#{TARGET_URL}://#{url_method}?bunch=#{bunch}#{params})
|
108
111
|
end
|
109
112
|
end
|
110
113
|
|
@@ -187,25 +190,32 @@ EOF
|
|
187
190
|
end
|
188
191
|
else
|
189
192
|
bunch = find_bunch(str)
|
193
|
+
params = []
|
194
|
+
params << "fragment=#{CGI.escape(@fragment)}" if @fragment
|
195
|
+
params.concat(variable_query) if @variables
|
190
196
|
unless bunch
|
191
197
|
if File.exists?(str)
|
192
198
|
@url_method = 'file'
|
199
|
+
_url = url(str)
|
200
|
+
_url += '&' + params.join('&') if params.length
|
193
201
|
if @show_url
|
194
|
-
$stdout.puts
|
202
|
+
$stdout.puts _url
|
195
203
|
else
|
196
204
|
warn "Opening file"
|
197
|
-
`open '#{
|
205
|
+
`open '#{_url}'`
|
198
206
|
end
|
199
207
|
else
|
200
208
|
warn 'No matching Bunch found'
|
201
209
|
Process.exit 1
|
202
210
|
end
|
203
211
|
else
|
212
|
+
_url = url(bunch[:title])
|
213
|
+
_url += '&' + params.join('&') if params.length
|
204
214
|
if @show_url
|
205
|
-
$stdout.puts
|
215
|
+
$stdout.puts _url
|
206
216
|
else
|
207
217
|
warn "#{human_action} #{bunch[:title]}"
|
208
|
-
`open '#{
|
218
|
+
`open '#{_url}'`
|
209
219
|
end
|
210
220
|
end
|
211
221
|
end
|
data/lib/bunch/url_generator.rb
CHANGED
@@ -158,7 +158,7 @@ class BunchFinder
|
|
158
158
|
attr_accessor :config_dir
|
159
159
|
|
160
160
|
def initialize
|
161
|
-
config_dir = `
|
161
|
+
config_dir = `osascript -e 'tell app "#{TARGET_APP}" to get preference "Folder"'`.strip
|
162
162
|
config_dir = File.expand_path(config_dir)
|
163
163
|
if File.directory?(config_dir)
|
164
164
|
@config_dir = config_dir
|
@@ -167,6 +167,15 @@ class BunchFinder
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
+
def bunches_to_items
|
171
|
+
items = []
|
172
|
+
`osascript -e 'tell app "#{TARGET_APP}" to list bunches'`.strip.split(/,/).each do |b|
|
173
|
+
filename = b.strip
|
174
|
+
items << MenuItem.new(filename, filename, filename)
|
175
|
+
end
|
176
|
+
items
|
177
|
+
end
|
178
|
+
|
170
179
|
def files_to_items(dir, pattern)
|
171
180
|
Dir.chdir(dir)
|
172
181
|
items = []
|
@@ -180,12 +189,12 @@ class BunchFinder
|
|
180
189
|
end
|
181
190
|
|
182
191
|
def choose_bunch
|
183
|
-
items =
|
184
|
-
items.map! do |item|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
192
|
+
items = bunches_to_items
|
193
|
+
# items.map! do |item|
|
194
|
+
# item.title = File.basename(item.title, '.bunch')
|
195
|
+
# item.value = File.basename(item.title, '.bunch')
|
196
|
+
# item
|
197
|
+
# end
|
189
198
|
menu = Menu.new(items)
|
190
199
|
menu.choose('Select a Bunch')
|
191
200
|
end
|
data/lib/bunch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunchcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.10.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -21,7 +21,6 @@ files:
|
|
21
21
|
- ".gitignore"
|
22
22
|
- CHANGELOG.md
|
23
23
|
- Gemfile
|
24
|
-
- Gemfile.lock
|
25
24
|
- LICENSE.txt
|
26
25
|
- README.md
|
27
26
|
- Rakefile
|
@@ -49,11 +48,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
48
|
version: 2.0.0
|
50
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
|
-
- - "
|
51
|
+
- - ">"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
53
|
+
version: 1.3.1
|
55
54
|
requirements: []
|
56
|
-
rubygems_version: 3.
|
55
|
+
rubygems_version: 3.2.3
|
57
56
|
signing_key:
|
58
57
|
specification_version: 4
|
59
58
|
summary: A CLI for use with Bunch.app (macOS)
|
data/Gemfile.lock
DELETED