validates_identity-co_cc 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 47de987a587b171e72a15d5fa13d8b5834a3f0b59dff29b2105da74d4491c83f
4
+ data.tar.gz: bf6862d501ddcf5386ecbe4da5172c10bf839cc5cedd6a80a940d7f4f7aefee2
5
+ SHA512:
6
+ metadata.gz: d56b55d32369f854187a04af4da7355c9278e5c45fe5d434bbb1a757a190762f39e71265184c048f5871bb878615c049385e5747251977e023afa06b2c858f79
7
+ data.tar.gz: 514489ad5a5150bddb552ce4a6ddb25b22d8dd8eaf4da78277ea7fe3ef466575b8af6b85b582bc7e6e88690a0de63af5a1c261e193ddb083ec5d335363cdf4a9
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+ TargetRubyVersion: 2.6
8
+
9
+ Layout/LineLength:
10
+ Max: 150
11
+
12
+ Metrics/BlockLength:
13
+ Enabled: false
14
+
15
+ RSpec/NestedGroups:
16
+ Max: 4
17
+
18
+ Style/Documentation:
19
+ Enabled: false
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ validate_identity
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ### Added
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at plribeiro3000@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in validates_identity-co_cc.gemspec
6
+ gemspec
7
+
8
+ gem 'jazz_fingers'
9
+ gem 'rake'
10
+ gem 'rspec'
11
+ gem 'rubocop-rake'
12
+ gem 'rubocop-rspec'
13
+ gem 'shoulda-matchers'
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ validates_identity-co_cc (0.1.0)
5
+ activemodel
6
+ validates_identity (>= 0.5.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activemodel (7.1.3.2)
12
+ activesupport (= 7.1.3.2)
13
+ activesupport (7.1.3.2)
14
+ base64
15
+ bigdecimal
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ connection_pool (>= 2.2.5)
18
+ drb
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ mutex_m
22
+ tzinfo (~> 2.0)
23
+ amazing_print (1.6.0)
24
+ ast (2.4.2)
25
+ base64 (0.2.0)
26
+ bigdecimal (3.1.7)
27
+ byebug (11.1.3)
28
+ coderay (1.1.3)
29
+ concurrent-ruby (1.2.3)
30
+ connection_pool (2.4.1)
31
+ coolline (0.5.0)
32
+ unicode_utils (~> 1.4)
33
+ diff-lcs (1.5.1)
34
+ drb (2.2.1)
35
+ i18n (1.14.4)
36
+ concurrent-ruby (~> 1.0)
37
+ jazz_fingers (6.2.0)
38
+ amazing_print (~> 1.3)
39
+ pry (~> 0.10)
40
+ pry-byebug (~> 3.9)
41
+ pry-coolline (~> 0.2)
42
+ json (2.7.1)
43
+ language_server-protocol (3.17.0.3)
44
+ method_source (1.0.0)
45
+ minitest (5.22.3)
46
+ mutex_m (0.2.0)
47
+ parallel (1.24.0)
48
+ parser (3.3.0.5)
49
+ ast (~> 2.4.1)
50
+ racc
51
+ pry (0.14.2)
52
+ coderay (~> 1.1)
53
+ method_source (~> 1.0)
54
+ pry-byebug (3.10.1)
55
+ byebug (~> 11.0)
56
+ pry (>= 0.13, < 0.15)
57
+ pry-coolline (0.2.6)
58
+ coolline (~> 0.5)
59
+ pry (~> 0.13)
60
+ racc (1.7.3)
61
+ rainbow (3.1.1)
62
+ rake (13.1.0)
63
+ regexp_parser (2.9.0)
64
+ rexml (3.2.6)
65
+ rspec (3.13.0)
66
+ rspec-core (~> 3.13.0)
67
+ rspec-expectations (~> 3.13.0)
68
+ rspec-mocks (~> 3.13.0)
69
+ rspec-core (3.13.0)
70
+ rspec-support (~> 3.13.0)
71
+ rspec-expectations (3.13.0)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.13.0)
74
+ rspec-mocks (3.13.0)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.13.0)
77
+ rspec-support (3.13.1)
78
+ rubocop (1.62.1)
79
+ json (~> 2.3)
80
+ language_server-protocol (>= 3.17.0)
81
+ parallel (~> 1.10)
82
+ parser (>= 3.3.0.2)
83
+ rainbow (>= 2.2.2, < 4.0)
84
+ regexp_parser (>= 1.8, < 3.0)
85
+ rexml (>= 3.2.5, < 4.0)
86
+ rubocop-ast (>= 1.31.1, < 2.0)
87
+ ruby-progressbar (~> 1.7)
88
+ unicode-display_width (>= 2.4.0, < 3.0)
89
+ rubocop-ast (1.31.2)
90
+ parser (>= 3.3.0.4)
91
+ rubocop-capybara (2.20.0)
92
+ rubocop (~> 1.41)
93
+ rubocop-factory_bot (2.25.1)
94
+ rubocop (~> 1.41)
95
+ rubocop-rake (0.6.0)
96
+ rubocop (~> 1.0)
97
+ rubocop-rspec (2.27.1)
98
+ rubocop (~> 1.40)
99
+ rubocop-capybara (~> 2.17)
100
+ rubocop-factory_bot (~> 2.22)
101
+ ruby-progressbar (1.13.0)
102
+ shoulda-matchers (6.2.0)
103
+ activesupport (>= 5.2.0)
104
+ tzinfo (2.0.6)
105
+ concurrent-ruby (~> 1.0)
106
+ unicode-display_width (2.5.0)
107
+ unicode_utils (1.4.0)
108
+ validates_identity (1.0.0)
109
+ activemodel
110
+
111
+ PLATFORMS
112
+ ruby
113
+ x86_64-darwin-21
114
+
115
+ DEPENDENCIES
116
+ jazz_fingers
117
+ rake
118
+ rspec
119
+ rubocop-rake
120
+ rubocop-rspec
121
+ shoulda-matchers
122
+ validates_identity-co_cc!
123
+
124
+ BUNDLED WITH
125
+ 2.5.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Paulo Ribeiro
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,68 @@
1
+ # ValidatesIdentity::CoCc
2
+
3
+ This projects aims to validate Colombia [Cédula de ciudadanía](https://es.wikipedia.org/wiki/C%C3%A9dula_de_ciudadan%C3%ADa_(Colombia)) identification document.
4
+ This project depends on `validates_identity` gem and is a plugin for it.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'validates_identity-co_cc'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install validates_identity-co_cc
21
+
22
+ ## Usage
23
+
24
+ Just use as any other validator:
25
+
26
+ ```ruby
27
+ class User < ActiveRecord::Base
28
+ # :identity_type is the attribute that will be used to determine the identity type and is required
29
+ validates :identity, identity: { identity_type: :identity_type }
30
+ end
31
+ ```
32
+
33
+ ## Advanced Usage
34
+
35
+ New Identity Validators can be registered through the public apis of `ValidatesIdentity`
36
+
37
+ ```ruby
38
+ ValidatesIdentity.register_identity_type('CustomIdentity', CustomIdentityValidator)
39
+ ```
40
+
41
+ Each Validator should have:
42
+
43
+ - a constructor with 2 params: `value` and `options` as a hash
44
+ - a `valid?` method that returns a boolean
45
+
46
+ In case of a legacy system where keys were already defined and differ from the official ones, aliases can be registered as well
47
+
48
+ ```ruby
49
+ ValidatesIdentity.register_identity_type_alias('LegacyIdentity', 'CustomIdentity')
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/plribeiro3000/validates_identity-co_cc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/plribeiro3000/validates_identity-co_cc/blob/master/CODE_OF_CONDUCT.md).
61
+
62
+ ## License
63
+
64
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
65
+
66
+ ## Code of Conduct
67
+
68
+ Everyone interacting in the ValidatesIdentity::CoCc project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/plribeiro3000/validates_identity-co_cc/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ValidatesIdentity
4
+ module CoCc
5
+ class Validator
6
+ VALIDATION_REGULAR_EXPRESSION = /\A\d{6,10}\z/i.freeze
7
+
8
+ attr_reader :value
9
+
10
+ def initialize(value)
11
+ @value = value.to_s
12
+ end
13
+
14
+ def valid?
15
+ return true if value.blank?
16
+
17
+ result.present?
18
+ end
19
+
20
+ def formatted
21
+ value
22
+ end
23
+
24
+ private
25
+
26
+ def result
27
+ @result ||= VALIDATION_REGULAR_EXPRESSION.match(value)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ValidatesIdentity
4
+ module CoCc
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'validates_identity'
4
+ require_relative 'co_cc/version'
5
+
6
+ class ValidatesIdentity
7
+ module CoCc
8
+ autoload :Validator, 'validates_identity/co_cc/validator'
9
+ end
10
+ end
11
+
12
+ ValidatesIdentity.register_person_identity_type('CO_CC', ValidatesIdentity::CoCc::Validator)
13
+ ValidatesIdentity::ShouldaMatchers.register_person_allowed_values('CO_CC', %w[123456 1234567 12345678 123456789 1234567890])
14
+ ValidatesIdentity::ShouldaMatchers.register_person_disallowed_values('CO_CC', %w[12345 12345678901])
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/validates_identity/co_cc/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'validates_identity-co_cc'
7
+ spec.version = ValidatesIdentity::CoCc::VERSION
8
+ spec.authors = ['Paulo Ribeiro']
9
+ spec.email = ['plribeiro3000@gmail.com']
10
+
11
+ spec.summary = 'Validates Colombia CC Document and test it with matchers in a simple way.'
12
+ spec.homepage = 'https://github.com/plribeiro3000/validates_identity-co_cc'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/plribeiro3000/validates_identity-co_cc/blob/master'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/plribeiro3000/validates_identity-co_cc/blob/master/CHANGELOG.md'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_runtime_dependency 'activemodel'
32
+ spec.add_runtime_dependency 'validates_identity', '>= 0.5.0'
33
+ spec.metadata['rubygems_mfa_required'] = 'true'
34
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validates_identity-co_cc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paulo Ribeiro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: validates_identity
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ description:
42
+ email:
43
+ - plribeiro3000@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - ".ruby-gemset"
51
+ - ".ruby-version"
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/validates_identity/co_cc.rb
60
+ - lib/validates_identity/co_cc/validator.rb
61
+ - lib/validates_identity/co_cc/version.rb
62
+ - validates_identity-co_cc.gemspec
63
+ homepage: https://github.com/plribeiro3000/validates_identity-co_cc
64
+ licenses:
65
+ - MIT
66
+ metadata:
67
+ homepage_uri: https://github.com/plribeiro3000/validates_identity-co_cc
68
+ source_code_uri: https://github.com/plribeiro3000/validates_identity-co_cc/blob/master
69
+ changelog_uri: https://github.com/plribeiro3000/validates_identity-co_cc/blob/master/CHANGELOG.md
70
+ rubygems_mfa_required: 'true'
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.6.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.5.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Validates Colombia CC Document and test it with matchers in a simple way.
90
+ test_files: []