legacy_column 0.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee20abfdeccbe8272d2ab663d6978c4de1034061750bedc386b9f6538f380f76
4
- data.tar.gz: 751edea2ab275196035179d7d15a93fcd02fc6f8d4e1665123334ff59f251baf
3
+ metadata.gz: 3e0f3e99c2f72f39807384c2224be01fe1edf691d130b841cf5164e6c03fea7d
4
+ data.tar.gz: f6cabee32966225461c81efb9b8eef15b4dc5d7dc0d37d946e8636f4b5eacac1
5
5
  SHA512:
6
- metadata.gz: fd99cfa33049ebdfd7a64bd5589350ae4c963845319b9637afd472f9ee0efae3d6a2e0fe09f14db461cd2f134816dd768829dec347d69da85dfd21ab9ebaa653
7
- data.tar.gz: e1bec36f5e7420cbd1eb25b38b8748cff21afba5f32ff4d533c3fd43b185562b39d0b0c2ad2cc29e732bb37e2e7ed506df0100a3f6c8722beb51277bdca13c7a
6
+ metadata.gz: 011c616903e4d49021400d15f372c8ce9e080dc6d060337448f54e5c377768d61dc7d5f04fd64035f195432341b986b203fb88bcd303c916d8e75d56fe3073d8
7
+ data.tar.gz: c60ecb2598d4281fd947e800b65e0b3f4e6cfdfc006bf945123ef7d28ab49956565f2ad6ffcc724edef0bb3ba797cbfb81fd0a995b204a3d678078d703bba8ec
data/CLAUDE.md ADDED
@@ -0,0 +1,53 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a Ruby gem called `legacy_column` that provides a Rails plugin for warning developers when they attempt to use legacy database columns that should be avoided. The gem uses ActiveSupport::Concern to extend ActiveRecord models with a class method that marks specified columns as legacy and prints warning messages when those columns are modified.
8
+
9
+ ## Core Architecture
10
+
11
+ - **Main module**: `lib/legacy_column.rb` - The core concern that provides the `legacy_column` class method and warning functionality
12
+ - **Rails integration**: `lib/legacy_column/railtie.rb` - Handles automatic inclusion into ActiveRecord::Base when Rails is present
13
+ - **Version file**: `lib/legacy_column/version.rb` - Contains gem version constant
14
+ - **Entry points**: `init.rb` and `rails/init.rb` - Legacy entry points for older Rails versions
15
+
16
+ The gem works by:
17
+ 1. Including the LegacyColumn concern into ActiveRecord::Base
18
+ 2. Adding a `legacy_column` class method that accepts column names and an optional message
19
+ 3. Setting up a `before_validation` callback that checks for changes to legacy columns
20
+ 4. Printing warnings to stdout when legacy columns are modified
21
+
22
+ ## Development Commands
23
+
24
+ ### Setup
25
+ ```bash
26
+ bin/setup # Install dependencies
27
+ ```
28
+
29
+ ### Testing
30
+ ```bash
31
+ bundle exec rake # Run all tests (default rake task)
32
+ bundle exec rspec # Run tests directly with RSpec
33
+ ```
34
+
35
+ ### Building
36
+ ```bash
37
+ bundle exec rake build # Build the gem
38
+ bundle exec rake install # Install gem locally
39
+ bundle exec rake release # Release gem (bumps version, creates git tag, pushes to rubygems)
40
+ ```
41
+
42
+ ## Test Database Configuration
43
+
44
+ The test suite uses SQLite3 with configuration in `spec/db/database.yml` and schema in `spec/db/schema.rb`. Tests create a temporary User model to test the legacy column functionality.
45
+
46
+ ## Dependencies
47
+
48
+ - **Runtime**: ActiveSupport >= 4.0.0, ActiveRecord >= 4.0.0
49
+ - **Development**: RSpec 3.2+, SQLite3 1.4.2+, Bundler 2.2.33+, Rake 13.0.1+
50
+
51
+ ## CI/CD
52
+
53
+ CircleCI configuration uses Ruby 2.6.3 and runs `bundle exec rake` to execute the test suite.
data/Gemfile.lock CHANGED
@@ -1,29 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- legacy_column (0.1.2)
5
- activerecord (>= 4.0.0)
6
- activesupport (>= 4.0.0)
4
+ legacy_column (0.2.0)
5
+ activerecord (>= 5.2.0, < 9.0)
6
+ activesupport (>= 5.2.0, < 9.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- activemodel (6.1.4.4)
12
- activesupport (= 6.1.4.4)
13
- activerecord (6.1.4.4)
14
- activemodel (= 6.1.4.4)
15
- activesupport (= 6.1.4.4)
16
- activesupport (6.1.4.4)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ activemodel (8.0.2.1)
12
+ activesupport (= 8.0.2.1)
13
+ activerecord (8.0.2.1)
14
+ activemodel (= 8.0.2.1)
15
+ activesupport (= 8.0.2.1)
16
+ timeout (>= 0.4.0)
17
+ activesupport (8.0.2.1)
18
+ base64
19
+ benchmark (>= 0.3)
20
+ bigdecimal
21
+ concurrent-ruby (~> 1.0, >= 1.3.1)
22
+ connection_pool (>= 2.2.5)
23
+ drb
18
24
  i18n (>= 1.6, < 2)
25
+ logger (>= 1.4.2)
19
26
  minitest (>= 5.1)
20
- tzinfo (~> 2.0)
21
- zeitwerk (~> 2.3)
22
- concurrent-ruby (1.1.9)
27
+ securerandom (>= 0.3)
28
+ tzinfo (~> 2.0, >= 2.0.5)
29
+ uri (>= 0.13.1)
30
+ base64 (0.3.0)
31
+ benchmark (0.4.1)
32
+ bigdecimal (3.2.3)
33
+ concurrent-ruby (1.3.5)
34
+ connection_pool (2.5.4)
23
35
  diff-lcs (1.4.4)
24
- i18n (1.8.11)
36
+ drb (2.2.3)
37
+ i18n (1.14.7)
25
38
  concurrent-ruby (~> 1.0)
26
- minitest (5.15.0)
39
+ logger (1.7.0)
40
+ mini_portile2 (2.8.9)
41
+ minitest (5.25.5)
27
42
  rake (13.0.1)
28
43
  rspec (3.9.0)
29
44
  rspec-core (~> 3.9.0)
@@ -38,10 +53,13 @@ GEM
38
53
  diff-lcs (>= 1.2.0, < 2.0)
39
54
  rspec-support (~> 3.9.0)
40
55
  rspec-support (3.9.3)
41
- sqlite3 (1.4.2)
42
- tzinfo (2.0.4)
56
+ securerandom (0.4.1)
57
+ sqlite3 (2.7.3)
58
+ mini_portile2 (~> 2.8.0)
59
+ timeout (0.4.3)
60
+ tzinfo (2.0.6)
43
61
  concurrent-ruby (~> 1.0)
44
- zeitwerk (2.5.3)
62
+ uri (1.0.3)
45
63
 
46
64
  PLATFORMS
47
65
  ruby
@@ -51,7 +69,7 @@ DEPENDENCIES
51
69
  legacy_column!
52
70
  rake (~> 13.0.1)
53
71
  rspec (~> 3.2)
54
- sqlite3 (~> 1.4.2)
72
+ sqlite3 (>= 1.4.0)
55
73
 
56
74
  BUNDLED WITH
57
75
  2.3.4
data/README.md CHANGED
@@ -7,11 +7,23 @@ A gem that will print a message if a developer is trying to use a column that is
7
7
 
8
8
  ## Installation
9
9
 
10
+ Add this line to your application's Gemfile:
10
11
 
11
12
  ```ruby
12
13
  gem 'legacy_column'
13
14
  ```
14
15
 
16
+ And then execute:
17
+ ```bash
18
+ bundle install
19
+ ```
20
+
21
+ ## Compatibility
22
+
23
+ This gem supports:
24
+ - Ruby 2.7+
25
+ - Rails 5.2+, 6.0+, 6.1+, 7.0+, 7.1+, 7.2+, 8.0+
26
+
15
27
  ## Usage
16
28
 
17
29
  Just list the column names:
@@ -24,7 +36,7 @@ A custom message can be added:
24
36
  legacy_column :old_email, :old_phone_number, message: 'Do not touch this!!!'
25
37
  ```
26
38
 
27
- It will output something like this in rails logs:
39
+ It will output something like this in Rails logs:
28
40
 
29
41
  ```
30
42
  Use of legacy column detected.
@@ -32,6 +44,12 @@ Use of legacy column detected.
32
44
  Do not touch this!!!
33
45
  ```
34
46
 
47
+ ## Output
48
+
49
+ The gem will:
50
+ - Log warnings to `Rails.logger` when Rails is available
51
+ - Fall back to `puts` for non-Rails environments or when Rails.logger is not available
52
+
35
53
  ## Contributing
36
54
  Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
37
55
 
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_rubygems_version = ">= 1.3.4"
20
20
 
21
- spec.add_dependency "activesupport", [">= 4.0.0"]
22
- spec.add_dependency "activerecord", [">= 4.0.0"]
21
+ spec.add_dependency "activesupport", [">= 5.2.0", "< 9.0"]
22
+ spec.add_dependency "activerecord", [">= 5.2.0", "< 9.0"]
23
23
  spec.add_development_dependency "bundler", ">= 2.2.33"
24
24
  spec.add_development_dependency "rake", "~> 13.0.1"
25
25
  spec.add_development_dependency "rspec", "~> 3.2"
26
- spec.add_development_dependency "sqlite3", "~> 1.4.2"
26
+ spec.add_development_dependency "sqlite3", ">= 1.4.0"
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module LegacyColumn
2
- VERSION = '0.1.2'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/legacy_column.rb CHANGED
@@ -27,8 +27,12 @@ module LegacyColumn
27
27
 
28
28
  def legacy_column
29
29
  legacy_column_names.each do |column|
30
- if changed_attributes.key?(column.to_s)
31
- puts "\n\nUSE of legacy column detected.\n #{self.class} => #{column}\n #{legacy_column_message}\n\n"
30
+ if changes_to_save.key?(column.to_s)
31
+ if defined?(Rails) && Rails.logger
32
+ Rails.logger.warn "\n\nUSE of legacy column detected.\n #{self.class} => #{column}\n #{legacy_column_message}\n\n"
33
+ else
34
+ puts "\n\nUSE of legacy column detected.\n #{self.class} => #{column}\n #{legacy_column_message}\n\n"
35
+ end
32
36
  end
33
37
  end
34
38
  end
data/spec/db/test.sqlite3 CHANGED
Binary file
data/spec/spec_helper.rb CHANGED
@@ -5,8 +5,14 @@ require "active_record"
5
5
  require "yaml"
6
6
 
7
7
  config = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'db', 'database.yml')))
8
- ActiveRecord::Base.configurations = {'test' => config[ENV['DB'] || 'sqlite3']}
9
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
8
+ db_config = config[ENV['DB'] || 'sqlite3']
9
+
10
+ if ActiveRecord::VERSION::MAJOR >= 6
11
+ ActiveRecord::Base.establish_connection(db_config)
12
+ else
13
+ ActiveRecord::Base.configurations = {'test' => db_config}
14
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
15
+ end
10
16
 
11
17
  # Load Test Schema into the Database
12
18
  load(File.dirname(__FILE__) + "/db/schema.rb")
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legacy_column
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksander Lopez Yazikov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -16,28 +15,40 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 4.0.0
18
+ version: 5.2.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ">="
25
27
  - !ruby/object:Gem::Version
26
- version: 4.0.0
28
+ version: 5.2.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9.0'
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: activerecord
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
36
  - - ">="
32
37
  - !ruby/object:Gem::Version
33
- version: 4.0.0
38
+ version: 5.2.0
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '9.0'
34
42
  type: :runtime
35
43
  prerelease: false
36
44
  version_requirements: !ruby/object:Gem::Requirement
37
45
  requirements:
38
46
  - - ">="
39
47
  - !ruby/object:Gem::Version
40
- version: 4.0.0
48
+ version: 5.2.0
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '9.0'
41
52
  - !ruby/object:Gem::Dependency
42
53
  name: bundler
43
54
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +95,16 @@ dependencies:
84
95
  name: sqlite3
85
96
  requirement: !ruby/object:Gem::Requirement
86
97
  requirements:
87
- - - "~>"
98
+ - - ">="
88
99
  - !ruby/object:Gem::Version
89
- version: 1.4.2
100
+ version: 1.4.0
90
101
  type: :development
91
102
  prerelease: false
92
103
  version_requirements: !ruby/object:Gem::Requirement
93
104
  requirements:
94
- - - "~>"
105
+ - - ">="
95
106
  - !ruby/object:Gem::Version
96
- version: 1.4.2
107
+ version: 1.4.0
97
108
  description: A gem that will print a message if a developer is trying to use a column
98
109
  that is from a legacy system but has to stay there.
99
110
  email:
@@ -102,6 +113,7 @@ executables: []
102
113
  extensions: []
103
114
  extra_rdoc_files: []
104
115
  files:
116
+ - CLAUDE.md
105
117
  - Gemfile
106
118
  - Gemfile.lock
107
119
  - README.md
@@ -120,7 +132,6 @@ homepage: https://github.com/logicalgroove/legacy_column
120
132
  licenses:
121
133
  - MIT
122
134
  metadata: {}
123
- post_install_message:
124
135
  rdoc_options: []
125
136
  require_paths:
126
137
  - lib
@@ -135,8 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
146
  - !ruby/object:Gem::Version
136
147
  version: 1.3.4
137
148
  requirements: []
138
- rubygems_version: 3.2.27
139
- signing_key:
149
+ rubygems_version: 3.6.9
140
150
  specification_version: 4
141
151
  summary: Warning for your legacy columns.
142
152
  test_files: []