valvat 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +7 -1
- data/lib/valvat/utils.rb +2 -1
- data/lib/valvat/version.rb +1 -1
- data/spec/valvat/utils_spec.rb +10 -1
- metadata +2 -2
data/CHANGES.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
### dev
|
2
2
|
|
3
|
-
[full changelog](http://github.com/yolk/valvat/compare/v0.2.
|
3
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.2.3...master)
|
4
|
+
|
5
|
+
### 0.2.3 / 2011-01-10
|
6
|
+
|
7
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.2.2...v0.2.3)
|
8
|
+
|
9
|
+
* Valvat::Utils.normalize now removes spaces and special chars anywhere
|
4
10
|
|
5
11
|
### 0.2.2 / 2011-01-10
|
6
12
|
|
data/lib/valvat/utils.rb
CHANGED
@@ -3,6 +3,7 @@ class Valvat
|
|
3
3
|
|
4
4
|
EU_COUNTRIES = %w(AT BE BG CY CZ DE DK EE ES FI FR GB GR HU IE IT LT LU LV MT NL PL PT RO SE SI SK)
|
5
5
|
COUNTRY_PATTERN = /\A([A-Z]{2})(.+)\Z/
|
6
|
+
NORMALIZE_PATTERN = /[-\.:_\s,;]+/
|
6
7
|
|
7
8
|
def self.split(vat)
|
8
9
|
COUNTRY_PATTERN =~ vat
|
@@ -12,7 +13,7 @@ class Valvat
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.normalize(vat)
|
15
|
-
vat.upcase.gsub(
|
16
|
+
vat.upcase.gsub(NORMALIZE_PATTERN, "")
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.vat_country_to_iso_country(vat_country)
|
data/lib/valvat/version.rb
CHANGED
data/spec/valvat/utils_spec.rb
CHANGED
@@ -37,10 +37,19 @@ describe Valvat::Utils do
|
|
37
37
|
Valvat::Utils.normalize("DE345889003 ").should eql("DE345889003")
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "does not change already normalized vat numbers" do
|
41
41
|
Valvat::Utils.normalize("DE345889003").should eql("DE345889003")
|
42
42
|
Valvat::Utils.normalize("ESX4588900X").should eql("ESX4588900X")
|
43
43
|
end
|
44
|
+
|
45
|
+
it "removes spaces" do
|
46
|
+
Valvat::Utils.normalize("DE 345889003").should eql("DE345889003")
|
47
|
+
Valvat::Utils.normalize("ESX 458 8900 X").should eql("ESX4588900X")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "removes special chars" do
|
51
|
+
Valvat::Utils.normalize("DE.345-889_00:3,;").should eql("DE345889003")
|
52
|
+
end
|
44
53
|
end
|
45
54
|
|
46
55
|
context "#vat_country_to_iso_country" do
|