valvat 0.4.7 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rbenv-version +1 -1
- data/CHANGES.md +8 -1
- data/Guardfile +1 -1
- data/README.md +27 -2
- data/lib/valvat.rb +5 -0
- data/lib/valvat/active_model.rb +4 -1
- data/lib/valvat/checksum.rb +60 -0
- data/lib/valvat/checksum/at.rb +18 -0
- data/lib/valvat/checksum/be.rb +13 -0
- data/lib/valvat/checksum/bg.rb +61 -0
- data/lib/valvat/checksum/de.rb +21 -0
- data/lib/valvat/checksum/dk.rb +20 -0
- data/lib/valvat/checksum/es.rb +45 -0
- data/lib/valvat/checksum/fi.rb +15 -0
- data/lib/valvat/checksum/gr.rb +14 -0
- data/lib/valvat/checksum/ie.rb +29 -0
- data/lib/valvat/checksum/it.rb +22 -0
- data/lib/valvat/checksum/lu.rb +13 -0
- data/lib/valvat/checksum/nl.rb +17 -0
- data/lib/valvat/checksum/pl.rb +14 -0
- data/lib/valvat/checksum/pt.rb +14 -0
- data/lib/valvat/checksum/se.rb +30 -0
- data/lib/valvat/checksum/si.rb +19 -0
- data/lib/valvat/lookup.rb +8 -5
- data/lib/valvat/lookup/request.rb +1 -3
- data/lib/valvat/syntax.rb +0 -1
- data/lib/valvat/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/valvat/active_model_spec.rb +18 -0
- data/spec/valvat/checksum/at_spec.rb +15 -0
- data/spec/valvat/checksum/be_spec.rb +15 -0
- data/spec/valvat/checksum/bg_spec.rb +15 -0
- data/spec/valvat/checksum/de_spec.rb +15 -0
- data/spec/valvat/checksum/dk_spec.rb +15 -0
- data/spec/valvat/checksum/es_spec.rb +15 -0
- data/spec/valvat/checksum/fi_spec.rb +15 -0
- data/spec/valvat/checksum/gr_spec.rb +15 -0
- data/spec/valvat/checksum/ie_spec.rb +15 -0
- data/spec/valvat/checksum/it_spec.rb +23 -0
- data/spec/valvat/checksum/lu_spec.rb +15 -0
- data/spec/valvat/checksum/nl_spec.rb +15 -0
- data/spec/valvat/checksum/pl_spec.rb +19 -0
- data/spec/valvat/checksum/pt_spec.rb +15 -0
- data/spec/valvat/checksum/se_spec.rb +19 -0
- data/spec/valvat/checksum/si_spec.rb +23 -0
- data/spec/valvat/checksum_spec.rb +25 -0
- data/spec/valvat/lookup_spec.rb +1 -1
- data/spec/valvat_spec.rb +13 -0
- data/valvat.gemspec +2 -1
- metadata +83 -44
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Valvat::Checksum::SE do
|
4
|
+
%w(SE136695975501 SE556464687401 SE502052817901 SE556555952201 SE556084097601).each do |valid_vat|
|
5
|
+
it "returns true on valid vat #{valid_vat}" do
|
6
|
+
Valvat::Checksum.validate(valid_vat).should eql(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
|
+
|
11
|
+
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
+
Valvat::Checksum.validate(invalid_vat).should eql(false)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns false on special case invalid vat SE556464687400" do
|
17
|
+
Valvat::Checksum.validate("SE556464687400").should eql(false)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Valvat::Checksum::SI do
|
4
|
+
%w(SI59082437 SI51049406 SI86154575 SI47431857 SI22511822 SI22511880).each do |valid_vat|
|
5
|
+
it "returns true on valid vat #{valid_vat}" do
|
6
|
+
Valvat::Checksum.validate(valid_vat).should eql(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
invalid_vat = "#{valid_vat[0..-5]}#{valid_vat[-1]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-2]}"
|
10
|
+
|
11
|
+
it "returns false on invalid vat #{invalid_vat}" do
|
12
|
+
Valvat::Checksum.validate(invalid_vat).should eql(false)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns false on special case invalid vat SI11111107" do
|
17
|
+
Valvat::Checksum.validate("SI11111107").should eql(false)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns false on special case invalid vat SI01111108" do
|
21
|
+
Valvat::Checksum.validate("SI01111108").should eql(false)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require File.dirname(__FILE__) + '/../../tmp/valid_vat_numbers.rb'
|
5
|
+
rescue LoadError
|
6
|
+
VALID_VAT_NUMBERS = []
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Valvat::Checksum do
|
10
|
+
describe "#validate" do
|
11
|
+
it "returns true on vat number with unknown checksum algorithm" do
|
12
|
+
Valvat::Checksum.validate("FR99123543267").should eql(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns false on corrupt number (e.g checks syntax)" do
|
16
|
+
Valvat::Checksum.validate("FI1234567891").should eql(false)
|
17
|
+
end
|
18
|
+
|
19
|
+
VALID_VAT_NUMBERS.each do |valid_vat|
|
20
|
+
it "returns true on valid vat number #{valid_vat}" do
|
21
|
+
Valvat::Checksum.validate(valid_vat).should eql(true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/valvat/lookup_spec.rb
CHANGED
data/spec/valvat_spec.rb
CHANGED
@@ -30,6 +30,7 @@ describe Valvat do
|
|
30
30
|
|
31
31
|
context "on european vat number" do
|
32
32
|
let(:de_vat) { Valvat.new("DE259597697") } # valid & exists
|
33
|
+
let(:invalid_checksum) { Valvat.new("DE259597687") } # valid & invalid checksum
|
33
34
|
let(:at_vat) { Valvat.new("ATU458890031") } # invalid
|
34
35
|
let(:gr_vat) { Valvat.new("EL999943280") } # valid & exists
|
35
36
|
|
@@ -44,6 +45,18 @@ describe Valvat do
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
describe "#valid_checksum?" do
|
49
|
+
it "returns true on valid numbers" do
|
50
|
+
de_vat.should be_valid_checksum
|
51
|
+
gr_vat.should be_valid_checksum
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns false on invalid numbers" do
|
55
|
+
at_vat.should_not be_valid_checksum
|
56
|
+
invalid_checksum.should_not be_valid_checksum
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
47
60
|
describe "#exist(s)?" do
|
48
61
|
context "on existing vat numbers" do
|
49
62
|
before do
|
data/valvat.gemspec
CHANGED
@@ -6,6 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "valvat"
|
7
7
|
s.version = Valvat::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
+
s.license = 'MIT'
|
9
10
|
s.authors = ["Sebastian Munz"]
|
10
11
|
s.email = ["sebastian@yo.lk"]
|
11
12
|
s.homepage = "https://github.com/yolk/valvat"
|
@@ -27,7 +28,7 @@ Gem::Specification.new do |s|
|
|
27
28
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
28
29
|
s.require_paths = ["lib"]
|
29
30
|
|
30
|
-
s.add_dependency 'savon', '
|
31
|
+
s.add_dependency 'savon', '>=2.2.0'
|
31
32
|
|
32
33
|
s.add_development_dependency 'rspec', '>= 2.4.0'
|
33
34
|
s.add_development_dependency 'guard-rspec', '>=0.1.9'
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valvat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sebastian Munz
|
@@ -14,119 +13,109 @@ dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: savon
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - '
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 2.2.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - '
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 2.2.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 2.4.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 2.4.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: guard-rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 0.1.9
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 0.1.9
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: growl
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 1.0.3
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.0.3
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rb-fsevent
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: 0.9.1
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: 0.9.1
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: activemodel
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '3.0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '3.0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: fakeweb
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 1.3.0
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: 1.3.0
|
126
|
-
description:
|
127
|
-
|
128
|
-
|
129
|
-
|
111
|
+
description: |2
|
112
|
+
Validates european vat numbers. Standalone or as a ActiveModel validator.
|
113
|
+
|
114
|
+
* Simple syntax verification
|
115
|
+
* Lookup via the VIES web service
|
116
|
+
* Supports details & requester identification
|
117
|
+
* (Optional) ActiveModel/Rails3 integration
|
118
|
+
* I18n locales for country specific error messages
|
130
119
|
email:
|
131
120
|
- sebastian@yo.lk
|
132
121
|
executables: []
|
@@ -144,6 +133,23 @@ files:
|
|
144
133
|
- Rakefile
|
145
134
|
- lib/valvat.rb
|
146
135
|
- lib/valvat/active_model.rb
|
136
|
+
- lib/valvat/checksum.rb
|
137
|
+
- lib/valvat/checksum/at.rb
|
138
|
+
- lib/valvat/checksum/be.rb
|
139
|
+
- lib/valvat/checksum/bg.rb
|
140
|
+
- lib/valvat/checksum/de.rb
|
141
|
+
- lib/valvat/checksum/dk.rb
|
142
|
+
- lib/valvat/checksum/es.rb
|
143
|
+
- lib/valvat/checksum/fi.rb
|
144
|
+
- lib/valvat/checksum/gr.rb
|
145
|
+
- lib/valvat/checksum/ie.rb
|
146
|
+
- lib/valvat/checksum/it.rb
|
147
|
+
- lib/valvat/checksum/lu.rb
|
148
|
+
- lib/valvat/checksum/nl.rb
|
149
|
+
- lib/valvat/checksum/pl.rb
|
150
|
+
- lib/valvat/checksum/pt.rb
|
151
|
+
- lib/valvat/checksum/se.rb
|
152
|
+
- lib/valvat/checksum/si.rb
|
147
153
|
- lib/valvat/locales/bg.yml
|
148
154
|
- lib/valvat/locales/de.yml
|
149
155
|
- lib/valvat/locales/en.yml
|
@@ -161,40 +167,73 @@ files:
|
|
161
167
|
- lib/valvat/version.rb
|
162
168
|
- spec/spec_helper.rb
|
163
169
|
- spec/valvat/active_model_spec.rb
|
170
|
+
- spec/valvat/checksum/at_spec.rb
|
171
|
+
- spec/valvat/checksum/be_spec.rb
|
172
|
+
- spec/valvat/checksum/bg_spec.rb
|
173
|
+
- spec/valvat/checksum/de_spec.rb
|
174
|
+
- spec/valvat/checksum/dk_spec.rb
|
175
|
+
- spec/valvat/checksum/es_spec.rb
|
176
|
+
- spec/valvat/checksum/fi_spec.rb
|
177
|
+
- spec/valvat/checksum/gr_spec.rb
|
178
|
+
- spec/valvat/checksum/ie_spec.rb
|
179
|
+
- spec/valvat/checksum/it_spec.rb
|
180
|
+
- spec/valvat/checksum/lu_spec.rb
|
181
|
+
- spec/valvat/checksum/nl_spec.rb
|
182
|
+
- spec/valvat/checksum/pl_spec.rb
|
183
|
+
- spec/valvat/checksum/pt_spec.rb
|
184
|
+
- spec/valvat/checksum/se_spec.rb
|
185
|
+
- spec/valvat/checksum/si_spec.rb
|
186
|
+
- spec/valvat/checksum_spec.rb
|
164
187
|
- spec/valvat/lookup_spec.rb
|
165
188
|
- spec/valvat/syntax_spec.rb
|
166
189
|
- spec/valvat/utils_spec.rb
|
167
190
|
- spec/valvat_spec.rb
|
168
191
|
- valvat.gemspec
|
169
192
|
homepage: https://github.com/yolk/valvat
|
170
|
-
licenses:
|
193
|
+
licenses:
|
194
|
+
- MIT
|
195
|
+
metadata: {}
|
171
196
|
post_install_message:
|
172
197
|
rdoc_options: []
|
173
198
|
require_paths:
|
174
199
|
- lib
|
175
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
201
|
requirements:
|
178
|
-
- -
|
202
|
+
- - '>='
|
179
203
|
- !ruby/object:Gem::Version
|
180
204
|
version: '0'
|
181
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
206
|
requirements:
|
184
|
-
- -
|
207
|
+
- - '>='
|
185
208
|
- !ruby/object:Gem::Version
|
186
209
|
version: '0'
|
187
210
|
requirements: []
|
188
211
|
rubyforge_project:
|
189
|
-
rubygems_version:
|
212
|
+
rubygems_version: 2.0.3
|
190
213
|
signing_key:
|
191
|
-
specification_version:
|
214
|
+
specification_version: 4
|
192
215
|
summary: Validates european vat numbers. Standalone or as a ActiveModel validator.
|
193
216
|
test_files:
|
194
217
|
- spec/spec_helper.rb
|
195
218
|
- spec/valvat/active_model_spec.rb
|
219
|
+
- spec/valvat/checksum/at_spec.rb
|
220
|
+
- spec/valvat/checksum/be_spec.rb
|
221
|
+
- spec/valvat/checksum/bg_spec.rb
|
222
|
+
- spec/valvat/checksum/de_spec.rb
|
223
|
+
- spec/valvat/checksum/dk_spec.rb
|
224
|
+
- spec/valvat/checksum/es_spec.rb
|
225
|
+
- spec/valvat/checksum/fi_spec.rb
|
226
|
+
- spec/valvat/checksum/gr_spec.rb
|
227
|
+
- spec/valvat/checksum/ie_spec.rb
|
228
|
+
- spec/valvat/checksum/it_spec.rb
|
229
|
+
- spec/valvat/checksum/lu_spec.rb
|
230
|
+
- spec/valvat/checksum/nl_spec.rb
|
231
|
+
- spec/valvat/checksum/pl_spec.rb
|
232
|
+
- spec/valvat/checksum/pt_spec.rb
|
233
|
+
- spec/valvat/checksum/se_spec.rb
|
234
|
+
- spec/valvat/checksum/si_spec.rb
|
235
|
+
- spec/valvat/checksum_spec.rb
|
196
236
|
- spec/valvat/lookup_spec.rb
|
197
237
|
- spec/valvat/syntax_spec.rb
|
198
238
|
- spec/valvat/utils_spec.rb
|
199
239
|
- spec/valvat_spec.rb
|
200
|
-
has_rdoc:
|