vatman 0.1.0 → 1.0.0
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 +4 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -12
- data/lib/vatman.rb +32 -25
- data/lib/vatman/version.rb +3 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/vatman_spec.rb +25 -0
- data/vatman.gemspec +17 -26
- metadata +69 -80
- data.tar.gz.sig +0 -2
- data/Manifest +0 -5
- data/test/test_helper.rb +0 -2
- data/test/test_vatman.rb +0 -18
- metadata.gz.sig +0 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,12 +1 @@
|
|
1
|
-
require
|
2
|
-
require 'rake'
|
3
|
-
require 'echoe'
|
4
|
-
|
5
|
-
Echoe.new('vatman', '0.1.0') do |p|
|
6
|
-
p.description = "A gem that checks VAT numbers against the Europa web service"
|
7
|
-
p.url = "http://github.com/neilmiddleton/vatman"
|
8
|
-
p.author = "Neil Middleton"
|
9
|
-
p.email = "neilmiddleton @nospam@ gmail.com"
|
10
|
-
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
-
p.development_dependencies = []
|
12
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/vatman.rb
CHANGED
@@ -1,29 +1,36 @@
|
|
1
|
-
require
|
1
|
+
require "vatman/version"
|
2
|
+
require 'savon'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def name
|
9
|
-
get_variable(:name)
|
10
|
-
end
|
11
|
-
|
12
|
-
def address
|
13
|
-
get_variable(:address)
|
14
|
-
end
|
15
|
-
|
16
|
-
def valid?
|
17
|
-
get_variable(:valid) == 'true'
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def response
|
23
|
-
@response ||= SOAP::WSDLDriverFactory.new('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl').create_rpc_driver.checkVat(:countryCode => @country, :vatNumber => @number)
|
4
|
+
module Vatman
|
5
|
+
class Check
|
6
|
+
|
7
|
+
def initialize(country, number)
|
8
|
+
@country, @number = country, number.to_s.gsub(' ', '')
|
24
9
|
end
|
25
10
|
|
26
|
-
def
|
27
|
-
response
|
11
|
+
def valid?
|
12
|
+
response[:valid]
|
28
13
|
end
|
29
|
-
|
14
|
+
|
15
|
+
def name
|
16
|
+
response[:name]
|
17
|
+
end
|
18
|
+
|
19
|
+
def address
|
20
|
+
response[:address]
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def response
|
26
|
+
@response ||= get_vat_check
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_vat_check
|
30
|
+
client = ::Savon::Client.new("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
|
31
|
+
response = client.request :tnsl, :check_vat, :body => {:country_code => @country, :vat_number => @number}
|
32
|
+
response.to_hash[:check_vat_response]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/spec/spec_helper.rb
ADDED
data/spec/vatman_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vatman do
|
4
|
+
it 'should return details of a valid VAT number' do
|
5
|
+
v = Vatman::Check.new("GB", 800634860)
|
6
|
+
v.should be_valid
|
7
|
+
v.name.should == 'KYANMEDIA LTD'
|
8
|
+
v.address.should == "171 HIGH STREET\nGUILDFORD\nSURREY\n\n\nGU1 3AJ"
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should accept string formatted numbers' do
|
12
|
+
v = Vatman::Check.new("GB", "800 6348 60")
|
13
|
+
v.should be_valid
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should reject invalid VAT numbers' do
|
17
|
+
v = Vatman::Check.new("GB", 12345679)
|
18
|
+
v.should_not be_valid
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should reject invalid string vat numbers' do
|
22
|
+
v = Vatman::Check.new("GB", "abcdefghijkl")
|
23
|
+
v.should_not be_valid
|
24
|
+
end
|
25
|
+
end
|
data/vatman.gemspec
CHANGED
@@ -1,33 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "vatman/version"
|
2
4
|
|
3
5
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
+
s.name = "vatman"
|
7
|
+
s.version = Vatman::VERSION
|
8
|
+
s.authors = ["Neil Middleton"]
|
9
|
+
s.email = ["neil.middleton@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A gem that checks VAT numbers against the Europa web service}
|
6
12
|
|
7
|
-
s.
|
8
|
-
s.authors = ["Neil Middleton"]
|
9
|
-
s.cert_chain = ["/Users/neil/.ssh/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2010-09-24}
|
11
|
-
s.description = %q{A gem that checks VAT numbers against the Europa web service}
|
12
|
-
s.email = %q{neilmiddleton @nospam@ gmail.com}
|
13
|
-
s.extra_rdoc_files = ["lib/vatman.rb"]
|
14
|
-
s.files = ["Rakefile", "lib/vatman.rb", "test/test_helper.rb", "test/test_vatman.rb", "Manifest", "vatman.gemspec"]
|
15
|
-
s.homepage = %q{http://github.com/neilmiddleton/vatman}
|
16
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Vatman", "--main", "Readme.rdoc"]
|
17
|
-
s.require_paths = ["lib"]
|
18
|
-
s.rubyforge_project = %q{vatman}
|
19
|
-
s.rubygems_version = %q{1.3.7}
|
20
|
-
s.signing_key = %q{/Users/neil/.ssh/gem-private_key.pem}
|
21
|
-
s.summary = %q{A gem that checks VAT numbers against the Europa web service}
|
22
|
-
s.test_files = ["test/test_helper.rb", "test/test_vatman.rb"]
|
13
|
+
s.rubyforge_project = "vatman"
|
23
14
|
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
20
|
+
# specify any dependencies here; for example:
|
21
|
+
s.add_development_dependency "rspec"
|
22
|
+
s.add_runtime_dependency "savon"
|
23
|
+
s.add_runtime_dependency "curb"
|
33
24
|
end
|
metadata
CHANGED
@@ -1,100 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vatman
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Neil Middleton
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
|
-
cert_chain:
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70252596627560 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70252596627560
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: savon
|
27
|
+
requirement: &70252596627140 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70252596627140
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: curb
|
38
|
+
requirement: &70252596626720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70252596626720
|
47
|
+
description:
|
48
|
+
email:
|
49
|
+
- neil.middleton@gmail.com
|
45
50
|
executables: []
|
46
|
-
|
47
51
|
extensions: []
|
48
|
-
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .rspec
|
56
|
+
- Gemfile
|
52
57
|
- Rakefile
|
53
58
|
- lib/vatman.rb
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
59
|
+
- lib/vatman/version.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/vatman_spec.rb
|
57
62
|
- vatman.gemspec
|
58
|
-
|
59
|
-
homepage: http://github.com/neilmiddleton/vatman
|
63
|
+
homepage: ''
|
60
64
|
licenses: []
|
61
|
-
|
62
65
|
post_install_message:
|
63
|
-
rdoc_options:
|
64
|
-
|
65
|
-
- --inline-source
|
66
|
-
- --title
|
67
|
-
- Vatman
|
68
|
-
- --main
|
69
|
-
- Readme.rdoc
|
70
|
-
require_paths:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
71
68
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
70
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
- 0
|
80
|
-
version: "0"
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
76
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 1
|
89
|
-
- 2
|
90
|
-
version: "1.2"
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
91
81
|
requirements: []
|
92
|
-
|
93
82
|
rubyforge_project: vatman
|
94
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.6
|
95
84
|
signing_key:
|
96
85
|
specification_version: 3
|
97
86
|
summary: A gem that checks VAT numbers against the Europa web service
|
98
|
-
test_files:
|
99
|
-
-
|
100
|
-
-
|
87
|
+
test_files:
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/vatman_spec.rb
|
data.tar.gz.sig
DELETED
data/Manifest
DELETED
data/test/test_helper.rb
DELETED
data/test/test_vatman.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class TestVatman < Test::Unit::TestCase
|
2
|
-
|
3
|
-
def setup
|
4
|
-
end
|
5
|
-
|
6
|
-
def test_vatman
|
7
|
-
v = Vatman.new('GB', 802925148)
|
8
|
-
assert v.valid?
|
9
|
-
assert_equal 'MONOCHROME LIMITED', v.name
|
10
|
-
assert_equal "SUITE K\nTHE PAVILLIONS\n1 WESTERN ROAD\nEPSOM\nSURREY\nKT17 1JG", v.address
|
11
|
-
|
12
|
-
v = Vatman.new('GB', 123456789)
|
13
|
-
assert !v.valid?
|
14
|
-
|
15
|
-
v = Vatman.new('GB', "abcdefg")
|
16
|
-
assert !v.valid?
|
17
|
-
end
|
18
|
-
end
|
metadata.gz.sig
DELETED
Binary file
|