rails_action_tracker 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ac49da8b8c381b52b130ff021067565cfc75f0a9ca0ddd33d02d91f6858ffed
4
+ data.tar.gz: '0097165c635b76cf03054f6b235f49e5b9d237fcd696fcd2617ac22a120b96e0'
5
+ SHA512:
6
+ metadata.gz: 28e478e066c0a7789ee22ea02fac9cdd622328c71c80bcb5f9ed8e3f31a626645d06ddfd677175d369647cec0986fc726f8559c3d6377190d6d70771ded18917
7
+ data.tar.gz: a6b6e669e028b166c975744da0dec15071c748a4609f64aa85a64455d1761b069ec53a9d090fddf9b975f62997d63b86ac7060734576c15632ec15ec9c7fcc1b
data/.rubocop.yml ADDED
@@ -0,0 +1,61 @@
1
+ AllCops:
2
+ SuggestExtensions: false
3
+ TargetRubyVersion: 2.7
4
+
5
+ Style/StringLiterals:
6
+ EnforcedStyle: single_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ EnforcedStyle: single_quotes
10
+
11
+ # We want consistent documentation but not strict
12
+ Style/Documentation:
13
+ Enabled: false
14
+
15
+ # Allow long lines in some contexts
16
+ Layout/LineLength:
17
+ Max: 120
18
+ Exclude:
19
+ - 'Rakefile'
20
+ - '**/*.gemspec'
21
+
22
+ # Disable some metrics that are too strict for test files
23
+ Metrics/BlockLength:
24
+ Exclude:
25
+ - 'test/**/*'
26
+ - 'spec/**/*'
27
+ - '**/*.gemspec'
28
+
29
+ Metrics/MethodLength:
30
+ Exclude:
31
+ - 'test/**/*'
32
+ - 'spec/**/*'
33
+
34
+ # Allow multiple classes in one file for test helpers
35
+ Style/ClassAndModuleChildren:
36
+ Enabled: false
37
+
38
+ # Reasonable limits for a gem project
39
+ Metrics/ClassLength:
40
+ Max: 200
41
+ Exclude:
42
+ - 'lib/rails_action_tracker/tracker.rb'
43
+
44
+ Metrics/MethodLength:
45
+ Max: 30
46
+ Exclude:
47
+ - 'test/**/*'
48
+ - 'spec/**/*'
49
+
50
+ Metrics/CyclomaticComplexity:
51
+ Max: 15
52
+
53
+ Metrics/PerceivedComplexity:
54
+ Max: 15
55
+
56
+ # Disable complex assignment checks in tests
57
+ Metrics/AbcSize:
58
+ Max: 40
59
+ Exclude:
60
+ - 'test/**/*'
61
+ - 'spec/**/*'
data/Appraisals ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Appraisals for testing against Rails versions
4
+ # Starting simple with Rails 6 versions, will expand later
5
+
6
+ appraise 'rails-6.0' do
7
+ gem 'activesupport', '~> 6.0.0'
8
+ gem 'actionpack', '~> 6.0.0'
9
+ gem 'railties', '~> 6.0.0'
10
+ end
11
+
12
+ appraise 'rails-6.1' do
13
+ gem 'activesupport', '~> 6.1.0'
14
+ gem 'actionpack', '~> 6.1.0'
15
+ gem 'railties', '~> 6.1.0'
16
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
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.1.0] - 2025-01-02
11
+
12
+ ### Added
13
+ - Initial release of RailsActionTracker gem
14
+ - ActiveRecord model read/write operation tracking
15
+ - Service usage detection (Redis, Sidekiq, Pusher, HTTP calls, etc.)
16
+ - Configurable logging options:
17
+ - Rails logger output with colors
18
+ - Separate log file output (plain text)
19
+ - Both destinations simultaneously
20
+ - Controller and action name display in output
21
+ - Thread-safe tracking using thread-local storage
22
+ - Automatic Rails middleware integration
23
+ - Ignored tables configuration (PostgreSQL system tables, Rails internals)
24
+ - Custom service detection patterns
25
+ - Rails generator for easy setup (`rails generate rails_action_tracker:install`)
26
+ - Comprehensive test suite with 45 tests, 188 assertions
27
+ - Multi-Rails version support (5.0-8.0) via Appraisal
28
+ - Multi-Ruby version support (2.7-3.4)
29
+ - GitHub Actions CI/CD pipeline
30
+ - Colorized tabular output format
31
+
32
+ ### Features
33
+ - **Model Tracking**: Tracks SELECT, INSERT, UPDATE operations on database tables
34
+ - **Service Detection**: Automatically detects common services from log messages
35
+ - **Flexible Configuration**: Multiple logging destinations and custom patterns
36
+ - **Performance Optimized**: Minimal overhead, skips tracking for assets and test environment
37
+ - **Rails Integration**: Seamless integration via Railtie and middleware
38
+ - **Developer Friendly**: Easy setup with generator and comprehensive documentation
39
+
40
+ [Unreleased]: https://github.com/deepakmahakale/rails_action_tracker/compare/v0.1.0...HEAD
41
+ [0.1.0]: https://github.com/deepakmahakale/rails_action_tracker/releases/tag/v0.1.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,172 @@
1
+ # Contributing to RailsActionTracker
2
+
3
+ We welcome contributions to RailsActionTracker! This document provides guidelines for contributing to the project.
4
+
5
+ ## Getting Started
6
+
7
+ Before contributing, please:
8
+ 1. Read this document completely
9
+ 2. Check existing issues and pull requests
10
+ 3. Set up your development environment (see [DEVELOPMENT.md](DEVELOPMENT.md))
11
+
12
+ ## Types of Contributions
13
+
14
+ ### Bug Reports
15
+ - **Search existing issues** first to avoid duplicates
16
+ - **Use the issue template** if available
17
+ - **Provide clear steps to reproduce** the bug
18
+ - **Include relevant system information** (Ruby version, Rails version, gem version)
19
+ - **Add error messages** and stack traces when applicable
20
+
21
+ ### Feature Requests
22
+ - **Explain the use case** for your proposed feature
23
+ - **Provide examples** of how it would be used
24
+ - **Consider backward compatibility** implications
25
+ - **Discuss implementation approach** if you have ideas
26
+
27
+ ### Code Contributions
28
+ - **Fork the repository** and create a feature branch
29
+ - **Follow coding standards** (see Code Style section below)
30
+ - **Write comprehensive tests** for your changes
31
+ - **Update documentation** when needed
32
+ - **Ensure CI passes** before submitting
33
+
34
+ ## Development Process
35
+
36
+ ### 1. Fork and Clone
37
+ ```bash
38
+ git clone https://github.com/YOUR_USERNAME/rails_action_tracker.git
39
+ cd rails_action_tracker
40
+ ```
41
+
42
+ ### 2. Create Feature Branch
43
+ ```bash
44
+ git checkout -b feature/your-feature-name
45
+ # or
46
+ git checkout -b fix/issue-description
47
+ ```
48
+
49
+ ### 3. Make Changes
50
+ - Follow the coding standards outlined below
51
+ - Write or update tests for your changes
52
+ - Update documentation if needed
53
+
54
+ ### 4. Test Your Changes
55
+ ```bash
56
+ # Run the full test suite
57
+ bundle exec rake test
58
+
59
+ # Test against multiple Rails versions
60
+ ./script/test-all
61
+
62
+ # Check code style
63
+ bundle exec rubocop
64
+ ```
65
+
66
+ ### 5. Submit Pull Request
67
+ - **Write a clear title** and description
68
+ - **Reference related issues** using keywords like "Closes #123"
69
+ - **Explain your changes** and why they're needed
70
+ - **Include screenshots** for UI changes (if applicable)
71
+
72
+ ## Code Style
73
+
74
+ ### Ruby Style Guide
75
+ We use RuboCop to enforce code style. Key points:
76
+ - **Use single quotes** for string literals
77
+ - **2 spaces** for indentation
78
+ - **Line length**: 120 characters maximum
79
+ - **Follow Ruby community conventions**
80
+
81
+ ### Testing Standards
82
+ - **Write tests** for all new functionality
83
+ - **Update existing tests** when modifying behavior
84
+ - **Use descriptive test names** that explain what is being tested
85
+ - **Follow existing test patterns** in the codebase
86
+
87
+ ### Documentation Standards
88
+ - **Update README.md** for user-facing changes
89
+ - **Add inline comments** for complex logic
90
+ - **Update CHANGELOG.md** for notable changes
91
+ - **Use clear, concise language**
92
+
93
+ ## Commit Guidelines
94
+
95
+ ### Commit Messages
96
+ Follow these guidelines for commit messages:
97
+ - **Use present tense** ("Add feature" not "Added feature")
98
+ - **Use imperative mood** ("Move cursor to..." not "Moves cursor to...")
99
+ - **Limit first line to 72 characters**
100
+ - **Reference issues and pull requests** when applicable
101
+
102
+ ### Examples
103
+ ```
104
+ Add support for custom service detection patterns
105
+
106
+ - Allow users to specify custom regex patterns for service detection
107
+ - Update configuration documentation
108
+ - Add comprehensive tests
109
+
110
+ Closes #123
111
+ ```
112
+
113
+ ## Review Process
114
+
115
+ ### What to Expect
116
+ - **All PRs require review** before merging
117
+ - **Automated tests** must pass
118
+ - **Code style checks** must pass
119
+ - **Maintainer feedback** may require changes
120
+
121
+ ### How to Address Feedback
122
+ - **Respond to all comments** even if just to acknowledge
123
+ - **Make requested changes** in new commits (don't force push)
124
+ - **Ask for clarification** if feedback is unclear
125
+ - **Be patient and respectful** during the review process
126
+
127
+ ## Release Process
128
+
129
+ Releases are handled by maintainers:
130
+ 1. Version bump in `lib/rails_action_tracker/version.rb`
131
+ 2. Update `CHANGELOG.md` with changes
132
+ 3. Create git tag and push to GitHub
133
+ 4. Build and push gem to RubyGems
134
+
135
+ ## Code of Conduct
136
+
137
+ ### Our Pledge
138
+ We are committed to providing a friendly, safe, and welcoming environment for all contributors.
139
+
140
+ ### Expected Behavior
141
+ - **Be respectful** and inclusive
142
+ - **Accept constructive feedback** gracefully
143
+ - **Focus on what's best** for the community
144
+ - **Show empathy** towards other community members
145
+
146
+ ### Unacceptable Behavior
147
+ - **Harassment** of any form
148
+ - **Discriminatory language** or behavior
149
+ - **Personal attacks** or trolling
150
+ - **Publishing private information** without consent
151
+
152
+ ## Getting Help
153
+
154
+ ### Resources
155
+ - **Documentation**: Check README.md and other docs first
156
+ - **Development Setup**: See [DEVELOPMENT.md](DEVELOPMENT.md)
157
+ - **Issues**: Search existing issues for similar problems
158
+ - **Discussions**: Use GitHub Discussions for questions
159
+
160
+ ### Contact
161
+ - **GitHub Issues**: For bugs and feature requests
162
+ - **GitHub Discussions**: For general questions
163
+ - **Email**: For security issues or private matters
164
+
165
+ ## Recognition
166
+
167
+ Contributors are recognized in:
168
+ - **CHANGELOG.md** for notable contributions
169
+ - **GitHub contributors page** automatically
170
+ - **Release notes** for significant features
171
+
172
+ Thank you for contributing to RailsActionTracker! 🎉
data/DEVELOPMENT.md ADDED
@@ -0,0 +1,191 @@
1
+ # Development Guide
2
+
3
+ We welcome contributions! Here's how to get started with development and testing.
4
+
5
+ ## Prerequisites
6
+
7
+ - Ruby 2.7+ (we test against 2.7, 3.0, 3.1, 3.4)
8
+ - Bundler
9
+ - Git
10
+
11
+ ## Setup
12
+
13
+ 1. **Clone the repository**
14
+ ```bash
15
+ git clone https://github.com/deepakmahakale/rails_action_tracker.git
16
+ cd rails_action_tracker
17
+ ```
18
+
19
+ 2. **Install dependencies**
20
+ ```bash
21
+ bundle install
22
+ ```
23
+
24
+ 3. **Generate Appraisal gemfiles** (for multi-Rails version testing)
25
+ ```bash
26
+ bundle exec appraisal install
27
+ ```
28
+
29
+ ## Testing
30
+
31
+ ### Quick Tests (Current Ruby + Latest Rails)
32
+ ```bash
33
+ # Run all tests with current setup
34
+ bundle exec rake test
35
+
36
+ # Run with verbose output
37
+ bundle exec rake test TESTOPTS="-v"
38
+ ```
39
+
40
+ ### Multi-Rails Version Testing
41
+ ```bash
42
+ # Test against specific Rails version
43
+ bundle exec appraisal rails-7.1 rake test
44
+ bundle exec appraisal rails-6.1 rake test
45
+
46
+ # Test all Rails versions (comprehensive)
47
+ ./script/test-all
48
+ ```
49
+
50
+ ### Multi-Ruby Version Testing
51
+ We use GitHub Actions for multi-Ruby testing, but you can test locally with rbenv/rvm:
52
+
53
+ ```bash
54
+ # Example with rbenv
55
+ rbenv shell 3.1.0
56
+ bundle install
57
+ bundle exec rake test
58
+
59
+ rbenv shell 2.7.6
60
+ bundle install
61
+ bundle exec rake test
62
+ ```
63
+
64
+ ## Code Quality
65
+
66
+ ### Run RuboCop (linting)
67
+ ```bash
68
+ # Check for style issues
69
+ bundle exec rubocop
70
+
71
+ # Auto-fix issues where possible
72
+ bundle exec rubocop -a
73
+ ```
74
+
75
+ ### Run Security Checks
76
+ ```bash
77
+ # Install and run bundle audit
78
+ gem install bundler-audit
79
+ bundle audit --update
80
+
81
+ # Install and run Brakeman (if you have a Rails app structure)
82
+ gem install brakeman
83
+ brakeman --rails4 --no-pager
84
+ ```
85
+
86
+ ## Testing Your Changes
87
+
88
+ ### Test Different Scenarios
89
+ ```bash
90
+ # Test specific functionality
91
+ bundle exec ruby -Ilib:test test/test_tracker.rb
92
+ bundle exec ruby -Ilib:test test/test_middleware.rb
93
+
94
+ # Test with different configurations
95
+ RAILS_ENV=development bundle exec rake test
96
+ RAILS_ENV=production bundle exec rake test
97
+ ```
98
+
99
+ ### Manual Testing in Rails App
100
+ 1. Build the gem locally:
101
+ ```bash
102
+ gem build rails_action_tracker.gemspec
103
+ ```
104
+
105
+ 2. In a Rails app, use the local gem:
106
+ ```ruby
107
+ # Gemfile
108
+ gem 'rails_action_tracker', path: '/path/to/local/rails_action_tracker'
109
+ # or
110
+ gem 'rails_action_tracker', '~> 0.1.0', path: '/path/to/local/rails_action_tracker'
111
+ ```
112
+
113
+ 3. Test the functionality:
114
+ ```bash
115
+ cd your_rails_app
116
+ bundle install
117
+ rails generate rails_action_tracker:install
118
+ rails server
119
+ # Make requests and observe the tracking output
120
+ ```
121
+
122
+ ## Supported Versions
123
+
124
+ The gem is tested against these combinations:
125
+
126
+ **Ruby Versions:**
127
+ - 2.7.x
128
+ - 3.0.x
129
+ - 3.1.x
130
+ - 3.4.x
131
+
132
+ **Rails Versions:**
133
+ - 5.0.x, 5.1.x, 5.2.x (Ruby 2.7 only)
134
+ - 6.0.x (Ruby 2.7, 3.0 only)
135
+ - 6.1.x, 7.0.x, 7.1.x (Ruby 2.7, 3.0, 3.1, 3.4)
136
+ - 8.0.x (Ruby 3.0, 3.1, 3.4 only)
137
+
138
+ ## Debugging
139
+
140
+ ### Enable Verbose Logging
141
+ ```ruby
142
+ # In your test or Rails app
143
+ RailsActionTracker::Tracker.configure(
144
+ print_to_rails_log: true,
145
+ write_to_file: true,
146
+ log_file_path: 'debug_tracker.log'
147
+ )
148
+ ```
149
+
150
+ ### Test Individual Components
151
+ ```bash
152
+ # Test just the tracker
153
+ bundle exec ruby -Ilib -e "require 'rails_action_tracker'; puts 'Loaded successfully'"
154
+
155
+ # Test SQL parsing
156
+ bundle exec ruby -Ilib:test -e "
157
+ require 'test_helper'
158
+ tracker = RailsActionTracker::Tracker
159
+ tracker.start_tracking
160
+ tracker.send(:log_query, 'SELECT * FROM users WHERE id = 1')
161
+ puts tracker.stop_tracking
162
+ "
163
+ ```
164
+
165
+ ## Release Process
166
+
167
+ To release a new version:
168
+
169
+ 1. Update the version number in `lib/rails_action_tracker/version.rb`
170
+ 2. Update `CHANGELOG.md` with new changes
171
+ 3. Run the full test suite: `./script/test-all`
172
+ 4. Commit changes: `git commit -am 'Release v0.x.x'`
173
+ 5. Create git tag: `git tag v0.x.x`
174
+ 6. Push changes: `git push origin master --tags`
175
+ 7. Build and push gem: `bundle exec rake release`
176
+
177
+ ## Project Structure
178
+
179
+ ```
180
+ ├── lib/
181
+ │ ├── rails_action_tracker/
182
+ │ │ ├── tracker.rb # Core tracking logic
183
+ │ │ ├── middleware.rb # Rails middleware integration
184
+ │ │ ├── railtie.rb # Rails engine integration
185
+ │ │ └── version.rb # Version definition
186
+ │ └── rails_action_tracker.rb # Main entry point
187
+ ├── test/ # Test suite
188
+ ├── gemfiles/ # Appraisal-generated gemfiles
189
+ ├── script/test-all # Multi-version testing script
190
+ └── .github/workflows/ci.yml # GitHub Actions CI
191
+ ```
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Deepak Mahakale
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.