misogi 0.1.0 → 0.2.0

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: 16a145081d2d9ac3ab9f9eae729fc782f25e757823b028b2bb6a4ab2042871ca
4
- data.tar.gz: 0f954963b9739d50232789ae9864486e8eb10c2040d74dfaf7ec82afe5a69521
3
+ metadata.gz: 82aebf0fd073991337784a716bffd744a392fc39130dbb4df28ab09250f68503
4
+ data.tar.gz: 37ffc3498476d27b0bae291100add371815788e66fa0ecb8eaa222937cb70236
5
5
  SHA512:
6
- metadata.gz: 3c36b33996d2ee6bfd3115010b3eca3e4e7e4038bace4b11ff2dd19efd4f5f5f5bfc1c21f6fb4d2ca05cf8f4359695c35339fff42a45eb9504a901a16d2ca6bd
7
- data.tar.gz: 2859f98328c7a4185a1d3e49e069902ba8cc6ef16a19be28b2e3c11c028b466cd0a41d37607b4e3c7ee3b7d7db4a0f98726f2175e02c110301138aa51d9216bf
6
+ metadata.gz: e5ba3450b633aa7e0f43e1a151f2046ae226d9660a3a17e07cfc23064ff12a6b4941a25a4b04f77d52f935875fd88b353637cb00ab9757288ae18d3abbae642f
7
+ data.tar.gz: 2236cbf2ac2e708f56dfd9255314a9abd6da0252aec67089e2cdebccb526baea611889c1ec7521150bfae834cccaa58a6e2447f8f1ad27d5a81d1b2e3a77f072
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [未リリース]
2
2
 
3
+ ## [0.2.0] - 2025-11-07
4
+
5
+ - JSON出力機能の追加(`-f json`)
6
+
3
7
  ## [0.1.0] - 2025-10-31
4
8
 
5
9
  - 初回リリース
data/README.md CHANGED
@@ -47,6 +47,9 @@ misogi --base-path src
47
47
  # ヘルプを表示
48
48
  misogi --help
49
49
 
50
+ # 出力フォーマット指定
51
+ misogi --format json
52
+
50
53
  # バージョンを表示
51
54
  misogi --version
52
55
  ```
data/lib/misogi/cli.rb CHANGED
@@ -13,7 +13,8 @@ module Misogi
13
13
  rules: nil, # nilの場合は設定ファイルを使用
14
14
  base_path: nil,
15
15
  pattern: nil,
16
- config_path: ".misogi.yml"
16
+ config_path: ".misogi.yml",
17
+ format: "text"
17
18
  }
18
19
  end
19
20
 
@@ -107,6 +108,10 @@ module Misogi
107
108
  @options[:config_path] = path
108
109
  end
109
110
 
111
+ opts.on("-f", "--format FORMAT", "出力フォーマット(text|json)") do |format|
112
+ @options[:format] = format
113
+ end
114
+
110
115
  opts.on("-h", "--help", "ヘルプを表示") do
111
116
  puts opts
112
117
  exit 0
@@ -235,12 +240,18 @@ module Misogi
235
240
  # 違反を表示
236
241
  # @param violations [Array<Violation>] 違反のリスト
237
242
  def display_violations(violations)
238
- if violations.empty?
239
- puts "✓ 違反は見つかりませんでした"
240
- else
241
- puts "✗ #{violations.size}件の違反が見つかりました:\n\n"
242
- violations.each do |violation|
243
- puts violation
243
+ case @options[:format]
244
+ when "json"
245
+ require "json"
246
+ puts JSON.pretty_generate(violations.map(&:to_h))
247
+ when "text"
248
+ if violations.empty?
249
+ puts "✓ 違反は見つかりませんでした"
250
+ else
251
+ puts "✗ #{violations.size}件の違反が見つかりました:\n\n"
252
+ violations.each do |violation|
253
+ puts violation
254
+ end
244
255
  end
245
256
  end
246
257
  end
@@ -24,9 +24,10 @@ module Misogi
24
24
  # 違反を作成するヘルパーメソッド
25
25
  # @param file_path [String] ファイルパス
26
26
  # @param message [String] 違反メッセージ
27
+ # @param suggest_path [String|nil] 修正案のパス
27
28
  # @return [Violation]
28
- def violation(file_path:, message:)
29
- Violation.new(file_path: file_path, message: message, rule_name: name)
29
+ def violation(file_path:, message:, suggest_path: nil)
30
+ Violation.new(file_path: file_path, message: message, rule_name: name, suggest_path:)
30
31
  end
31
32
  end
32
33
  end
@@ -66,7 +66,8 @@ module Misogi
66
66
  defined_namespaces = parsed_content.namespaces.join(", ")
67
67
  violations << violation(
68
68
  file_path: file_path,
69
- message: "名前空間 '#{defined_namespaces}' は #{expected_paths_str} に配置すべきです"
69
+ message: "名前空間 '#{defined_namespaces}' は #{expected_paths_str} に配置すべきです",
70
+ suggest_path: expected_paths_str
70
71
  )
71
72
  end
72
73
 
@@ -64,7 +64,8 @@ module Misogi
64
64
  described_str = described_namespaces.join(", ")
65
65
  violations << violation(
66
66
  file_path: file_path,
67
- message: "テスト対象 '#{described_str}' のspecファイルは #{expected_paths_str} に配置すべきです"
67
+ message: "テスト対象 '#{described_str}' のspecファイルは #{expected_paths_str} に配置すべきです",
68
+ suggest_path: expected_paths_str
68
69
  )
69
70
  end
70
71
 
@@ -40,7 +40,8 @@ module Misogi
40
40
  defined_namespaces = parsed_content.namespaces.join(", ")
41
41
  violations << violation(
42
42
  file_path: file_path,
43
- message: "名前空間 '#{defined_namespaces}' は #{expected_paths_str} に配置すべきです"
43
+ message: "名前空間 '#{defined_namespaces}' は #{expected_paths_str} に配置すべきです",
44
+ suggest_path: expected_paths_str
44
45
  )
45
46
  end
46
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Misogi
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -3,15 +3,17 @@
3
3
  module Misogi
4
4
  # ファイルパスとコンテンツの検証違反を表すクラス
5
5
  class Violation
6
- attr_reader :file_path, :message, :rule_name
6
+ attr_reader :file_path, :message, :rule_name, :suggest_path
7
7
 
8
8
  # @param file_path [String] 違反が見つかったファイルパス
9
9
  # @param message [String] 違反の詳細メッセージ
10
10
  # @param rule_name [String] 違反を検出したルール名
11
- def initialize(file_path:, message:, rule_name:)
11
+ # @param suggest_path [String|] 修正案のパス
12
+ def initialize(file_path:, message:, rule_name:, suggest_path: nil)
12
13
  @file_path = file_path
13
14
  @message = message
14
15
  @rule_name = rule_name
16
+ @suggest_path = suggest_path
15
17
  end
16
18
 
17
19
  # 違反情報を文字列として表現
@@ -19,5 +21,16 @@ module Misogi
19
21
  def to_s
20
22
  "#{file_path}: [#{rule_name}] #{message}"
21
23
  end
24
+
25
+ # 違反情報をハッシュとして表現
26
+ # @return [Hash]
27
+ def to_h
28
+ {
29
+ file_path:,
30
+ message:,
31
+ rule_name:,
32
+ suggest_path:
33
+ }
34
+ end
22
35
  end
23
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misogi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iyuuya