resident 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf01e9d01d506e8d1679e55d195fbf5b2b68e4f1ea92e071faa067c628ccdeed
4
- data.tar.gz: 05faa5d541a34c27f6bfd7b3285ca1d7e45b0ec6a8368a76bc989f670bea6f88
3
+ metadata.gz: 90fe6f9288f6764f383ff5f8e74cc2a2e31854df1eaf42ebacd505ee586b9328
4
+ data.tar.gz: 9fb294f619eeaf83066b315ab3daeedcc79cf713ff8b64ce188289313e54d554
5
5
  SHA512:
6
- metadata.gz: c5c5dae1f39cfc92325e801ccbe0af1823578afb21ace71433853d9bd689988789bf263751837589c35b89ffdf8affd2c5588971753393de21b86b5492c889a6
7
- data.tar.gz: 6796c74e79556f2a291b6e18657551a5300809951c9310fa4dd5f0788f422b84bdd5ddf1b3cad52e9c175f72429a7c317931ae4c9d2bc5ff47b2d3dc408d87ad
6
+ metadata.gz: bfa89495903de491d933a9d76f603213f8a84d28b7a828de49f79c5c9cee25c598c18b298e02296afc134f161ac99386e36d49c05733976553a213b57922c36e
7
+ data.tar.gz: 7c1725cea3d9e57f7efe7cebc63d91e461a1feac2edfbcffac1bad466b4cdce96d0f3a3c3463d5c851893ea0482434f7a0168c05ec364f1f4ffb1aec5f8a317f
@@ -10,14 +10,14 @@ module NationalIdentificationNumber
10
10
  super
11
11
  @number.gsub!(/[^0-9]/, '')
12
12
  if (matches = @number.match(/\A(?<birthday>[0-9]{6})(?<checksum>[0-9]{4})\z/))
13
- birthday, checksum = matches.values_at(:birthday, :checksum)
13
+ birthday, checksum = %w[birthday checksum].map { |group| matches[group] }
14
14
  @number = "#{birthday}-#{checksum}"
15
15
  end
16
16
  end
17
17
 
18
18
  def validate
19
19
  if (matches = @number.match(/\A(?<day>\d{2})(?<month>\d{2})(?<year>\d{2})-(?<serial>\d{3})(?<checksum>\d{1})\z/))
20
- day, month, year, serial, checksum = matches.values_at(:day, :month, :year, :serial, :checksum)
20
+ day, month, year, serial, checksum = %i[day month year serial checksum].map { |group| matches[group] }
21
21
  begin
22
22
  @date = Date.parse("#{full_year(serial, year)}-#{month}-#{day}")
23
23
  @valid = true
@@ -13,7 +13,8 @@ module NationalIdentificationNumber
13
13
 
14
14
  def validate
15
15
  if (matches = @number.match(/\A(?<day>\d{2})(?<month>\d{2})(?<year>\d{2})(?<serial>\d{3})(?<checksum>\d{2})\z/))
16
- day, month, year, serial, checksum = matches.values_at(:day, :month, :year, :serial, :checksum)
16
+ day, month, year, serial, checksum = %i[day month year serial checksum].map { |group| matches[group] }
17
+
17
18
  sans_checksum = "#{day}#{month}#{year}#{serial}"
18
19
 
19
20
  if checksum == calculate_checksum(sans_checksum)
@@ -53,7 +54,7 @@ module NationalIdentificationNumber
53
54
  def weighted_modulo_11(digits_and_weights)
54
55
  result = 11 - (digits_and_weights.map do |terms|
55
56
  terms.reduce(:*)
56
- end.sum % 11)
57
+ end.reduce(:+) % 11)
57
58
  result > 9 ? 0 : result
58
59
  end
59
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resident
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bukowskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-28 00:00:00.000000000 Z
11
+ date: 2022-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec