valvat 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CHANGES.md +15 -0
- data/{README.rdoc → README.md} +13 -8
- data/lib/valvat.rb +1 -0
- data/lib/valvat/active_model.rb +7 -0
- data/lib/valvat/version.rb +1 -1
- data/spec/spec_helper.rb +17 -1
- data/spec/valvat/active_model_spec.rb +27 -0
- data/valvat.gemspec +1 -3
- metadata +23 -7
- data/CHANGES.markdown +0 -5
- data/Gemfile.lock +0 -42
data/.gitignore
CHANGED
data/CHANGES.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
### dev
|
2
|
+
|
3
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.0.2...0.0.3)
|
4
|
+
|
5
|
+
### 0.0.3 / 2011-01-06
|
6
|
+
|
7
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.0.1...v0.0.2)
|
8
|
+
|
9
|
+
* Basic support for ActiveModel validation
|
10
|
+
|
11
|
+
### 0.0.2 / 2011-01-06
|
12
|
+
|
13
|
+
[full changelog](http://github.com/yolk/valvat/compare/v0.0.1...v0.0.2)
|
14
|
+
|
15
|
+
* Use REST-wrapper for accessing VIES web service; this removes dependency on savon and some lines of code. See http://isvat.appspot.com/
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
## valvat
|
2
2
|
|
3
3
|
Validates european vat numbers. Supports simple syntax verification and lookup via the VIES web service.
|
4
4
|
|
5
|
-
|
5
|
+
valvat is tested and works with ruby 1.8.7 and 1.9.2.
|
6
|
+
|
7
|
+
### Installation
|
6
8
|
|
7
9
|
gem install valvat
|
8
10
|
|
9
|
-
|
11
|
+
### Basic Usage
|
10
12
|
|
11
13
|
To verify the syntax of a vat number:
|
12
14
|
|
@@ -22,7 +24,7 @@ Keep in mind that the VIES webservice might be offline at some time for some cou
|
|
22
24
|
|
23
25
|
See http://ec.europa.eu/taxation_customs/vies/viesspec.do for more accurate information at what time the service for a specific country will be down.
|
24
26
|
|
25
|
-
|
27
|
+
### Utilities
|
26
28
|
|
27
29
|
To split a vat number into the ISO country code and the remaining chars:
|
28
30
|
|
@@ -38,12 +40,15 @@ To normalize a vat number:
|
|
38
40
|
|
39
41
|
This basically just removes trailing spaces and ensures all chars are upcase.
|
40
42
|
|
41
|
-
|
43
|
+
### Links
|
42
44
|
|
43
45
|
* http://ec.europa.eu/taxation_customs/vies
|
44
|
-
* http://
|
46
|
+
* http://bzst.de/DE/Steuern_International/USt_Identifikationsnummer/Merkblaetter/Aufbau_USt_IdNr.html (german)
|
45
47
|
* http://en.wikipedia.org/wiki/European_Union_Value_Added_Tax
|
48
|
+
* http://isvat.appspot.com/
|
49
|
+
|
50
|
+
### BlaBla
|
46
51
|
|
47
|
-
|
52
|
+
Copyright (c) 2011 Yolk Sebastian Munz & Julia Soergel GbR
|
48
53
|
|
49
|
-
|
54
|
+
Beyond that, the implementation is licensed under the MIT License.
|
data/lib/valvat.rb
CHANGED
data/lib/valvat/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
require 'rspec'
|
2
|
+
require 'active_model'
|
2
3
|
|
3
|
-
require File.dirname(__FILE__) + '/../lib/valvat.rb'
|
4
|
+
require File.dirname(__FILE__) + '/../lib/valvat.rb'
|
5
|
+
|
6
|
+
class ModelBase
|
7
|
+
include ActiveModel::Serialization
|
8
|
+
include ActiveModel::Validations
|
9
|
+
|
10
|
+
attr_accessor :attributes
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
@attributes = attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
def read_attribute_for_validation(key)
|
17
|
+
@attributes[key]
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Invoice < ModelBase
|
4
|
+
validates :vat_number, :valvat => true
|
5
|
+
end
|
6
|
+
|
7
|
+
describe Invoice do
|
8
|
+
context "with valid vat number" do
|
9
|
+
before do
|
10
|
+
Valvat::Syntax.stub(:validate => true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be valid" do
|
14
|
+
Invoice.new(:vat_number => "DE345889003").should be_valid
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with invalid vat number" do
|
19
|
+
before do
|
20
|
+
Valvat::Syntax.stub(:validate => false)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be valid" do
|
24
|
+
Invoice.new(:vat_number => "DE345889003").should_not be_valid
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/valvat.gemspec
CHANGED
@@ -21,7 +21,5 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency 'guard-rspec', '>=0.1.9'
|
22
22
|
s.add_development_dependency 'growl', '>=1.0.3'
|
23
23
|
s.add_development_dependency 'rb-fsevent', '>=0.3.9'
|
24
|
-
|
25
|
-
s.has_rdoc = true
|
26
|
-
s.extra_rdoc_files = ['README.rdoc']
|
24
|
+
s.add_development_dependency 'activemodel', '>=3.0'
|
27
25
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sebastian Munz
|
@@ -77,6 +77,20 @@ dependencies:
|
|
77
77
|
version: 0.3.9
|
78
78
|
type: :development
|
79
79
|
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: activemodel
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 3
|
90
|
+
- 0
|
91
|
+
version: "3.0"
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id005
|
80
94
|
description: Validates european vat numbers. Supports simple syntax verification and lookup via the VIES web service.
|
81
95
|
email:
|
82
96
|
- sebastian@yo.lk
|
@@ -84,24 +98,25 @@ executables: []
|
|
84
98
|
|
85
99
|
extensions: []
|
86
100
|
|
87
|
-
extra_rdoc_files:
|
88
|
-
|
101
|
+
extra_rdoc_files: []
|
102
|
+
|
89
103
|
files:
|
90
104
|
- .gitignore
|
91
105
|
- .rvmrc
|
92
|
-
- CHANGES.
|
106
|
+
- CHANGES.md
|
93
107
|
- Gemfile
|
94
|
-
- Gemfile.lock
|
95
108
|
- Guardfile
|
96
109
|
- MIT-LICENSE
|
97
|
-
- README.
|
110
|
+
- README.md
|
98
111
|
- Rakefile
|
99
112
|
- lib/valvat.rb
|
113
|
+
- lib/valvat/active_model.rb
|
100
114
|
- lib/valvat/lookup.rb
|
101
115
|
- lib/valvat/syntax.rb
|
102
116
|
- lib/valvat/utils.rb
|
103
117
|
- lib/valvat/version.rb
|
104
118
|
- spec/spec_helper.rb
|
119
|
+
- spec/valvat/active_model_spec.rb
|
105
120
|
- spec/valvat/lookup_spec.rb
|
106
121
|
- spec/valvat/syntax_spec.rb
|
107
122
|
- spec/valvat/utils_spec.rb
|
@@ -141,6 +156,7 @@ specification_version: 3
|
|
141
156
|
summary: Validates european vat numbers. Supports simple syntax verification and lookup via the VIES web service.
|
142
157
|
test_files:
|
143
158
|
- spec/spec_helper.rb
|
159
|
+
- spec/valvat/active_model_spec.rb
|
144
160
|
- spec/valvat/lookup_spec.rb
|
145
161
|
- spec/valvat/syntax_spec.rb
|
146
162
|
- spec/valvat/utils_spec.rb
|
data/CHANGES.markdown
DELETED
data/Gemfile.lock
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
valvat (0.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
configuration (1.2.0)
|
10
|
-
diff-lcs (1.1.2)
|
11
|
-
growl (1.0.3)
|
12
|
-
guard (0.2.2)
|
13
|
-
open_gem (~> 1.4.2)
|
14
|
-
thor (~> 0.14.3)
|
15
|
-
guard-rspec (0.1.9)
|
16
|
-
guard (>= 0.2.2)
|
17
|
-
launchy (0.3.7)
|
18
|
-
configuration (>= 0.0.5)
|
19
|
-
rake (>= 0.8.1)
|
20
|
-
open_gem (1.4.2)
|
21
|
-
launchy (~> 0.3.5)
|
22
|
-
rake (0.8.7)
|
23
|
-
rb-fsevent (0.3.9)
|
24
|
-
rspec (2.4.0)
|
25
|
-
rspec-core (~> 2.4.0)
|
26
|
-
rspec-expectations (~> 2.4.0)
|
27
|
-
rspec-mocks (~> 2.4.0)
|
28
|
-
rspec-core (2.4.0)
|
29
|
-
rspec-expectations (2.4.0)
|
30
|
-
diff-lcs (~> 1.1.2)
|
31
|
-
rspec-mocks (2.4.0)
|
32
|
-
thor (0.14.6)
|
33
|
-
|
34
|
-
PLATFORMS
|
35
|
-
ruby
|
36
|
-
|
37
|
-
DEPENDENCIES
|
38
|
-
growl (>= 1.0.3)
|
39
|
-
guard-rspec (>= 0.1.9)
|
40
|
-
rb-fsevent (>= 0.3.9)
|
41
|
-
rspec (>= 2.4.0)
|
42
|
-
valvat!
|