hiiro 0.1.15 → 0.1.16

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/h-link +20 -1
  3. data/lib/hiiro/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1976453cdeb8c87f0abb85e7fc0061f7809ea40dfd23f5737838c9ef2352128d
4
- data.tar.gz: 98521457732fceb0b2b33d816c5f53ecceac9f250a235e5c16d8d43f780466f7
3
+ metadata.gz: 79ae7c6943bffba4ffb21c734c699946ec9ee43eb247e8dc1e77532f9fe8b506
4
+ data.tar.gz: 18b3196492b5f9838dabd1cb8085d3184b2798aac27799f28ae114a497025284
5
5
  SHA512:
6
- metadata.gz: 97f152f96b8a4af4f0b956f21dd5a6d9232f5bf3f3aa3093cdaef897914b9379b9e5e754a87cb1a274ab27ecc7bd6cd2a03843b547ffc6a96ea6acaffbfbff35
7
- data.tar.gz: 6668446ba8ec596bd7ad163d7519ab90181c1af5632b335090b79bc438787153b43ebbf419324890c6e9caa6bdedc0e63cbddc59b687ef829f61605d9e79054f
6
+ metadata.gz: ce091b64e298217a27dcd291906e0cd9284ada1ab9654d257632d062c575af95466d06f874328e0f02cce4db17e4d096ab3663763c170952d4d7fe29c3b96ad7
7
+ data.tar.gz: dcc6e3a169b876aaf9f16e6cb7173eda73a71700869bd13e683be87d5f7b6fd56608868f79cff5cb377f448d5334122e947cf232d1321923ad68e669641820fb
data/bin/h-link CHANGED
@@ -39,9 +39,15 @@ def hash_matches?(links, *args)
39
39
  end
40
40
  end
41
41
 
42
- def link_matches?(link, *args)
42
+ def search_links(links, *args)
43
43
  terms = args.map(&:downcase)
44
44
 
45
+ links.select do |link|
46
+ link_matches?(link, *terms)
47
+ end
48
+ end
49
+
50
+ def link_matches?(link, *terms)
45
51
  searchable = [
46
52
  link['url'],
47
53
  link['description'],
@@ -234,6 +240,8 @@ o.add_subcmd(:open) do |*args|
234
240
  if args.empty?
235
241
  lines = load_link_hash(links)
236
242
 
243
+ exit_code = 1
244
+
237
245
  if args.any?
238
246
  lines = hash_matches?(lines, *args)
239
247
  end
@@ -244,12 +252,23 @@ o.add_subcmd(:open) do |*args|
244
252
  if status.success? && !selected.strip.empty?
245
253
  if selected =~ /^\s*(\d+)\.\s+(\S+)/
246
254
  system('open', $2)
255
+ exit_code = 0
247
256
  end
248
257
  end
258
+
259
+ exit exit_code
249
260
  end
250
261
 
251
262
  idx, link = find_link_by_ref(args.first, links)
252
263
 
264
+ if link.nil?
265
+ matches = search_links(links, *args)
266
+
267
+ if matches.count == 1
268
+ link = matches.first
269
+ end
270
+ end
271
+
253
272
  if link.nil?
254
273
  puts "Link not found: #{args.first}"
255
274
  exit 1
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota