bunchcli 1.1.9.pre → 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/bin/bunch +0 -4
- data/lib/bunch.rb +3 -0
- data/lib/bunch/bunchCLI.rb +23 -23
- data/lib/bunch/url_generator.rb +16 -7
- data/lib/bunch/version.rb +1 -1
- 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: 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/bin/bunch
CHANGED
@@ -18,10 +18,6 @@ bunch = Bunch.new
|
|
18
18
|
optparse = OptionParser.new do |opts|
|
19
19
|
opts.banner = "CLI for Bunch.app v#{BunchCLI::VERSION}"
|
20
20
|
|
21
|
-
opts.on('-b', '--beta', 'Use Bunch Beta for commands') do |_opt|
|
22
|
-
bunch.target_app = 'Bunch Beta'
|
23
|
-
end
|
24
|
-
|
25
21
|
opts.on('-l', '--list', 'List available Bunches') do |_opt|
|
26
22
|
bunch.list_bunches
|
27
23
|
Process.exit 0
|
data/lib/bunch.rb
CHANGED
data/lib/bunch/bunchCLI.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
class Bunch
|
2
2
|
include Util
|
3
|
-
attr_writer :
|
3
|
+
attr_writer :url_method, :fragment, :variables, :show_url
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@target_app = nil
|
7
6
|
@bunch_dir = nil
|
8
7
|
@url_method = nil
|
9
8
|
@bunches = nil
|
@@ -26,13 +25,11 @@ class Bunch
|
|
26
25
|
@bunch_dir = nil
|
27
26
|
@url_method = nil
|
28
27
|
@bunches = nil
|
29
|
-
@target_app = nil
|
30
28
|
target = File.expand_path(CACHE_FILE)
|
31
29
|
settings = {
|
32
30
|
'bunchDir' => bunch_dir,
|
33
31
|
'method' => url_method,
|
34
32
|
'bunches' => bunches,
|
35
|
-
'target_app' => target_app,
|
36
33
|
'updated' => Time.now.strftime('%s').to_i
|
37
34
|
}
|
38
35
|
File.open(target,'w') do |f|
|
@@ -55,7 +52,6 @@ class Bunch
|
|
55
52
|
@bunch_dir = settings['bunchDir'] || bunch_dir
|
56
53
|
@url_method = settings['method'] || url_method
|
57
54
|
@bunches = settings['bunches'] || generate_bunch_list
|
58
|
-
@target_app = settings['target_app'] || target_app
|
59
55
|
end
|
60
56
|
|
61
57
|
def variable_query
|
@@ -73,10 +69,11 @@ class Bunch
|
|
73
69
|
# items.push({title: 0})
|
74
70
|
def generate_bunch_list
|
75
71
|
items = []
|
76
|
-
|
72
|
+
`osascript -e 'tell app "#{TARGET_APP}" to list bunches'`.strip.split(/,/).each do |b|
|
73
|
+
b.strip!
|
77
74
|
items.push(
|
78
|
-
path:
|
79
|
-
title:
|
75
|
+
path: File.join(bunch_dir, b + '.bunch'),
|
76
|
+
title: b
|
80
77
|
)
|
81
78
|
end
|
82
79
|
items
|
@@ -84,18 +81,14 @@ class Bunch
|
|
84
81
|
|
85
82
|
def bunch_dir
|
86
83
|
@bunch_dir ||= begin
|
87
|
-
dir = `osascript -e 'tell app "#{
|
84
|
+
dir = `osascript -e 'tell app "#{TARGET_APP}" to get preference "Folder"'`.strip
|
88
85
|
# dir = `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist configDir`.strip
|
89
86
|
File.expand_path(dir)
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
93
|
-
def target_app
|
94
|
-
@target_app ||= "Bunch"
|
95
|
-
end
|
96
|
-
|
97
90
|
def url_method
|
98
|
-
@url_method ||= `osascript -e 'tell app "#{
|
91
|
+
@url_method ||= `osascript -e 'tell app "#{TARGET_APP}" to get preference "Toggle"'`.strip == '1' ? 'toggle' : 'open'
|
99
92
|
# @url_method ||= `/usr/bin/defaults read #{ENV['HOME']}/Library/Preferences/com.brettterpstra.Bunch.plist toggleBunches`.strip == '1' ? 'toggle' : 'open'
|
100
93
|
end
|
101
94
|
|
@@ -106,15 +99,15 @@ class Bunch
|
|
106
99
|
def url(bunch)
|
107
100
|
params = "&x-success=#{@success}" if @success
|
108
101
|
if url_method == 'file'
|
109
|
-
%(
|
102
|
+
%(#{TARGET_URL}://raw?file=#{bunch}#{params})
|
110
103
|
elsif url_method == 'raw'
|
111
|
-
%(
|
104
|
+
%(#{TARGET_URL}://raw?txt=#{bunch}#{params})
|
112
105
|
elsif url_method == 'snippet'
|
113
|
-
%(
|
106
|
+
%(#{TARGET_URL}://snippet?file=#{bunch}#{params})
|
114
107
|
elsif url_method == 'setPref'
|
115
|
-
%(
|
108
|
+
%(#{TARGET_URL}://setPref?#{bunch})
|
116
109
|
else
|
117
|
-
%(
|
110
|
+
%(#{TARGET_URL}://#{url_method}?bunch=#{bunch}#{params})
|
118
111
|
end
|
119
112
|
end
|
120
113
|
|
@@ -197,25 +190,32 @@ EOF
|
|
197
190
|
end
|
198
191
|
else
|
199
192
|
bunch = find_bunch(str)
|
193
|
+
params = []
|
194
|
+
params << "fragment=#{CGI.escape(@fragment)}" if @fragment
|
195
|
+
params.concat(variable_query) if @variables
|
200
196
|
unless bunch
|
201
197
|
if File.exists?(str)
|
202
198
|
@url_method = 'file'
|
199
|
+
_url = url(str)
|
200
|
+
_url += '&' + params.join('&') if params.length
|
203
201
|
if @show_url
|
204
|
-
$stdout.puts
|
202
|
+
$stdout.puts _url
|
205
203
|
else
|
206
204
|
warn "Opening file"
|
207
|
-
`open '#{
|
205
|
+
`open '#{_url}'`
|
208
206
|
end
|
209
207
|
else
|
210
208
|
warn 'No matching Bunch found'
|
211
209
|
Process.exit 1
|
212
210
|
end
|
213
211
|
else
|
212
|
+
_url = url(bunch[:title])
|
213
|
+
_url += '&' + params.join('&') if params.length
|
214
214
|
if @show_url
|
215
|
-
$stdout.puts
|
215
|
+
$stdout.puts _url
|
216
216
|
else
|
217
217
|
warn "#{human_action} #{bunch[:title]}"
|
218
|
-
`open '#{
|
218
|
+
`open '#{_url}'`
|
219
219
|
end
|
220
220
|
end
|
221
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-04-
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|