hiiro 0.1.13 → 0.1.15
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/h-link +70 -8
- data/lib/hiiro/version.rb +1 -1
- data/links.backup.yml +13 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1976453cdeb8c87f0abb85e7fc0061f7809ea40dfd23f5737838c9ef2352128d
|
|
4
|
+
data.tar.gz: 98521457732fceb0b2b33d816c5f53ecceac9f250a235e5c16d8d43f780466f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97f152f96b8a4af4f0b956f21dd5a6d9232f5bf3f3aa3093cdaef897914b9379b9e5e754a87cb1a274ab27ecc7bd6cd2a03843b547ffc6a96ea6acaffbfbff35
|
|
7
|
+
data.tar.gz: 6668446ba8ec596bd7ad163d7519ab90181c1af5632b335090b79bc438787153b43ebbf419324890c6e9caa6bdedc0e63cbddc59b687ef829f61605d9e79054f
|
data/bin/h-link
CHANGED
|
@@ -25,6 +25,42 @@ def ensure_links_file
|
|
|
25
25
|
File.write(LINKS_FILE, [].to_yaml) unless File.exist?(LINKS_FILE)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def hash_matches?(links, *args)
|
|
29
|
+
terms = args.map(&:downcase)
|
|
30
|
+
|
|
31
|
+
links.select do |line, link|
|
|
32
|
+
searchable = [
|
|
33
|
+
link['url'],
|
|
34
|
+
link['description'],
|
|
35
|
+
link['shorthand']
|
|
36
|
+
].compact.join(' ').downcase
|
|
37
|
+
|
|
38
|
+
terms.all? { |term| searchable.include?(term) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def link_matches?(link, *args)
|
|
43
|
+
terms = args.map(&:downcase)
|
|
44
|
+
|
|
45
|
+
searchable = [
|
|
46
|
+
link['url'],
|
|
47
|
+
link['description'],
|
|
48
|
+
link['shorthand']
|
|
49
|
+
].compact.join(' ').downcase
|
|
50
|
+
|
|
51
|
+
terms.all? { |term| searchable.include?(term) }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def load_link_hash(links=nil)
|
|
55
|
+
links ||= load_links
|
|
56
|
+
|
|
57
|
+
links.each_with_index.each_with_object({}) do |(link, idx), h|
|
|
58
|
+
num = (idx + 1).to_s.rjust(3)
|
|
59
|
+
desc = link['description'].to_s.empty? ? "" : " - #{link['description']}"
|
|
60
|
+
h["#{num}. #{link['url']}#{desc}"] = link
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
28
64
|
def load_links
|
|
29
65
|
ensure_links_file
|
|
30
66
|
YAML.load_file(LINKS_FILE) || []
|
|
@@ -136,19 +172,20 @@ end
|
|
|
136
172
|
|
|
137
173
|
o.add_subcmd(:select) do |*args|
|
|
138
174
|
links = load_links
|
|
175
|
+
|
|
139
176
|
if links.empty?
|
|
140
177
|
STDERR.puts "No links saved."
|
|
141
178
|
exit 1
|
|
142
179
|
end
|
|
143
180
|
|
|
144
|
-
lines = links
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
181
|
+
lines = load_link_hash(links)
|
|
182
|
+
|
|
183
|
+
if args.any?
|
|
184
|
+
lines = hash_matches?(lines, *args)
|
|
148
185
|
end
|
|
149
186
|
|
|
150
187
|
require 'open3'
|
|
151
|
-
selected, status = Open3.capture2('sk', stdin_data: lines.join("\n"))
|
|
188
|
+
selected, status = Open3.capture2('sk', stdin_data: lines.keys.join("\n"))
|
|
152
189
|
|
|
153
190
|
if status.success? && !selected.strip.empty?
|
|
154
191
|
if selected =~ /^\s*(\d+)\.\s+(\S+)/
|
|
@@ -157,6 +194,18 @@ o.add_subcmd(:select) do |*args|
|
|
|
157
194
|
end
|
|
158
195
|
end
|
|
159
196
|
|
|
197
|
+
o.add_subcmd(:editall) do |*args|
|
|
198
|
+
links_before = load_links
|
|
199
|
+
system(ENV['EDITOR'] || 'vim', LINKS_FILE)
|
|
200
|
+
|
|
201
|
+
begin
|
|
202
|
+
links_after = load_links
|
|
203
|
+
rescue => e
|
|
204
|
+
puts "ERROR: Unable to read updated file...reverting."
|
|
205
|
+
save_links(links_before)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
160
209
|
o.add_subcmd(:edit) do |*args|
|
|
161
210
|
if args.empty?
|
|
162
211
|
puts "Usage: h link edit <number|shorthand>"
|
|
@@ -180,12 +229,25 @@ o.add_subcmd(:edit) do |*args|
|
|
|
180
229
|
end
|
|
181
230
|
|
|
182
231
|
o.add_subcmd(:open) do |*args|
|
|
232
|
+
links = load_links
|
|
233
|
+
|
|
183
234
|
if args.empty?
|
|
184
|
-
|
|
185
|
-
|
|
235
|
+
lines = load_link_hash(links)
|
|
236
|
+
|
|
237
|
+
if args.any?
|
|
238
|
+
lines = hash_matches?(lines, *args)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
require 'open3'
|
|
242
|
+
selected, status = Open3.capture2('sk', stdin_data: lines.keys.join("\n"))
|
|
243
|
+
|
|
244
|
+
if status.success? && !selected.strip.empty?
|
|
245
|
+
if selected =~ /^\s*(\d+)\.\s+(\S+)/
|
|
246
|
+
system('open', $2)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
186
249
|
end
|
|
187
250
|
|
|
188
|
-
links = load_links
|
|
189
251
|
idx, link = find_link_by_ref(args.first, links)
|
|
190
252
|
|
|
191
253
|
if link.nil?
|
data/lib/hiiro/version.rb
CHANGED
data/links.backup.yml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
- url: http://auth.unixsuperhero.com:9969
|
|
3
|
+
description: stash
|
|
4
|
+
shorthand: fap
|
|
5
|
+
created_at: '2026-01-27T00:58:36-05:00'
|
|
6
|
+
- url: http://auth.unixsuperhero.com:8012
|
|
7
|
+
description: utorrent
|
|
8
|
+
shorthand: utor
|
|
9
|
+
created_at: '2026-01-27T22:10:55-05:00'
|
|
10
|
+
- url: http://auth.unixsuperhero.com:3005
|
|
11
|
+
description: sandbox nas
|
|
12
|
+
shorthand: sandbox
|
|
13
|
+
created_at: '2026-01-27T22:12:16-05:00'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hiiro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
@@ -62,6 +62,7 @@ files:
|
|
|
62
62
|
- hiiro.gemspec
|
|
63
63
|
- lib/hiiro.rb
|
|
64
64
|
- lib/hiiro/version.rb
|
|
65
|
+
- links.backup.yml
|
|
65
66
|
- plugins/notify.rb
|
|
66
67
|
- plugins/pins.rb
|
|
67
68
|
- plugins/project.rb
|