lex-detect 0.2.0 → 0.2.1

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: 7e40e042cb6111ce0d3708ed3de574e32baf92839704e2a22ed4c239bcaf4907
4
- data.tar.gz: 4fdd6b3f2388a5aeb8a5a862e57cc29d57aa239793dbccdcabbdc1967267a031
3
+ metadata.gz: 8e8430d894d1792494f0781c7f13c28de7da13817c40fa3a9f80cfc4c89bc9ad
4
+ data.tar.gz: 2bff9f69460165c22a025dc97912639202cca9200366e91dafbc84dc9d37bb8f
5
5
  SHA512:
6
- metadata.gz: 8d8a294a962b08b21d08d26b9189ab01e7194a244e04299b2094e3eecfd5b00f40cebc56d438ea71b5ed2a47aab10bb77bf465eb8b71eff5821fdb5e11cd9f55
7
- data.tar.gz: 634257c97700a444f7a846ef249d69d718e5cf2d0202793bd38ba156bb48fae025410d98e7aeba56a8735647334d34c2f4bfd7cbdf53fc2c8870e50bf55297ce
6
+ metadata.gz: b087321a87beeff9cd42417286a39477edd5608ca8190bc67877b6e55b57f6bd4f971c05b802eadf47b68967acbb40c0e74b96c25a1d970d1431adffc3f43d2a
7
+ data.tar.gz: 6f9c61761fad7069ad09110f21d23227a664a606fcc5b50737d0d05c462ce9240b60e6f91a7d3b1684845b76c92f1500e2951a512725c33880eafacbc8ac3274
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1] - 2026-03-22
4
+
5
+ ### Added
6
+ - `Formatters::Json` passthrough formatter returning detections unchanged (or as pretty-printed JSON via `.to_json`)
7
+ - `Formatters` module entry point with `Formatters.format(detections, format:)` dispatcher for `:sarif`, `:markdown`, and `:json`
8
+ - `format_results` now delegates to `Formatters.format` instead of dispatching inline
9
+ - 5 new specs for `Formatters::Json` covering passthrough identity, field preservation, JSON serialization, and empty input
10
+
3
11
  ## [0.2.0] - 2026-03-22
4
12
 
5
13
  ### Added
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module Detect
8
+ module Formatters
9
+ module Json
10
+ module_function
11
+
12
+ def format(detections)
13
+ detections
14
+ end
15
+
16
+ def to_json(detections)
17
+ ::JSON.pretty_generate(format(detections))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/detect/formatters/json'
4
+ require 'legion/extensions/detect/formatters/sarif'
5
+ require 'legion/extensions/detect/formatters/markdown_pr'
6
+
7
+ module Legion
8
+ module Extensions
9
+ module Detect
10
+ module Formatters
11
+ module_function
12
+
13
+ def format(detections, format: :json)
14
+ case format.to_sym
15
+ when :sarif then Sarif.to_json(detections)
16
+ when :markdown then MarkdownPr.format(detections)
17
+ else Json.format(detections)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Detect
6
- VERSION = '0.2.0'
6
+ VERSION = '0.2.1'
7
7
  end
8
8
  end
9
9
  end
@@ -4,8 +4,7 @@ require 'legion/extensions/detect/version'
4
4
  require 'legion/extensions/detect/catalog'
5
5
  require 'legion/extensions/detect/scanner'
6
6
  require 'legion/extensions/detect/installer'
7
- require 'legion/extensions/detect/formatters/sarif'
8
- require 'legion/extensions/detect/formatters/markdown_pr'
7
+ require 'legion/extensions/detect/formatters'
9
8
  require_relative 'detect/runners/task_observer'
10
9
  require_relative 'detect/runners/cancel_task'
11
10
 
@@ -46,11 +45,7 @@ module Legion
46
45
 
47
46
  def format_results(format: :json, detections: nil)
48
47
  results = detections || scan
49
- case format.to_sym
50
- when :sarif then Formatters::Sarif.to_json(results)
51
- when :markdown then Formatters::MarkdownPr.format(results)
52
- else results
53
- end
48
+ Formatters.format(results, format: format)
54
49
  end
55
50
  end
56
51
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-detect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -31,6 +31,8 @@ files:
31
31
  - lib/legion/extensions/detect/actors/full_scan.rb
32
32
  - lib/legion/extensions/detect/actors/observer_tick.rb
33
33
  - lib/legion/extensions/detect/catalog.rb
34
+ - lib/legion/extensions/detect/formatters.rb
35
+ - lib/legion/extensions/detect/formatters/json.rb
34
36
  - lib/legion/extensions/detect/formatters/markdown_pr.rb
35
37
  - lib/legion/extensions/detect/formatters/sarif.rb
36
38
  - lib/legion/extensions/detect/installer.rb