hiiro 0.1.320 → 0.1.322

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: ac5dd6b23a9eb04c9cb6594be7dd68811fd4852b59939505e14e74d8b1f50baf
4
- data.tar.gz: fa1d62dee0b0dcaaa845c2f1814de85f0bd5ddd69506267e2b8407384a045ec0
3
+ metadata.gz: e9afb3fb676cd088cb19aeeaa944954a58fa3b10de8b9bbcd5e320ddcba8ee51
4
+ data.tar.gz: 1566f46fdbb10c362ecd8a6b7418350720c432d5822b9682464dc6336f73eb98
5
5
  SHA512:
6
- metadata.gz: 38db0092aeed1d9fe80b6ef6d5750bbe88a1c1ea9296b2c4ad6d3434b43a4770b6e9708dba9177d9defeed239a4b524425aceb6636ba186c3aea80761ad042ee
7
- data.tar.gz: 86ba0fd4e1e23f04adaa0dfce69400baac5adc05f1121c7910e9b872c67190bd8eea68e95da0470d5dd4a04d7695171660cb3ea24a20bfdd04e20cbad472f5d6
6
+ metadata.gz: 84565259d3a19aae0295a8fa8d5adca7b28d5d834962a39a8d9965eb99ec5130d9e7c4a24bb44b1965e915f0c8bed9f56b9639c0370611f546849e55f431dcf7
7
+ data.tar.gz: fc8c1f1d6ea48a3399d3a7a1187800b96982b2aff2918753f31dd2fcc2aa2c4ea64395cf4cae3467b7cd5d554fa9e9e75b29ec23e268a850c0f147f89b93b7b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.322] - 2026-04-01
4
+
5
+ ### Changed
6
+ - Refactor `h link tags` filtering logic to use new `Hiiro::Tag.tags_by_type` helper
7
+ - Simplify tag query to use `Hiiro::Link.where(id:)` instead of manual filtering
8
+ - Extract `tags_by_type(type)` singleton method to `Hiiro::Tag` for code reuse
9
+
10
+ ## [0.1.321] - 2026-04-01
11
+
12
+ ### Changed
13
+ - Extract `open_config` to `Hiiro::Config.open` singleton method; simplify parameter order from `dir:, file:` to positional `file, dir: nil`
14
+ - Update all config subcommands to use new `Hiiro::Config.open` interface
15
+
3
16
  ## [0.1.320] - 2026-04-01
4
17
 
5
18
  ### Changed
data/bin/h-config CHANGED
@@ -6,43 +6,43 @@ Hiiro.run(*ARGV) {
6
6
  add_subcmd(:vim) {
7
7
  dir = '~/.config/nvim'
8
8
  file = File.exist?(File.expand_path('~/.config/nvim/init.lua')) ? 'init.lua' : 'init.vim'
9
- open_config(dir: dir, file: file)
9
+ open_config(file, dir: dir)
10
10
  }
11
11
 
12
12
  add_subcmd(:git) {
13
13
  make_child(subcmd, *args) {
14
14
  add_subcmd(:global) {
15
- open_config(dir: '~', file: '.gitconfig')
15
+ open_config('.gitconfig', dir: '~')
16
16
  }
17
17
 
18
18
  add_subcmd(:ignore) {
19
- open_config(dir: '~/.config/git', file: 'ignore')
19
+ open_config('ignore', dir: '~/.config/git')
20
20
  }
21
21
 
22
22
  add_subcmd(:local) {
23
23
  root = `git rev-parse --show-toplevel`.chomp
24
- open_config(dir: root, file: '.git/config')
24
+ open_config('.git/config', dir: root)
25
25
  }
26
26
  }.run
27
27
  }
28
28
 
29
29
  add_subcmd(:tmux) {
30
- open_config(dir: '~', file: '.tmux.conf')
30
+ open_config('.tmux.conf', dir: '~')
31
31
  }
32
32
 
33
33
  add_subcmd(:zsh) {
34
- open_config(dir: '~', file: '.zshrc')
34
+ open_config('.zshrc', dir: '~')
35
35
  }
36
36
 
37
37
  add_subcmd(:profile) {
38
- open_config(dir: '~', file: '.zprofile')
38
+ open_config('.zprofile', dir: '~')
39
39
  }
40
40
 
41
41
  add_subcmd(:starship) {
42
- open_config(dir: '~/.config/starship', file: 'starship.toml')
42
+ open_config('starship.toml', dir: '~/.config/starship')
43
43
  }
44
44
 
45
45
  add_subcmd(:claude) {
46
- open_config(dir: '~/.claude', file: 'settings.json')
46
+ open_config('settings.json', dir: '~/.claude')
47
47
  }
48
48
  }
