lux-hammer 0.3.30 → 0.8.4

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: 2ca175d7445c386d0c8bd3be6834b057e6b958ee3d0de48d72e49a53ef4da776
4
- data.tar.gz: 3303a15ee74702d81ebfba70d15366870bfb8dccc2d5b0fc8c5304e2fe28ef0e
3
+ metadata.gz: 62f3507ae302513e173b9c4ee719b1c27448d47ef4a8568f0be0e8e8485410c5
4
+ data.tar.gz: 92983a6f6e7c0dd96c75f0dd3abca3bab91808c4f2c10b93205aa426932d7405
5
5
  SHA512:
6
- metadata.gz: d925611cf831aa0e6c4198d4761bdcb04b7454afab82a8cc12100130e23dc63139f3bad8fbf0473cd67f7bf71ea46ef3ceeb91e266f6bddba51f4097469231dc
7
- data.tar.gz: a489e910f4027422474b1741a0ff45e4e5729009af2d5c6ba7fbf79a7f11661e547b9947058c6b5c237e41fbecfc5baa9a2a2686158a95460a0c2be7ba4bf329
6
+ metadata.gz: 1fd6204a4915f166d68bbb51fe33474ae44dff46e088486e939b0f7b887378a150548cb5fb646c25699381fcfeb79c97ed4028ee0149a1f8872daac38b755eee
7
+ data.tar.gz: c798f9716fe791388075077034486e817dca3025a9f042bf04d8ac472c2af8e1c67d36b4914c8c100ecf7fd253d830738ccca619ce2aabe7808130232c980571
data/.version CHANGED
@@ -1 +1 @@
1
- 0.3.30
1
+ 0.8.4
data/AGENTS.md CHANGED
@@ -15,8 +15,9 @@ usable as a library (`require 'lux-hammer'`, subclass `Hammer`, call
15
15
 
16
16
  * **One root constant**: `Hammer`. Never pollute `Object` or introduce
17
17
  another top-level constant. Sub-types live as `Hammer::Shell`,
18
- `Hammer::Option`, `Hammer::Parser`, `Hammer::Command`,
19
- `Hammer::Loader`, `Hammer::Builder`, `Hammer::CommandBuilder`. The one
18
+ `Hammer::Version`, `Hammer::Option`, `Hammer::Parser`,
19
+ `Hammer::Command`, `Hammer::Loader`, `Hammer::Builder`,
20
+ `Hammer::CommandBuilder`. The one
20
21
  exception is `String#color(:name)` (defined in `lib/hammer/shell.rb`)
21
22
  - a tiny convenience for `"hi".color(:cyan)`. Do not add more
22
23
  monkey-patches.
@@ -39,6 +40,7 @@ usable as a library (`require 'lux-hammer'`, subclass `Hammer`, call
39
40
  bin/hammer # CLI entry point
40
41
  lib/lux-hammer.rb # Entry - defines class Hammer and its DSL
41
42
  lib/hammer/shell.rb # ANSI/IO helpers
43
+ lib/hammer/version.rb # Hammer::Version - git-count version + .version fallback
42
44
  lib/hammer/option.rb # One option definition (types: string/boolean/integer/float/array/json)
43
45
  lib/hammer/input.rb # opts[:stdin], prepare_json!, JSON @file / pipe helpers
44
46
  lib/hammer/parser.rb # ARGV -> [positional, opts_hash]
@@ -58,6 +60,7 @@ test/parser_test.rb # ARGV parsing edge cases
58
60
  test/option_test.rb # Option declaration / casting
59
61
  test/command_test.rb # Command data type
60
62
  test/shell_test.rb # ANSI / IO helpers
63
+ test/version_test.rb # version formatting (git count -> dotted)
61
64
  test/cli_test.rb # `hammer` binary end-to-end
62
65
  test/cron_test.rb # schedule parser (matches?/due?/next_run)
63
66
  test/cron_server_test.rb # job discovery, state, rotation, web UI
@@ -422,6 +425,22 @@ new code in this gem should show.
422
425
  * Inside a handler, just call `error 'msg'` - it resolves via the
423
426
  `Shell` mixin.
424
427
 
428
+ ## Versioning
429
+
430
+ * `Hammer::VERSION` is the dboss-style formatted commit count on `main`
431
+ (falling back to `master`, then `HEAD`): `v82` -> `0.8.2`, `v1123` ->
432
+ `11.2.3`, left-padded so `v5` -> `0.0.5`. It is bare (no leading `v`)
433
+ so it stays a valid `Gem::Version`.
434
+ * `Hammer::Version.string` is that value, `Hammer::Version.raw` is the
435
+ `v<count>` behind it, and `Hammer::Version.format` is the pure
436
+ formatter (a non-`v<digits>` string is returned unchanged).
437
+ * A released gem has no `.git` and falls back to the committed
438
+ `.version` file. `hammer gem --inc` writes the git-count value into
439
+ `.version` (overwriting `.version.prev`), so the built gem's version
440
+ matches the checkout; the release workflow tags `v$(cat .version)`.
441
+ * Don't reintroduce manual major/minor/patch bumps - the count is the
442
+ version.
443
+
425
444
  ## Coding rules
426
445
 
427
446
  * No trailing spaces on empty lines. End every file with a newline.
@@ -0,0 +1,52 @@
1
+ class Hammer
2
+ # The running version, derived the way dboss derives its own: the number
3
+ # of commits reachable from main (or master, or HEAD) rendered as a dotted
4
+ # triple, so v82 -> 0.8.2 and v1123 -> 11.2.3. A released gem has no .git
5
+ # and falls back to the .version file baked in at build time, which is also
6
+ # what `hammer gem --inc` writes.
7
+ module Version
8
+ module_function
9
+
10
+ ROOT ||= File.expand_path('../..', __dir__)
11
+
12
+ # Dotted, no leading v, so it stays a valid Gem::Version (v1.2.3 -> 1.2.3).
13
+ def string
14
+ format(raw)
15
+ end
16
+
17
+ # v<commit count> in a git checkout, else the packaged .version string.
18
+ def raw
19
+ count = git_count
20
+ count ? "v#{count}" : file_version
21
+ end
22
+
23
+ # v123 -> 1.2.3, v1123 -> 11.2.3, v5 -> 0.0.5. Anything that is not
24
+ # v<digits> (dev, an already-dotted version) is returned unchanged.
25
+ def format(version)
26
+ text = version.to_s
27
+ count = text.start_with?('v') ? text[1..] : nil
28
+ return text unless count && !count.empty? && count.match?(/\A\d+\z/)
29
+
30
+ count = count.rjust(3, '0')
31
+ "#{count[0...-2]}.#{count[-2]}.#{count[-1]}"
32
+ end
33
+
34
+ def git_count
35
+ return nil unless File.exist?(File.join(ROOT, '.git'))
36
+
37
+ %w[main master HEAD].each do |ref|
38
+ out = IO.popen(['git', '-C', ROOT, 'rev-list', '--count', ref],
39
+ err: File::NULL, &:read).to_s.strip
40
+ return out.to_i if out.match?(/\A\d+\z/)
41
+ end
42
+ nil
43
+ rescue SystemCallError
44
+ nil
45
+ end
46
+
47
+ def file_version
48
+ path = File.join(ROOT, '.version')
49
+ File.exist?(path) ? File.read(path).strip : 'dev'
50
+ end
51
+ end
52
+ end
data/lib/lux-hammer.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require_relative 'hammer/shell'
2
+ require_relative 'hammer/version'
2
3
  require_relative 'hammer/input'
3
4
  require_relative 'hammer/option'
4
5
  require_relative 'hammer/parser'
@@ -47,8 +48,9 @@ class Hammer
47
48
  Error ||= Class.new(StandardError)
48
49
  AmbiguousMatch ||= Class.new(Error)
49
50
 
50
- # Gem version, read once from the bundled .version file.
51
- VERSION ||= File.read(File.expand_path('../.version', __dir__)).strip
51
+ # Gem version: the formatted main-branch commit count in a checkout, or the
52
+ # bundled .version baked into a released gem. See Hammer::Version.
53
+ VERSION ||= Version.string
52
54
 
53
55
  # Convenience aliases so recipes can write `Hammer.prepare_json!(opts)`
54
56
  # without the Input module path. See Hammer::Input.
@@ -770,12 +770,19 @@ module LlmUsage
770
770
 
771
771
  def row_cells(row, period)
772
772
  if period_label(period) == 'month'
773
- [row.name, row.month_pct || '-', row.month_reset || '-']
773
+ [row.name, utilization_bar(row.month_pct), row.month_reset || '-']
774
774
  else
775
- [row.name, row.session_pct, row.session_reset, row.week_pct, row.week_reset]
775
+ [row.name, utilization_bar(row.session_pct), row.session_reset, utilization_bar(row.week_pct), row.week_reset]
776
776
  end
777
777
  end
778
778
 
779
+ def utilization_bar(value)
780
+ return '-' if value.nil? || value == '-'
781
+
782
+ filled = (value.to_f.clamp(0, 100) / 10).round
783
+ "[#{'#' * filled}#{'-' * (10 - filled)}] #{value.rjust(4)}"
784
+ end
785
+
779
786
  def row_to_hash(row, period: nil)
780
787
  if period_label(period) == 'month'
781
788
  # Mirror row_cells: providers with no month window render '-', not null.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux-hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.30
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-26 00:00:00.000000000 Z
11
+ date: 2026-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -52,6 +52,7 @@ files:
52
52
  - "./lib/hammer/parser.rb"
53
53
  - "./lib/hammer/recipe.rb"
54
54
  - "./lib/hammer/shell.rb"
55
+ - "./lib/hammer/version.rb"
55
56
  - "./lib/lux-hammer.rb"
56
57
  - "./recipes/deploy.rb"
57
58
  - "./recipes/git-helper.rb"