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 +4 -4
- data/.github/workflows/ruby.yml +29 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +19 -0
- data/README.md +7 -7
- data/europe.gemspec +3 -0
- data/lib/europe/countries/countries.rb +2 -2
- data/lib/europe/vat/format.rb +1 -2
- data/lib/europe/vat/vat.rb +9 -13
- data/lib/europe/version.rb +1 -1
- data/test/europe/countries/country_test.rb +1 -1
- data/test/europe/vat/format_test.rb +0 -4
- data/test/europe/vat/validation_test.rb +0 -5
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ed6dabe018e89d9bbf23e67b0137974b05035aa1bbe684634b5f486cb080675
|
4
|
+
data.tar.gz: 1d326773840b959bb92b198cc834ee1a90343c87ca5eed0f76b044f74cf5039e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/.rubocop.yml
CHANGED
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('
|
46
|
+
Europe::Vat.validate('NL009291477B01')
|
47
47
|
```
|
48
48
|
Response
|
49
49
|
```ruby
|
50
|
-
{ :country_code=>"
|
51
|
-
:vat_number=>"
|
52
|
-
:request_date
|
53
|
-
:valid=>true,
|
54
|
-
:name=>"
|
55
|
-
:address=>
|
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: :
|
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: :
|
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' },
|
data/lib/europe/vat/format.rb
CHANGED
@@ -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[
|
48
|
+
if %i[DK FR].include?(country_code)
|
50
49
|
number.gsub(/\.|\t/, '').upcase
|
51
50
|
else
|
52
51
|
number.gsub(/\.|\t|\s/, '').upcase
|
data/lib/europe/vat/vat.rb
CHANGED
@@ -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,
|
51
|
-
country_code: extract_data(body,
|
52
|
-
vat_number: extract_data(body,
|
53
|
-
request_date: convert_date(extract_data(body,
|
54
|
-
name: extract_data(body,
|
55
|
-
address: extract_data(body,
|
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.
|
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
|
-
|
78
|
-
|
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)
|
data/lib/europe/version.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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.
|