data/bin/h-link CHANGED
@@ -528,35 +528,21 @@ Hiiro.run(*ARGV, plugins: [Pins], links_file: lm.links_file) do
528
528
  end
529
529
 
530
530
  add_subcmd(:tags) do |*tag_args|
531
- all_known = Hiiro::Tag.where(taggable_type: 'Link').distinct.pluck(:name).sort
531
+ all_known = Hiiro::Tag.tags_by_type('Link')
532
+ filtered = all_known.select{|t|
533
+ tag_args.any?{|ta| t.start_with?(ta) }
534
+ }
532
535
 
533
- if tag_args.empty?
534
- if all_known.empty?
535
- puts "No tags found."
536
- else
537
- all_known.each { |t| puts t }
538
- end
539
- next
540
- end
541
-
542
- # Prefix-match the given args against known tags
543
- matched_tags = tag_args.flat_map { |arg|
544
- all_known.select { |t| t.start_with?(arg) }
545
- }.uniq
546
-
547
- if matched_tags.empty?
548
- puts "No tags match: #{tag_args.join(', ')}"
549
- next
550
- end
551
-
552
- # Batch-load all link tags to avoid N+1
553
- tagged_ids = Hiiro::Tag.where(taggable_type: 'Link', name: matched_tags).map { |t| t.taggable_id.to_i }.uniq
554
- links = lm.load_links.select { |link| tagged_ids.include?(link.id) }
555
-
556
- if links.empty?
557
- puts "No links tagged with: #{matched_tags.join(', ')}"
536
+ if filtered.empty?
537
+ puts "No tags found."
558
538
  else
559
- links.each_with_index { |link, idx| puts link.display_string(idx) }
539
+ filtered.each do |tag_name|
540
+ ids = Hiiro::Tag.where(taggable_type: 'Link', name: tag_name).select(:taggable_id).map(&:taggable_id).map(&:to_i)
541
+ # links = lm.load_links.select |link| tagged_ids.include?(link.id) }
542
+ links = Hiiro::Link.where(id: ids)
543
+ puts "#{tag_name}:"
544
+ links.each { |link| puts " #{link.display_string(exclude_tags: [tag_name])}" }
545
+ end
560
546
  end
561
547
  end
562
548
 
data/lib/hiiro/config.rb CHANGED
@@ -4,6 +4,13 @@ class Hiiro
4
4
  DATA_DIR = File.join(Dir.home, '.local/share/hiiro')
5
5
 
6
6
  class << self
7
+ def open(file, dir: nil)
8
+ dir_path = File.expand_path(dir || '~')
9
+ full_path = File.expand_path(file, dir_path)
10
+ Dir.chdir(dir_path)
11
+ system(ENV['EDITOR'] || 'vim', full_path)
12
+ end
13
+
7
14
  def path(relpath='')
8
15
  File.join(BASE_DIR, relpath)
9
16
  end
data/lib/hiiro/link.rb CHANGED
@@ -40,11 +40,11 @@ class Hiiro
40
40
  terms.all? { |term| searchable.include?(term.downcase) }
41
41
  end
42
42
 
43
- def display_string(index = nil)
43
+ def display_string(index = nil, exclude_tags: [])
44
44
  num = index ? "#{(index + 1).to_s.rjust(3)}." : ""
45
45
  shorthand_str = shorthand ? " [#{shorthand}]" : ""
46
46
  desc_str = description.to_s.empty? ? "" : " - #{description}"
47
- link_tags = tags
47
+ link_tags = tags - Array(exclude_tags)
48
48
  tags_str = link_tags.any? ? " \e[30;104m#{link_tags.join(' ')}\e[0m" : ""
49
49
  "#{num}#{shorthand_str} #{url}#{desc_str}#{tags_str}".strip
50
50
  end
data/lib/hiiro/tags.rb CHANGED
@@ -21,6 +21,11 @@ class Hiiro
21
21
  klass&.[](taggable_id)
22
22
  end
23
23
 
24
+ # Returns all Tag rows for a given object
25
+ def self.tags_by_type(type)
26
+ where(taggable_type: type.to_s).select(:name).distinct.map(&:name).sort
27
+ end
28
+
24
29
  # Returns all Tag rows for a given object
25
30
  def self.for(obj)
26
31
  t = obj.class.name.split('::').last
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.320"
2
+ VERSION = "0.1.322"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -221,10 +221,8 @@ class Hiiro
221
221
  end
222
222
  end
223
223
 
224
- def open_config(dir:, file:)
225
- full_path = File.expand_path(File.join(dir, file))
226
- Dir.chdir(File.expand_path(dir))
227
- edit_files(full_path)
224
+ def open_config(file, dir: nil)
225
+ Hiiro::Config.open(file, dir: dir)
228
226
  end
229
227
 
230
228
  def tmux_client
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.320
4
+ version: 0.1.322
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota