calltally 0.2.0 → 0.3.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: 6fea4843020352c2c0240ca2c515294e3f52b13632ed35effadc7c51d8b7768f
4
- data.tar.gz: b610951792601626adb3a86848b0fa6754dc3091032e5fd1118688ac106ccf61
3
+ metadata.gz: cf90fa10c80dda9e70241b47b215748c8736eceff222cb92a96d75506fb09ab4
4
+ data.tar.gz: 8aaa86646d5f8bb1010f71485cf98bd99e84940cc06e24e42da17571abef992d
5
5
  SHA512:
6
- metadata.gz: d1c4898e3676299fcd98545c6c5891651671d4fe02bea46556f3446b75aa28cf42d813399da0ccb03a291e831db23cb05eba09c0bbc6dac99110503e0819d0f1
7
- data.tar.gz: ffe9ae0edee7a44cfb0d957fedde983de4356e30453cff7603cb2d07de062f0bd1afe2d3dc90a67e2a4dfe55aeb5430245ff65e5200c2f10f6df6414ef229727
6
+ metadata.gz: e325e9b2de437c842f5c9eb5b4048a156389c68d89d4e6f16ce840cdf7e2c4f37b1659e2d4684da003cc64ab5cbb7e8e7d8d4efa1134e49a303331eb772f0281
7
+ data.tar.gz: fad085d0dabf7ea45e8864c7c060ddb1680e13070f60d8737e0b10fee48bee461297f17b2234a53fb31f1b9fbca1748334ad6dedcb93ccb8f359dd77eb27f5b8
data/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.1] - 2025-10-10
11
+
12
+ ### Fixed
13
+ - Fixed `--exclude` option not properly excluding root-level directories (e.g., `spec/`, `test/`)
14
+ - Simplified exclude pattern matching logic for better reliability
15
+
16
+ ### Changed
17
+ - Removed `test` and `spec` from default exclude list to enable test code analysis
18
+ - Test and spec directories are now scanned by default (can still be excluded with `-x test,spec`)
19
+
20
+ ## [0.3.0] - 2025-09-20
21
+
22
+ ### Added
23
+ - Plugin system for extensible file processing
24
+ - New `--plugins` option to load external plugins
25
+ - Plugin API with `register`, `handle`, and `registered_exts` methods
26
+ - Plugins can register custom file handlers for any extension
27
+
28
+ ### Changed
29
+ - Updated Prism dependency to 1.5.1
30
+
10
31
  ## [0.2.0] - 2025-09-14
11
32
 
12
33
  ### Removed
@@ -41,6 +62,7 @@ Focus for now is on Ruby code in models/controllers/services; view logic can be
41
62
  - Output formats: table, JSON, CSV
42
63
  - Ruby 3.2+ compatibility
43
64
 
44
- [Unreleased]: https://github.com/nsgc/calltally/compare/v0.2.0...HEAD
65
+ [Unreleased]: https://github.com/nsgc/calltally/compare/v0.3.0...HEAD
66
+ [0.3.0]: https://github.com/nsgc/calltally/compare/v0.2.0...v0.3.0
45
67
  [0.2.0]: https://github.com/nsgc/calltally/compare/v0.1.0...v0.2.0
46
68
  [0.1.0]: https://github.com/nsgc/calltally/releases/tag/v0.1.0
data/README.md CHANGED
@@ -95,7 +95,6 @@ exclude: # Patterns to exclude
95
95
  - test
96
96
  - vendor
97
97
  top: 50 # Number of results to show
98
- # ERB files are not analyzed to avoid compilation noise
99
98
  mode: pairs # pairs|methods|receivers
100
99
  skip_operators: true # Skip operators like +, -, ==
