normalize_attributes 0.3.1 → 0.4.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: d02d2f9fd6b4e46578d0aa42b7d88600319f141d0b344ee9099cfc1f55c2ade3
4
- data.tar.gz: 1f2ad30cb3c68301d103cbf9f3e2f0b98b1907b9610d78c370ee124a36c948cc
3
+ metadata.gz: cd2b8ac00d154b24d7d2ac9c7f964ad3c1b35c292a66dd7cca31c879cdea5074
4
+ data.tar.gz: adcbcd92a0c5d9494184658a8b3e6bd532b6914178fd0df32339c54389033723
5
5
  SHA512:
6
- metadata.gz: 442645e30d41a53d349c2a8ae4277e2170cc19ed0044bb02176553ab5b5cbfa5b5c3474643b336a58712e94ba8d3531e72998c078322866b43275eb553fea5ba
7
- data.tar.gz: 7c3910ebb292d98268509bf04bd50880cbb1688d33e2e5f464de3a2379d12917992d93b0692a302ce9db08175aec09b1d3a5a136218138e02a989d63ce3a1c53
6
+ metadata.gz: 20e8a7b0f18c042923e36ae733843b963e32989fa302099cd831e4797778a3e3bcaa7c7eb2c9d6f0ae8904b0765d14967551e882b4d02718bba67d6bdf663146
7
+ data.tar.gz: b6f78a1e10674ec14722b19bcf1f9765168c8d9cdcc9faaa738a08f0a283ac9dc6241237055ac5c86de3a9e5017d705aad09315f3e0755a7dd516f8fb896a6c9
@@ -0,0 +1,4 @@
1
+ # You can read more about CODEOWNERS at
2
+ # https://help.github.com/github/creating-cloning-and-archiving-repositories/about-code-owners
3
+
4
+ * @fnando
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+ ---
3
+ github: [fnando]
4
+ custom: ["https://paypal.me/fnando/🍕"]
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: "🐛 Bug Report"
3
+ about: Report a reproducible bug or regression.
4
+ title: 'Bug: '
5
+ labels: 'Status: Unconfirmed'
6
+
7
+ ---
8
+
9
+ <!--
10
+ - Please provide a clear and concise description of what the bug is.
11
+ - If possible, add an example reproducing your issue.
12
+ - Please test using the latest version of normalize_attributes
13
+ to make sure your issue has not already been fixed.
14
+ -->
15
+
16
+ ## Description
17
+
18
+ [Add bug description here]
19
+
20
+ ## How to reproduce
21
+
22
+ [Add steps on how to reproduce this issue]
23
+
24
+ ## What do you expect
25
+
26
+ [Describe what do you expect to happen]
27
+
28
+ ## What happened instead
29
+
30
+ [Describe the actual results]
31
+
32
+ ## Software:
33
+
34
+ - Gem version: [Add gem version here]
35
+ - Ruby version: [Add version here]
36
+
37
+ ## Full backtrace
38
+
39
+ ```text
40
+ [Paste full backtrace here]
41
+ ```
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: "💡 Feature request"
3
+ about: Have an idea that may be useful? Make a suggestion!
4
+ title: 'Feature Request: '
5
+ labels: 'Feature request'
6
+
7
+ ---
8
+
9
+ ## Description
10
+
11
+ _A clear and concise description of what the problem is._
12
+
13
+ ## Describe the solution
14
+
15
+ _A clear and concise description of what you want to happen._
16
+
17
+ ## Alternatives you considered
18
+
19
+ _A clear and concise description of any alternative solutions or features you've considered._
20
+
21
+ ## Additional context
22
+
23
+ _Add any other context, screenshots, links, etc about the feature request here._
@@ -0,0 +1,38 @@
1
+ <!--
2
+ If you're making a doc PR or something tiny where the below is irrelevant,
3
+ delete this template and use a short description, but in your description aim to
4
+ include both what the change is, and why it is being made, with enough context
5
+ for anyone to understand.
6
+ -->
7
+
8
+ <details>
9
+ <summary>PR Checklist</summary>
10
+
11
+ ### PR Structure
12
+
13
+ - [ ] This PR has reasonably narrow scope (if not, break it down into smaller
14
+ PRs).
15
+ - [ ] This PR avoids mixing refactoring changes with feature changes (split into
16
+ two PRs otherwise).
17
+ - [ ] This PR's title starts is concise and descriptive.
18
+
19
+ ### Thoroughness
20
+
21
+ - [ ] This PR adds tests for the most critical parts of the new functionality or
22
+ fixes.
23
+ - [ ] I've updated any docs, `.md` files, etc… affected by this change.
24
+
25
+ </details>
26
+
27
+ ### What
28
+
29
+ [TODO: Short statement about what is changing.]
30
+
31
+ ### Why
32
+
33
+ [TODO: Why this change is being made. Include any context required to understand
34
+ the why.]
35
+
36
+ ### Known limitations
37
+
38
+ [TODO or N/A]
@@ -0,0 +1,15 @@
1
+ ---
2
+ # Documentation:
3
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
4
+
5
+ version: 2
6
+ updates:
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "daily"
11
+
12
+ - package-ecosystem: bundler
13
+ directory: "/"
14
+ schedule:
15
+ interval: "daily"
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: ruby-tests
3
+
4
+ on:
5
+ pull_request_target:
6
+ push:
7
+ branches:
8
+ - main
9
+ workflow_dispatch:
10
+ inputs: {}
11
+
12
+ jobs:
13
+ build:
14
+ name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
15
+ runs-on: "ubuntu-latest"
16
+ if: |
17
+ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
18
+ github.actor != 'dependabot[bot]'
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ ruby: ["2.7", "3.0", "3.1"]
23
+ gemfile:
24
+ - Gemfile
25
+ - gemfiles/rails_7_0.gemfile
26
+ - gemfiles/rails_6_1.gemfile
27
+ - gemfiles/rails_6_0.gemfile
28
+
29
+ steps:
30
+ - uses: actions/checkout@v2.4.0
31
+
32
+ - uses: actions/cache@v2
33
+ with:
34
+ path: vendor/bundle
35
+ key: >
36
+ ${{ runner.os }}-${{ matrix.ruby }}-gems-${{
37
+ hashFiles(matrix.gemfile) }}
38
+
39
+ - name: Set up Ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: ${{ matrix.ruby }}
43
+
44
+ - name: Install gem dependencies
45
+ env:
46
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
47
+ run: |
48
+ gem install bundler
49
+ bundle config path vendor/bundle
50
+ bundle update --jobs 4 --retry 3
51
+
52
+ - name: Run Tests
53
+ env:
54
+ PGHOST: localhost
55
+ PGUSER: postgres
56
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
57
+ run: |
58
+ bundle exec rake
data/.rubocop.yml CHANGED
@@ -4,3 +4,4 @@ inherit_gem:
4
4
 
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.7
7
+ NewCops: enable
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ <!--
4
+ Prefix your message with one of the following:
5
+
6
+ - [Added] for new features.
7
+ - [Changed] for changes in existing functionality.
8
+ - [Deprecated] for soon-to-be removed features.
9
+ - [Removed] for now removed features.
10
+ - [Fixed] for any bug fixes.
11
+ - [Security] in case of vulnerabilities.
12
+ -->
13
+
14
+ ## v0.4.0 - 2022-01-12
15
+
16
+ - [Added] Allow using private methods as normalizers.
17
+ - [Fixed] Fixed errors raised by latest versions of ActiveModel.
@@ -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 me@fnando.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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,79 @@
1
+ # Contributing to normalize_attributes
2
+
3
+ 👍🎉 First off, thanks for taking the time to contribute! 🎉👍
4
+
5
+ The following is a set of guidelines for contributing to this project. These are
6
+ mostly guidelines, not rules. Use your best judgment, and feel free to propose
7
+ changes to this document in a pull request.
8
+
9
+ ## Code of Conduct
10
+
11
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and
12
+ mailing lists is expected to follow the [code of conduct](https://github.com/fnando/normalize_attributes/blob/main/CODE_OF_CONDUCT.md).
13
+
14
+ ## Reporting bugs
15
+
16
+ This section guides you through submitting a bug report. Following these
17
+ guidelines helps maintainers and the community understand your report, reproduce
18
+ the behavior, and find related reports.
19
+
20
+ - Before creating bug reports, please check the open issues; somebody may
21
+ already have submitted something similar, and you may not need to create a new
22
+ one.
23
+ - When you are creating a bug report, please include as many details as
24
+ possible, with an example reproducing the issue.
25
+
26
+ ## Contributing with code
27
+
28
+ Before making any radicals changes, please make sure you discuss your intention
29
+ by [opening an issue on Github](https://github.com/fnando/normalize_attributes/issues).
30
+
31
+ When you're ready to make your pull request, follow checklist below to make sure
32
+ your contribution is according to how this project works.
33
+
34
+ 1. [Fork](https://help.github.com/forking/) normalize_attributes
35
+ 2. Create a topic branch - `git checkout -b my_branch`
36
+ 3. Make your changes using [descriptive commit messages](#commit-messages)
37
+ 4. Update CHANGELOG.md describing your changes by adding an entry to the
38
+ "Unreleased" section. If this section is not available, create one right
39
+ before the last version.
40
+ 5. Push to your branch - `git push origin my_branch`
41
+ 6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
42
+ 7. That's it!
43
+
44
+ ## Styleguides
45
+
46
+ ### Commit messages
47
+
48
+ - Use the present tense ("Add feature" not "Added feature")
49
+ - Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
50
+ - Limit the first line to 72 characters or less
51
+ - Reference issues and pull requests liberally after the first line
52
+
53
+ ### Changelog
54
+
55
+ - Add a message describing your changes to the "Unreleased" section. The
56
+ changelog message should follow the same style as the commit message.
57
+ - Prefix your message with one of the following:
58
+ - `[Added]` for new features.
59
+ - `[Changed]` for changes in existing functionality.
60
+ - `[Deprecated]` for soon-to-be removed features.
61
+ - `[Removed]` for now removed features.
62
+ - `[Fixed]` for any bug fixes.
63
+ - `[Security]` in case of vulnerabilities.
64
+
65
+ ### Ruby code
66
+
67
+ - This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
68
+ submitting your changes, make sure your tests are passing and code conforms to
69
+ the expected style by running `rake`.
70
+ - Do not change the library version. This will be done by the maintainer
71
+ whenever a new version is about to be released.
72
+
73
+ ### JavaScript code
74
+
75
+ - This project uses [ESLint](https://eslint.org) to enforce code style. Before
76
+ submitting your changes, make sure your tests are passing and code conforms to
77
+ the expected style by running `yarn test:ci`.
78
+ - Do not change the library version. This will be done by the maintainer
79
+ whenever a new version is about to be released.
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Nando Vieira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Normalize Attributes
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/normalize_attributes.svg)](https://travis-ci.org/fnando/normalize_attributes)
3
+ [![Tests](https://github.com/fnando/normalize_attributes/workflows/ruby-tests/badge.svg)](https://github.com/fnando/normalize_attributes)
4
4
  [![Code Climate](https://codeclimate.com/github/fnando/normalize_attributes/badges/gpa.svg)](https://codeclimate.com/github/fnando/normalize_attributes)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/normalize_attributes/badges/coverage.svg)](https://codeclimate.com/github/fnando/normalize_attributes/coverage)
6
5
  [![Gem](https://img.shields.io/gem/v/normalize_attributes.svg)](https://rubygems.org/gems/normalize_attributes)
7
6
  [![Gem](https://img.shields.io/gem/dt/normalize_attributes.svg)](https://rubygems.org/gems/normalize_attributes)
8
7
 
@@ -94,27 +93,25 @@ end
94
93
 
95
94
  ## Maintainer
96
95
 
97
- * Nando Vieira (http://nandovieira.com)
96
+ - [Nando Vieira](https://github.com/fnando)
98
97
 
99
- ## License:
98
+ ## Contributors
100
99
 
101
- (The MIT License)
100
+ - https://github.com/fnando/normalize_attributes/contributors
102
101
 
103
- Permission is hereby granted, free of charge, to any person obtaining
104
- a copy of this software and associated documentation files (the
105
- 'Software'), to deal in the Software without restriction, including
106
- without limitation the rights to use, copy, modify, merge, publish,
107
- distribute, sublicense, and/or sell copies of the Software, and to
108
- permit persons to whom the Software is furnished to do so, subject to
109
- the following conditions:
102
+ ## Contributing
110
103
 
111
- The above copyright notice and this permission notice shall be
112
- included in all copies or substantial portions of the Software.
104
+ For more details about how to contribute, please read
105
+ https://github.com/fnando/normalize_attributes/blob/main/CONTRIBUTING.md.
113
106
 
114
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
115
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
116
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
117
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
118
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
119
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
120
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the
110
+ [MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
111
+ found at https://github.com/fnando/normalize_attributes/blob/main/LICENSE.md.
112
+
113
+ ## Code of Conduct
114
+
115
+ Everyone interacting in the normalize_attributes project's codebases, issue
116
+ trackers, chat rooms and mailing lists is expected to follow the
117
+ [code of conduct](https://github.com/fnando/normalize_attributes/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -2,11 +2,14 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
+ require "rubocop/rake_task"
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
8
  t.libs << "test"
9
+ t.libs << "lib"
8
10
  t.test_files = FileList["test/**/*_test.rb"]
9
- t.warning = false
10
11
  end
11
12
 
12
- task default: :test
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "rails", "~> 6.0.0"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "rails", "~> 6.1.0"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "rails", "~> 7.0.0"
@@ -33,16 +33,14 @@ module NormalizeAttributes
33
33
  value = normalizer.call(value)
34
34
  elsif value.respond_to?(normalizer)
35
35
  value = value.send(normalizer)
36
- elsif record.respond_to?(normalizer)
36
+ elsif record.respond_to?(normalizer, true)
37
37
  value = record.send(normalizer, value)
38
+ else
39
+ raise "Unknown normalizer #{normalizer.inspect}"
38
40
  end
39
41
  end
40
42
 
41
- begin
42
- record.send(:write_attribute, attribute, value)
43
- rescue ActiveModel::MissingAttributeError
44
- record.public_send("#{attribute}=", value)
45
- end
43
+ record.public_send("#{attribute}=", value)
46
44
  end
47
45
 
48
46
  module Callbacks
@@ -3,8 +3,8 @@
3
3
  module NormalizeAttributes
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 3
7
- PATCH = 1
6
+ MINOR = 4
7
+ PATCH = 0
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
@@ -12,6 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.summary = "Normalize ActiveRecord attributes"
13
13
  s.description = s.summary
14
14
  s.license = "MIT"
15
+ s.required_ruby_version = ">= 2.7"
16
+ s.metadata = {"rubygems_mfa_required" => "true"}
15
17
 
16
18
  s.files = `git ls-files`.split("\n")
17
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -25,6 +27,8 @@ Gem::Specification.new do |s|
25
27
  s.add_development_dependency "bundler"
26
28
  s.add_development_dependency "minitest-utils"
27
29
  s.add_development_dependency "rake"
30
+ s.add_development_dependency "rubocop"
31
+ s.add_development_dependency "rubocop-fnando"
28
32
  s.add_development_dependency "simplecov"
29
33
  s.add_development_dependency "sqlite3"
30
34
  end
@@ -43,6 +43,13 @@ class NormalizeAttributesTest < Minitest::Test
43
43
  assert_equal "johndoe", user.username
44
44
  end
45
45
 
46
+ test "apply private instance method" do
47
+ User.normalize(:username, with: :private_normalize_username)
48
+ user = User.create(username: "johndoe")
49
+
50
+ assert_equal "JOHNDOE", user.username
51
+ end
52
+
46
53
  test "use value before type casting" do
47
54
  User.normalize(:age, raw: true) do |v|
48
55
  v.to_f * 10
@@ -98,11 +105,12 @@ class NormalizeAttributesTest < Minitest::Test
98
105
  assert_equal "100", user.username
99
106
  end
100
107
 
101
- test "don't apply filter when object do not respond to normalizer" do
108
+ test "raises an error when object do not respond to normalizer" do
102
109
  User.normalize :username, with: :missing
103
110
 
104
- user = User.create(username: nil)
105
- user.save
111
+ assert_raises(%[Unknown normalizer ":missing"]) do
112
+ User.create(username: nil)
113
+ end
106
114
  end
107
115
 
108
116
  test "normalize attributes that are not backed by database columns" do
data/test/support/user.rb CHANGED
@@ -9,4 +9,8 @@ class User < ActiveRecord::Base
9
9
  def normalize_username(username)
10
10
  username.downcase
11
11
  end
12
+
13
+ private def private_normalize_username(username)
14
+ username.upcase
15
+ end
12
16
  end
data/test/test_helper.rb CHANGED
@@ -15,4 +15,4 @@ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
15
15
  # Load database schema
16
16
  load "schema.rb"
17
17
 
18
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].sort.each {|f| require f }
18
+ Dir["#{__dir__}/support/**/*.rb"].sort.each {|f| require f }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalize_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-10 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-fnando
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: simplecov
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -115,12 +143,25 @@ executables: []
115
143
  extensions: []
116
144
  extra_rdoc_files: []
117
145
  files:
146
+ - ".github/CODEOWNERS"
147
+ - ".github/FUNDING.yml"
148
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
149
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
150
+ - ".github/PULL_REQUEST_TEMPLATE.md"
151
+ - ".github/dependabot.yml"
152
+ - ".github/workflows/ruby-tests.yml"
118
153
  - ".gitignore"
119
154
  - ".rubocop.yml"
120
- - ".travis.yml"
155
+ - CHANGELOG.md
156
+ - CODE_OF_CONDUCT.md
157
+ - CONTRIBUTING.md
121
158
  - Gemfile
159
+ - LICENSE.md
122
160
  - README.md
123
161
  - Rakefile
162
+ - gemfiles/rails_6_0.gemfile
163
+ - gemfiles/rails_6_1.gemfile
164
+ - gemfiles/rails_7_0.gemfile
124
165
  - lib/normalize_attributes.rb
125
166
  - lib/normalize_attributes/callbacks.rb
126
167
  - lib/normalize_attributes/version.rb
@@ -133,8 +174,9 @@ files:
133
174
  homepage: http://rubygems.org/gems/normalize_attributes
134
175
  licenses:
135
176
  - MIT
136
- metadata: {}
137
- post_install_message:
177
+ metadata:
178
+ rubygems_mfa_required: 'true'
179
+ post_install_message:
138
180
  rdoc_options: []
139
181
  require_paths:
140
182
  - lib
@@ -142,15 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
184
  requirements:
143
185
  - - ">="
144
186
  - !ruby/object:Gem::Version
145
- version: '0'
187
+ version: '2.7'
146
188
  required_rubygems_version: !ruby/object:Gem::Requirement
147
189
  requirements:
148
190
  - - ">="
149
191
  - !ruby/object:Gem::Version
150
192
  version: '0'
151
193
  requirements: []
152
- rubygems_version: 3.1.2
153
- signing_key:
194
+ rubygems_version: 3.3.3
195
+ signing_key:
154
196
  specification_version: 4
155
197
  summary: Normalize ActiveRecord attributes
156
198
  test_files:
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- notifications:
6
- email: false
7
- rvm:
8
- - 2.7.0
9
- before_install:
10
- - gem install bundler
11
- before_script:
12
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
- - chmod +x ./cc-test-reporter
14
- - "./cc-test-reporter before-build"
15
- after_script:
16
- - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
17
- env:
18
- global:
19
- secure: U80HNhPVE+IUJaxOPxMJc0CqlQSsl23EOOsqcnuXUjrlcjvfeCnQU58rxFOUCBeKxmno4tatfZXdwBa+FvQ3PcnOXXnesMfCR0UAPdGmaA6ScSMyL+KijC1wGI0N80ccBZRaBA4quR02XTMiJt1saTrBT1cuOCsWs2gjOB4EwoA=