hiiro 0.1.325 → 0.1.327

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: a61e29cf5753cc2154058877c0d6a4a5c5abff6a09ba8933ba25011dcbc580f4
4
- data.tar.gz: ac848fa9c6d775348d4c52d6a015e14415029e115bc29db01c9f8134dcbdb4fc
3
+ metadata.gz: 5b59bf7d57b8661136281afe559d7fb3afd1e7fa090483f556074be405aa69a4
4
+ data.tar.gz: '08e9ff25437d1991c0f75007cabeb0bc993fb8e8a98225538fbd39b9e0baf71d'
5
5
  SHA512:
6
- metadata.gz: b3625f77565d8090239e7dc71d90b8b55f1f844e9020c3f180238410a3a17a443fc2481adf89875ab2b960f79e9f8223b8e6651a7af58ee21b1d3640c4d0ce5f
7
- data.tar.gz: 606b45991e1ecda0a01c634483d9064ae85e912c97e7386c793e7580bf92eaaf52387e00aa23ea330cd3b2af8e4d9843e7308ad299c64dc2af3dbf2c35a4fac7
6
+ metadata.gz: 2e4cc0a15c2216ebd6f4a3159b72b1a9cb9b2beda9fb47f0aede821c4024f8f95743838df19d0068edd5e0b1ec37001e5d4f68bbce4f3aa09fa15383376b9066
7
+ data.tar.gz: 103b722f78dbd84c6680ba171f3c60c69cf3848017b79ccb42a1e30f6eab10645cc1ace1e6edbec1280199dad00e1f55dc22f0e4f19f20990ff3723fcbe233fd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.327] - 2026-04-02
4
+
5
+ ### Added
6
+ - `h branch save --tag <tag>` (repeatable) — apply tags to branches during save operation
7
+
8
+ ## [0.1.326] - 2026-04-02
9
+
10
+ ### Changed
11
+ - Improve tag display formatting in link output by mapping individual tags to colored badges
12
+ - Refactor `h link tags` filtering logic to use `Hiiro::Tag` helpers for cleaner code
13
+ - Relocate `taggable` accessor method in `Hiiro::Tag` model
14
+
15
+ ### Added
16
+ - `Hiiro::Tag.tagged_by_type` helper method to query tagged objects by tag name and type
17
+
3
18
  ## [0.1.325] - 2026-04-02
4
19
 
5
20
  ### Fixed
data/bin/h-branch CHANGED
@@ -245,7 +245,17 @@ Hiiro.run(*ARGV) do
245
245
  }
246
246
 
247
247
  add_subcmd(:edit) { edit_files(__FILE__) }
248
- add_subcmd(:save) { |branch_name = nil| manager.save(branch_name) }
248
+ add_subcmd(:save) do |*save_args|
249
+ opts = Hiiro::Options.parse(save_args) { option(:tag, short: 't', desc: 'Tag to apply (repeatable)', multi: true) }
250
+ branch_name = opts.args.first
251
+ manager.save(branch_name)
252
+ tags = Array(opts.tag).reject(&:empty?)
253
+ if tags.any?
254
+ branch_name ||= git.branch
255
+ tag_store.add(branch_name, *tags)
256
+ puts "Tagged with: #{tags.join(', ')}"
257
+ end
258
+ end
249
259
 
250
260
  add_subcmd(:saved) do |*saved_args|
251
261
  data = manager.load_data
data/bin/h-link CHANGED
@@ -528,22 +528,11 @@ 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.tags_by_type('Link')
532
- filtered = all_known.select{|t|
533
- tag_args.any?{|ta| t.start_with?(ta) }
534
- }
535
-
536
- if filtered.empty?
537
- puts "No tags found."
538
- else
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
546
- end
531
+ Hiiro::Tag.search(tag_args, type: 'Link').each do |tag|
532
+ links = Hiiro::Tag.tagged_by_type(tag, 'Link')
533
+ puts "#{tag}:"
534
+ links.each { |link| puts " #{link.display_string(exclude_tags: [tag])}" }
535
+ end.empty? && puts("No tags found!")
547
536
  end
548
537
 
549
538
  add_subcmd(:paste) do |*paste_args|
data/bin/h-tags ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hiiro'
4
+
5
+ Hiiro.run do
6
+ add_subcmd(:tags_by_type) do |*args|
7
+ # use options to determine if we want a tag or the object?
8
+ tags = Hiiro::Tag.tags_by_type(args)
9
+ puts tags
10
+
11
+ tagged = tags.flat_map{|tag|
12
+ Hiiro::Tag.tagged_by_type(tag, args)
13
+ }
14
+ puts tagged
15
+ binding.pry
16
+ end
17
+ end
18
+
data/lib/hiiro/link.rb CHANGED
@@ -45,7 +45,7 @@ class Hiiro
45
45
  shorthand_str = shorthand ? " [#{shorthand}]" : ""
46
46
  desc_str = description.to_s.empty? ? "" : " - #{description}"
47
47
  link_tags = tags - Array(exclude_tags)
48
- tags_str = link_tags.any? ? " \e[30;104m#{link_tags.join(' ')}\e[0m" : ""
48
+ tags_str = link_tags.any? ? " " + link_tags.map { |t| "\e[30;104m#{t}\e[0m" }.join(' ') : ""
49
49
  "#{num}#{shorthand_str} #{url}#{desc_str}#{tags_str}".strip
50
50
  end
51
51
 
data/lib/hiiro/tags.rb CHANGED
@@ -4,64 +4,93 @@ class Hiiro
4
4
  class Tag < Sequel::Model(:tags)
5
5
  Hiiro::DB.register(self)
6
6
 
