From 7e8afd2e1a4321dbc206b0717537b365547afc21 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 2 Dec 2025 16:43:57 -0300 Subject: [PATCH 1/4] to 5.0.0 --- .ruby-version | 2 +- CHANGELOG.md | 36 ++++++++++++++++++++++++ has_normalized_attributes.gemspec | 22 +++++++-------- lib/has_normalized_attributes/version.rb | 2 +- 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.ruby-version b/.ruby-version index 4a36342..f989260 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.0 +3.4.4 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bff98c0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,36 @@ +# HAS_NORMALIZED_ATTRIBUTES + +# Changelog + +All notable changes to this project are documented in this file + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +### Guiding Principles + +- Changelogs are for humans, not machines. +- There should be an entry for every single version. +- The same types of changes should be grouped. +- Versions and sections should be linkable. +- The latest version comes first. +- The release date of each version is displayed. +- Mention whether you follow Semantic Versioning. + +### Types of changes + +- **Added** for new features. +- **Changed** for changes in existing functionality. +- **Deprecated** for soon-to-be removed features. +- **Removed** for now removed features. +- **Fixed** for any bug fixes. +- **Security** in case of vulnerabilities. + +## [5.0.0] 2025-12-01 + +### Added +- Main changelog file created + +### Changed +- Ruby version upgrade from 3.0.0 to 3.4.4 +- In the gemspec file, allow to be used for Rails versions between 6.1 and 8.1.1. diff --git a/has_normalized_attributes.gemspec b/has_normalized_attributes.gemspec index de95dad..7f62b50 100644 --- a/has_normalized_attributes.gemspec +++ b/has_normalized_attributes.gemspec @@ -9,21 +9,19 @@ Gem::Specification.new do |s| s.version = HasNormalizedAttributes::VERSION s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Kyle Ginavan"] - s.date = %q{2010-05-18} - s.description = %q{has_normalized_attributes is a Ruby on Rails gem that lets you normalize user data for an improved user experience. + s.authors = ["Kyle Ginavan"] + s.date = %q{2010-05-18} + s.description = %q{has_normalized_attributes is a Ruby on Rails gem that lets you normalize user data for an improved user experience. It takes the messy user inputed data and normalizes it into a nice clean standard format.} s.email = %q{kylejginavan@gmail.com} - s.extra_rdoc_files = [ - "README.rdoc" - ] - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } - s.homepage = "https://github.com/kylejginavan/has_normalized_attributes" - s.require_paths = ["lib"] + s.extra_rdoc_files = [ "README.rdoc" ] + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.homepage = "https://github.com/kylejginavan/has_normalized_attributes" + s.require_paths = ["lib"] s.rubygems_version = %q{1.5.2} - s.summary = %q{Ruby on Rails gem for normalize data prior to save} + s.summary = %q{Ruby on Rails gem for normalize data prior to save} # s.rubyforge_project = "has_normalized_attributes" s.add_development_dependency "activerecord", ">= 3.1.0" diff --git a/lib/has_normalized_attributes/version.rb b/lib/has_normalized_attributes/version.rb index c6ee91b..63312db 100644 --- a/lib/has_normalized_attributes/version.rb +++ b/lib/has_normalized_attributes/version.rb @@ -1,3 +1,3 @@ module HasNormalizedAttributes - VERSION = "1.0.2" + VERSION = "5.0.0" end \ No newline at end of file From b1a3ac3a61f8254e60219833468bb9a889cda75a Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Tue, 2 Dec 2025 17:37:47 -0300 Subject: [PATCH 2/4] version patch --- lib/has_normalized_attributes/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/has_normalized_attributes/version.rb b/lib/has_normalized_attributes/version.rb index 63312db..ce98091 100644 --- a/lib/has_normalized_attributes/version.rb +++ b/lib/has_normalized_attributes/version.rb @@ -1,3 +1,3 @@ module HasNormalizedAttributes - VERSION = "5.0.0" + VERSION = "5.0.0-beta.1" end \ No newline at end of file From c0b0a55a3de1b2200b427776fdcd09c3f2dce827 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 7 Jan 2026 16:36:36 -0300 Subject: [PATCH 3/4] beta 2 --- .circleci/config.yml | 8 +- .rubocop.yml | 2 + .tekton/Chart.yaml | 8 +- .tekton/values-main.yaml | 16 +- .tekton/values-pr.yaml | 8 +- .tekton/values.yaml | 4 +- Gemfile | 2 + Rakefile | 9 +- has_normalized_attributes.gemspec | 52 +++--- lib/has_normalized_attributes.rb | 40 ++--- lib/has_normalized_attributes/version.rb | 6 +- spec/has_normalized_fields_spec.rb | 210 ++++++++++++----------- 12 files changed, 197 insertions(+), 168 deletions(-) create mode 100644 .rubocop.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 059b2e9..69e3bc1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,8 +25,8 @@ jobs: - restore_cache: keys: - - has_normalized_attributes-dependencies-v1-{{ checksum "has_normalized_attributes.gemspec" }} - - has_normalized_attributes-dependencies-v1- + - has_normalized_attributes-dependencies-v1-{{ checksum "has_normalized_attributes.gemspec" }} + - has_normalized_attributes-dependencies-v1- - run: name: Install dependencies @@ -65,8 +65,8 @@ jobs: - restore_cache: keys: - - has_normalized_attributes-dependencies-v1-{{ checksum "has_normalized_attributes.gemspec" }} - - has_normalized_attributes-dependencies-v1- + - has_normalized_attributes-dependencies-v1-{{ checksum "has_normalized_attributes.gemspec" }} + - has_normalized_attributes-dependencies-v1- - run: name: Install dependencies diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..615f909 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +inherit_from: + - https://onehq.com/rubocop3_4.yml diff --git a/.tekton/Chart.yaml b/.tekton/Chart.yaml index 89ff100..b093632 100644 --- a/.tekton/Chart.yaml +++ b/.tekton/Chart.yaml @@ -11,7 +11,7 @@ version: 0.1.0 dependencies: -- name: ruby-pipelines - alias: delivery - version: "0.2.0-dev.3" - repository: "oci://public.ecr.aws/c7o8r4o5" + - name: ruby-pipelines + alias: delivery + version: "0.2.0-dev.3" + repository: "oci://public.ecr.aws/c7o8r4o5" diff --git a/.tekton/values-main.yaml b/.tekton/values-main.yaml index 010fc40..1499591 100644 --- a/.tekton/values-main.yaml +++ b/.tekton/values-main.yaml @@ -3,12 +3,12 @@ publish: true delivery: rbac: rolebindings: - - role: edit - subjects: - - kind: Group - name: hq-platform + - role: edit + subjects: + - kind: Group + name: hq-platform - - role: view - subjects: - - kind: Group - name: hq-product \ No newline at end of file + - role: view + subjects: + - kind: Group + name: hq-product \ No newline at end of file diff --git a/.tekton/values-pr.yaml b/.tekton/values-pr.yaml index 6e5fb28..2ab25ba 100644 --- a/.tekton/values-pr.yaml +++ b/.tekton/values-pr.yaml @@ -2,8 +2,8 @@ publish: false delivery: rbac: rolebindings: - - role: edit - subjects: - - kind: Group - name: hq-product + - role: edit + subjects: + - kind: Group + name: hq-product diff --git a/.tekton/values.yaml b/.tekton/values.yaml index edd90f7..45baecf 100644 --- a/.tekton/values.yaml +++ b/.tekton/values.yaml @@ -9,11 +9,11 @@ git: # sha: global: - taskAnnotations: + taskAnnotations: vault.security.banzaicloud.io/vault-addr: "https://vault.internal.onehq.com" vault.security.banzaicloud.io/vault-path: "jwt" vault.security.banzaicloud.io/vault-auth-method: "jwt" - vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca" + vault.security.banzaicloud.io/vault-tls-secret: "custom-trusted-ca" gem: *gem rubyVersion: 3.0.2 mountGemDockerfile: true \ No newline at end of file diff --git a/Gemfile b/Gemfile index 2863e46..8472340 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" # Specify your gem's dependencies in send_grid.gemspec diff --git a/Rakefile b/Rakefile index f54f5e1..874bb9b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,8 @@ -require 'bundler' -require 'rspec/core/rake_task' +# frozen_string_literal: true + +require "bundler" +require "rspec/core/rake_task" + Bundler::GemHelper.install_tasks RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec diff --git a/has_normalized_attributes.gemspec b/has_normalized_attributes.gemspec index 7f62b50..28dc3ef 100644 --- a/has_normalized_attributes.gemspec +++ b/has_normalized_attributes.gemspec @@ -1,33 +1,45 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: true + lib = File.expand_path("../lib/", __FILE__) $:.unshift lib unless $:.include?(lib) require "has_normalized_attributes/version" Gem::Specification.new do |s| - s.name = %q{has_normalized_attributes} - s.version = HasNormalizedAttributes::VERSION + s.name = "has_normalized_attributes" + s.version = HasNormalizedAttributes::VERSION + s.authors = ["Kyle Ginavan"] + s.email = ["kylejginavan@gmail.com"] + s.date = "2010-05-18" + s.summary = "Normalize user-provided data before save" + s.description = <<~DESC + has_normalized_attributes is a Ruby on Rails gem that lets you normalize user data + for an improved user experience. It takes messy user input and normalizes it into + a clean, standard format. + DESC + s.homepage = "https://github.com/kylejginavan/has_normalized_attributes" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Kyle Ginavan"] - s.date = %q{2010-05-18} - s.description = %q{has_normalized_attributes is a Ruby on Rails gem that lets you normalize user data for an improved user experience. -It takes the messy user inputed data and normalizes it into a nice clean standard format.} - s.email = %q{kylejginavan@gmail.com} + s.required_ruby_version = ">= 3.4" + s.files = Dir.chdir(__dir__) do + `git ls-files -z`.split("\x0").reject do |f| + f.match?(%r{\A(?:test|spec|features)/}) || + f.end_with?(".gem") + end + end + s.require_paths = ["lib"] s.extra_rdoc_files = [ "README.rdoc" ] - s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } - s.homepage = "https://github.com/kylejginavan/has_normalized_attributes" - s.require_paths = ["lib"] - s.rubygems_version = %q{1.5.2} - s.summary = %q{Ruby on Rails gem for normalize data prior to save} - # s.rubyforge_project = "has_normalized_attributes" + s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) } + - s.add_development_dependency "activerecord", ">= 3.1.0" - s.add_development_dependency "byebug" - s.add_development_dependency "database_cleaner" - s.add_development_dependency "rspec_junit_formatter", "~> 0.3", ">= 0.3.0" - s.add_development_dependency "rspec" + s.add_development_dependency "activerecord", "~> 7.2" + s.add_development_dependency "byebug", "~> 12.0" + s.add_development_dependency "database_cleaner", "~> 2.1" + s.add_development_dependency "rspec", "~> 3.13" + s.add_development_dependency "rspec_junit_formatter", "~> 0.6" + s.add_dependency "rubocop", "~> 1.81" # code quality check for sonarqube + s.add_dependency "rubocop-performance", "~> 1.26" + s.add_dependency "rubocop-rails", "~> 2.34" s.add_development_dependency "sqlite3" end diff --git a/lib/has_normalized_attributes.rb b/lib/has_normalized_attributes.rb index a9e1597..797531a 100644 --- a/lib/has_normalized_attributes.rb +++ b/lib/has_normalized_attributes.rb @@ -1,20 +1,22 @@ +# frozen_string_literal: true + module HasNormalizedAttributes - #CONSTANTS - Do not mix these into ActiveRecord!!! - ZIPCODE = /[-.\s)(,]/ - PHONE = /[-.\s)(,]|^(0)|^(\+1)/ - SSN = /[-.\s)(,]/ - TAXID = /[-.\s)(,]/ - DOLLAR = /[$,\s]/ - NUMBER = /[,\s]/ - PERCENT = /[%,\s]/ - SPACES = /\s/ + # CONSTANTS - Do not mix these into ActiveRecord!!! + ZIPCODE = /[-.\s)(,]/ + PHONE = /[-.\s)(,]|^(0)|^(\+1)/ + SSN = /[-.\s)(,]/ + TAXID = /[-.\s)(,]/ + DOLLAR = /[$,\s]/ + NUMBER = /[,\s]/ + PERCENT = /[%,\s]/ + SPACES = /\s/ module CoreExtensions extend ActiveSupport::Concern # Prepending a dynamically defined module to add functionality to the current normalize_ methods. # This is similar to alias_method_chain, but accomplished in a cleaner way using inheritance. - prepend Module.new { + prepend(Module.new do def self.normalizations(*args) args.each do |arg| # Convert outer parentheses into a negative (-) sign on the result of the super method. @@ -28,9 +30,9 @@ def self.normalizations(*args) end normalizations :number, :dollar - } + end) - #instance methods + # instance methods def self.normalizations(*args) args.each do |arg| define_method "normalize_#{arg}" do @@ -38,13 +40,13 @@ def self.normalizations(*args) self && self.respond_to?(:strip) ? self.strip : self else reg_exp = HasNormalizedAttributes.const_get(arg.upcase) - self && is_a?(String) && match(reg_exp) ? gsub(reg_exp,'') : self + self && is_a?(String) && match(reg_exp) ? gsub(reg_exp, "") : self end end end end - #loading all methods dynamically + # loading all methods dynamically normalizations :phone, :zipcode, :ssn, :taxid, :dollar, :number, :percent, :spaces, :strip end @@ -53,13 +55,12 @@ module ActiveRecord module ClassMethods def has_normalized_attributes(args = {}) - if args.blank? || !args.is_a?(Hash) raise ArgumentError, 'Must define the fields you want to be normalize with has_normalized_attributes :field_one => "phone", :field_two => "zipcode"' end args.each do |field, normalization_type| - define_method "#{field.to_s}=" do |value| + define_method "#{field}=" do |value| if value.present? normalized_value = value.send("normalize_#{normalization_type.downcase}".to_sym) else @@ -68,15 +69,14 @@ def has_normalized_attributes(args = {}) super normalized_value end end - end end end end -#extend these classes - Numeric is a parent class for all of Ruby's numeric types. +# extend these classes - Numeric is a parent class for all of Ruby's numeric types. [String, Numeric, NilClass].each do |klass| klass.send(:include, HasNormalizedAttributes::CoreExtensions) end -#include activerecord -ActiveRecord::Base.send :include, HasNormalizedAttributes::ActiveRecord \ No newline at end of file +# include activerecord +ActiveRecord::Base.include HasNormalizedAttributes::ActiveRecord diff --git a/lib/has_normalized_attributes/version.rb b/lib/has_normalized_attributes/version.rb index ce98091..ec481dc 100644 --- a/lib/has_normalized_attributes/version.rb +++ b/lib/has_normalized_attributes/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module HasNormalizedAttributes - VERSION = "5.0.0-beta.1" -end \ No newline at end of file + VERSION = "5.0.0-beta.2" +end diff --git a/spec/has_normalized_fields_spec.rb b/spec/has_normalized_fields_spec.rb index c0c3af1..fcddc10 100644 --- a/spec/has_normalized_fields_spec.rb +++ b/spec/has_normalized_fields_spec.rb @@ -1,143 +1,151 @@ -require 'spec_helper' +# frozen_string_literal: true + +require "spec_helper" class Resource < ActiveRecord::Base - has_normalized_attributes :phone_attr => :phone, :zipcode_attr => :zipcode, :ssn_attr => :ssn, - :dollar_attr => :dollar, :taxid_attr => :taxid, :number_attr => :number, - :percent_attr => :percent, :spaces_attr => :spaces, :strip_attr => :strip + has_normalized_attributes phone_attr: :phone, zipcode_attr: :zipcode, ssn_attr: :ssn, + dollar_attr: :dollar, taxid_attr: :taxid, number_attr: :number, + percent_attr: :percent, spaces_attr: :spaces, strip_attr: :strip end -describe "HasNormalizedAttributes" do - before(:each) do +RSpec.describe "HasNormalizedAttributes" do + before do @resource = Resource.new end describe "class method" do it "should work" do - expect { - Resource.send(:has_normalized_attributes, {:phone_attr => :phone}) - }.to_not raise_error + expect do + Resource.send(:has_normalized_attributes, { phone_attr: :phone }) + end.not_to raise_error end it "should raise an error if no fields are passed in" do - expect { + expect do Resource.send(:has_normalized_attributes) - }.to raise_error(ArgumentError, 'Must define the fields you want to be normalize with has_normalized_attributes :field_one => "phone", :field_two => "zipcode"') + end.to raise_error( + ArgumentError, + 'Must define the fields you want to be normalize with has_normalized_attributes :field_one => "phone", :field_two => "zipcode"' + ) end end describe "#phone" do - it{@resource.phone_attr = "11-111"; @resource.phone_attr.should == "11111"} - it{@resource.phone_attr = "1111111111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "111 111 1111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = " 111 111 1111 "; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "111.111.1111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "(111)111-1111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "(111)1111111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = " 111-111.1111 "; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "0111-111.1111 "; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "1011-111.1111 "; @resource.phone_attr.should == "10111111111"} - it{@resource.phone_attr = "111-0222.333 "; @resource.phone_attr.should == "1110222333"} - it{@resource.phone_attr = "111-0222.333\t"; @resource.phone_attr.should == "1110222333"} - it{@resource.phone_attr = "+1111-0222.333\t"; @resource.phone_attr.should == "1110222333"} - it{@resource.phone_attr = "+1(111)111-1111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = "+1 111 111 1111"; @resource.phone_attr.should == "1111111111"} - it{@resource.phone_attr = ""; @resource.phone_attr.should == ""} - it{@resource.phone_attr = nil; @resource.phone_attr.should == nil} + it { @resource.phone_attr = "11-111"; expect(@resource.phone_attr).to eq("11111") } + it { @resource.phone_attr = "1111111111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "111 111 1111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = " 111 111 1111 "; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "111.111.1111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "(111)111-1111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "(111)1111111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = " 111-111.1111 "; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "0111-111.1111 "; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "1011-111.1111 "; expect(@resource.phone_attr).to eq("10111111111") } + it { @resource.phone_attr = "111-0222.333 "; expect(@resource.phone_attr).to eq("1110222333") } + it { @resource.phone_attr = "111-0222.333\t"; expect(@resource.phone_attr).to eq("1110222333") } + it { @resource.phone_attr = "+1111-0222.333\t"; expect(@resource.phone_attr).to eq("1110222333") } + it { @resource.phone_attr = "+1(111)111-1111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = "+1 111 111 1111"; expect(@resource.phone_attr).to eq("1111111111") } + it { @resource.phone_attr = ""; expect(@resource.phone_attr).to eq("") } + it { @resource.phone_attr = nil; expect(@resource.phone_attr).to be_nil } end describe "#zipcode" do - it{@resource.zipcode_attr = "11111"; @resource.zipcode_attr.should == "11111"} - it{@resource.zipcode_attr = " 11 1-11 "; @resource.zipcode_attr.should == "11111"} - it{@resource.zipcode_attr = " 111-11 ("; @resource.zipcode_attr.should == "11111"} - it{@resource.zipcode_attr = "11,1-11"; @resource.zipcode_attr.should == "11111"} - it{@resource.zipcode_attr = "11.111"; @resource.zipcode_attr.should == "11111"} - it{@resource.zipcode_attr = "111111111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = "(11111) 1111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = "11111) -1111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = "11111\t-1111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = "11111.1111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = "11111 --1111"; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = " 11111,1111 "; @resource.zipcode_attr.should == "111111111"} - it{@resource.zipcode_attr = ""; @resource.zipcode_attr.should == ""} - it{@resource.zipcode_attr = nil; @resource.zipcode_attr.should == nil} - it{@resource.zipcode_attr = "(111)"; @resource.zipcode_attr.should == "111"} - it{@resource.zipcode_attr = "11111"; @resource.zipcode_attr.should == "11111"} - skip("Possible inconsistency between ActiveRecord and SQLite") {@resource.zipcode_attr = 111.11; @resource.zipcode_attr.should == 111.11} # It appears that there is inconsistency with the return value from a string field such as zipcode_attr. + it { @resource.zipcode_attr = "11111"; expect(@resource.zipcode_attr).to eq("11111") } + it { @resource.zipcode_attr = " 11 1-11 "; expect(@resource.zipcode_attr).to eq("11111") } + it { @resource.zipcode_attr = " 111-11 ("; expect(@resource.zipcode_attr).to eq("11111") } + it { @resource.zipcode_attr = "11,1-11"; expect(@resource.zipcode_attr).to eq("11111") } + it { @resource.zipcode_attr = "11.111"; expect(@resource.zipcode_attr).to eq("11111") } + it { @resource.zipcode_attr = "111111111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = "(11111) 1111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = "11111) -1111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = "11111\t-1111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = "11111.1111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = "11111 --1111"; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = " 11111,1111 "; expect(@resource.zipcode_attr).to eq("111111111") } + it { @resource.zipcode_attr = ""; expect(@resource.zipcode_attr).to eq("") } + it { @resource.zipcode_attr = nil; expect(@resource.zipcode_attr).to be_nil } + it { @resource.zipcode_attr = "(111)"; expect(@resource.zipcode_attr).to eq("111") } + it { @resource.zipcode_attr = "11111"; expect(@resource.zipcode_attr).to eq("11111") } + + skip("Possible inconsistency between ActiveRecord and SQLite") do + @resource.zipcode_attr = 111.11 + expect(@resource.zipcode_attr).to eq(111.11) + end end describe "#ssn" do - it{@resource.ssn_attr = "111 111 1111"; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = " 111 111 1111 "; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = "111.111.1111"; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = "(111)111-1111"; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = "(111)1111111"; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = " 111-111.1111 "; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = " 111-111.1111\t"; @resource.ssn_attr.should == "1111111111"} - it{@resource.ssn_attr = ""; @resource.ssn_attr.should == ""} - it{@resource.ssn_attr = nil; @resource.ssn_attr.should == nil} + it { @resource.ssn_attr = "111 111 1111"; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = " 111 111 1111 "; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = "111.111.1111"; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = "(111)111-1111"; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = "(111)1111111"; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = " 111-111.1111 "; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = " 111-111.1111\t"; expect(@resource.ssn_attr).to eq("1111111111") } + it { @resource.ssn_attr = ""; expect(@resource.ssn_attr).to eq("") } + it { @resource.ssn_attr = nil; expect(@resource.ssn_attr).to be_nil } end describe "#taxid" do - it{@resource.taxid_attr = "12-345"; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = "12.345"; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = "1-2345"; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = "1,2345"; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = "1,2345 "; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = "1,2345\t"; @resource.taxid_attr.should == "12345"} - it{@resource.taxid_attr = ""; @resource.taxid_attr.should == ""} - it{@resource.taxid_attr = nil; @resource.taxid_attr.should == nil} + it { @resource.taxid_attr = "12-345"; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = "12.345"; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = "1-2345"; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = "1,2345"; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = "1,2345 "; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = "1,2345\t"; expect(@resource.taxid_attr).to eq("12345") } + it { @resource.taxid_attr = ""; expect(@resource.taxid_attr).to eq("") } + it { @resource.taxid_attr = nil; expect(@resource.taxid_attr).to be_nil } end describe "#dollar" do - it{@resource.dollar_attr = "$111111";@resource.dollar_attr.should == "111111"} - it{@resource.dollar_attr = "111,111";@resource.dollar_attr.should == "111111"} - it{@resource.dollar_attr = "111 111 ";@resource.dollar_attr.should == "111111"} - it{@resource.dollar_attr = "$111, 111 ";@resource.dollar_attr.should == "111111"} - it{@resource.dollar_attr = "$111\t111\t";@resource.dollar_attr.should == "111111"} - it{@resource.dollar_attr = "";@resource.dollar_attr.should == ""} - it{@resource.dollar_attr = nil;@resource.dollar_attr.should == nil} - it{@resource.dollar_attr = 111111.51;@resource.dollar_attr.should == "111111.51"} - it{@resource.dollar_attr = "(321.45)";@resource.dollar_attr.should == "-321.45"} - it{@resource.dollar_attr = "$(321.45)";@resource.dollar_attr.should == "-321.45"} - it{@resource.dollar_attr = "($321.45)";@resource.dollar_attr.should == "-321.45"} - it{@resource.dollar_attr = BigDecimal("321.45");@resource.dollar_attr.should == "321.45"} + it { @resource.dollar_attr = "$111111"; expect(@resource.dollar_attr).to eq("111111") } + it { @resource.dollar_attr = "111,111"; expect(@resource.dollar_attr).to eq("111111") } + it { @resource.dollar_attr = "111 111 "; expect(@resource.dollar_attr).to eq("111111") } + it { @resource.dollar_attr = "$111, 111 "; expect(@resource.dollar_attr).to eq("111111") } + it { @resource.dollar_attr = "$111\t111\t"; expect(@resource.dollar_attr).to eq("111111") } + it { @resource.dollar_attr = ""; expect(@resource.dollar_attr).to eq("") } + it { @resource.dollar_attr = nil; expect(@resource.dollar_attr).to be_nil } + it { @resource.dollar_attr = 111111.51; expect(@resource.dollar_attr).to eq("111111.51") } + it { @resource.dollar_attr = "(321.45)"; expect(@resource.dollar_attr).to eq("-321.45") } + it { @resource.dollar_attr = "$(321.45)"; expect(@resource.dollar_attr).to eq("-321.45") } + it { @resource.dollar_attr = "($321.45)"; expect(@resource.dollar_attr).to eq("-321.45") } + it { @resource.dollar_attr = BigDecimal("321.45"); expect(@resource.dollar_attr).to eq("321.45") } end describe "#number" do - it{@resource.number_attr = "1,23";@resource.number_attr.should == "123"} - it{@resource.number_attr = "1 23 ";@resource.number_attr.should == "123"} - it{@resource.number_attr = "1\t23\t";@resource.number_attr.should == "123"} - it{@resource.number_attr = "";@resource.number_attr.should == ""} - it{@resource.number_attr = nil;@resource.number_attr.should == nil} - it{@resource.number_attr = 111111.51;@resource.number_attr.should == "111111.51"} - it{@resource.number_attr = "(321.45)";@resource.number_attr.should == "-321.45"} - it{@resource.number_attr = "-321.45";@resource.number_attr.should == "-321.45"} - it{@resource.number_attr = BigDecimal("321.45");@resource.number_attr.should == "321.45"} + it { @resource.number_attr = "1,23"; expect(@resource.number_attr).to eq("123") } + it { @resource.number_attr = "1 23 "; expect(@resource.number_attr).to eq("123") } + it { @resource.number_attr = "1\t23\t"; expect(@resource.number_attr).to eq("123") } + it { @resource.number_attr = ""; expect(@resource.number_attr).to eq("") } + it { @resource.number_attr = nil; expect(@resource.number_attr).to be_nil } + it { @resource.number_attr = 111111.51; expect(@resource.number_attr).to eq("111111.51") } + it { @resource.number_attr = "(321.45)"; expect(@resource.number_attr).to eq("-321.45") } + it { @resource.number_attr = "-321.45"; expect(@resource.number_attr).to eq("-321.45") } + it { @resource.number_attr = BigDecimal("321.45"); expect(@resource.number_attr).to eq("321.45") } end describe "#percent" do - it{@resource.percent_attr = " 1 1 ";@resource.percent_attr.should == "11"} - it{@resource.percent_attr = "11%";@resource.percent_attr.should == "11"} - it{@resource.percent_attr = "%11";@resource.percent_attr.should == "11"} - it{@resource.percent_attr = "1 1 % ";@resource.percent_attr.should == "11"} - it{@resource.percent_attr = "1\t1\t%\t";@resource.percent_attr.should == "11"} - it{@resource.percent_attr = "";@resource.percent_attr.should == ""} - it{@resource.percent_attr = nil;@resource.percent_attr.should == nil} + it { @resource.percent_attr = " 1 1 "; expect(@resource.percent_attr).to eq("11") } + it { @resource.percent_attr = "11%"; expect(@resource.percent_attr).to eq("11") } + it { @resource.percent_attr = "%11"; expect(@resource.percent_attr).to eq("11") } + it { @resource.percent_attr = "1 1 % "; expect(@resource.percent_attr).to eq("11") } + it { @resource.percent_attr = "1\t1\t%\t"; expect(@resource.percent_attr).to eq("11") } + it { @resource.percent_attr = ""; expect(@resource.percent_attr).to eq("") } + it { @resource.percent_attr = nil; expect(@resource.percent_attr).to be_nil } end describe "#spaces" do - it{@resource.spaces_attr = "5 0";@resource.spaces_attr.should == "50"} - it{@resource.spaces_attr = "5\t0";@resource.spaces_attr.should == "50"} - it{@resource.spaces_attr = "";@resource.spaces_attr.should == ""} - it{@resource.spaces_attr = nil;@resource.spaces_attr.should == nil} + it { @resource.spaces_attr = "5 0"; expect(@resource.spaces_attr).to eq("50") } + it { @resource.spaces_attr = "5\t0"; expect(@resource.spaces_attr).to eq("50") } + it { @resource.spaces_attr = ""; expect(@resource.spaces_attr).to eq("") } + it { @resource.spaces_attr = nil; expect(@resource.spaces_attr).to be_nil } end describe "#strip" do - it{@resource.strip_attr = "text "; @resource.strip_attr.should == "text"} - it{@resource.strip_attr = " text"; @resource.strip_attr.should == "text"} - it{@resource.strip_attr = " text "; @resource.strip_attr.should == "text"} - it{@resource.strip_attr = " some text"; @resource.strip_attr.should == "some text"} - it{@resource.strip_attr = " some text "; @resource.strip_attr.should == "some text"} + it { @resource.strip_attr = "text "; expect(@resource.strip_attr).to eq("text") } + it { @resource.strip_attr = " text"; expect(@resource.strip_attr).to eq("text") } + it { @resource.strip_attr = " text "; expect(@resource.strip_attr).to eq("text") } + it { @resource.strip_attr = " some text"; expect(@resource.strip_attr).to eq("some text") } + it { @resource.strip_attr = " some text "; expect(@resource.strip_attr).to eq("some text") } end - -end \ No newline at end of file +end From 66626b1bbf57216e27b1118e1c468efb2d3139d4 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 7 Jan 2026 16:42:17 -0300 Subject: [PATCH 4/4] sqlite version --- has_normalized_attributes.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/has_normalized_attributes.gemspec b/has_normalized_attributes.gemspec index 28dc3ef..fd41210 100644 --- a/has_normalized_attributes.gemspec +++ b/has_normalized_attributes.gemspec @@ -41,5 +41,5 @@ Gem::Specification.new do |s| s.add_dependency "rubocop", "~> 1.81" # code quality check for sonarqube s.add_dependency "rubocop-performance", "~> 1.26" s.add_dependency "rubocop-rails", "~> 2.34" - s.add_development_dependency "sqlite3" + s.add_development_dependency "sqlite3", "~> 2.9" end