diff --git a/.rubocop.yml b/.rubocop.yml index a38ef2c..1eed7f2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ require: - rubocop-rake AllCops: + NewCops: enable TargetRubyVersion: 2.5 Bundler/OrderedGems: @@ -42,9 +43,6 @@ Metrics/MethodLength: Style/Documentation: Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false - Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes diff --git a/Gemfile b/Gemfile index 9b2f406..e053c32 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec diff --git a/Rakefile b/Rakefile index 3d52175..8ca97e1 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/gem_tasks" require "rake/testtask" diff --git a/bin/console b/bin/console index d7cd4be..f507c35 100755 --- a/bin/console +++ b/bin/console @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "bundler/setup" require "itax_code" diff --git a/itax_code.gemspec b/itax_code.gemspec index 8002511..13e1cc3 100644 --- a/itax_code.gemspec +++ b/itax_code.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "lib/itax_code/version" Gem::Specification.new do |spec| @@ -23,4 +25,5 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_dependency "activesupport" + spec.metadata["rubygems_mfa_required"] = "true" end diff --git a/lib/itax_code.rb b/lib/itax_code.rb index 266ef7a..92f5983 100644 --- a/lib/itax_code.rb +++ b/lib/itax_code.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/all" require "itax_code/version" diff --git a/lib/itax_code/encoder.rb b/lib/itax_code/encoder.rb index 22ad561..0180d4e 100644 --- a/lib/itax_code/encoder.rb +++ b/lib/itax_code/encoder.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ItaxCode # Handles the tax code generation logic. # @@ -60,9 +62,7 @@ def encode_name consonants = utils.extract_consonants chars vowels = utils.extract_vowels chars - if consonants.length > 3 - consonants = consonants.chars.values_at(0, 2..consonants.chars.size).join - end + consonants = consonants.chars.values_at(0, 2..consonants.size).join if consonants.length > 3 "#{consonants[0..2]}#{vowels[0..2]}XXX"[0..2].upcase end diff --git a/lib/itax_code/omocode.rb b/lib/itax_code/omocode.rb index 6ac1b80..0adf44d 100644 --- a/lib/itax_code/omocode.rb +++ b/lib/itax_code/omocode.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ItaxCode class Omocode attr_reader :tax_code, :utils @@ -11,26 +13,35 @@ def initialize(tax_code, utils = Utils.new) @utils = utils end - # Computes the omocodes from a given tax_code. + # Computes the omocodes from a given tax_code by first identifying the original + # tax_code and then appending all the omocodes. # # @return [Array] - def list - chars = tax_code[0..14].chars - (omocodes(:decode, chars) + omocodes(:encode, chars)).uniq + def omocodes + [original_omocode] + utils.omocodia_indexes_combos.map do |combo| + omocode(combo, ->(char) { utils.omocodia_encode(char) }) + end + end + + # The original omocode is the one that have all the omocody indexes decoded + # as number, and from which any of its omocodes are generated. + # + # @return [String] + def original_omocode + omocode(utils.omocodia_indexes, ->(char) { utils.omocodia_decode(char) }) end private - def omocodes(action, chars) - utils.omocodia_subs_indexes.reverse.map do |i| - chars[i] = utils.public_send("omocodia_#{action}".to_sym, chars[i]) - omocode(chars) + def omocode(indexes, translation) + chars = tax_code[0..14].chars + + indexes.each do |index| + chars[index] = translation.call(chars[index]) end - end - def omocode(chars) - code = chars.join - code + utils.encode_cin(code) + omocode = chars.join + omocode + utils.encode_cin(omocode) end end end diff --git a/lib/itax_code/parser.rb b/lib/itax_code/parser.rb index e7a7961..6e14ae7 100644 --- a/lib/itax_code/parser.rb +++ b/lib/itax_code/parser.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "itax_code/omocode" module ItaxCode @@ -30,7 +32,7 @@ def decode gender: gender, birthdate: birthdate, birthplace: birthplace, - omocodes: Omocode.new(tax_code).list, + omocodes: Omocode.new(tax_code).omocodes, raw: raw } end diff --git a/lib/itax_code/utils.rb b/lib/itax_code/utils.rb index e46ad2a..07b7056 100644 --- a/lib/itax_code/utils.rb +++ b/lib/itax_code/utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "csv" module ItaxCode @@ -10,9 +12,7 @@ def regex end def slugged(str, separator = "-") - str.gsub!(/\s*@\s*/, " at ") - str.gsub!(/\s*&\s*/, " and ") - str.parameterize(separator: separator) + str.gsub(/\s*@\s*/, " at ").gsub(/\s*&\s*/, " and ").parameterize(separator: separator) end def months @@ -29,23 +29,17 @@ def vowels def cin_odds { - "0": 1, "1": 0, "2": 5, "3": 7, "4": 9, "5": 13, - "6": 15, "7": 17, "8": 19, "9": 21, "A": 1, "B": 0, - "C": 5, "D": 7, "E": 9, "F": 13, "G": 15, "H": 17, - "I": 19, "J": 21, "K": 2, "L": 4, "M": 18, "N": 20, - "O": 11, "P": 3, "Q": 6, "R": 8, "S": 12, "T": 14, - "U": 16, "V": 10, "W": 22, "X": 25, "Y": 24, "Z": 23 + "0": 1, "1": 0, "2": 5, "3": 7, "4": 9, "5": 13, "6": 15, "7": 17, "8": 19, "9": 21, + A: 1, B: 0, C: 5, D: 7, E: 9, F: 13, G: 15, H: 17, I: 19, J: 21, K: 2, L: 4, M: 18, + N: 20, O: 11, P: 3, Q: 6, R: 8, S: 12, T: 14, U: 16, V: 10, W: 22, X: 25, Y: 24, Z: 23 } end def cin_evens { - "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, - "6": 6, "7": 7, "8": 8, "9": 9, "A": 0, "B": 1, - "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7, - "I": 8, "J": 9, "K": 10, "L": 11, "M": 12, "N": 13, - "O": 14, "P": 15, "Q": 16, "R": 17, "S": 18, "T": 19, - "U": 20, "V": 21, "W": 22, "X": 23, "Y": 24, "Z": 25 + "0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, + A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6, H: 7, I: 8, J: 9, K: 10, L: 11, M: 12, N: 13, + O: 14, P: 15, Q: 16, R: 17, S: 18, T: 19, U: 20, V: 21, W: 22, X: 23, Y: 24, Z: 25 } end @@ -68,8 +62,14 @@ def omocodia_letters omocodia.values.join end - def omocodia_subs_indexes - [6, 7, 9, 10, 12, 13, 14] + def omocodia_indexes + [6, 7, 9, 10, 12, 13, 14].reverse + end + + def omocodia_indexes_combos + (1..omocodia_indexes.size).flat_map do |index| + omocodia_indexes.combination(index).to_a + end end def omocodia_encode(val) diff --git a/lib/itax_code/validator.rb b/lib/itax_code/validator.rb index 61ed9ba..1e0b727 100644 --- a/lib/itax_code/validator.rb +++ b/lib/itax_code/validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ItaxCode # Handles the validation logic. # diff --git a/lib/itax_code/version.rb b/lib/itax_code/version.rb index ee34f9a..e496661 100644 --- a/lib/itax_code/version.rb +++ b/lib/itax_code/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ItaxCode - VERSION = "0.3.0".freeze + VERSION = "0.3.0" end diff --git a/rakelib/cities.rake b/rakelib/cities.rake index 9c15bec..b38a4fa 100644 --- a/rakelib/cities.rake +++ b/rakelib/cities.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "csv" require "net/http" require "tempfile" @@ -25,9 +27,7 @@ namespace :cities do end end - File.open("lib/itax_code/data/cities.csv", "w") do |output_file| - output_file.write(output_string) - end + File.write("lib/itax_code/data/cities.csv", output_string) ensure tempfile.close tempfile.unlink diff --git a/test/itax_code/encoder_test.rb b/test/itax_code/encoder_test.rb index 14ecdc7..a951aff 100644 --- a/test/itax_code/encoder_test.rb +++ b/test/itax_code/encoder_test.rb @@ -1,9 +1,12 @@ +# frozen_string_literal: true + require "test_helper" module ItaxCode class EncoderTest < ActiveSupport::TestCase test "public interface" do instance_methods = Encoder.instance_methods - Object.instance_methods + assert_equal %i[encode], instance_methods end diff --git a/test/itax_code/parser_test.rb b/test/itax_code/parser_test.rb index 5ad7702..eb7567c 100644 --- a/test/itax_code/parser_test.rb +++ b/test/itax_code/parser_test.rb @@ -1,9 +1,12 @@ +# frozen_string_literal: true + require "test_helper" module ItaxCode class ParserTest < ActiveSupport::TestCase test "public interface" do instance_methods = Parser.instance_methods - Object.instance_methods + assert_equal %i[decode], instance_methods end @@ -37,11 +40,131 @@ def decoded omocodes: %w[ CCCFBA85D03L219P CCCFBA85D03L21VE + CCCFBA85D03L2M9A + CCCFBA85D03LN19E + CCCFBA85D0PL219L + CCCFBA85DL3L219A + CCCFBA8RD03L219B + CCCFBAU5D03L219M CCCFBA85D03L2MVP + CCCFBA85D03LN1VT + CCCFBA85D0PL21VA + CCCFBA85DL3L21VP + CCCFBA8RD03L21VQ + CCCFBAU5D03L21VB + CCCFBA85D03LNM9P + CCCFBA85D0PL2M9W + CCCFBA85DL3L2M9L + CCCFBA8RD03L2M9M + CCCFBAU5D03L2M9X + CCCFBA85D0PLN19A + CCCFBA85DL3LN19P + CCCFBA8RD03LN19Q + CCCFBAU5D03LN19B + CCCFBA85DLPL219W + CCCFBA8RD0PL219X + CCCFBAU5D0PL219I + CCCFBA8RDL3L219M + CCCFBAU5DL3L219X + CCCFBAURD03L219Y CCCFBA85D03LNMVE + CCCFBA85D0PL2MVL + CCCFBA85DL3L2MVA + CCCFBA8RD03L2MVB + CCCFBAU5D03L2MVM + CCCFBA85D0PLN1VP + CCCFBA85DL3LN1VE + CCCFBA8RD03LN1VF + CCCFBAU5D03LN1VQ + CCCFBA85DLPL21VL + CCCFBA8RD0PL21VM + CCCFBAU5D0PL21VX + CCCFBA8RDL3L21VB + CCCFBAU5DL3L21VM + CCCFBAURD03L21VN + CCCFBA85D0PLNM9L + CCCFBA85DL3LNM9A + CCCFBA8RD03LNM9B + CCCFBAU5D03LNM9M + CCCFBA85DLPL2M9H + CCCFBA8RD0PL2M9I + CCCFBAU5D0PL2M9T + CCCFBA8RDL3L2M9X + CCCFBAU5DL3L2M9I + CCCFBAURD03L2M9J + CCCFBA85DLPLN19L + CCCFBA8RD0PLN19M + CCCFBAU5D0PLN19X + CCCFBA8RDL3LN19B + CCCFBAU5DL3LN19M + CCCFBAURD03LN19N + CCCFBA8RDLPL219I + CCCFBAU5DLPL219T + CCCFBAURD0PL219U + CCCFBAURDL3L219J CCCFBA85D0PLNMVA + CCCFBA85DL3LNMVP + CCCFBA8RD03LNMVQ + CCCFBAU5D03LNMVB + CCCFBA85DLPL2MVW + CCCFBA8RD0PL2MVX + CCCFBAU5D0PL2MVI + CCCFBA8RDL3L2MVM + CCCFBAU5DL3L2MVX + CCCFBAURD03L2MVY + CCCFBA85DLPLN1VA + CCCFBA8RD0PLN1VB + CCCFBAU5D0PLN1VM + CCCFBA8RDL3LN1VQ + CCCFBAU5DL3LN1VB + CCCFBAURD03LN1VC + CCCFBA8RDLPL21VX + CCCFBAU5DLPL21VI + CCCFBAURD0PL21VJ + CCCFBAURDL3L21VY + CCCFBA85DLPLNM9W + CCCFBA8RD0PLNM9X + CCCFBAU5D0PLNM9I + CCCFBA8RDL3LNM9M + CCCFBAU5DL3LNM9X + CCCFBAURD03LNM9Y + CCCFBA8RDLPL2M9T + CCCFBAU5DLPL2M9E + CCCFBAURD0PL2M9F + CCCFBAURDL3L2M9U + CCCFBA8RDLPLN19X + CCCFBAU5DLPLN19I + CCCFBAURD0PLN19J + CCCFBAURDL3LN19Y + CCCFBAURDLPL219F CCCFBA85DLPLNMVL + CCCFBA8RD0PLNMVM + CCCFBAU5D0PLNMVX + CCCFBA8RDL3LNMVB + CCCFBAU5DL3LNMVM + CCCFBAURD03LNMVN + CCCFBA8RDLPL2MVI + CCCFBAU5DLPL2MVT + CCCFBAURD0PL2MVU + CCCFBAURDL3L2MVJ + CCCFBA8RDLPLN1VM + CCCFBAU5DLPLN1VX + CCCFBAURD0PLN1VY + CCCFBAURDL3LN1VN + CCCFBAURDLPL21VU + CCCFBA8RDLPLNM9I + CCCFBAU5DLPLNM9T + CCCFBAURD0PLNM9U + CCCFBAURDL3LNM9J + CCCFBAURDLPL2M9Q + CCCFBAURDLPLN19U CCCFBA8RDLPLNMVX + CCCFBAU5DLPLNMVI + CCCFBAURD0PLNMVJ + CCCFBAURDL3LNMVY + CCCFBAURDLPL2MVF + CCCFBAURDLPLN1VJ + CCCFBAURDLPLNM9F CCCFBAURDLPLNMVU ], raw: { @@ -72,11 +195,131 @@ def decoded_f omocodes: %w[ RSSMRA80A41F205B RSSMRA80A41F20RW + RSSMRA80A41F2L5M + RSSMRA80A41FN05Q + RSSMRA80A4MF205T + RSSMRA80AQ1F205N + RSSMRA8LA41F205M + RSSMRAU0A41F205Y RSSMRA80A41F2LRH + RSSMRA80A41FN0RL + RSSMRA80A4MF20RO + RSSMRA80AQ1F20RI + RSSMRA8LA41F20RH + RSSMRAU0A41F20RT + RSSMRA80A41FNL5B + RSSMRA80A4MF2L5E + RSSMRA80AQ1F2L5Y + RSSMRA8LA41F2L5X + RSSMRAU0A41F2L5J + RSSMRA80A4MFN05I + RSSMRA80AQ1FN05C + RSSMRA8LA41FN05B + RSSMRAU0A41FN05N + RSSMRA80AQMF205F + RSSMRA8LA4MF205E + RSSMRAU0A4MF205Q + RSSMRA8LAQ1F205Y + RSSMRAU0AQ1F205K + RSSMRAULA41F205J RSSMRA80A41FNLRW + RSSMRA80A4MF2LRZ + RSSMRA80AQ1F2LRT + RSSMRA8LA41F2LRS + RSSMRAU0A41F2LRE + RSSMRA80A4MFN0RD + RSSMRA80AQ1FN0RX + RSSMRA8LA41FN0RW + RSSMRAU0A41FN0RI + RSSMRA80AQMF20RA + RSSMRA8LA4MF20RZ + RSSMRAU0A4MF20RL + RSSMRA8LAQ1F20RT + RSSMRAU0AQ1F20RF + RSSMRAULA41F20RE + RSSMRA80A4MFNL5T + RSSMRA80AQ1FNL5N + RSSMRA8LA41FNL5M + RSSMRAU0A41FNL5Y + RSSMRA80AQMF2L5Q + RSSMRA8LA4MF2L5P + RSSMRAU0A4MF2L5B + RSSMRA8LAQ1F2L5J + RSSMRAU0AQ1F2L5V + RSSMRAULA41F2L5U + RSSMRA80AQMFN05U + RSSMRA8LA4MFN05T + RSSMRAU0A4MFN05F + RSSMRA8LAQ1FN05N + RSSMRAU0AQ1FN05Z + RSSMRAULA41FN05Y + RSSMRA8LAQMF205Q + RSSMRAU0AQMF205C + RSSMRAULA4MF205B + RSSMRAULAQ1F205V RSSMRA80A4MFNLRO + RSSMRA80AQ1FNLRI + RSSMRA8LA41FNLRH + RSSMRAU0A41FNLRT + RSSMRA80AQMF2LRL + RSSMRA8LA4MF2LRK + RSSMRAU0A4MF2LRW + RSSMRA8LAQ1F2LRE + RSSMRAU0AQ1F2LRQ + RSSMRAULA41F2LRP + RSSMRA80AQMFN0RP + RSSMRA8LA4MFN0RO + RSSMRAU0A4MFN0RA + RSSMRA8LAQ1FN0RI + RSSMRAU0AQ1FN0RU + RSSMRAULA41FN0RT + RSSMRA8LAQMF20RL + RSSMRAU0AQMF20RX + RSSMRAULA4MF20RW + RSSMRAULAQ1F20RQ + RSSMRA80AQMFNL5F + RSSMRA8LA4MFNL5E + RSSMRAU0A4MFNL5Q + RSSMRA8LAQ1FNL5Y + RSSMRAU0AQ1FNL5K + RSSMRAULA41FNL5J + RSSMRA8LAQMF2L5B + RSSMRAU0AQMF2L5N + RSSMRAULA4MF2L5M + RSSMRAULAQ1F2L5G + RSSMRA8LAQMFN05F + RSSMRAU0AQMFN05R + RSSMRAULA4MFN05Q + RSSMRAULAQ1FN05K + RSSMRAULAQMF205N RSSMRA80AQMFNLRA + RSSMRA8LA4MFNLRZ + RSSMRAU0A4MFNLRL + RSSMRA8LAQ1FNLRT + RSSMRAU0AQ1FNLRF + RSSMRAULA41FNLRE + RSSMRA8LAQMF2LRW + RSSMRAU0AQMF2LRI + RSSMRAULA4MF2LRH + RSSMRAULAQ1F2LRB + RSSMRA8LAQMFN0RA + RSSMRAU0AQMFN0RM + RSSMRAULA4MFN0RL + RSSMRAULAQ1FN0RF + RSSMRAULAQMF20RI + RSSMRA8LAQMFNL5Q + RSSMRAU0AQMFNL5C + RSSMRAULA4MFNL5B + RSSMRAULAQ1FNL5V + RSSMRAULAQMF2L5Y + RSSMRAULAQMFN05C RSSMRA8LAQMFNLRL + RSSMRAU0AQMFNLRX + RSSMRAULA4MFNLRW + RSSMRAULAQ1FNLRQ + RSSMRAULAQMF2LRT + RSSMRAULAQMFN0RX + RSSMRAULAQMFNL5N RSSMRAULAQMFNLRI ], raw: { @@ -105,11 +348,131 @@ def decoded_foreign omocodes: %w[ BRRDRN70M41Z602D BRRDRN70M41Z60NS + BRRDRN70M41Z6L2O + BRRDRN70M41ZS02A + BRRDRN70M4MZ602V + BRRDRN70MQ1Z602P + BRRDRN7LM41Z602O + BRRDRNT0M41Z602A BRRDRN70M41Z6LND + BRRDRN70M41ZS0NP + BRRDRN70M4MZ60NK + BRRDRN70MQ1Z60NE + BRRDRN7LM41Z60ND + BRRDRNT0M41Z60NP + BRRDRN70M41ZSL2L + BRRDRN70M4MZ6L2G + BRRDRN70MQ1Z6L2A + BRRDRN7LM41Z6L2Z + BRRDRNT0M41Z6L2L + BRRDRN70M4MZS02S + BRRDRN70MQ1ZS02M + BRRDRN7LM41ZS02L + BRRDRNT0M41ZS02X + BRRDRN70MQMZ602H + BRRDRN7LM4MZ602G + BRRDRNT0M4MZ602S + BRRDRN7LMQ1Z602A + BRRDRNT0MQ1Z602M + BRRDRNTLM41Z602L BRRDRN70M41ZSLNA + BRRDRN70M4MZ6LNV + BRRDRN70MQ1Z6LNP + BRRDRN7LM41Z6LNO + BRRDRNT0M41Z6LNA + BRRDRN70M4MZS0NH + BRRDRN70MQ1ZS0NB + BRRDRN7LM41ZS0NA + BRRDRNT0M41ZS0NM + BRRDRN70MQMZ60NW + BRRDRN7LM4MZ60NV + BRRDRNT0M4MZ60NH + BRRDRN7LMQ1Z60NP + BRRDRNT0MQ1Z60NB + BRRDRNTLM41Z60NA + BRRDRN70M4MZSL2D + BRRDRN70MQ1ZSL2X + BRRDRN7LM41ZSL2W + BRRDRNT0M41ZSL2I + BRRDRN70MQMZ6L2S + BRRDRN7LM4MZ6L2R + BRRDRNT0M4MZ6L2D + BRRDRN7LMQ1Z6L2L + BRRDRNT0MQ1Z6L2X + BRRDRNTLM41Z6L2W + BRRDRN70MQMZS02E + BRRDRN7LM4MZS02D + BRRDRNT0M4MZS02P + BRRDRN7LMQ1ZS02X + BRRDRNT0MQ1ZS02J + BRRDRNTLM41ZS02I + BRRDRN7LMQMZ602S + BRRDRNT0MQMZ602E + BRRDRNTLM4MZ602D + BRRDRNTLMQ1Z602X BRRDRN70M4MZSLNS + BRRDRN70MQ1ZSLNM + BRRDRN7LM41ZSLNL + BRRDRNT0M41ZSLNX + BRRDRN70MQMZ6LNH + BRRDRN7LM4MZ6LNG + BRRDRNT0M4MZ6LNS + BRRDRN7LMQ1Z6LNA + BRRDRNT0MQ1Z6LNM + BRRDRNTLM41Z6LNL + BRRDRN70MQMZS0NT + BRRDRN7LM4MZS0NS + BRRDRNT0M4MZS0NE + BRRDRN7LMQ1ZS0NM + BRRDRNT0MQ1ZS0NY + BRRDRNTLM41ZS0NX + BRRDRN7LMQMZ60NH + BRRDRNT0MQMZ60NT + BRRDRNTLM4MZ60NS + BRRDRNTLMQ1Z60NM + BRRDRN70MQMZSL2P + BRRDRN7LM4MZSL2O + BRRDRNT0M4MZSL2A + BRRDRN7LMQ1ZSL2I + BRRDRNT0MQ1ZSL2U + BRRDRNTLM41ZSL2T + BRRDRN7LMQMZ6L2D + BRRDRNT0MQMZ6L2P + BRRDRNTLM4MZ6L2O + BRRDRNTLMQ1Z6L2I + BRRDRN7LMQMZS02P + BRRDRNT0MQMZS02B + BRRDRNTLM4MZS02A + BRRDRNTLMQ1ZS02U + BRRDRNTLMQMZ602P BRRDRN70MQMZSLNE + BRRDRN7LM4MZSLND + BRRDRNT0M4MZSLNP + BRRDRN7LMQ1ZSLNX + BRRDRNT0MQ1ZSLNJ + BRRDRNTLM41ZSLNI + BRRDRN7LMQMZ6LNS + BRRDRNT0MQMZ6LNE + BRRDRNTLM4MZ6LND + BRRDRNTLMQ1Z6LNX + BRRDRN7LMQMZS0NE + BRRDRNT0MQMZS0NQ + BRRDRNTLM4MZS0NP + BRRDRNTLMQ1ZS0NJ + BRRDRNTLMQMZ60NE + BRRDRN7LMQMZSL2A + BRRDRNT0MQMZSL2M + BRRDRNTLM4MZSL2L + BRRDRNTLMQ1ZSL2F + BRRDRNTLMQMZ6L2A + BRRDRNTLMQMZS02M BRRDRN7LMQMZSLNP + BRRDRNT0MQMZSLNB + BRRDRNTLM4MZSLNA + BRRDRNTLMQ1ZSLNU + BRRDRNTLMQMZ6LNP + BRRDRNTLMQMZS0NB + BRRDRNTLMQMZSL2X BRRDRNTLMQMZSLNM ], raw: { diff --git a/test/itax_code/validator_test.rb b/test/itax_code/validator_test.rb index 0a75ee7..881ebb9 100644 --- a/test/itax_code/validator_test.rb +++ b/test/itax_code/validator_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" module ItaxCode @@ -5,6 +7,7 @@ class ValidatorTest < ActiveSupport::TestCase test "public interface" do instance_methods = Validator.instance_methods - Object.instance_methods class_methods = Validator.methods - Object.methods + assert_equal %i[valid?], instance_methods assert_equal %i[standard_length?], class_methods end diff --git a/test/itax_code_test.rb b/test/itax_code_test.rb index 5915ecf..824abac 100644 --- a/test/itax_code_test.rb +++ b/test/itax_code_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ItaxCodeTest < ActiveSupport::TestCase @@ -9,11 +11,12 @@ class ItaxCodeTest < ActiveSupport::TestCase birthdate: Date.new(1980, 1, 10), birthplace: "Milano" ) + assert_equal "RSSMRA80A10F205Z", result end test "#decode" do - assert_equal Hash, klass.decode("RSSMRA80A41F205B").class + assert_instance_of Hash, klass.decode("RSSMRA80A41F205B") end test "#valid?" do diff --git a/test/test_helper.rb b/test/test_helper.rb index 3e57197..90faf98 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "simplecov" SimpleCov.start