rw_validator 0.1.0 → 0.1.1

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: 6ddd2b405a5a0c1feadbc3e1581326043e87522e0f4de10e0bfbd0cf89068dd6
4
- data.tar.gz: 5e638c126d65fcf762269c27bb982bbf7f4a11e98f8b4d1c15220279e189e293
3
+ metadata.gz: 2c65589b8620235352d2924fb4bcfeaabdf441d7aa6a23258282c58aceb59fbc
4
+ data.tar.gz: 3efc703468e18bba2a65d4bb4d9defe156d24783511c2c03b5181d4c48e045c0
5
5
  SHA512:
6
- metadata.gz: 6d5672a54622c078e114192fec34ff3962432358f355e59b349015e9c43bbd43b244e8d3b0941f4e88182e89ac482258b9b5fb3393287eeccc8bff1c4939b284
7
- data.tar.gz: b1aa6cf035dc4d1b12277593f642d7d07383dc555908a41748a30d991d630ee9dc08eaeb0e4b5999dccc13034fad7c8826644532aa435c1d536bdaf52001d870
6
+ metadata.gz: ce7290828e74679a135c6f407275029f74ef60c6550e5a4949c02937dcf6d4b91abc4a90336ed3d84c9324d371b2d7593dac8eb34d910ea5fc13a9c1d7890841
7
+ data.tar.gz: 43203a490428887ebfd7509f0966a8a466cc4781e4871f7bc7d5208e3a9a2bb40541ae0a6c442e8085b4f5d953bf5e64cf8a5d3e680f7aa57397fbfc740880d6
@@ -0,0 +1,22 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6
19
+ - name: Install dependencies
20
+ run: bundle install
21
+ - name: Run tests
22
+ run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.7
3
+ SuggestExtensions: false
3
4
 
4
5
  Style/StringLiterals:
5
6
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2021-06-14
4
+
5
+ - Linting
6
+ - Code refactoring
7
+
3
8
  ## [0.1.0] - 2021-06-14
4
9
 
5
10
  - Added phone number validator
data/README.md CHANGED
@@ -25,8 +25,8 @@ Or install it yourself as:
25
25
  ```ruby
26
26
  require "rw_validator"
27
27
 
28
- RwValidator.is_phone_number? "0788854444" // true
29
- RwValidator.is_phone_number? "0778854444" // false
28
+ RwValidator.phone_number? "0788854444" // true
29
+ RwValidator.phone_number? "0778854444" // false
30
30
 
31
31
  ```
32
32
 
@@ -34,8 +34,8 @@ Or install it yourself as:
34
34
 
35
35
  ```ruby
36
36
 
37
- RwValidator.is_national_id? "1199672222000040" // true
38
- RwValidator.is_national_id? "1201772222000040" // false
37
+ RwValidator.national_id? "1199672222000040" // true
38
+ RwValidator.national_id? "1201772222000040" // false
39
39
 
40
40
  ```
41
41
 
@@ -49,4 +49,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
49
49
 
50
50
  ## Code of Conduct
51
51
 
52
- Everyone interacting in the rw_validator::Validator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/knowbee/rw-validator-gem/blob/master/CODE_OF_CONDUCT.md).
52
+ Everyone interacting in the rw_validator::Validator project's codebases, and issue trackers is expected to follow the [code of conduct](https://github.com/knowbee/rw-validator-gem/blob/master/CODE_OF_CONDUCT.md).
data/lib/rw_validator.rb CHANGED
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "./rw_validator/validator"
2
4
 
5
+ # RwValidator Module
3
6
  module RwValidator
4
-
5
- class << self
6
- def is_phone_number?(number)
7
- Validate.new.is_phone_number?(number)
7
+ class << self
8
+ def phone_number?(number)
9
+ Validate.new.phone_number?(number)
8
10
  end
9
11
 
10
- def is_national_id?(id)
11
- Validate.new.is_national_id?(id)
12
+ def national_id?(id)
13
+ Validate.new.national_id?(id)
12
14
  end
13
15
  end
14
- end
16
+ end
@@ -3,22 +3,24 @@
3
3
  require_relative "version"
4
4
 
5
5
  module RwValidator
6
- class Error < StandardError; end
7
- class Validate
8
- def is_phone_number?(number)
9
- number.match(/^(\+?25)?(078|075|073|072)\d{7}$/).nil? ? false : true
10
- end
6
+ class Error < StandardError; end
11
7
 
12
- def is_national_id?(id)
13
- return false if id.length < 16 || id.length > 16
14
- year_born = id[1..4]
15
- return !id.match(/^[1-3](19|20)\d{2}[7-8]\d{7}[0-9]\d{2}$/).nil? && check_if_eligible?(year_born)
16
- end
8
+ # Validate class, validate phone number and national id
9
+ class Validate
10
+ def phone_number?(number)
11
+ number.match(/^(\+?25)?(079|078|075|073|072)\d{7}$/).nil? ? false : true
12
+ end
13
+
14
+ def national_id?(id)
15
+ return false if id.length < 16 || id.length > 16
17
16
 
18
- def check_if_eligible?(year_born)
19
- current_year = Time.new.year
20
- current_year.to_i - year_born.to_i < 16 ? false : true
21
- end
17
+ year_born = id[1..4]
18
+ !id.match(/^[1-3](19|20)\d{2}[7-8]\d{7}[0-9]\d{2}$/).nil? && check_if_eligible?(year_born)
22
19
  end
23
20
 
21
+ def check_if_eligible?(year_born)
22
+ current_year = Time.new.year
23
+ current_year.to_i - year_born.to_i >= 16
24
+ end
25
+ end
24
26
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RwValidator
2
4
  module VERSION
3
5
  MAJOR = 0
4
6
  MINOR = 1
5
- TINY = 0
7
+ TINY = 1
6
8
  PRE = nil
7
9
 
8
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
10
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
9
11
 
10
12
  SUMMARY = "rw_validator #{STRING}"
11
13
  end
12
- end
14
+ end
data/rw_validator.gemspec CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.push File.expand_path('lib', __dir__)
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
3
4
  require_relative "lib/rw_validator/version"
4
5
 
5
6
  Gem::Specification.new do |spec|
@@ -12,9 +13,9 @@ Gem::Specification.new do |spec|
12
13
  spec.description = "Validate Rwandan phone numbers and national id"
13
14
  spec.homepage = "https://github.com/knowbee/rw-validator-gem"
14
15
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
16
17
 
17
- spec.metadata["allowed_push_host"] = 'https://rubygems.org'
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
19
 
19
20
  spec.metadata["homepage_uri"] = spec.homepage
20
21
  spec.metadata["source_code_uri"] = "https://github.com/knowbee/rw-validator-gem.git"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rw_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igwaneza Bruce
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/workflows/ci.yml"
20
21
  - ".gitignore"
21
22
  - ".rspec"
22
23
  - ".rubocop.yml"
@@ -48,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
49
  requirements:
49
50
  - - ">="
50
51
  - !ruby/object:Gem::Version
51
- version: 2.4.0
52
+ version: 2.7.0
52
53
  required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  requirements:
54
55
  - - ">="
@@ -58,5 +59,5 @@ requirements: []
58
59
  rubygems_version: 3.2.16
59
60
  signing_key:
60
61
  specification_version: 4
61
- summary: rw_validator 0.1.0
62
+ summary: rw_validator 0.1.1
62
63
  test_files: []