valvat 1.2.1 → 1.4.0

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: 9b0b39e1acd3284cb03b0a5cd1a2beec5dc11b7539491829ebf56086c7a40413
4
- data.tar.gz: 15c2ae43ec8fb9ad276d7cd473c51c1c505bdc53e1049ddc6554fea15a2a0c4d
3
+ metadata.gz: 15db8a8eed2ca747b9a57a31d9b86b3cf15de8805c60e4c9088f6d4307c61f3e
4
+ data.tar.gz: 7e39c7bce5487ca35f919c92bce4b424feacdded7a2ae917d272836bb2a224f7
5
5
  SHA512:
6
- metadata.gz: c6342f5e92bc881b491ac326a17b6327c622f639476bbffa60876b89aa1a1f6ab30848d56f58202567b51a930037e715dcbe10e8cadc021d4f72a5560227df84
7
- data.tar.gz: b029ff8192f35b77abf95bdc5adcff6ce3afbb6895b46d2dcb51d9d062c46de7d9e64a9e6653e16201938b6f3b32976ea83656b08551619d5d89d9894c823dac
6
+ metadata.gz: 0f4f6c82582854e8bed285713f0e98322d4caaddc9ad544f75116a22c5522e8ef224fdf126e704396a5c2651819cc5c155536a6d736923e80966c9b9a4a72810
7
+ data.tar.gz: 6d2f3e585eb86086600e6976df74cf1fe46a145aedaa25fe3eb8fad3eb8bd5eba7db3c24d2b43efead054bec086188512767816cfe52d4fe1eb0280a5f870e23
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1 @@
1
- I!�\$PmsK܉�-'2����Ŀ�S\�H�eR�kZa1s70NDEs�oPr4d����܏��b'��KeE-�x�,^�C�-*��[$Fb��Z����5yw_O
2
- 0����T��FC%V,�3~L}ʍԨHK�]�����bh$d���΃g��m���t������Z洕Zt�����:rRpY�g:8�����A��,�5�R������ڙf���2�Bt�7ɖ^��ε�*G����ML��љ���1uk��}�QI� ���v_��s�z�֛}�XJ>���NĀ�q��C�W�>�RF��ՙW�ǯ2f}6dŐ�j�&/a���®=��1� �zd���+�iė��A�ȜaH�@u�����7
1
+ �2��TV���}���K�h�[r�_�~���n��Z ��6snj�$���l9�Z�"[��V6������&y ����{OcM`���[���7O�V~ #��|j�F�~�]�\�fw�"��Y������w���K(�A3�~��/��12xv#缃���j � !�nM�c�]?��� wg�<� �G0pee�C���-�AD}hWv��OǛ�w�&�!��$�n�{��sf_N ���Դ @ld�F�O#>_�!�R�� (���V��\y wh:2�ALE�,�5�1}9�X�8��Y��V'/\o>�����ޔ�=�A�Lx���^˵mB0�W��;e.`���n��_�p}}F�,��<�PUAu�[�_N��q`;JM��fs(f�
@@ -0,0 +1,17 @@
1
+ name: RuboCop
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - name: Set up Ruby 2.7
12
+ uses: ruby/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.7
15
+ bundler-cache: true
16
+ - name: Run RuboCop
17
+ run: bundle exec rubocop --parallel
@@ -12,25 +12,29 @@ on:
12
12
  jobs:
13
13
  test:
14
14
  if: "!contains(github.event.head_commit.message, '[skip ci]')"
15
- runs-on: ubuntu-latest
15
+ runs-on: ubuntu-20.04
16
16
  env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
17
17
  BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
18
18
  strategy:
19
19
  matrix:
20
- ruby-version: ['2.6', '2.7', '3.0', '3.1', 'jruby-9.3.2.0']
20
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', 'jruby-9.4.0.0']
21
21
  gemfile: [ 'standalone', 'activemodel-5', 'activemodel-6', 'activemodel-7' ]
22
22
  exclude:
23
- - ruby-version: '3.0'
23
+ - ruby-version: '3.2'
24
+ gemfile: 'activemodel-5'
25
+ - ruby-version: '3.1'
24
26
  gemfile: 'activemodel-5'
25
27
  - ruby-version: '3.1'
28
+ gemfile: 'standalone'
29
+ - ruby-version: '3.0'
26
30
  gemfile: 'activemodel-5'
27
31
  - ruby-version: '2.6'
28
32
  gemfile: 'activemodel-7'
29
- - ruby-version: 'jruby-9.3.2.0'
30
- gemfile: 'activemodel-7'
33
+ - ruby-version: 'jruby-9.4.0.0'
34
+ gemfile: 'activemodel-5'
31
35
 
32
36
  steps:
33
- - uses: actions/checkout@v2
37
+ - uses: actions/checkout@v3
34
38
  - name: Set up Ruby
35
39
  uses: ruby/setup-ruby@v1
36
40
  with:
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  require: rubocop-rspec
2
2
  AllCops:
3
3
  NewCops: enable
4
- TargetRubyVersion: 2.5
4
+ TargetRubyVersion: 2.6
5
5
 
6
6
  Metrics/BlockLength:
7
7
  Exclude:
data/CHANGES.md CHANGED
@@ -1,7 +1,22 @@
1
1
 
2
2
  ### dev
3
3
 
4
- [full changelog](http://github.com/yolk/valvat/compare/v1.2.1...master)
4
+ [full changelog](http://github.com/yolk/valvat/compare/v1.4.0...master)
5
+
6
+ ### 1.4.0 / 2023-07-20
7
+
8
+ [full changelog](http://github.com/yolk/valvat/compare/v1.3.0...v1.4.0)
9
+
10
+ * Valvat.configure: Allow global configuration
11
+ * Update the Cyprus syntax regular expression by [Orien Madgwick](https://github.com/orien))
12
+ * Valvat::Checksum::ES: Fixed issue with VAT ids starting with '*00' #124 / #115 (by [Thomas Scalise](https://github.com/KirtashW17))
13
+
14
+ ### 1.3.0 / 2023-04-19
15
+
16
+ [full changelog](http://github.com/yolk/valvat/compare/v1.2.1...v1.3.0)
17
+
18
+ * Checksum::FR: Correct validation for french VAT ids not starting with two numerical chars #119
19
+ * Equality for Valvat objects #120
5
20
 
6
21
  ### 1.2.1 / 2022-10-05
7
22
 
data/Gemfile CHANGED
@@ -5,4 +5,10 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in valvat.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'activemodel', '>= 5.0'
8
9
  gem 'guard-rspec', '~>4.0'
10
+ gem 'rake'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'rubocop', '~> 1.50'
13
+ gem 'rubocop-rspec', '~> 2.19'
14
+ gem 'webmock', '~> 3.0'
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2022 mite GmbH
1
+ Copyright (c) mite GmbH
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -22,7 +22,7 @@ Northern Ireland received its own VAT number prefix - XI which is supported by V
22
22
  * I18n locales for language specific error messages in English, German, French, Spanish, Italian, Portuguese, Polish, Swedish, Dutch, Danish, Czech, Slovakian, Hungarian, Bulgarian, Romanian, Latvian, Catalan, Norwegian, and Finnish.
23
23
  * *Experimental* checksum verification
24
24
 
25
- valvat is tested and works with ruby MRI 2.6/2.7/3.0/3.1, jruby and ActiveModel 5/6/7. If you need support for ruby down to 1.9.3 and ActiveModel 3 and 4 use [v1.0.1](https://github.com/yolk/valvat/tree/v1.0.1).
25
+ valvat is tested and works with ruby MRI 2.6/2.7/3.0/3.1/3.2, jruby and ActiveModel 5/6/7. If you need support for ruby down to 1.9.3 and ActiveModel 3 and 4 use [v1.0.1](https://github.com/yolk/valvat/tree/v1.0.1).
26
26
 
27
27
  ## Installation
28
28
 
@@ -129,7 +129,7 @@ Valvat.new("IE6388047V").exists?(raise_error: true)
129
129
 
130
130
  This raises `Valvat::ServiceUnavailable` or `Valvat::MemberStateUnavailable` instead of returning `nil`.
131
131
 
132
- Visit [http://ec.europa.eu/taxation_customs/vies/viesspec.do](http://ec.europa.eu/taxation_customs/vies/viesspec.do) for more accurate information at what time the service for a specific member state will be down.
132
+ Visit [https://ec.europa.eu/taxation_customs/vies/#/help](https://ec.europa.eu/taxation_customs/vies/#/help) for more accurate information at what time the service for a specific member state will be down.
133
133
 
134
134
  ### Handling of other errors
135
135
 
@@ -183,6 +183,20 @@ Valvat::Checksum.validate("DE345789003")
183
183
  # => true or false
184
184
  ```
185
185
 
186
+ ## Configuration
187
+
188
+ Instead of passing in the same options again and again, Valvat allows to alter its default configuration. This feature is intended to be used when initializing your application (for example in a Rails initializer file).
189
+
190
+ ```ruby
191
+ Valvat.configure(
192
+ uk: true,
193
+ raise_error: true,
194
+ http: { read_timeout: 5 }
195
+ )
196
+ ```
197
+
198
+ To see all options and the defaults, take a look at [valvat/configuration](https://github.com/yolk/valvat/blob/master/lib/valvat/configuration.rb#L25).
199
+
186
200
  ## Usage with ActiveModel / Rails
187
201
 
188
202
  ### Loading
@@ -329,8 +343,8 @@ https://github.com/yolk/valvat/graphs/contributors
329
343
 
330
344
  ## BlaBla
331
345
 
332
- Copyright (c) 2011-2022 mite GmbH
346
+ Copyright (c) 2011-2023 mite GmbH
333
347
 
334
348
  Beyond that, the implementation is licensed under the MIT License.
335
349
 
336
- Code was originally extracted from our time tracking webapp [mite](https://mite.yo.lk/en/).
350
+ Code was originally extracted from our time tracking webapp [mite](https://mite.de/en/).
data/certs/mite.pem ADDED
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MRIwEAYDVQQDDAlzZWJh
3
+ c3RpYW4xFDASBgoJkiaJk/IsZAEZFgRtaXRlMRIwEAYKCZImiZPyLGQBGRYCZGUw
4
+ HhcNMjMwNDE5MDkxMzEyWhcNMjQwNDE4MDkxMzEyWjA+MRIwEAYDVQQDDAlzZWJh
5
+ c3RpYW4xFDASBgoJkiaJk/IsZAEZFgRtaXRlMRIwEAYKCZImiZPyLGQBGRYCZGUw
6
+ ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDAWAF/CaDp0cmY7Q2vAqVn
7
+ TpB3xmKKPNfF1Bh9X3P9pKRBl2iCW+JmqIV+J5Yts9mB+OYKfxjJM7mmQwT8DMf2
8
+ KwYIVISGKooRyXPgGgKepYfSfemizey6soCoejIIEHczsRk/FeKcvwlFrqMymBrF
9
+ QP5XhnF0TEQvg/sG97w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+fAu6dlLcbEpij9z
25
+ 4QlUng62OJRSBV/ejaTTItcAOXBeh028ZFWC0QQR4r0=
26
+ -----END CERTIFICATE-----
@@ -1,7 +1,8 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activemodel", "~> 5.0"
3
+ gem 'activemodel', '~> 5.0'
4
+ gem 'rake'
5
+ gem 'rspec', '~> 3.0'
6
+ gem 'webmock', '~> 3.0'
4
7
 
5
- gem 'rack'
6
-
7
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,10 +1,8 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activemodel", "~> 6.0"
3
+ gem 'activemodel', '~> 6.0'
4
+ gem 'rake'
5
+ gem 'rspec', '~> 3.0'
6
+ gem 'webmock', '~> 3.0'
4
7
 
5
- gem 'rack'
6
- gem 'net-smtp', require: false
7
- gem 'net-imap', require: false
8
- gem 'net-pop', require: false
9
-
10
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,10 +1,8 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "activemodel", "~> 7.0"
3
+ gem 'activemodel', '~> 7.0'
4
+ gem 'rake'
5
+ gem 'rspec', '~> 3.0'
6
+ gem 'webmock', '~> 3.0'
4
7
 
5
- gem 'rack'
6
- gem 'net-smtp', require: false
7
- gem 'net-imap', require: false
8
- gem 'net-pop', require: false
9
-
10
- gemspec path: "../"
8
+ gemspec path: '../'
data/gemfiles/standalone CHANGED
@@ -1,8 +1,7 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'rack', '< 2'
4
- gem 'net-smtp', require: false
5
- gem 'net-imap', require: false
6
- gem 'net-pop', require: false
3
+ gem 'rake'
4
+ gem 'rspec', '~> 3.0'
5
+ gem 'webmock', '~> 3.0'
7
6
 
8
- gemspec path: "../"
7
+ gemspec path: '../'
@@ -9,7 +9,7 @@ class Valvat
9
9
  end
10
10
 
11
11
  def str_wo_country
12
- super[1..-1]
12
+ super[1..]
13
13
  end
14
14
  end
15
15
  end
@@ -23,9 +23,9 @@ class Valvat
23
23
  !(
24
24
  # [KLM]: CD first two numerical digits must be between 01 and 56 (both inclusive)
25
25
  (vat.to_s_wo_country =~ SPECIAL_NIF_EXP &&
26
- vat.to_s_wo_country[1..2].to_i > 56) or vat.to_s_wo_country[1..2].to_i < 0o1 ||
27
- # Exceptions: X0000000T, 00000001R, 00000000T, 99999999R are invalid.
28
- %w[X0000000T 00000001R 00000000T 99999999R].include?(vat.to_s_wo_country)
26
+ (vat.to_s_wo_country[1..2].to_i > 56 || vat.to_s_wo_country[1..2].to_i < 1)) ||
27
+ # Exceptions: X0000000T, 00000001R, 00000000T & 99999999R are invalid.
28
+ %w[X0000000T 00000001R 00000000T 99999999R].include?(vat.to_s_wo_country)
29
29
  )
30
30
  end
31
31
 
@@ -55,7 +55,7 @@ class Valvat
55
55
 
56
56
  def str_wo_country
57
57
  str = super
58
- str[0] =~ /\d/ ? str : str[1..-1]
58
+ str[0] =~ /\d/ ? str : str[1..]
59
59
  end
60
60
 
61
61
  def person?
@@ -3,14 +3,35 @@
3
3
  class Valvat
4
4
  module Checksum
5
5
  class FR < Base
6
+ # the valid characters for the first two digits (O and I are missing)
7
+ ALPHABET = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZ'
8
+ NUMERIC = /^\d+$/.freeze
9
+
10
+ def validate
11
+ return super if str_wo_country[0..1] =~ NUMERIC
12
+
13
+ check = alt_check_digit
14
+
15
+ (str_wo_country[2..].to_i + 1 + (check / 11)) % 11 == check % 11
16
+ end
17
+
18
+ private
19
+
6
20
  def check_digit
7
- siren = str_wo_country[2..-1].to_i
21
+ siren = str_wo_country[2..].to_i
8
22
  (12 + ((3 * siren) % 97)) % 97
9
23
  end
10
24
 
11
25
  def given_check_digit
12
26
  str_wo_country[0..1].to_i
13
27
  end
28
+
29
+ def alt_check_digit
30
+ first_is_numeric = str_wo_country[0] =~ NUMERIC
31
+
32
+ (ALPHABET.index(str_wo_country[0]) * (first_is_numeric ? 24 : 34)) +
33
+ ALPHABET.index(str_wo_country[1]) - (first_is_numeric ? 10 : 100)
34
+ end
14
35
  end
15
36
  end
16
37
  end
@@ -6,7 +6,7 @@ class Valvat
6
6
  check_digit_length 0
7
7
 
8
8
  def validate
9
- vat.to_s_wo_country[-2..-1].to_i.positive? &&
9
+ vat.to_s_wo_country[-2..].to_i.positive? &&
10
10
  super
11
11
  end
12
12
 
@@ -21,7 +21,7 @@ class Valvat
21
21
  private
22
22
 
23
23
  def given_check_digit_str
24
- str_wo_country[-self.class.check_digit_length..-1]
24
+ str_wo_country[-self.class.check_digit_length..]
25
25
  end
26
26
 
27
27
  def given_check_digit
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'singleton'
4
+
5
+ class Valvat
6
+ ##
7
+ # Configuration options should be set by passing a hash:
8
+ #
9
+ # Valvat.configure(
10
+ # uk: true
11
+ # )
12
+ #
13
+ def self.configure(options)
14
+ Configuration.instance.configure(options) unless options.nil?
15
+ end
16
+
17
+ # Read-only access to config
18
+ def self.config
19
+ Configuration.instance
20
+ end
21
+
22
+ class Configuration
23
+ include Singleton
24
+
25
+ DEFAULTS = {
26
+ # Set to true to always raise error, even on temporary maintenance downtime errors,
27
+ # set to false to suppress all errors and return nil instead
28
+ raise_error: nil,
29
+
30
+ # Set options for the http client.
31
+ # These options are directly passed to `Net::HTTP.start`
32
+ http: {}.freeze,
33
+
34
+ # Return details hash on lookup instead of boolean
35
+ detail: false,
36
+
37
+ # Your own VAT number used on lookup
38
+ requester: nil,
39
+
40
+ # Skip local validation on lookup
41
+ skip_local_validation: false,
42
+
43
+ # Use lookup via HMRC for VAT numbers from the UK
44
+ # if set to false lookup will always return false for UK VAT numbers
45
+ uk: false
46
+ }.freeze
47
+
48
+ def self.initialize
49
+ instance.send(:initialize)
50
+ end
51
+
52
+ def [](key)
53
+ @data[key]
54
+ end
55
+
56
+ def configure(options)
57
+ @data = @data.merge(Utils.deep_symbolize_keys(options))
58
+ end
59
+
60
+ def initialize
61
+ @data = DEFAULTS.clone
62
+ end
63
+ end
64
+ end
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'net/http'
4
+ require_relative '../options'
4
5
 
5
6
  class Valvat
6
7
  class Lookup
7
8
  class Base
8
9
  def initialize(vat, options = {})
9
10
  @vat = Valvat(vat)
10
- @options = options
11
+ @options = Valvat::Options(options)
11
12
  @requester = @options[:requester] && Valvat(@options[:requester])
12
13
  end
13
14
 
@@ -39,7 +40,7 @@ class Valvat
39
40
  def fetch(uri, limit = 0)
40
41
  response = send_request(uri)
41
42
 
42
- if Net::HTTPRedirection == response && limit < 5
43
+ if response == Net::HTTPRedirection && limit < 5
43
44
  fetch(URI.parse(response['Location']), limit + 1)
44
45
  else
45
46
  response
@@ -59,14 +60,7 @@ class Valvat
59
60
  end
60
61
 
61
62
  def options_for(uri)
62
- options = if @options.key?(:savon)
63
- puts 'DEPRECATED: The option :savon is deprecated. Use :http instead.'
64
- @options[:savon]
65
- else
66
- @options[:http]
67
- end || {}
68
-
69
- options.merge({ use_ssl: URI::HTTPS === uri })
63
+ @options[:http].merge({ use_ssl: URI::HTTPS === uri })
70
64
  end
71
65
  end
72
66
  end
@@ -15,7 +15,7 @@ class Valvat
15
15
  }.freeze
16
16
 
17
17
  def perform
18
- return { valid: false } unless @options[:uk] == true
18
+ return { valid: false } unless @options[:uk]
19
19
 
20
20
  parse(fetch(endpoint_uri).body)
21
21
  end
data/lib/valvat/lookup.rb CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  require_relative 'lookup/vies'
4
4
  require_relative 'lookup/hmrc'
5
+ require_relative 'options'
5
6
 
6
7
  class Valvat
7
8
  class Lookup
8
9
  def initialize(vat, options = {})
9
10
  @vat = Valvat(vat)
10
- @options = options || {}
11
- @options[:requester] ||= @options[:requester_vat]
11
+ @options = Valvat::Options(options)
12
12
  end
13
13
 
14
14
  def validate
@@ -26,20 +26,14 @@ class Valvat
26
26
 
27
27
  private
28
28
 
29
- def valid?
30
- response[:valid]
31
- end
32
-
33
29
  def response
34
30
  @response ||= webservice.new(@vat, @options).perform
35
31
  end
36
32
 
37
33
  def webservice
38
- case @vat.vat_country_code
39
- when 'GB' then HMRC
40
- else
41
- VIES
42
- end
34
+ return HMRC if @vat.vat_country_code == 'GB'
35
+
36
+ VIES
43
37
  end
44
38
 
45
39
  def show_details?
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'configuration'
4
+
5
+ class Valvat
6
+ class Options
7
+ DEPRECATED_KEYS = {
8
+ requester_vat: :requester,
9
+ savon: :http
10
+ }.freeze
11
+
12
+ def initialize(options, silence: false)
13
+ @options = options || {}
14
+
15
+ DEPRECATED_KEYS.each do |deprecated, key|
16
+ if @options.key?(deprecated)
17
+ puts "DEPRECATED: The option :#{deprecated} is deprecated. Use :#{key} instead." unless silence
18
+ @options[key] ||= @options[deprecated]
19
+ end
20
+ end
21
+ end
22
+
23
+ def [](key)
24
+ @options.key?(key) ? @options[key] : Valvat.config[key]
25
+ end
26
+ end
27
+
28
+ def self.Options(options)
29
+ options.is_a?(Valvat::Options) ? options : Valvat::Options.new(options)
30
+ end
31
+ end
data/lib/valvat/syntax.rb CHANGED
@@ -6,7 +6,7 @@ class Valvat
6
6
  'AT' => /\AATU[0-9]{8}\Z/, # Austria
7
7
  'BE' => /\ABE[0-1][0-9]{9}\Z/, # Belgium
8
8
  'BG' => /\ABG[0-9]{9,10}\Z/, # Bulgaria
9
- 'CY' => /\ACY(?!12)[0-59][0-9]{7}[A-Z]\Z/, # Cyprus
9
+ 'CY' => /\ACY(?!12)[0-69][0-9]{7}[A-Z]\Z/, # Cyprus
10
10
  'CZ' => /\ACZ[0-9]{8,10}\Z/, # Czech Republic
11
11
  'DE' => /\ADE[0-9]{9}\Z/, # Germany
12
12
  'DK' => /\ADK[0-9]{8}\Z/, # Denmark
@@ -14,7 +14,7 @@ class Valvat
14
14
  'GR' => /\AEL[0-9]{9}\Z/, # Greece
15
15
  'ES' => /\AES([A-Z][0-9]{8}|[0-9]{8}[A-Z]|[A-Z][0-9]{7}[A-Z])\Z/, # Spain
16
16
  'FI' => /\AFI[0-9]{8}\Z/, # Finland
17
- 'FR' => /\AFR[A-Z0-9]{2}[0-9]{9}\Z/, # France
17
+ 'FR' => /\AFR[A-HJ-NP-Z0-9]{2}[0-9]{9}\Z/, # France
18
18
  'GB' => /\A(GB|XI)([0-9]{9}|[0-9]{12}|(HA|GD)[0-9]{3})\Z/, # United Kingdom
19
19
  'HR' => /\AHR[0-9]{11}\Z/, # Croatia
20
20
  'HU' => /\AHU[0-9]{8}\Z/, # Hungary
data/lib/valvat/utils.rb CHANGED
@@ -33,5 +33,17 @@ class Valvat
33
33
  def self.country_is_supported?(iso_country)
34
34
  SUPPORTED_STATES.include?(iso_country)
35
35
  end
36
+
37
+ def self.deep_symbolize_keys(value)
38
+ value = value.transform_keys do |key|
39
+ key.to_sym
40
+ rescue StandardError
41
+ key
42
+ end
43
+
44
+ value.transform_values! do |val|
45
+ val.is_a?(Hash) ? deep_symbolize_keys(val) : val
46
+ end
47
+ end
36
48
  end
37
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Valvat
4
- VERSION = '1.2.1'
4
+ VERSION = '1.4.0'
5
5
  end
data/lib/valvat.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'valvat/error'
4
4
  require 'valvat/utils'
5
+ require 'valvat/options'
6
+ require 'valvat/configuration'
5
7
  require 'valvat/syntax'
6
8
  require 'valvat/checksum'
7
9
  require 'valvat/version'
@@ -52,6 +54,11 @@ class Valvat
52
54
  raw
53
55
  end
54
56
 
57
+ def ==(other)
58
+ raw == other.raw
59
+ end
60
+ alias eql? ==
61
+
55
62
  def inspect
56
63
  "#<Valvat #{[raw, iso_country_code].compact.join(' ')}>"
57
64
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe Valvat::Checksum::ES do
6
6
  %w[ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980
7
- ESY3860557K ESY2207765D ES28350472M ES41961720Z ESM1171170X ESK0928769Y].each do |valid_vat|
7
+ ESY3860557K ESY2207765D ES28350472M ES41961720Z ESM1171170X ESK0928769Y ES50095545G].each do |valid_vat|
8
8
  it "returns true on valid VAT #{valid_vat}" do
9
9
  expect(Valvat::Checksum.validate(valid_vat)).to be(true)
10
10
  end
@@ -45,7 +45,7 @@ describe Valvat::Checksum::ES do
45
45
  end
46
46
 
47
47
  describe 'applies special rules to validation' do
48
- describe 'special NIF categories (KLM) require CD to be a letter and first two digits '\
48
+ describe 'special NIF categories (KLM) require CD to be a letter and first two digits ' \
49
49
  'to be between 01 and 56 (inclusive)' do
50
50
  %w[ESK8201230M ESK0001230B].each do |invalid_vat|
51
51
  it "returns false on invalid VAT #{invalid_vat}" do
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Valvat::Checksum::FR do
6
- %w[FR60528551658 FR43820567501].each do |valid_vat|
6
+ %w[FR60528551658 FR43820567501 FR0H384498879].each do |valid_vat|
7
7
  it "returns true on valid VAT #{valid_vat}" do
8
8
  expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
9
  end
@@ -7,6 +7,10 @@ describe Valvat::Lookup::HMRC do
7
7
  stub_const('Valvat::Lookup::HMRC::ENDPOINT_URL', 'https://test-api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup')
8
8
  end
9
9
 
10
+ after do
11
+ Valvat.configure(uk: false)
12
+ end
13
+
10
14
  it 'returns hash with valid: true on success' do
11
15
  response = described_class.new('GB553557881', { uk: true }).perform
12
16
 
@@ -29,4 +33,26 @@ describe Valvat::Lookup::HMRC do
29
33
  response = described_class.new('GB553557881', {}).perform
30
34
  expect(response).to match({ valid: false })
31
35
  end
36
+
37
+ it 'returns valid: false when uk option is set to false' do
38
+ response = described_class.new('GB553557881', { uk: false }).perform
39
+ expect(response).to match({ valid: false })
40
+ end
41
+
42
+ it 'returns valid: false when uk option is not set' do
43
+ response = described_class.new('GB553557881').perform
44
+ expect(response).to match({ valid: false })
45
+ end
46
+
47
+ it 'respects global :uk setting' do
48
+ Valvat.configure(uk: true)
49
+ response = described_class.new('GB553557881').perform
50
+ expect(response).to include({ valid: true })
51
+ end
52
+
53
+ it 'overwrite global :uk setting' do
54
+ Valvat.configure(uk: true)
55
+ response = described_class.new('GB553557881', uk: false).perform
56
+ expect(response).to include({ valid: false })
57
+ end
32
58
  end
@@ -6,6 +6,8 @@ describe Valvat::Lookup::VIES do
6
6
  it 'returns hash with valid: true on success' do
7
7
  response = described_class.new('IE6388047V', {}).perform
8
8
 
9
+ skip 'VIES is down' if response[:error].is_a?(Valvat::MemberStateUnavailable)
10
+
9
11
  expect(response).to match({
10
12
  valid: true,
11
13
  address: '3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4',
@@ -107,6 +107,8 @@ describe Valvat::Lookup do
107
107
  it 'supports old :requester_vat option for backwards compatibility' do
108
108
  result = described_class.validate('IE6388047V', requester_vat: 'LU21416127')
109
109
 
110
+ skip 'VIES is down' if result.nil?
111
+
110
112
  expect(result).to match({
111
113
  request_date: kind_of(Date),
112
114
  request_identifier: /\A[\w\W]{16}\Z/,
@@ -138,7 +140,7 @@ describe Valvat::Lookup do
138
140
  expect do
139
141
  described_class.validate('GB727255821', requester: 'IE6388047V', uk: true)
140
142
  end.to raise_error(Valvat::InvalidRequester,
141
- 'The HMRC web service returned the error: '\
143
+ 'The HMRC web service returned the error: ' \
142
144
  'INVALID_REQUEST (Invalid requesterVrn - Vrn parameters should be 9 or 12 digits)')
143
145
  end
144
146
 
@@ -146,10 +148,32 @@ describe Valvat::Lookup do
146
148
  expect do
147
149
  described_class.validate('GB727255821', requester: 'GB6388047', uk: true)
148
150
  end.to raise_error(Valvat::InvalidRequester,
149
- 'The HMRC web service returned the error: '\
151
+ 'The HMRC web service returned the error: ' \
150
152
  'INVALID_REQUEST (Invalid requesterVrn - Vrn parameters should be 9 or 12 digits)')
151
153
  end
152
154
  end
155
+
156
+ context 'when set in global config' do
157
+ before { Valvat.configure(requester: 'IE6388047V') }
158
+ after { Valvat.configure(requester: nil) }
159
+
160
+ it 'returns hash of details instead of true' do
161
+ result = described_class.validate('IE6388047V')
162
+
163
+ skip 'VIES is down' if result.nil?
164
+
165
+ expect(result).to match({
166
+ request_date: kind_of(Date),
167
+ request_identifier: /\A[\w\W]{16}\Z/,
168
+ country_code: 'IE',
169
+ vat_number: '6388047V',
170
+ name: 'GOOGLE IRELAND LIMITED',
171
+ company_type: nil,
172
+ address: '3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4',
173
+ valid: true
174
+ })
175
+ end
176
+ end
153
177
  end
154
178
  end
155
179
 
@@ -363,7 +387,7 @@ describe Valvat::Lookup do
363
387
 
364
388
  describe 'Error : MESSAGE_THROTTLED_OUT' do
365
389
  before do
366
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_return(
390
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_return(
367
391
  status: 429,
368
392
  body: '{"code":"MESSAGE_THROTTLED_OUT"}'
369
393
  )
@@ -380,7 +404,7 @@ describe Valvat::Lookup do
380
404
 
381
405
  describe 'Error : SCHEDULED_MAINTENANCE' do
382
406
  before do
383
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_return(
407
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_return(
384
408
  status: 503,
385
409
  body: '{"code":"SCHEDULED_MAINTENANCE"}'
386
410
  )
@@ -399,7 +423,7 @@ describe Valvat::Lookup do
399
423
 
400
424
  describe 'Error : SERVER_ERROR' do
401
425
  before do
402
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_return(
426
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_return(
403
427
  status: 503,
404
428
  body: '{"code":"SERVER_ERROR"}'
405
429
  )
@@ -418,7 +442,7 @@ describe Valvat::Lookup do
418
442
 
419
443
  describe 'Error : GATEWAY_TIMEOUT' do
420
444
  before do
421
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_return(
445
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_return(
422
446
  status: 504,
423
447
  body: '{"code":"GATEWAY_TIMEOUT"}'
424
448
  )
@@ -435,7 +459,7 @@ describe Valvat::Lookup do
435
459
 
436
460
  describe 'Network timeout' do
437
461
  before do
438
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_timeout
462
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_timeout
439
463
  end
440
464
 
441
465
  it 'raises error' do
@@ -451,7 +475,7 @@ describe Valvat::Lookup do
451
475
 
452
476
  describe 'Error : INTERNAL_SERVER_ERROR' do
453
477
  before do
454
- stub_request(:get, /test-api.service.hmrc.gov.uk/).to_return(
478
+ stub_request(:get, /test-api\.service\.hmrc\.gov\.uk/).to_return(
455
479
  status: 500,
456
480
  body: '{"code":"INTERNAL_SERVER_ERROR"}'
457
481
  )
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Valvat::Options do
6
+ describe '#[]' do
7
+ it 'returns global config by default' do
8
+ expect(described_class.new({})[:uk]).to be(false)
9
+ end
10
+
11
+ it 'returns option if set' do
12
+ expect(described_class.new({ uk: true })[:uk]).to be(true)
13
+ end
14
+
15
+ context 'when options contains deprecated key' do
16
+ let(:options) { described_class.new({ requester_vat: 'DE123' }, silence: true) }
17
+
18
+ it 'returns it on new key' do
19
+ expect(options[:requester]).to be('DE123')
20
+ end
21
+ end
22
+ end
23
+ end
@@ -21,7 +21,7 @@ describe Valvat::Syntax do
21
21
  it_validates(%w[ATU03458890], %w[ATU034588908 ATU0345908 ATU0345889Y])
22
22
  it_validates(%w[BE0817331995 BE1817331999], %w[BE081733199 BE08173319944 BE081733199H BE2817331999])
23
23
  it_validates(%w[BG468134789 BG4681347897], %w[BG46813478979 BG4681347897C BG46813478G BG46813478])
24
- it_validates(%w[CY36579347A CY36579347C], %w[CY36579347 CY365793478 CY365793478A CY365793G])
24
+ it_validates(%w[CY36579347A CY36579347C CY60000347C], %w[CY36579347 CY365793478 CY365793478A CY365793G])
25
25
  it_validates(%w[CZ56389267 CZ563892670 CZ5638926790], %w[CZ5638926 CZ56389268901])
26
26
  it_validates(%w[DE345889003], %w[DE34588900 DE3458890090 DE34588900C])
27
27
  it_validates(%w[DK67893463], %w[DK678934637 DK6789346 DK6789346H])
@@ -112,4 +112,14 @@ describe Valvat::Utils do
112
112
  end
113
113
  end
114
114
  end
115
+
116
+ describe '#deep_symbolize_keys' do
117
+ it 'symbolizes keys of flat hash' do
118
+ expect(described_class.deep_symbolize_keys({ 'a' => 1, :b => 2 })).to eql({ a: 1, b: 2 })
119
+ end
120
+
121
+ it 'symbolizes all hashes' do
122
+ expect(described_class.deep_symbolize_keys({ 'a' => 1, :b => { 'c' => 3 } })).to eql({ a: 1, b: { c: 3 } })
123
+ end
124
+ end
115
125
  end
data/spec/valvat_spec.rb CHANGED
@@ -18,12 +18,12 @@ describe Valvat do
18
18
 
19
19
  describe 'Valvat()' do
20
20
  it 'initializes new Valvat instance on string' do
21
- expect(Valvat('abc')).to be_kind_of(described_class)
21
+ expect(Valvat('abc')).to be_a(described_class)
22
22
  end
23
23
 
24
24
  it 'returns same Valvat instance on Valvat instance' do
25
25
  vat = described_class.new('abc')
26
- expect(Valvat(vat)).to be_kind_of(described_class)
26
+ expect(Valvat(vat)).to be_a(described_class)
27
27
  expect(Valvat(vat).object_id).to eql(vat.object_id)
28
28
  end
29
29
  end
@@ -42,6 +42,29 @@ describe Valvat do
42
42
  end
43
43
  end
44
44
 
45
+ describe 'object equality' do
46
+ it 'returns true when the underlying number are the same' do
47
+ first = 'DE259597697'
48
+ second = 'DE259597697'
49
+
50
+ expect(described_class.new(first)).to eql(described_class.new(second))
51
+ end
52
+
53
+ it 'returns true when the underlying number are the same when normalized' do
54
+ first = 'DE259597697'
55
+ second = 'DE 2595 9 7697 '
56
+
57
+ expect(described_class.new(first)).to eql(described_class.new(second))
58
+ end
59
+
60
+ it 'returns false when the underlying number are different' do
61
+ first = 'DE259597697'
62
+ second = 'ATU458890031'
63
+
64
+ expect(described_class.new(first)).not_to eql(described_class.new(second))
65
+ end
66
+ end
67
+
45
68
  context 'with european VAT number' do
46
69
  let(:de_vat) { described_class.new('DE259597697') } # valid & exists
47
70
  let(:invalid_checksum) { described_class.new('DE259597687') } # valid & invalid checksum
@@ -117,14 +140,6 @@ describe Valvat do
117
140
  end
118
141
  end
119
142
 
120
- describe '#european?' do
121
- it 'returns true' do
122
- expect(de_vat).to be_european
123
- expect(at_vat).to be_european
124
- expect(gr_vat).to be_european
125
- end
126
- end
127
-
128
143
  describe '#to_s' do
129
144
  it 'returns full VAT number' do
130
145
  expect(de_vat.to_s).to eql('DE259597697')
@@ -183,13 +198,6 @@ describe Valvat do
183
198
  end
184
199
  end
185
200
 
186
- describe '#european?' do
187
- it 'returns false' do
188
- expect(us_vat).not_to be_european
189
- expect(ch_vat).not_to be_european
190
- end
191
- end
192
-
193
201
  describe '#to_s' do
194
202
  it 'returns full given VAT number' do
195
203
  expect(us_vat.to_s).to eql('US345889003')
@@ -247,15 +255,6 @@ describe Valvat do
247
255
  end
248
256
  end
249
257
 
250
- describe '#european?' do
251
- it 'returns false' do
252
- expect(only_iso_vat).not_to be_european
253
- expect(num_vat).not_to be_european
254
- expect(empty_vat).not_to be_european
255
- expect(nil_vat).not_to be_european
256
- end
257
- end
258
-
259
258
  describe '#to_s' do
260
259
  it 'returns full given VAT number' do
261
260
  expect(only_iso_vat.to_s).to eql('DE')
data/valvat.gemspec CHANGED
@@ -4,28 +4,21 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
4
  require 'valvat/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = 'valvat'
8
- s.version = Valvat::VERSION
9
- s.platform = Gem::Platform::RUBY
10
- s.license = 'MIT'
11
- s.authors = ['Sebastian Munz']
12
- s.email = ['sebastian@yo.lk']
13
- s.homepage = 'https://github.com/yolk/valvat'
14
- s.summary = 'Validates european vat numbers. Standalone or as a ActiveModel validator.'
15
- s.description = 'Validates european vat numbers. Standalone or as a ActiveModel validator.'
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- spec/*`.split("\n")
18
- s.require_paths = ['lib']
19
- s.cert_chain = ['certs/yolk.pem']
20
- s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
21
- s.required_ruby_version = '>= 2.5.0'
7
+ s.name = 'valvat'
8
+ s.version = Valvat::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.license = 'MIT'
11
+ s.authors = ['Sebastian Munz']
12
+ s.email = ['sebastian@mite.de']
13
+ s.homepage = 'https://github.com/yolk/valvat'
14
+ s.summary = 'Validates european vat numbers. Standalone or as a ActiveModel validator.'
15
+ s.description = 'Validates european vat numbers. Standalone or as a ActiveModel validator.'
16
+ s.files = `git ls-files`.split("\n")
17
+ s.require_paths = ['lib']
18
+ s.cert_chain = ['certs/mite.pem']
19
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
20
+ s.metadata['rubygems_mfa_required'] = 'true'
21
+ s.required_ruby_version = '>= 2.6.0'
22
22
 
23
23
  s.add_runtime_dependency('rexml', '>= 3.2', '< 4.0')
24
-
25
- s.add_development_dependency 'activemodel', '>= 5.0'
26
- s.add_development_dependency 'rake'
27
- s.add_development_dependency 'rspec', '~> 3.0'
28
- s.add_development_dependency 'webmock', '~> 3.0'
29
-
30
- s.metadata['rubygems_mfa_required'] = 'true'
31
24
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valvat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Munz
@@ -10,32 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEZDCCAsygAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MRIwEAYDVQQDDAlzZWJh
14
- c3RpYW4xEjAQBgoJkiaJk/IsZAEZFgJ5bzESMBAGCgmSJomT8ixkARkWAmxrMB4X
15
- DTIyMDEyNjE4MjIxNFoXDTIzMDEyNjE4MjIxNFowPDESMBAGA1UEAwwJc2ViYXN0
16
- aWFuMRIwEAYKCZImiZPyLGQBGRYCeW8xEjAQBgoJkiaJk/IsZAEZFgJsazCCAaIw
17
- DQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAM8Gdm81LvuqMyJr9sO+KtJz+PhM
18
- x75w6uc5q3J8sTHGhOtWJlXiBFf8gbBkxUsQwDMEEbJ+WV63oqq9InVBrMHg9FxH
19
- 415dC0UlCv5IjKij4N5OVRnUTZDoxXczVVscNFyQcRhJO1TqORw6uOF8gd/MVWl4
20
- 6gJapzkLBMTIaqRUVbX3hTJpiGc1RV2zJmLkkvBtJ+lzqza0bklXh52LLs2UpTc1
21
- e5ADVoq9K09G5QXES/GlFMYerQbtdXl0KpUQugXtRFAOoOrFKQFLETZSDq80lC7p
22
- +zN+wNOEAuHtJP7EZVk/gU8hEkSDMexW5NRndgeQb+N/JH8DIRBbhOytZbAo19Pq
23
- LEZBucHheI0xstLWuIP+ktwa/rIWv5v4gv3JZ/4H3q6tGPHigLKneRmaXo3e6jna
24
- RFDxQLXbJgI37qusk4Qyl/iBVSBZ+TABBvA/jPXnHdd29qkuMTXvWLIiBDM6H0+2
25
- SUabsieR1CqNZs/6YLO7nQHwFudHqzo8OB4+3QIDAQABo3EwbzAJBgNVHRMEAjAA
26
- MAsGA1UdDwQEAwIEsDAdBgNVHQ4EF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qY+Duw2Gz+DdP
34
+ VyquPzH92Wc7Etd50IFILEkNV2VvRctuyY5/TAWoLKI9RQGYpKxd4jqZRtZFfODY
35
+ O1ARwPz8pN+xIvxo8ex8Hz1sazm/iFgVBwHgaI3O3ctK7vF4+fAu6dlLcbEpij9z
36
+ 4QlUng62OJRSBV/ejaTTItcAOXBeh028ZFWC0QQR4r0=
37
37
  -----END CERTIFICATE-----
38
- date: 2022-10-05 00:00:00.000000000 Z
38
+ date: 2023-07-20 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexml
@@ -57,71 +57,16 @@ dependencies:
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '4.0'
60
- - !ruby/object:Gem::Dependency
61
- name: activemodel
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '5.0'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '5.0'
74
- - !ruby/object:Gem::Dependency
75
- name: rake
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- - !ruby/object:Gem::Dependency
89
- name: rspec
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '3.0'
95
- type: :development
96
- prerelease: false
97
- version_requirements: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '3.0'
102
- - !ruby/object:Gem::Dependency
103
- name: webmock
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '3.0'
109
- type: :development
110
- prerelease: false
111
- version_requirements: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '3.0'
116
60
  description: Validates european vat numbers. Standalone or as a ActiveModel validator.
117
61
  email:
118
- - sebastian@yo.lk
62
+ - sebastian@mite.de
119
63
  executables: []
120
64
  extensions: []
121
65
  extra_rdoc_files: []
122
66
  files:
123
67
  - ".editorconfig"
124
- - ".github/workflows/ruby.yml"
68
+ - ".github/workflows/rubocop.yml"
69
+ - ".github/workflows/specs.yml"
125
70
  - ".gitignore"
126
71
  - ".rubocop.yml"
127
72
  - CHANGES.md
@@ -130,7 +75,7 @@ files:
130
75
  - MIT-LICENSE
131
76
  - README.md
132
77
  - Rakefile
133
- - certs/yolk.pem
78
+ - certs/mite.pem
134
79
  - gemfiles/activemodel-5
135
80
  - gemfiles/activemodel-6
136
81
  - gemfiles/activemodel-7
@@ -163,6 +108,7 @@ files:
163
108
  - lib/valvat/checksum/ro.rb
164
109
  - lib/valvat/checksum/se.rb
165
110
  - lib/valvat/checksum/si.rb
111
+ - lib/valvat/configuration.rb
166
112
  - lib/valvat/error.rb
167
113
  - lib/valvat/local.rb
168
114
  - lib/valvat/locales/bg.yml
@@ -189,6 +135,7 @@ files:
189
135
  - lib/valvat/lookup/base.rb
190
136
  - lib/valvat/lookup/hmrc.rb
191
137
  - lib/valvat/lookup/vies.rb
138
+ - lib/valvat/options.rb
192
139
  - lib/valvat/syntax.rb
193
140
  - lib/valvat/utils.rb
194
141
  - lib/valvat/version.rb
@@ -223,6 +170,7 @@ files:
223
170
  - spec/valvat/lookup/hmrc_spec.rb
224
171
  - spec/valvat/lookup/vies_spec.rb
225
172
  - spec/valvat/lookup_spec.rb
173
+ - spec/valvat/options_spec.rb
226
174
  - spec/valvat/syntax_spec.rb
227
175
  - spec/valvat/utils_spec.rb
228
176
  - spec/valvat_spec.rb
@@ -240,49 +188,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
188
  requirements:
241
189
  - - ">="
242
190
  - !ruby/object:Gem::Version
243
- version: 2.5.0
191
+ version: 2.6.0
244
192
  required_rubygems_version: !ruby/object:Gem::Requirement
245
193
  requirements:
246
194
  - - ">="
247
195
  - !ruby/object:Gem::Version
248
196
  version: '0'
249
197
  requirements: []
250
- rubygems_version: 3.3.3
198
+ rubygems_version: 3.3.26
251
199
  signing_key:
252
200
  specification_version: 4
253
201
  summary: Validates european vat numbers. Standalone or as a ActiveModel validator.
254
- test_files:
255
- - spec/active_model/validations/valvat_validator_spec.rb
256
- - spec/spec_helper.rb
257
- - spec/valvat/checksum/at_spec.rb
258
- - spec/valvat/checksum/be_spec.rb
259
- - spec/valvat/checksum/bg_spec.rb
260
- - spec/valvat/checksum/cy_spec.rb
261
- - spec/valvat/checksum/de_spec.rb
262
- - spec/valvat/checksum/dk_spec.rb
263
- - spec/valvat/checksum/ee_spec.rb
264
- - spec/valvat/checksum/es_spec.rb
265
- - spec/valvat/checksum/fi_spec.rb
266
- - spec/valvat/checksum/fr_spec.rb
267
- - spec/valvat/checksum/gb_spec.rb
268
- - spec/valvat/checksum/gr_spec.rb
269
- - spec/valvat/checksum/hr_spec.rb
270
- - spec/valvat/checksum/hu_spec.rb
271
- - spec/valvat/checksum/ie_spec.rb
272
- - spec/valvat/checksum/it_spec.rb
273
- - spec/valvat/checksum/lt_spec.rb
274
- - spec/valvat/checksum/lu_spec.rb
275
- - spec/valvat/checksum/mt_spec.rb
276
- - spec/valvat/checksum/nl_spec.rb
277
- - spec/valvat/checksum/pl_spec.rb
278
- - spec/valvat/checksum/pt_spec.rb
279
- - spec/valvat/checksum/ro_spec.rb
280
- - spec/valvat/checksum/se_spec.rb
281
- - spec/valvat/checksum/si_spec.rb
282
- - spec/valvat/checksum_spec.rb
283
- - spec/valvat/lookup/hmrc_spec.rb
284
- - spec/valvat/lookup/vies_spec.rb
285
- - spec/valvat/lookup_spec.rb
286
- - spec/valvat/syntax_spec.rb
287
- - spec/valvat/utils_spec.rb
288
- - spec/valvat_spec.rb
202
+ test_files: []
metadata.gz.sig CHANGED
Binary file
data/certs/yolk.pem DELETED
@@ -1,26 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIEZDCCAsygAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MRIwEAYDVQQDDAlzZWJh
3
- c3RpYW4xEjAQBgoJkiaJk/IsZAEZFgJ5bzESMBAGCgmSJomT8ixkARkWAmxrMB4X
4
- DTIyMDEyNjE4MjIxNFoXDTIzMDEyNjE4MjIxNFowPDESMBAGA1UEAwwJc2ViYXN0
5
- aWFuMRIwEAYKCZImiZPyLGQBGRYCeW8xEjAQBgoJkiaJk/IsZAEZFgJsazCCAaIw
6
- DQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAM8Gdm81LvuqMyJr9sO+KtJz+PhM
7
- x75w6uc5q3J8sTHGhOtWJlXiBFf8gbBkxUsQwDMEEbJ+WV63oqq9InVBrMHg9FxH
8
- 415dC0UlCv5IjKij4N5OVRnUTZDoxXczVVscNFyQcRhJO1TqORw6uOF8gd/MVWl4
9
- 6gJapzkLBMTIaqRUVbX3hTJpiGc1RV2zJmLkkvBtJ+lzqza0bklXh52LLs2UpTc1
10
- e5ADVoq9K09G5QXES/GlFMYerQbtdXl0KpUQugXtRFAOoOrFKQFLETZSDq80lC7p
11
- +zN+wNOEAuHtJP7EZVk/gU8hEkSDMexW5NRndgeQb+N/JH8DIRBbhOytZbAo19Pq
12
- LEZBucHheI0xstLWuIP+ktwa/rIWv5v4gv3JZ/4H3q6tGPHigLKneRmaXo3e6jna
13
- RFDxQLXbJgI37qusk4Qyl/iBVSBZ+TABBvA/jPXnHdd29qkuMTXvWLIiBDM6H0+2
14
- SUabsieR1CqNZs/6YLO7nQHwFudHqzo8OB4+3QIDAQABo3EwbzAJBgNVHRMEAjAA
15
- MAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUfC99QRDzqEe0tw1Da+XR9u4dmjEwGgYD
16
- VR0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