calltally 0.2.0 → 0.3.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: 6fea4843020352c2c0240ca2c515294e3f52b13632ed35effadc7c51d8b7768f
4
- data.tar.gz: b610951792601626adb3a86848b0fa6754dc3091032e5fd1118688ac106ccf61
3
+ metadata.gz: 7bbb05d3dd40bb7ec180388541a0d0290023f2a152834f8246c98f285dcf40b9
4
+ data.tar.gz: 363208eb22a5a347963ce4accb45ce85744f2e10507a74071d450f5af44d9a51
5
5
  SHA512:
6
- metadata.gz: d1c4898e3676299fcd98545c6c5891651671d4fe02bea46556f3446b75aa28cf42d813399da0ccb03a291e831db23cb05eba09c0bbc6dac99110503e0819d0f1
7
- data.tar.gz: ffe9ae0edee7a44cfb0d957fedde983de4356e30453cff7603cb2d07de062f0bd1afe2d3dc90a67e2a4dfe55aeb5430245ff65e5200c2f10f6df6414ef229727
6
+ metadata.gz: 1c4797bf33d18a63b4230887986df0a917785f5d0064053f91bb9702089230de430ceeef0224fbd5a7178bd2b4f610c75b8ea336f823e8dd5cda82a34e070726
7
+ data.tar.gz: 015abe2bf689816f2c81951797fac0da9cefb1eebf51f0ed80990b76ff02f21453c1b508e4039524aeba2d22949b612006915ec4d3e6e20786e1119192aa1129
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2025-09-20
11
+
12
+ ### Added
13
+ - Plugin system for extensible file processing
14
+ - New `--plugins` option to load external plugins
15
+ - Plugin API with `register`, `handle`, and `registered_exts` methods
16
+ - Plugins can register custom file handlers for any extension
17
+
18
+ ### Changed
19
+ - Updated Prism dependency to 1.5.1
20
+
10
21
  ## [0.2.0] - 2025-09-14
11
22
 
12
23
  ### Removed
@@ -41,6 +52,7 @@ Focus for now is on Ruby code in models/controllers/services; view logic can be
41
52
  - Output formats: table, JSON, CSV
42
53
  - Ruby 3.2+ compatibility
43
54
 
44
- [Unreleased]: https://github.com/nsgc/calltally/compare/v0.2.0...HEAD
55
+ [Unreleased]: https://github.com/nsgc/calltally/compare/v0.3.0...HEAD
56
+ [0.3.0]: https://github.com/nsgc/calltally/compare/v0.2.0...v0.3.0
45
57
  [0.2.0]: https://github.com/nsgc/calltally/compare/v0.1.0...v0.2.0
46
58
  [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[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"]
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|
@@ -85,8 +88,25 @@ module Calltally
85
88
  end
86
89
 
87
90
  def read_source(path)
88
- src = File.binread(path)
89
- src.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "")
91
+ src = File.binread(path).encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "")
92
+
93
+ if (plugin_result = Calltally::Plugin.handle(path, src, @config))
94
+ return plugin_result
95
+ end
96
+
97
+ src
98
+ end
99
+
100
+ def load_plugins(plugin_names = [])
101
+ return if plugin_names.empty?
102
+
103
+ plugin_names.each do |plugin_name|
104
+ require "calltally/#{plugin_name}"
105
+
106
+ warn_verbose "Loaded plugin: calltally-#{plugin_name}"
107
+ rescue LoadError
108
+ warn "Plugin 'calltally-#{plugin_name}' not found. Install with: gem install calltally-#{plugin_name}"
109
+ end
90
110
  end
91
111
  end
92
112
  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.0"
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.0
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