7
- def self.create_table!(db)
8
- db.create_table?(:tags) do
9
- primary_key :id
10
- String :name, null: false # tag value, e.g. "oncall"
11
- String :taggable_type, null: false # e.g. "Branch", "PinnedPr", "Task"
12
- String :taggable_id, null: false # string id of tagged object
13
- String :created_at
14
- unique [:name, :taggable_type, :taggable_id]
7
+ class << self
8
+ def create_table!(db)
9
+ db.create_table?(:tags) do
10
+ primary_key :id
11
+ String :name, null: false # tag value, e.g. "oncall"
12
+ String :taggable_type, null: false # e.g. "Branch", "PinnedPr", "Task"
13
+ String :taggable_id, null: false # string id of tagged object
14
+ String :created_at
15
+ unique [:name, :taggable_type, :taggable_id]
16
+ end
15
17
  end
16
- end
17
18
 
18
- # Polymorphic accessor — returns the tagged object
19
- def taggable
20
- klass = Hiiro.const_get(taggable_type) rescue nil
21
- klass&.[](taggable_id)
22
- end
19
+ def all_tags
20
+ select(:name).distinct
21
+ end
23
22
 
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
23
+ def filter(terms, tags=all_tags)
24
+ $stderr.puts("tags class: #{tags.class}")
25
+ $stderr.puts("terms count: #{terms.count}")
26
+ return tags if terms.empty?
28
27
 
29
- # Returns all Tag rows for a given object
30
- def self.for(obj)
31
- t = obj.class.name.split('::').last
32
- where(taggable_type: t, taggable_id: obj.id.to_s)
33
- end
28
+ conditions = terms.map{|q| Sequel.like(:name, "%#{q}%") }
29
+ tags.where(Sequel.|(*conditions)).all
34
30
 
35
- # Returns all Tag rows with a given name
36
- def self.named(tag_name)
37
- where(name: tag_name.to_s)
38
- end
31
+ # tags.select{|tag|
32
+ # terms.any?{|term| tag.start_with?(term) }
33
+ # }
34
+ end
39
35
 
40
- # Returns all tagged objects across all types for a tag name
41
- def self.everything_tagged(tag_name)
42
- named(tag_name).map(&:taggable).compact
43
- end
36
+ def search(*terms, type: nil)
37
+ filter(terms.flatten, tags_by_type(type))
38
+ end
39
+
40
+ # Returns all Tag rows for a given object
41
+ def tags_by_type(type=nil)
42
+ return all_tags if type.nil?
43
+
44
+ where(taggable_type: type).select(:name).distinct.map(&:name).sort
45
+ end
44
46
 
45
- # Idempotent tag assignment
46
- def self.tag!(obj, *tag_names)
47
- t = obj.class.name.split('::').last
48
- tag_names.each do |name|
49
- find_or_create(
50
- name: name.to_s,
47
+ # Returns all Tag rows for a given object
48
+ def for(obj)
49
+ t = obj.class.name.split('::').last
50
+ where(taggable_type: t, taggable_id: obj.id.to_s)
51
+ end
52
+
53
+ # Returns all Tag rows with a given name
54
+ def named(tag_name)
55
+ where(name: tag_name.to_s)
56
+ end
57
+
58
+ def tagged_by_type(tag, type)
59
+ where(name: tag, taggable_type: type).map(&:taggable)
60
+ end
61
+
62
+ # Returns all tagged objects across all types for a tag name
63
+ def everything_tagged(tag_name)
64
+ named(tag_name).map(&:taggable).compact
65
+ end
66
+
67
+ # Idempotent tag assignment
68
+ def tag!(obj, *tag_names)
69
+ t = obj.class.name.split('::').last
70
+ tag_names.each do |name|
71
+ find_or_create(
72
+ name: name.to_s,
73
+ taggable_type: t,
74
+ taggable_id: obj.id.to_s
75
+ ) { |tag| tag.created_at = Time.now.iso8601 }
76
+ end
77
+ end
78
+
79
+ # Remove tags from an object
80
+ def untag!(obj, *tag_names)
81
+ t = obj.class.name.split('::').last
82
+ where(
51
83
  taggable_type: t,
52
- taggable_id: obj.id.to_s
53
- ) { |tag| tag.created_at = Time.now.iso8601 }
84
+ taggable_id: obj.id.to_s,
85
+ name: tag_names.map(&:to_s)
86
+ ).delete
54
87
  end
55
88
  end
56
89
 
57
- # Remove tags from an object
58
- def self.untag!(obj, *tag_names)
59
- t = obj.class.name.split('::').last
60
- where(
61
- taggable_type: t,
62
- taggable_id: obj.id.to_s,
63
- name: tag_names.map(&:to_s)
64
- ).delete
90
+ # Polymorphic accessor returns the tagged object
91
+ def taggable
92
+ klass = Hiiro.const_get(taggable_type) rescue nil
93
+ klass&.[](taggable_id)
65
94
  end
66
95
  end
67
96
 
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.325"
2
+ VERSION = "0.1.327"
3
3
  end
data/script/diffhome CHANGED
@@ -2,5 +2,7 @@
2
2
 
3
3
  diff_bin = File.join(__dir__, 'diff')
4
4
 
5
+ puts(diff_bin:,ARGV:)
6
+
5
7
  system(diff_bin, *ARGV)
6
8
 
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.325
4
+ version: 0.1.327
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -151,6 +151,7 @@ files:
151
151
  - bin/h-session
152
152
  - bin/h-sha
153
153
  - bin/h-sparse
154
+ - bin/h-tags
154
155
  - bin/h-title
155
156
  - bin/h-todo
156
157
  - bin/h-window