gem_activity_tracker 0.1.1 → 1.0.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 +4 -4
- data/README.md +96 -107
- data/exe/gem_activity_tracker +4 -15
- data/lib/gem_activity_tracker/railtie.rb +23 -12
- data/lib/gem_activity_tracker/tracker.rb +99 -20
- data/lib/gem_activity_tracker/version.rb +1 -3
- data/lib/gem_activity_tracker/watcher.rb +1 -7
- data/lib/gem_activity_tracker.rb +1 -2
- metadata +13 -18
- data/.gem_activity_tracker.gemspec.swp +0 -0
- data/CHANGELOG.md +0 -5
- data/Rakefile +0 -4
- data/gem_activity_tracker-0.1.0.gem +0 -0
- data/sig/gem_activity_tracker.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbf3e335476faecbfe09e7b427ec0706ad1cbfc397ceadd74ff8bd2dd68d56ae
|
4
|
+
data.tar.gz: 83d525f61caafca1a605244dca22be4859045739a04ea984a7edd9267361af51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55066b038228ba20827e13f17fd962d0e4da8c9056ca4d5c67d4b3b414fe01ac4e6f067c4652169089cff9d13407819e997203e28dfb7ec2c5eb5e10ace8960a
|
7
|
+
data.tar.gz: 354d740e41817c937009444eec07ffd896e0f41918896c1eb4725025b0592447459bd95d809e4673eff13c688328904b33dbb4af1bc7af2c7fe36bb7074e609e
|
data/README.md
CHANGED
@@ -1,39 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# 📊 Gem Activity Tracker
|
2
2
|
|
3
|
-
|
3
|
+
**`gem_activity_tracker`** is a Ruby gem that tracks the internal structure, changes, and metadata of your **Ruby** or **Rails** projects. It generates a complete project activity report in **YAML**, with support for **JSON/CSV export**, **auto-tracking with file watcher**, and **Git log visualization**.
|
4
4
|
|
5
5
|
---
|
6
6
|
|
7
|
-
##
|
7
|
+
## 🚀 Features
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
- 📊 Export report in:
|
18
|
-
- YAML (default)
|
19
|
-
- JSON
|
20
|
-
- CSV
|
21
|
-
- 🔁 Real-time file watcher using the `listen` gem
|
22
|
-
|
23
|
-
---
|
24
|
-
|
25
|
-
## 🔧 Compatibility
|
26
|
-
|
27
|
-
- ✅ **Ruby**: >= 2.6.5 and < 4.0
|
28
|
-
- ✅ **Rails**: >= 5.2 and <= 7.1
|
29
|
-
|
30
|
-
- ✅ Works with: **MySQL**, **PostgreSQL**, **SQLite**
|
9
|
+
- 🔍 Analyze project structure: models, controllers, jobs, services, mailers, routes, etc.
|
10
|
+
- 🧠 Advanced model analysis: attributes, associations, methods, validations, callbacks, and enums.
|
11
|
+
- 🏗️ Migration tracking and schema hashing.
|
12
|
+
- 🛠️ Detect database type from `database.yml`.
|
13
|
+
- 📦 Git history tracking (last 20 commits).
|
14
|
+
- 🔄 Auto-tracking using the `listen` gem on file changes.
|
15
|
+
- 📁 Export report to **YAML**, **JSON**, or **CSV**.
|
16
|
+
- ✅ Works with both **Rails** and **plain Ruby** projects.
|
31
17
|
|
32
18
|
---
|
33
19
|
|
34
20
|
## 📦 Installation
|
35
21
|
|
36
|
-
Add this line to your
|
22
|
+
Add this line to your application's Gemfile:
|
37
23
|
|
38
24
|
```ruby
|
39
25
|
gem 'gem_activity_tracker'
|
@@ -45,7 +31,7 @@ Then run:
|
|
45
31
|
bundle install
|
46
32
|
```
|
47
33
|
|
48
|
-
Or install it
|
34
|
+
Or install it directly:
|
49
35
|
|
50
36
|
```bash
|
51
37
|
gem install gem_activity_tracker
|
@@ -53,138 +39,141 @@ gem install gem_activity_tracker
|
|
53
39
|
|
54
40
|
---
|
55
41
|
|
56
|
-
##
|
57
|
-
|
58
|
-
Once installed, you can use the CLI commands:
|
42
|
+
## ⚙️ Usage
|
59
43
|
|
60
|
-
###
|
44
|
+
### 📌 Basic CLI Commands
|
61
45
|
|
62
46
|
```bash
|
63
|
-
gem_activity_tracker --track
|
47
|
+
gem_activity_tracker --track=PATH # Track a Ruby/Rails project and generate report
|
48
|
+
gem_activity_tracker --report # Show last generated report
|
49
|
+
gem_activity_tracker --export=json # Export report to JSON
|
50
|
+
gem_activity_tracker --export=csv # Export report to CSV
|
51
|
+
gem_activity_tracker --watch # Start file watcher to auto-track changes
|
64
52
|
```
|
65
53
|
|
66
|
-
|
54
|
+
### 🛠️ Rails Auto-Tracking
|
67
55
|
|
68
|
-
|
56
|
+
In a Rails app, the gem automatically hooks into the app after initialization via a Railtie.
|
69
57
|
|
70
|
-
|
58
|
+
Set this in your `.env` or shell:
|
71
59
|
|
72
60
|
```bash
|
73
|
-
|
61
|
+
export GEM_ACTIVITY_TRACKER_ENABLED=true
|
74
62
|
```
|
75
63
|
|
76
|
-
|
77
|
-
|
78
|
-
- Update the report
|
79
|
-
- Add a new entry to `log.txt`
|
64
|
+
Then start your Rails app and the gem will:
|
80
65
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
```bash
|
86
|
-
gem_activity_tracker --report
|
87
|
-
```
|
66
|
+
- Detect and track changes
|
67
|
+
- Update `activity_tracker/report.yml`
|
68
|
+
- Start watching the file system
|
88
69
|
|
89
70
|
---
|
90
71
|
|
91
|
-
|
92
|
-
|
93
|
-
```bash
|
94
|
-
gem_activity_tracker --export=json
|
95
|
-
```
|
96
|
-
|
97
|
-
---
|
72
|
+
## 📂 Output
|
98
73
|
|
99
|
-
|
74
|
+
The gem creates an `activity_tracker/` folder at your project root:
|
100
75
|
|
101
76
|
```bash
|
102
|
-
|
77
|
+
activity_tracker/
|
78
|
+
├── report.yml # Main YAML report
|
79
|
+
├── report.json # (Optional) Exported JSON
|
80
|
+
├── report.csv # (Optional) Exported CSV
|
81
|
+
└── log.txt # File change logs (when watch mode is on)
|
103
82
|
```
|
104
83
|
|
105
84
|
---
|
106
85
|
|
107
|
-
##
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
86
|
+
## 📊 What’s Tracked?
|
87
|
+
|
88
|
+
| Component | Details |
|
89
|
+
|------------|-------------------------------------------------------------------------|
|
90
|
+
| Models | Count, files, attributes, associations, methods, validations, enums |
|
91
|
+
| Controllers | List of files |
|
92
|
+
| Services | List of files |
|
93
|
+
| Mailers | List of files |
|
94
|
+
| Jobs | List of files |
|
95
|
+
| Migrations | Count and recent migration names |
|
96
|
+
| Routes | Full route listing via `rails routes` |
|
97
|
+
| Schema | Schema hash (`db/schema.rb`) |
|
98
|
+
| Git Log | Last 20 commits |
|
99
|
+
| Database | Type detected from `config/database.yml` |
|
118
100
|
|
119
101
|
---
|
120
102
|
|
121
|
-
##
|
103
|
+
## 🔁 Auto-Watcher
|
122
104
|
|
123
|
-
|
105
|
+
Auto-track changes in real-time using the `listen` gem:
|
124
106
|
|
125
107
|
```bash
|
126
|
-
|
127
|
-
cd gem_activity_tracker
|
128
|
-
bundle install
|
108
|
+
gem_activity_tracker --watch
|
129
109
|
```
|
130
110
|
|
131
|
-
|
111
|
+
You'll see logs like:
|
132
112
|
|
133
|
-
```
|
134
|
-
|
113
|
+
```
|
114
|
+
[2025-04-10 12:00:00] Modified: app/models/user.rb
|
115
|
+
[2025-04-10 12:00:01] Added: app/services/new_service.rb
|
135
116
|
```
|
136
117
|
|
137
|
-
|
118
|
+
Each change triggers regeneration of the report.
|
138
119
|
|
139
|
-
|
140
|
-
|
120
|
+
---
|
121
|
+
|
122
|
+
## 🧪 Example Output (YAML)
|
123
|
+
|
124
|
+
```yaml
|
125
|
+
ruby_version: ruby 3.2.2
|
126
|
+
rails_version: 6.1.4
|
127
|
+
database: postgresql
|
128
|
+
models:
|
129
|
+
count: 5
|
130
|
+
files:
|
131
|
+
- app/models/user.rb
|
132
|
+
- app/models/post.rb
|
133
|
+
detailed:
|
134
|
+
User:
|
135
|
+
table_name: users
|
136
|
+
attributes: [id, name, email]
|
137
|
+
associations:
|
138
|
+
has_many: [posts]
|
139
|
+
validations: ["PresenceValidator"]
|
140
|
+
callbacks: [before_create, after_save]
|
141
|
+
controllers:
|
142
|
+
count: 3
|
143
|
+
files: [...]
|
144
|
+
git_log:
|
145
|
+
- "1a2b3c4 - Atul Yadav (2025-04-10): Add model tracker"
|
146
|
+
- ...
|
141
147
|
```
|
142
148
|
|
143
149
|
---
|
144
150
|
|
145
|
-
##
|
151
|
+
## 💡 Configuration
|
146
152
|
|
147
|
-
|
148
|
-
2. Build and release:
|
153
|
+
You can toggle auto-tracking with an ENV variable:
|
149
154
|
|
150
155
|
```bash
|
151
|
-
|
156
|
+
export GEM_ACTIVITY_TRACKER_ENABLED=false # disables auto-tracking
|
152
157
|
```
|
153
158
|
|
154
|
-
This will:
|
155
|
-
|
156
|
-
- Create a `.gem` file
|
157
|
-
- Push to RubyGems
|
158
|
-
- Tag and push to GitHub
|
159
|
-
|
160
159
|
---
|
161
160
|
|
162
|
-
##
|
161
|
+
## 🧑 Author
|
163
162
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
6. Open a Pull Request
|
163
|
+
**Atul Yadav**
|
164
|
+
📧 atuIyadav9039@gmail.com
|
165
|
+
📍 Indore, India
|
166
|
+
🔗 [LinkedIn](https://www.linkedin.com/in/atul-yadav-9445ab1a4)
|
167
|
+
📦 RubyGems: [gem_activity_tracker](https://rubygems.org/gems/gem_activity_tracker)
|
170
168
|
|
171
169
|
---
|
172
170
|
|
173
171
|
## 📄 License
|
174
172
|
|
175
|
-
This project is licensed under the
|
176
|
-
|
177
|
-
---
|
178
|
-
|
179
|
-
## 🌍 Links
|
180
|
-
|
181
|
-
- 📦 [RubyGems Page](https://rubygems.org/gems/gem_activity_tracker)
|
182
|
-
- 🧠 [GitHub Repo](https://github.com/atul13055/gem_activity_tracker)
|
173
|
+
This project is licensed under the MIT License. See `LICENSE.txt` for details.
|
183
174
|
|
184
175
|
---
|
185
176
|
|
186
|
-
##
|
177
|
+
## 💬 Contributing
|
187
178
|
|
188
|
-
|
189
|
-
📧 [atuIyadav9039@gmail.com](mailto:atuIyadav9039@gmail.com)
|
190
|
-
🌐 [LinkedIn](https://www.linkedin.com/in/atul-yadav-9445ab1a4)
|
179
|
+
Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
|
data/exe/gem_activity_tracker
CHANGED
@@ -8,21 +8,10 @@ options = {}
|
|
8
8
|
OptionParser.new do |opts|
|
9
9
|
opts.banner = "Usage: gem_activity_tracker [options]"
|
10
10
|
|
11
|
-
opts.on("-tPATH", "--track=PATH", "Track a Rails/Ruby project")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
opts.on("-r", "--report", "Show last generated report") do
|
16
|
-
options[:report] = true
|
17
|
-
end
|
18
|
-
|
19
|
-
opts.on("-eFORMAT", "--export=FORMAT", "Export as json or csv") do |format|
|
20
|
-
options[:export] = format.to_sym
|
21
|
-
end
|
22
|
-
|
23
|
-
opts.on("-w", "--watch", "Start the file watcher") do
|
24
|
-
options[:watch] = true
|
25
|
-
end
|
11
|
+
opts.on("-tPATH", "--track=PATH", "Track a Rails/Ruby project") { |v| options[:track] = v }
|
12
|
+
opts.on("-r", "--report", "Show last generated report") { options[:report] = true }
|
13
|
+
opts.on("-eFORMAT", "--export=FORMAT", "Export as json or csv") { |v| options[:export] = v.to_sym }
|
14
|
+
opts.on("-w", "--watch", "Start the file watcher") { options[:watch] = true }
|
26
15
|
end.parse!
|
27
16
|
|
28
17
|
if options[:track]
|
@@ -3,27 +3,38 @@ require 'rails/railtie'
|
|
3
3
|
module GemActivityTracker
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
initializer "gem_activity_tracker.auto_track" do
|
6
|
-
|
6
|
+
Rails.application.config.after_initialize do
|
7
|
+
# Delay the execution slightly to avoid blocking boot
|
7
8
|
Thread.new do
|
9
|
+
sleep(2) # Give Rails a moment to fully start
|
10
|
+
|
8
11
|
begin
|
9
12
|
path = Rails.root.to_s
|
10
13
|
report_path = File.join(path, "activity_tracker", "report.yml")
|
14
|
+
tracking_enabled = ENV.fetch('GEM_ACTIVITY_TRACKER_ENABLED', 'true') == 'true'
|
15
|
+
|
16
|
+
if tracking_enabled
|
17
|
+
Rails.logger.info "[GemActivityTracker] 🔍 Checking for project changes..."
|
18
|
+
|
19
|
+
last_data = File.exist?(report_path) ? YAML.load_file(report_path) : {}
|
20
|
+
|
21
|
+
current_data = GemActivityTracker::Tracker.collect_data(path)
|
11
22
|
|
12
|
-
|
13
|
-
|
23
|
+
if last_data != current_data
|
24
|
+
Rails.logger.info "[GemActivityTracker] 🔄 Project activity changed. Updating report..."
|
25
|
+
GemActivityTracker::Tracker.track(path)
|
26
|
+
else
|
27
|
+
Rails.logger.info "[GemActivityTracker] ✅ No project changes detected."
|
28
|
+
end
|
14
29
|
|
15
|
-
|
16
|
-
|
17
|
-
GemActivityTracker::Tracker.track(path)
|
30
|
+
Rails.logger.info "[GemActivityTracker] 👀 Starting auto-watcher for #{path}..."
|
31
|
+
GemActivityTracker::Watcher.start(path)
|
18
32
|
else
|
19
|
-
|
33
|
+
Rails.logger.info "[GemActivityTracker] ⚙️ Auto-tracking disabled via ENV."
|
20
34
|
end
|
21
|
-
|
22
|
-
# ✅ Start auto watching
|
23
|
-
puts "👀 Starting auto-watcher for #{path} from Railtie..."
|
24
|
-
GemActivityTracker::Watcher.start(path)
|
25
35
|
rescue => e
|
26
|
-
|
36
|
+
Rails.logger.error "[GemActivityTracker] ⚠️ Error: #{e.message}"
|
37
|
+
Rails.logger.error e.backtrace.join("\n")
|
27
38
|
end
|
28
39
|
end
|
29
40
|
end
|
@@ -1,28 +1,39 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'json'
|
3
3
|
require 'fileutils'
|
4
|
-
require 'psych'
|
5
4
|
require 'csv'
|
6
5
|
require 'digest'
|
6
|
+
require 'active_support/all'
|
7
|
+
require 'active_record'
|
8
|
+
require 'active_support/dependencies'
|
7
9
|
|
8
10
|
module GemActivityTracker
|
9
11
|
class Tracker
|
10
12
|
def self.track(path)
|
11
13
|
puts "🔍 Tracking project at: #{path}"
|
12
|
-
data = collect_data(path)
|
13
14
|
|
15
|
+
if !defined?(Rails) || Rails.root.to_s != path
|
16
|
+
# Only require environment if we're not already inside a Rails app
|
17
|
+
$LOAD_PATH.unshift(path)
|
18
|
+
ENV['RAILS_ENV'] ||= 'development'
|
19
|
+
require File.join(path, 'config', 'environment')
|
20
|
+
end
|
21
|
+
|
22
|
+
data = collect_data(path)
|
14
23
|
FileUtils.mkdir_p("#{path}/activity_tracker")
|
15
24
|
File.write("#{path}/activity_tracker/report.yml", data.to_yaml)
|
16
25
|
|
17
26
|
puts "✅ Report generated at: #{path}/activity_tracker/report.yml"
|
18
27
|
end
|
19
|
-
|
28
|
+
|
20
29
|
def self.collect_data(path)
|
21
30
|
{
|
31
|
+
project_name: File.basename(path),
|
22
32
|
ruby_version: `ruby -v`.strip,
|
23
|
-
rails_version: get_rails_version(path),
|
33
|
+
# rails_version: get_rails_version(path),
|
34
|
+
rails_version: Rails.version,
|
24
35
|
database: detect_database(path),
|
25
|
-
models:
|
36
|
+
models: analyze_models(path),
|
26
37
|
controllers: list_and_count_files(path, "app/controllers"),
|
27
38
|
jobs: list_and_count_files(path, "app/jobs"),
|
28
39
|
mailers: list_and_count_files(path, "app/mailers"),
|
@@ -36,27 +47,18 @@ module GemActivityTracker
|
|
36
47
|
|
37
48
|
def self.report
|
38
49
|
file = "activity_tracker/report.yml"
|
39
|
-
|
40
|
-
puts YAML.load_file(file).to_yaml
|
41
|
-
else
|
42
|
-
puts "❌ No report found. Please run tracking first."
|
43
|
-
end
|
50
|
+
puts File.exist?(file) ? YAML.load_file(file).to_yaml : "❌ No report found."
|
44
51
|
end
|
45
52
|
|
46
53
|
def self.list_and_count_files(base, dir)
|
47
54
|
path = File.join(base, dir)
|
48
55
|
files = Dir.glob("#{path}/**/*.rb").map { |f| f.gsub(base + '/', '') }
|
49
|
-
{
|
50
|
-
count: files.count,
|
51
|
-
files: files
|
52
|
-
}
|
56
|
+
{ count: files.count, files: files }
|
53
57
|
end
|
54
58
|
|
55
59
|
def self.get_rails_version(path)
|
56
60
|
gemfile = File.join(path, 'Gemfile.lock')
|
57
|
-
|
58
|
-
|
59
|
-
File.read(gemfile)[/rails \((.*?)\)/, 1]
|
61
|
+
File.exist?(gemfile) ? File.read(gemfile)[/rails \((.*?)\)/, 1] : 'Not a Rails project'
|
60
62
|
end
|
61
63
|
|
62
64
|
def self.detect_database(path)
|
@@ -83,8 +85,7 @@ module GemActivityTracker
|
|
83
85
|
|
84
86
|
def self.schema_hash(path)
|
85
87
|
file = File.join(path, "db/schema.rb")
|
86
|
-
|
87
|
-
Digest::MD5.hexdigest(File.read(file))
|
88
|
+
File.exist?(file) ? Digest::MD5.hexdigest(File.read(file)) : nil
|
88
89
|
end
|
89
90
|
|
90
91
|
def self.get_git_log(path)
|
@@ -94,6 +95,84 @@ module GemActivityTracker
|
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
98
|
+
def self.analyze_models(path)
|
99
|
+
result = { count: 0, files: [], detailed: {} }
|
100
|
+
|
101
|
+
ActiveSupport::Dependencies.autoload_paths += Dir["#{path}/app/models/**/"]
|
102
|
+
|
103
|
+
Dir.glob("#{path}/app/models/**/*.rb").each do |file|
|
104
|
+
relative_path = file.gsub("#{path}/", '')
|
105
|
+
model_name = relative_path.sub('app/models/', '').sub('.rb', '').camelize
|
106
|
+
|
107
|
+
begin
|
108
|
+
require_dependency file
|
109
|
+
model_class = model_name.constantize
|
110
|
+
next unless model_class < ActiveRecord::Base
|
111
|
+
|
112
|
+
result[:count] += 1
|
113
|
+
result[:files] << relative_path
|
114
|
+
|
115
|
+
# Validations
|
116
|
+
validations = Hash.new { |hash, key| hash[key] = [] }
|
117
|
+
model_class.validators.each do |validator|
|
118
|
+
validator.attributes.each do |attr|
|
119
|
+
validations[attr] << validator.class.name.demodulize.underscore
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Callbacks
|
124
|
+
callbacks = {}
|
125
|
+
ActiveRecord::Callbacks::CALLBACKS.each do |cb|
|
126
|
+
if model_class.respond_to?("_#{cb}_callbacks")
|
127
|
+
methods = model_class.send("_#{cb}_callbacks").map(&:filter).uniq
|
128
|
+
callbacks[cb] = methods.map(&:to_s) if methods.any?
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Enums
|
133
|
+
# debugger
|
134
|
+
enums = model_class.defined_enums.transform_values { |v| v.keys }
|
135
|
+
|
136
|
+
# Associations
|
137
|
+
associations = model_class.reflect_on_all_associations.group_by(&:macro).transform_values { |a| a.map(&:name) }
|
138
|
+
|
139
|
+
# Scopes
|
140
|
+
scopes = model_class.methods(false).select do |method|
|
141
|
+
model_class.method(method).source_location&.first&.include?('/models/')
|
142
|
+
end.select { |m| model_class.respond_to?(m) && model_class.send(m).is_a?(ActiveRecord::Relation) rescue false }
|
143
|
+
|
144
|
+
# Class methods
|
145
|
+
class_methods = (model_class.methods(false) - ActiveRecord::Base.methods)
|
146
|
+
instance_methods = (model_class.instance_methods(false) - ActiveRecord::Base.instance_methods).map(&:to_s)
|
147
|
+
|
148
|
+
# # Comments
|
149
|
+
# comment = File.foreach(file).first if File.read(file).lines.first.strip.start_with?('#')
|
150
|
+
|
151
|
+
result[:detailed][model_class.name] = {
|
152
|
+
table_name: model_class.table_name,
|
153
|
+
file: relative_path,
|
154
|
+
# comment: comment&.strip,
|
155
|
+
attributes: model_class.columns.map(&:name),
|
156
|
+
associations: associations,
|
157
|
+
validations: validations,
|
158
|
+
enums: enums,
|
159
|
+
callbacks: callbacks,
|
160
|
+
scopes: scopes.map(&:to_s),
|
161
|
+
class_methods: class_methods.map(&:to_s),
|
162
|
+
instance_methods: instance_methods,
|
163
|
+
methods_count: model_class.instance_methods(false).count
|
164
|
+
}
|
165
|
+
|
166
|
+
rescue => e
|
167
|
+
result[:detailed][model_name] = { error: "Failed to load: #{e.message}" }
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
result
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
|
97
176
|
def self.export(path, format = :json)
|
98
177
|
file = "#{path}/activity_tracker/report.yml"
|
99
178
|
return puts "❌ Report not found." unless File.exist?(file)
|
@@ -110,7 +189,7 @@ module GemActivityTracker
|
|
110
189
|
data.each do |key, value|
|
111
190
|
if value.is_a?(Hash)
|
112
191
|
csv << [key.to_s, ""]
|
113
|
-
value.each { |k, v| csv << [" #{k}", v] }
|
192
|
+
value.each { |k, v| csv << [" #{k}", v.to_json] }
|
114
193
|
elsif value.is_a?(Array)
|
115
194
|
csv << [key.to_s, "#{value.count} items"]
|
116
195
|
value.each { |item| csv << ["", item] }
|
@@ -12,10 +12,7 @@ module GemActivityTracker
|
|
12
12
|
FileUtils.mkdir_p(File.dirname(log_file))
|
13
13
|
|
14
14
|
any_change = false
|
15
|
-
|
16
15
|
changes.each do |type, files|
|
17
|
-
next if files.empty?
|
18
|
-
|
19
16
|
files.each do |file|
|
20
17
|
timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
21
18
|
relative_path = file.sub("#{path}/", '')
|
@@ -26,10 +23,7 @@ module GemActivityTracker
|
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
|
-
if any_change
|
30
|
-
puts "🔄 Updating activity report..."
|
31
|
-
GemActivityTracker::Tracker.track(path)
|
32
|
-
end
|
26
|
+
GemActivityTracker::Tracker.track(path) if any_change
|
33
27
|
end
|
34
28
|
|
35
29
|
listener.start
|
data/lib/gem_activity_tracker.rb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative "gem_activity_tracker/version"
|
4
4
|
require_relative "gem_activity_tracker/tracker"
|
5
|
-
require_relative "gem_activity_tracker/railtie" if defined?(Rails)
|
6
5
|
require_relative "gem_activity_tracker/watcher"
|
6
|
+
require_relative "gem_activity_tracker/railtie" if defined?(Rails)
|
7
7
|
|
8
8
|
module GemActivityTracker
|
9
9
|
class Error < StandardError; end
|
10
|
-
# Additional code (if needed) goes here
|
11
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_activity_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atul Yadav
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
-
description:
|
28
|
-
|
27
|
+
description: 'A CLI gem to analyze Ruby/Rails projects and track activity: models,
|
28
|
+
migrations, routes, Git, schema, and more.'
|
29
29
|
email:
|
30
30
|
- atulyadav9039@gmail.com
|
31
31
|
executables:
|
@@ -33,25 +33,17 @@ executables:
|
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
|
-
- ".gem_activity_tracker.gemspec.swp"
|
37
|
-
- CHANGELOG.md
|
38
36
|
- README.md
|
39
|
-
- Rakefile
|
40
37
|
- exe/gem_activity_tracker
|
41
|
-
- gem_activity_tracker-0.1.0.gem
|
42
38
|
- lib/gem_activity_tracker.rb
|
43
39
|
- lib/gem_activity_tracker/railtie.rb
|
44
40
|
- lib/gem_activity_tracker/tracker.rb
|
45
41
|
- lib/gem_activity_tracker/version.rb
|
46
42
|
- lib/gem_activity_tracker/watcher.rb
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
metadata:
|
51
|
-
allowed_push_host: https://rubygems.org
|
52
|
-
homepage_uri: https://example.com/gem_activity_tracker
|
53
|
-
source_code_uri: https://example.com/gem_activity_tracker
|
54
|
-
changelog_uri: https://example.com/gem_activity_tracker/CHANGELOG.md
|
43
|
+
homepage: https://github.com/atul13055/gem_activity_tracker
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
55
47
|
post_install_message:
|
56
48
|
rdoc_options: []
|
57
49
|
require_paths:
|
@@ -60,7 +52,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
52
|
requirements:
|
61
53
|
- - ">="
|
62
54
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
55
|
+
version: '2.5'
|
56
|
+
- - "<"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '4.0'
|
64
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
60
|
requirements:
|
66
61
|
- - ">="
|
@@ -70,5 +65,5 @@ requirements: []
|
|
70
65
|
rubygems_version: 3.4.10
|
71
66
|
signing_key:
|
72
67
|
specification_version: 4
|
73
|
-
summary: Track gem
|
68
|
+
summary: Track gem and project activity in Ruby/Rails projects
|
74
69
|
test_files: []
|
Binary file
|
data/CHANGELOG.md
DELETED
data/Rakefile
DELETED
Binary file
|