europe 0.0.16 → 0.0.19

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: b8dfe84a1c050d715865f2f5878458f4f9708437770e629ee64564d59ff622d4
4
- data.tar.gz: d59e3b667b741269bfb5db4dafeb6cc531a052fd79ccfcbe354e941c5976cb13
3
+ metadata.gz: 4ed6dabe018e89d9bbf23e67b0137974b05035aa1bbe684634b5f486cb080675
4
+ data.tar.gz: 1d326773840b959bb92b198cc834ee1a90343c87ca5eed0f76b044f74cf5039e
5
5
  SHA512:
6
- metadata.gz: 5da3ca3fc8579d8b55043b6f9af8da9ac1f69aa46ec9e4c9858a2318cae1222724679553ec45f61308928f65595bbd71682279aa219e46e698811eb3a27217a2
7
- data.tar.gz: 3c5f1f99dab00df6e1e66acf202c4a12cf339fb0207566b5ef613d93c8ac262e61b243a05045e30c82dbc3b36667f89bc99345bb4b42456420951a5d7b889420
6
+ metadata.gz: e54ce40bbfa5985395dddbf38498b2a22887ebe12d81de4004b39a2643f0015a3adae16d49239e8b8ae3806f5300de3fa8aa474d36e545c9dab63548c5282094
7
+ data.tar.gz: 131df277ed531fe687f1f156d912d673f513e8806264572fb90343d5e0440cae6a4b20b8e1f0951bb964028d718d63a2b04f626070bddd375d784442ec7501d1
@@ -0,0 +1,29 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: 3.1.1
26
+ - name: Install dependencies
27
+ run: bundle install
28
+ - name: Run tests
29
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ mkmf.log
15
15
  .DS_Store
16
16
  coverage
17
17
  .byebug_history
18
+ *.gem
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 2.7
3
+ TargetRubyVersion: 3.1
4
4
  SuggestExtensions: false
5
5
  Exclude:
6
6
  - 'europe.gemspec'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
+ ## 0.0.19
5
+ - Fixed VAT validation call because XML response was updated
6
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.18...v0.0.19)
7
+ ## 0.0.18
8
+ - Added Estonia and Lithuania to eurozone
9
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.17...v0.0.18)
10
+ ## 0.0.17
11
+ - Removed all UK VAT logic
12
+ - Updated development dependencies
13
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.16...v0.0.17)
14
+ ## 0.0.16
15
+ - Changed Slovak Republic to Slovakia in country names
16
+ - Updated outdated endpoint for VAT rates, thanks to @firstpromoter
17
+ - Fixed a couple of rubocop issues
18
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.15...v0.0.16)
19
+ ## 0.0.15
20
+ - Checked library on Ruby 2.7
21
+ - Moved repository to gem-shards
22
+ - [Full Changelog](https://github.com/VvanGemert/europe/compare/v0.0.14...v0.0.15)
4
23
 
5
24
  ## 0.0.14
6
25
  - Fixed rubocop syntax issues
data/README.md CHANGED
@@ -43,16 +43,16 @@ where this gem can be used for.
43
43
  ** Updated: Parameter now consists of one value.**
44
44
  Call to validate VAT number (always starts with country code as specified in VIES)
45
45
  ```ruby
46
- Europe::Vat.validate('GB440627467')
46
+ Europe::Vat.validate('NL009291477B01')
47
47
  ```
48
48
  Response
49
49
  ```ruby
50
- { :country_code=>"GB",
51
- :vat_number=>"440627467",
52
- :request_date=>#<Date: 2015-12-15 ((2457372j,0s,0n),+0s,2299161j)>,
53
- :valid=>true,
54
- :name=>"SKY PLC",
55
- :address=>"6 CENTAURS BUSINESS PARK\nGRANT WAY\nISLEWORTH\nMIDDLESEX\n\nTW7 5QD" }
50
+ { :country_code => "NL",
51
+ :vat_number => "009291477B01",
52
+ :request_date => #<Date: 2015-12-15 ((2457372j,0s,0n),+0s,2299161j)>,
53
+ :valid => true,
54
+ :name => "KONINKLIJKE POSTNL B.V.",
55
+ :address => nil }
56
56
  ```
57
57
 
58
58
  ### Validate VAT number format
data/europe.gemspec CHANGED
@@ -15,6 +15,9 @@ Gem::Specification.new do |spec|
15
15
  'VAT validation, currency exchange rates and ' \
16
16
  'country information.'
17
17
  spec.homepage = 'https://github.com/gem-shards/europe.rb'
18
+ spec.metadata = {
19
+ 'source_code_uri' => 'https://github.com/gem-shards/europe.rb',
20
+ 'changelog_uri' => 'https://github.com/gem-shards/europe.rb/blob/master/CHANGELOG.md' }
18
21
  spec.license = 'MIT'
19
22
 
20
23
  spec.files = `git ls-files -z`.split("\x0")
@@ -26,7 +26,7 @@ module Europe
26
26
  tld: '.de', currency: :EUR, capital: 'Berlin' },
