hiiro 0.1.321 → 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 +4 -4
- data/CHANGELOG.md +8 -1
- data/bin/h-link +13 -27
- data/lib/hiiro/link.rb +2 -2
- data/lib/hiiro/tags.rb +5 -0
- data/lib/hiiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9afb3fb676cd088cb19aeeaa944954a58fa3b10de8b9bbcd5e320ddcba8ee51
|
|
4
|
+
data.tar.gz: 1566f46fdbb10c362ecd8a6b7418350720c432d5822b9682464dc6336f73eb98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84565259d3a19aae0295a8fa8d5adca7b28d5d834962a39a8d9965eb99ec5130d9e7c4a24bb44b1965e915f0c8bed9f56b9639c0370611f546849e55f431dcf7
|
|
7
|
+
data.tar.gz: fc8c1f1d6ea48a3399d3a7a1187800b96982b2aff2918753f31dd2fcc2aa2c4ea64395cf4cae3467b7cd5d554fa9e9e75b29ec23e268a850c0f147f89b93b7b5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
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
|
+
|
|
3
10
|
## [0.1.321] - 2026-04-01
|
|
4
11
|
|
|
5
12
|
### Changed
|
|
@@ -271,4 +278,4 @@
|
|
|
271
278
|
## [0.1.295]
|
|
272
279
|
|
|
273
280
|
### Changed
|
|
274
|
-
- Filter logic changes for PR management
|
|
281
|
+
- Filter logic changes for PR management
|
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.
|
|
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
|
|
534
|
-
|
|
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
|
-
|
|
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/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