activerecord-normalizations 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +18 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +96 -0
- data/Rakefile +10 -0
- data/activerecord-normalizations.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/activerecord-normalizations.rb +2 -0
- data/lib/activerecord-normalizations/normalizations.rb +83 -0
- data/lib/activerecord-normalizations/normalizers/spaces_normalizer.rb +29 -0
- data/lib/activerecord-normalizations/normalizers/text_transform_normalizer.rb +26 -0
- data/lib/activerecord-normalizations/railtie.rb +11 -0
- data/lib/activerecord-normalizations/version.rb +5 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb7d93cba49064fa20b5453e5124c018f1ffdd6520bc0cbd4bf54fc97cbb35c7
|
4
|
+
data.tar.gz: a5c16649bbfcca2abc18a8acd39fcceb598291598fbb6b2945c84fa9ab944353
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01646026f5ea34cff910dd0b5fad30c8369f84f1b57704c6f3ac961a68d017bba20283dd68592f51734776c48a83c4dc0dc5802cb17d8cd39386f0b33daa0289
|
7
|
+
data.tar.gz: c53c5988aec6e6114fab25467ca91bdba2c8ee0945015010b64d31b1a20804b746789c6faafdd78c34e1eadf1b229fa64ca4cf546681b80b6b06ffa1449d2136
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
env:
|
6
|
+
- "RAILS_VERSION=5.2.0"
|
7
|
+
- "RAILS_VERSION=6.0.0"
|
8
|
+
- "RAILS_VERSION=6.1.0"
|
9
|
+
rvm:
|
10
|
+
- 2.6.5
|
11
|
+
- 2.7.2
|
12
|
+
- 3.0.0
|
13
|
+
before_install: gem update bundler
|
14
|
+
jobs:
|
15
|
+
exclude:
|
16
|
+
- rvm: 3.0.0
|
17
|
+
env: "RAILS_VERSION=5.2.0"
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at cocchi.c@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in activerecord-normalizations.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
rails_version = ENV['RAILS_VERSION'] || 'default'
|
7
|
+
|
8
|
+
version = case rails_version
|
9
|
+
when 'master'
|
10
|
+
{ github: 'rails/rails' }
|
11
|
+
when "default"
|
12
|
+
'~> 6.1.3'
|
13
|
+
else
|
14
|
+
"~> #{rails_version}"
|
15
|
+
end
|
16
|
+
|
17
|
+
gem 'activerecord', version
|
18
|
+
gem 'activesupport', version
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Christopher Cocchi-Perrier
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 ccocchi
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# ActiveRecord::Normalizations
|
2
|
+
|
3
|
+
`ActiveRecord::Normalizations` gives you the possibility to transform, or normalize, your attributes before they are saved in your database. It behaves mostly like validations, applying normalizations in methods like `save` or `update` but being totally skipped when methods touching directly the database like `update_columns`.
|
4
|
+
|
5
|
+
## Compatibility
|
6
|
+
|
7
|
+
### Ruby
|
8
|
+
|
9
|
+
Currently supported Ruby versions: MRI 2.5, 2.6, 2.7, 3.0.
|
10
|
+
JRuby hasn't been tested but since it's purely Ruby, it should work fine with it.
|
11
|
+
|
12
|
+
### Rails
|
13
|
+
|
14
|
+
Any version of ActiveRecord >= 4.2. It is tested against AR 5.2, 6.0, 6.1
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'activerecord-normalizations'
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
`ActiveRecord::Normalizations` is included in `ActiveRecord::Base` by default so you can directly use the `normalize` method in your models:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
class User
|
28
|
+
normalizes :firstname, spaces: true, text_transform: :capitalize
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
The first argument is the attribute you want to normalize, and each subsequent option are the normalizers that are going to me applied to it, each with their option (much like ActiveRecord'd validations).
|
33
|
+
|
34
|
+
## Normalizers
|
35
|
+
|
36
|
+
The gem comes with the following normalizers:
|
37
|
+
|
38
|
+
### Spaces
|
39
|
+
|
40
|
+
Available mode: `:leading, :trailing, :both (default)`
|
41
|
+
|
42
|
+
This normalizer removes leading, trailing or both spaces from your attribute. It uses Ruby's `strip` methods family under the hood.
|
43
|
+
|
44
|
+
### TextTransform
|
45
|
+
|
46
|
+
Available mode: `:capitalize, :lowercase, :uppercase, :word_capitalize`
|
47
|
+
|
48
|
+
This normalizer transforms your string attribute per the given mode:
|
49
|
+
|
50
|
+
* `capitalize`, `lowercase` and `uppercase` are pretty straight-forward and use Ruby's equivalent methods
|
51
|
+
* `word_capitalize` will capitalize every word of a string, a word being 1 or more alpha characters. Useful when dealing with foreign names like `Jean-Michel` or `O'Connor`.
|
52
|
+
|
53
|
+
## Custom Normalizer
|
54
|
+
|
55
|
+
You can also define your own normalizers. They should be classes following the naming format `<option_name>Normalizer`, initialized with an options hash and responding to the `call` method with a single argument, the attribute to normalize.
|
56
|
+
|
57
|
+
For example, if you wanted to reverse your attribute you could do create the following class
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
# app/normalizers/reverse_normalizer.rb
|
61
|
+
class ReverseNormalizer
|
62
|
+
def initialize(*args)
|
63
|
+
end
|
64
|
+
|
65
|
+
def call(attr)
|
66
|
+
attr.reverse
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
then use it in your model like any other normalizer
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
# app/models/user.rb
|
75
|
+
class User < ApplicationRecord
|
76
|
+
normalizes :name, reverse: true
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
You can check the [normalizers](https://github.com/ccocchi/activerecord-normalizations/tree/main/lib/activerecord-normalizations/normalizers) folder to see how included normalizers are done.
|
81
|
+
|
82
|
+
## Development
|
83
|
+
|
84
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ccocchi/activerecord-normalizations. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
89
|
+
|
90
|
+
## License
|
91
|
+
|
92
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
93
|
+
|
94
|
+
## Code of Conduct
|
95
|
+
|
96
|
+
Everyone interacting in the ActiveRecord::Normalizations project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ccocchi/activerecord-normalizations/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "activerecord-normalizations/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "activerecord-normalizations"
|
8
|
+
spec.version = ActiveRecord::Normalizations::VERSION
|
9
|
+
spec.authors = ["ccocchi"]
|
10
|
+
spec.email = ["cocchi.c@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Normalize your ActiveRecord models' attributes"
|
13
|
+
spec.homepage = "https://github.com/ccocchi/activerecord-normalizations"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "activerecord", ">= 4.2", "< 7"
|
26
|
+
spec.add_dependency "activesupport", ">= 4.2", "< 7"
|
27
|
+
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
30
|
+
spec.add_development_dependency "activerecord-nulldb-adapter", "~> 0.7.0"
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "activerecord/normalizations"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module ActiveRecord::Normalizations
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class_attribute :_normalizers, instance_writer: false, default: Hash.new { |h, k| h[k] = [] }
|
8
|
+
end
|
9
|
+
|
10
|
+
SHARED_OPTIONS = [:on, :if, :unless].freeze
|
11
|
+
DEFAULT_OPTIONS = {}.freeze
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
#
|
15
|
+
# normalize :firstname, spaces: true, text_transform: :capitalize
|
16
|
+
#
|
17
|
+
def normalizes(attr, **normalizations)
|
18
|
+
attr_str = attr.to_s
|
19
|
+
|
20
|
+
normalizations.each do |key, options|
|
21
|
+
next unless options
|
22
|
+
|
23
|
+
key = "#{key.to_s.camelize}Normalizer"
|
24
|
+
|
25
|
+
begin
|
26
|
+
klass = key.include?("::") ? key.constantize : const_get(key)
|
27
|
+
rescue NameError
|
28
|
+
raise ArgumentError, "Unknown validator: '#{key}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
normalizer = klass.new(_parse_normalizer_options(options))
|
32
|
+
_normalizers[attr_str] << normalizer
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def _parse_normalizer_options(opts)
|
39
|
+
case opts
|
40
|
+
when TrueClass
|
41
|
+
DEFAULT_OPTIONS
|
42
|
+
when Hash
|
43
|
+
opts
|
44
|
+
when String, Symbol
|
45
|
+
{ with: opts }
|
46
|
+
else
|
47
|
+
raise
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def save(**options)
|
53
|
+
_perform_normalizations(options) if options[:validate] == false
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
def save!(**options)
|
58
|
+
_perform_normalizations(options) if options[:validate] == false
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def valid?(*args)
|
63
|
+
_perform_normalizations(DEFAULT_OPTIONS)
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def _perform_normalizations(options)
|
70
|
+
return if options[:normalize] == false
|
71
|
+
|
72
|
+
_normalizers.each do |attr, norms|
|
73
|
+
value = self[attr]
|
74
|
+
|
75
|
+
if value.present? && will_save_change_to_attribute?(attr)
|
76
|
+
self[attr] = norms.reduce(value) { |res, n| n.call(res) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
require "activerecord-normalizations/normalizers/spaces_normalizer"
|
83
|
+
require "activerecord-normalizations/normalizers/text_transform_normalizer"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveRecord::Normalizations
|
2
|
+
class SpacesNormalizer
|
3
|
+
VALID_TYPES = [:leading, :trailing, :both]
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
type = options[:with] || :both
|
7
|
+
raise ArgumentError, "#{type} must be one of #{VALID_TYPES}" if !VALID_TYPES.include?(type)
|
8
|
+
|
9
|
+
@method = determine_method(type)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(attr)
|
13
|
+
attr.send(@method)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def determine_method(type)
|
19
|
+
case type
|
20
|
+
when :leading
|
21
|
+
:lstrip
|
22
|
+
when :trailing
|
23
|
+
:rstrip
|
24
|
+
else
|
25
|
+
:strip
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActiveRecord::Normalizations
|
2
|
+
class TextTransformNormalizer
|
3
|
+
VALID_TRANSFORMATIONS = [:capitalize, :word_capitalize, :uppercase, :lowercase]
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@transformation = options[:with]
|
7
|
+
|
8
|
+
if !VALID_TRANSFORMATIONS.include?(@transformation)
|
9
|
+
raise ArgumentError, "#{@transformation} must be one of #{VALID_TRANSFORMATIONS}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(attr)
|
14
|
+
case @transformation
|
15
|
+
when :uppercase
|
16
|
+
attr.upcase
|
17
|
+
when :lowercase
|
18
|
+
attr.downcase
|
19
|
+
when :word_capitalize
|
20
|
+
attr.gsub(/[[:alpha:]]+/, &:capitalize)
|
21
|
+
else
|
22
|
+
attr.capitalize
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'activerecord-normalizations/normalizations'
|
2
|
+
|
3
|
+
module ActiveRecord::Normalizations
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
config.after_initialize do |app|
|
6
|
+
ActiveSupport.on_load :active_record do
|
7
|
+
include ActiveRecord::Normalizations
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerecord-normalizations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ccocchi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.2'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '7'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '4.2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '7'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rake
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '10.0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '10.0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: minitest
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '5.0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '5.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: activerecord-nulldb-adapter
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.7.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.7.0
|
95
|
+
description:
|
96
|
+
email:
|
97
|
+
- cocchi.c@gmail.com
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- ".gitignore"
|
103
|
+
- ".travis.yml"
|
104
|
+
- CHANGELOG.md
|
105
|
+
- CODE_OF_CONDUCT.md
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- activerecord-normalizations.gemspec
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/activerecord-normalizations.rb
|
115
|
+
- lib/activerecord-normalizations/normalizations.rb
|
116
|
+
- lib/activerecord-normalizations/normalizers/spaces_normalizer.rb
|
117
|
+
- lib/activerecord-normalizations/normalizers/text_transform_normalizer.rb
|
118
|
+
- lib/activerecord-normalizations/railtie.rb
|
119
|
+
- lib/activerecord-normalizations/version.rb
|
120
|
+
homepage: https://github.com/ccocchi/activerecord-normalizations
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubygems_version: 3.2.15
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Normalize your ActiveRecord models' attributes
|
143
|
+
test_files: []
|