27
27
  EE: { name: 'Estonia', source_name: 'Eesti',
28
28
  official_name: 'Republic of Estonia',
29
- tld: '.ee', currency: :EEK, capital: 'Tallinn' },
29
+ tld: '.ee', currency: :EUR, capital: 'Tallinn' },
30
30
  IE: { name: 'Ireland', source_name: 'Éire',
31
31
  official_name: 'Ireland',
32
32
  tld: '.ie', currency: :EUR, capital: 'Dublin' },
@@ -53,7 +53,7 @@ module Europe
53
53
  tld: '.lv', currency: :EUR, capital: 'Riga' },
54
54
  LT: { name: 'Lithuania', source_name: 'Lietuva',
55
55
  official_name: 'Republic of Lithuania',
56
- tld: '.lt', currency: :LTL, capital: 'Vilnius' },
56
+ tld: '.lt', currency: :EUR, capital: 'Vilnius' },
57
57
  LU: { name: 'Luxembourg', source_name: 'Luxembourg',
58
58
  official_name: 'Grand Duchy of Luxembourg',
59
59
  tld: '.lu', currency: :EUR, capital: 'Luxembourg City' },
@@ -19,7 +19,6 @@ module Europe
19
19
  ES: /^ES([A-Z0-9]\d{7}[A-Z0-9])$/,
20
20
  FI: /^FI\d{8}$/,
21
21
  FR: /^FR[A-Z0-9][A-Z0-9] \d{9}$/,
22
- GB: [/^GB(\d{3} \d{4} \d{2}( \d{3}5)?)$/, /^GB(HA|GD)\d{3}(6|7)$/],
23
22
  HR: /^HR\d{11}$/,
24
23
  HU: /^HU\d{8}$/,
25
24
  IE: /^IE\d[A-Z0-9\+\*|\d]\d{5}([A-Z]|WI)$/,
@@ -46,7 +45,7 @@ module Europe
46
45
  end
47
46
 
48
47
  def self.sanitize_number(number, country_code)
49
- if %i[GB DK FR].include?(country_code)
48
+ if %i[DK FR].include?(country_code)
50
49
  number.gsub(/\.|\t/, '').upcase
51
50
  else
52
51
  number.gsub(/\.|\t|\s/, '').upcase
@@ -47,18 +47,18 @@ module Europe
47
47
  def self.setup_response(response)
48
48
  body = response_xml(response)
49
49
  {
50
- valid: extract_data(body, 4) == 'true',
51
- country_code: extract_data(body, 1),
52
- vat_number: extract_data(body, 2),
53
- request_date: convert_date(extract_data(body, 3)),
54
- name: extract_data(body, 5),
55
- address: extract_data(body, 6)
50
+ valid: extract_data(body, 3) == 'true',
51
+ country_code: extract_data(body, 0),
52
+ vat_number: extract_data(body, 1),
53
+ request_date: convert_date(extract_data(body, 2)),
54
+ name: extract_data(body, 4),
55
+ address: extract_data(body, 5)
56
56
  }