101
100
  ```
data/lib/calltally/cli.rb CHANGED
@@ -58,6 +58,7 @@ module Calltally
58
58
  --only-constants Show only constant receivers
59
59
  --only-results Show only method results receivers
60
60
  --[no-]skip-operators Skip operator methods like +, -, ==, [] (default: true)
61
+ --plugins x,y Enable plugins (e.g., erb for calltally-erb)
61
62
  --format F table(default)|json|csv
62
63
  -o, --output PATH Write result to file instead of STDOUT
63
64
  --config PATH Use a specific .calltally.yml
@@ -88,6 +89,7 @@ module Calltally
88
89
  opt.on("--only-constants") { (cli_opts["receiver_types"] ||= []) << "constants" }
89
90
  opt.on("--only-results") { (cli_opts["receiver_types"] ||= []) << "results" }
90
91
  opt.on("--[no-]skip-operators") { |v| cli_opts["skip_operators"] = v }
92
+ opt.on("--plugins x,y", Array) { |v| cli_opts["plugins"] = v }
91
93
  opt.on("--format F", [:table, :json, :csv]) { |v| cli_opts["format"] = v.to_s }
92
94
  opt.on("-o PATH", "--output PATH") { |v| cli_opts["output"] = v }
93
95
  opt.on("--config PATH") { |v| config_override = v }
@@ -6,20 +6,21 @@ require "set"
6
6
  module Calltally
7
7
  class Config
8
8
  DEFAULTS = {
9
- "profile" => "auto", # auto|rails|default
10
- "dirs" => %w[.],
11
- "exclude" => %w[spec test vendor node_modules tmp log .git .bundle],
12
- "top" => 100,
13
- "verbose" => false,
14
- "mode" => "pairs", # pairs|methods|receivers
15
- "receivers" => nil, # ["User","Group"]
16
- "methods" => nil, # ["where","find"]
9
+ "profile" => "auto", # auto|rails|default
10
+ "dirs" => %w[.],
11
+ "exclude" => %w[vendor node_modules tmp log .git .bundle],
12
+ "top" => 100,
13
+ "verbose" => false,
14
+ "mode" => "pairs", # pairs|methods|receivers
15
+ "receivers" => nil, # ["User","Group"]
16
+ "methods" => nil, # ["where","find"]
17
17
  "include_nil_receiver" => false,
18
- "split_variables" => false, # Show variable names vs grouping
19
- "receiver_types" => nil, # ["locals", "ivars", "constants"] etc.
20
- "skip_operators" => true,
21
- "format" => "table", # table|json|csv
22
- "output" => nil
18
+ "split_variables" => false, # Show variable names vs grouping
19
+ "receiver_types" => nil, # ["locals", "ivars", "constants"] etc.
20
+ "skip_operators" => true,
21
+ "format" => "table", # table|json|csv
22
+ "output" => nil,
23
+ "plugins" => [] # Enable plugins (e.g., ["erb"])
23
24
  }.freeze
24
25
 
25
26
  RAILS_DIR_PRESET = %w[app lib config].freeze
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Calltally
4
+ module Plugin
5
+ @handlers = {}
6
+
7
+ class << self
8
+ def register(ext, &block)
9
+ @handlers[ext] = block
10
+ end
11
+
12
+ def handle(path, src, cfg)
13
+ if (handler = @handlers[File.extname(path)])
14
+ handler.call(path, src, cfg)
15
+ end
16
+ end
17
+
18
+ def registered_exts
19
+ @handlers.keys
20
+ end
21
+ end
22
+ end
23
+ end
@@ -2,12 +2,14 @@
2
2
 
3
3
  require "find"
4
4
  require "calltally/prism_visitor"
5
+ require "calltally/plugin"
5
6
 
6
7
  module Calltally
7
8
  class Scanner
8
9
  def initialize(base_dir:, config:)
9
10
  @base_dir = File.expand_path(base_dir)
10
11
  @config = config
12
+ load_plugins(@config["plugins"])
11
13
  end
12
14
 
13
15
  def scan
@@ -61,6 +63,7 @@ module Calltally
61
63
 
62
64
  def collect_paths
63
65
  exts = %w[.rb .ru .rake]
66
+ exts.concat(Calltally::Plugin.registered_exts)
64
67
 
65
68
  files = []
66
69
  @config["dirs"].each do |dir|
@@ -81,12 +84,31 @@ module Calltally
81
84
 
82
85
  def excluded?(path)
83
86
  rel = path.sub(@base_dir + "/", "")
84
- @config["exclude"].any? { |ex| rel.include?("/#{ex}/") || File.basename(rel).start_with?("#{ex}.") }
87
+ @config["exclude"].any? do |ex|
88
+ rel == ex || rel.start_with?("#{ex}/", "#{ex}.") || rel.include?("/#{ex}/")
89
+ end
85
90
  end
86
91
 
87
92
  def read_source(path)
88
- src = File.binread(path)
89
- src.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "")
93
+ src = File.binread(path).encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "")
94
+
95
+ if (plugin_result = Calltally::Plugin.handle(path, src, @config))
96
+ return plugin_result
97
+ end
98
+
99
+ src
100
+ end
101
+
102
+ def load_plugins(plugin_names = [])
103
+ return if plugin_names.empty?
104
+
105
+ plugin_names.each do |plugin_name|
106
+ require "calltally/#{plugin_name}"
107
+
108
+ warn_verbose "Loaded plugin: calltally-#{plugin_name}"
109
+ rescue LoadError
110
+ warn "Plugin 'calltally-#{plugin_name}' not found. Install with: gem install calltally-#{plugin_name}"
111
+ end
90
112
  end
91
113
  end
92
114
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Calltally
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calltally
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoki Nishiguchi
@@ -70,6 +70,7 @@ files:
70
70
  - lib/calltally/cli.rb
71
71
  - lib/calltally/config.rb
72
72
  - lib/calltally/formatter.rb
73
+ - lib/calltally/plugin.rb
73
74
  - lib/calltally/prism_visitor.rb
74
75
  - lib/calltally/scanner.rb
75
76
  - lib/calltally/version.rb