calltally 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 +4 -4
- data/CHANGELOG.md +46 -0
- data/README.md +23 -4
- data/lib/calltally/cli.rb +0 -7
- data/lib/calltally/config.rb +0 -9
- data/lib/calltally/scanner.rb +1 -13
- data/lib/calltally/version.rb +1 -1
- metadata +2 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fea4843020352c2c0240ca2c515294e3f52b13632ed35effadc7c51d8b7768f
|
4
|
+
data.tar.gz: b610951792601626adb3a86848b0fa6754dc3091032e5fd1118688ac106ccf61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1c4898e3676299fcd98545c6c5891651671d4fe02bea46556f3446b75aa28cf42d813399da0ccb03a291e831db23cb05eba09c0bbc6dac99110503e0819d0f1
|
7
|
+
data.tar.gz: ffe9ae0edee7a44cfb0d957fedde983de4356e30453cff7603cb2d07de062f0bd1afe2d3dc90a67e2a4dfe55aeb5430245ff65e5200c2f10f6df6414ef229727
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.2.0] - 2025-09-14
|
11
|
+
|
12
|
+
### Removed
|
13
|
+
- **BREAKING:** ERB file analysis
|
14
|
+
- `.erb` files are no longer analyzed
|
15
|
+
- Removed the `--erb` CLI option
|
16
|
+
- Disabled automatic ERB processing in the Rails profile
|
17
|
+
- This eliminates noise from ERB compilation artifacts (e.g., `to_s`, `safe_concat`, `concat`, etc.)
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
- Method-call tallies better reflect actual Ruby code usage (no ERB-generated noise)
|
21
|
+
|
22
|
+
### Rationale
|
23
|
+
ERB compilation introduces implementation artifacts that distort frequency counts:
|
24
|
+
- Implicit `to_s` for `<%= ... %>`
|
25
|
+
- Buffer operations (`safe_concat`, `concat`, `append`, etc.)
|
26
|
+
- Framework helpers (`html_escape`, etc.)
|
27
|
+
|
28
|
+
Focus for now is on Ruby code in models/controllers/services; view logic can be assessed via helpers or future plugins.
|
29
|
+
|
30
|
+
### Migration
|
31
|
+
- Remove any use of `--erb` (it now errors/does nothing).
|
32
|
+
- If you relied on ERB counts, consider extracting key helpers to Ruby modules and scanning those instead.
|
33
|
+
|
34
|
+
## [0.1.0] - 2025-09-13
|
35
|
+
### Added
|
36
|
+
- Initial release
|
37
|
+
- Static analysis of method usage in Ruby/Rails codebases
|
38
|
+
- Modes: receiver×method pairs, methods only, receivers only
|
39
|
+
- Variable bucketing and receiver filters
|
40
|
+
- Rails project auto-detection
|
41
|
+
- Output formats: table, JSON, CSV
|
42
|
+
- Ruby 3.2+ compatibility
|
43
|
+
|
44
|
+
[Unreleased]: https://github.com/nsgc/calltally/compare/v0.2.0...HEAD
|
45
|
+
[0.2.0]: https://github.com/nsgc/calltally/compare/v0.1.0...v0.2.0
|
46
|
+
[0.1.0]: https://github.com/nsgc/calltally/releases/tag/v0.1.0
|
data/README.md
CHANGED
@@ -44,8 +44,8 @@ Calltally automatically detects Rails projects and scans the right directories:
|
|
44
44
|
# Auto-detects Rails and scans app/, lib/, config/
|
45
45
|
calltally
|
46
46
|
|
47
|
-
#
|
48
|
-
calltally
|
47
|
+
# Analyze specific file patterns
|
48
|
+
calltally app/models
|
49
49
|
|
50
50
|
# Focus on ActiveRecord methods
|
51
51
|
calltally --methods where,find,joins --mode pairs
|
@@ -95,7 +95,7 @@ exclude: # Patterns to exclude
|
|
95
95
|
- test
|
96
96
|
- vendor
|
97
97
|
top: 50 # Number of results to show
|
98
|
-
|
98
|
+
# ERB files are not analyzed to avoid compilation noise
|
99
99
|
mode: pairs # pairs|methods|receivers
|
100
100
|
skip_operators: true # Skip operators like +, -, ==
|
101
101
|
```
|
@@ -148,7 +148,6 @@ Options:
|
|
148
148
|
-x, --exclude x,y Path parts to exclude
|
149
149
|
-n, --top N Show top N results (default: 100)
|
150
150
|
-v, --verbose Verbose output
|
151
|
-
--erb Include .erb files (requires erubi gem)
|
152
151
|
|
153
152
|
--mode MODE Output mode:
|
154
153
|
- pairs: receiver-method pairs (default)
|
@@ -207,6 +206,26 @@ Calltally shows method calls in your codebase with their receivers:
|
|
207
206
|
5. **Code reviews** - Quickly analyze unfamiliar codebases
|
208
207
|
6. **Gem development** - See how your gem's methods are used
|
209
208
|
|
209
|
+
## FAQ
|
210
|
+
|
211
|
+
### Why does grep show different counts than CallTally?
|
212
|
+
|
213
|
+
CallTally counts method **calls**, not all text occurrences:
|
214
|
+
- `grep "Current.user"` finds both `Current.user` (getter) and `Current.user = value` (setter)
|
215
|
+
- CallTally only counts `Current.user` (the getter method call)
|
216
|
+
- Setters like `name=` are separate methods and not counted as `name`
|
217
|
+
|
218
|
+
### Which file types are analyzed?
|
219
|
+
|
220
|
+
- **Ruby files**: `.rb`, `.ru`, `.rake`
|
221
|
+
- **Not included**: JavaScript, CSS, YAML, and other file types
|
222
|
+
|
223
|
+
### Why do I see (result) as a receiver?
|
224
|
+
|
225
|
+
When methods are chained, CallTally shows intermediate results as `(result)`:
|
226
|
+
- `user.posts.first` → `(var).posts` + `(result).first`
|
227
|
+
- This happens because CallTally doesn't infer types without type annotations
|
228
|
+
|
210
229
|
## Contributing
|
211
230
|
|
212
231
|
Bug reports and pull requests are welcome on GitHub at https://github.com/nsgc/calltally.
|
data/lib/calltally/cli.rb
CHANGED
@@ -43,7 +43,6 @@ module Calltally
|
|
43
43
|
-x, --exclude x,y Path parts to exclude
|
44
44
|
-n, --top N Show top N (default: 100)
|
45
45
|
-v, --verbose
|
46
|
-
--erb Include .erb (requires 'erubi' gem)
|
47
46
|
--mode MODE Output mode:
|
48
47
|
- pairs (default): receiver-method pairs
|
49
48
|
- methods: method names only
|
@@ -77,7 +76,6 @@ module Calltally
|
|
77
76
|
opt.on("-x x,y", "--exclude x,y", Array) { |v| cli_opts["exclude"] = v }
|
78
77
|
opt.on("-n N", "--top N", Integer) { |v| cli_opts["top"] = v }
|
79
78
|
opt.on("-v", "--verbose") { cli_opts["verbose"] = true }
|
80
|
-
opt.on("--erb") { cli_opts["include_erb"] = true }
|
81
79
|
opt.on("--mode MODE", [:pairs, :methods, :receivers]) { |v| cli_opts["mode"] = v.to_s }
|
82
80
|
opt.on("--receivers x,y", Array) { |v| cli_opts["receivers"] = v }
|
83
81
|
opt.on("--methods x,y", Array) { |v| cli_opts["methods"] = v }
|
@@ -109,11 +107,6 @@ module Calltally
|
|
109
107
|
|
110
108
|
config = Calltally::Config.load(base_dir: base_dir, cli_opts: cli_opts)
|
111
109
|
|
112
|
-
if config["profile"] == "rails" && config["include_erb"] && !Calltally::Config.erubi_available?
|
113
|
-
warn "[calltally] Rails profile detected but 'erubi' not found. ERB will be skipped. Install 'erubi' to include ERB."
|
114
|
-
config["include_erb"] = false
|
115
|
-
end
|
116
|
-
|
117
110
|
mode, rows = Calltally::Scanner.new(base_dir: base_dir, config: config).scan
|
118
111
|
|
119
112
|
out = config["output"] ? File.open(config["output"], "w") : $stdout
|
data/lib/calltally/config.rb
CHANGED
@@ -11,7 +11,6 @@ module Calltally
|
|
11
11
|
"exclude" => %w[spec test vendor node_modules tmp log .git .bundle],
|
12
12
|
"top" => 100,
|
13
13
|
"verbose" => false,
|
14
|
-
"include_erb" => false,
|
15
14
|
"mode" => "pairs", # pairs|methods|receivers
|
16
15
|
"receivers" => nil, # ["User","Group"]
|
17
16
|
"methods" => nil, # ["where","find"]
|
@@ -40,7 +39,6 @@ module Calltally
|
|
40
39
|
|
41
40
|
if config["profile"] == "rails"
|
42
41
|
config["dirs"] = RAILS_DIR_PRESET if config["dirs"] == DEFAULTS["dirs"]
|
43
|
-
config["include_erb"] = config["include_erb"] || erubi_available?
|
44
42
|
end
|
45
43
|
|
46
44
|
config["receivers"] = to_set_or_nil(config["receivers"])
|
@@ -59,13 +57,6 @@ module Calltally
|
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
|
-
def self.erubi_available?
|
63
|
-
require "erubi"
|
64
|
-
true
|
65
|
-
rescue LoadError
|
66
|
-
false
|
67
|
-
end
|
68
|
-
|
69
60
|
def self.to_set_or_nil(v)
|
70
61
|
case v
|
71
62
|
when nil then nil
|
data/lib/calltally/scanner.rb
CHANGED
@@ -61,7 +61,6 @@ module Calltally
|
|
61
61
|
|
62
62
|
def collect_paths
|
63
63
|
exts = %w[.rb .ru .rake]
|
64
|
-
exts << ".erb" if @config["include_erb"]
|
65
64
|
|
66
65
|
files = []
|
67
66
|
@config["dirs"].each do |dir|
|
@@ -87,18 +86,7 @@ module Calltally
|
|
87
86
|
|
88
87
|
def read_source(path)
|
89
88
|
src = File.binread(path)
|
90
|
-
src
|
91
|
-
|
92
|
-
if @config["include_erb"] && File.extname(path) == ".erb"
|
93
|
-
begin
|
94
|
-
require "erubi"
|
95
|
-
src = Erubi::Engine.new(src).src
|
96
|
-
rescue LoadError
|
97
|
-
warn "ERB requested but 'erubi' not installed. Skipping ERB compilation for #{path}."
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
src
|
89
|
+
src.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "")
|
102
90
|
end
|
103
91
|
end
|
104
92
|
end
|
data/lib/calltally/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoki Nishiguchi
|
@@ -51,20 +51,6 @@ dependencies:
|
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '13.0'
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: erubi
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
|
-
type: :development
|
62
|
-
prerelease: false
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
54
|
description: A simple yet powerful tool to analyze method usage in Ruby/Rails codebases.
|
69
55
|
Track which methods are called most frequently, filter by receivers or method names,
|
70
56
|
and export results in table, JSON, or CSV format. Perfect for understanding code
|
@@ -74,6 +60,7 @@ executables:
|
|
74
60
|
extensions: []
|
75
61
|
extra_rdoc_files: []
|
76
62
|
files:
|
63
|
+
- CHANGELOG.md
|
77
64
|
- CODE_OF_CONDUCT.md
|
78
65
|
- LICENSE.txt
|
79
66
|
- README.md
|