57
57
  end
58
58
 
59
59
  def self.response_xml(response)
60
60
  xml = REXML::Document.new(response.body)
61
- xml.first.elements.first.elements.first.elements
61
+ xml.elements.first.elements[2].elements[1]
62
62
  end
63
63
 
64
64
  def self.convert_date(date)
@@ -74,12 +74,8 @@ module Europe
74
74
  def self.charge_vat?(origin_country, number)
75
75
  return false if number.nil? || number.empty?
76
76
 
77
- if origin_country.to_sym == number[0..1].to_sym
78
- true
79
- else
80
- Europe::Countries::COUNTRIES
81
- .key?(number[0..1].to_sym)
82
- end
77
+ Europe::Vat::Fromat::VAT_REGEX.key?(origin_country.to_sym) ||
78
+ Europe::Vat::Fromat::VAT_REGEX.key?(number[0..1].to_sym)
83
79
  end
84
80
 
85
81
  def self.send_request(country_code, number)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Europe version
4
4
  module Europe
5
- VERSION = '0.0.16'
5
+ VERSION = '0.0.19'
6
6
  end
@@ -16,7 +16,7 @@ module Europe
16
16
 
17
17
  reversed_hash =
18
18
  Europe::Countries::Reversed.generate(:currency)
19
- assert_equal reversed_hash[:EUR].count, 17
19
+ assert_equal reversed_hash[:EUR].count, 19
20
20
  end
21
21
 
22
22
  def test_eurozone
@@ -21,10 +21,6 @@ module Europe
21
21
  ES: 'ESX9999999X',
22
22
  FI: 'FI99999999',
23
23
  FR: 'FRXX 999999999',
24
- GB: ['GB999 9999 99 9995',
25
- 'GBGD9996',
26
- 'GBHA9997',
27
- 'GB999 9999 99'],
28
24
  HR: 'HR99999999999',
29
25
  HU: 'HU99999999',
30
26
  IE: %w[IE9S99999L IE9999999WI],
@@ -23,11 +23,6 @@ module Europe
23
23
  assert validate_correct_vat[:valid] \
24
24
  unless %i[timeout failed].include?(validate_correct_vat)
25
25
 
26
- # Sky
27
- validate_correct_vat = Europe::Vat.validate('GB440627467')
28
- assert validate_correct_vat[:valid] \
29
- unless %i[timeout failed].include?(validate_correct_vat)
30
-
31
26
  # Volkswagen
32
27
  validate_correct_vat = Europe::Vat.validate('DE115235681')
33
28
  assert validate_correct_vat[:valid] \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: europe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gem shards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-31 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -145,6 +145,7 @@ extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
147
  - ".coveralls.yml"
148
+ - ".github/workflows/ruby.yml"
148
149
  - ".gitignore"
149
150
  - ".pryrc"
150
151
  - ".rubocop.yml"
@@ -180,7 +181,9 @@ files:
180
181
  homepage: https://github.com/gem-shards/europe.rb
181
182
  licenses:
182
183
  - MIT
183
- metadata: {}
184
+ metadata:
185
+ source_code_uri: https://github.com/gem-shards/europe.rb
186
+ changelog_uri: https://github.com/gem-shards/europe.rb/blob/master/CHANGELOG.md
184
187
  post_install_message:
185
188
  rdoc_options: []
186
189
  require_paths:
@@ -196,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
199
  - !ruby/object:Gem::Version
197
200
  version: '0'
198
201
  requirements: []
199
- rubygems_version: 3.1.4
202
+ rubygems_version: 3.3.7
200
203
  signing_key:
201
204
  specification_version: 4
202
205
  summary: Europe is a gem for retrieving and validating EU government data.