vat_rates 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/lib/vat_rates/fetcher.rb +65 -0
- data/lib/vat_rates/version.rb +3 -0
- data/lib/vat_rates.rb +5 -0
- data/spec/lib/fetcher_spec.rb +22 -0
- data/spec/spec_helper.rb +1 -0
- data/vat_rates.gemspec +26 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 415c82d33908d10236dbb9282de9388ec91708d7
|
4
|
+
data.tar.gz: 159b7e1ec89d6013e2430e0a55487c86ab3add62
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5632913747c624766d689fa4b93a3e7a2806adc7a3f0088da788d7010442d766694f1753677f0fb3bb33160edd6b31f09479804cc16700cc2bab0ef09747209d
|
7
|
+
data.tar.gz: 04db78f653d486b078fe3895c986fc623b1160e799c867eb5a889dec29efc696e28781234aeec0ac6f125e020daea363fdf7c02508b9a270425c5886565a658d
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/*
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Dmitry Polushkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# VAT Rates
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/dmitry/vat_rates.png?branch=master)](http://travis-ci.org/dmitry/vat_rates) [![Gem Version](https://badge.fury.io/rb/vat_rates.png)](http://badge.fury.io/rb/vat_rates)
|
4
|
+
|
5
|
+
VAT rates based on the [ec.europa.eu](http://ec.europa.eu/taxation_customs/tic/public/vatRates/vatratesSearch.html) website list. This gem parses data on the page, and provides interface to those data.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's `Gemfile`:
|
10
|
+
|
11
|
+
gem 'vat_rates'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install vat_rates
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To get current VAT rates from ec.europa.eu, just invoke following command:
|
24
|
+
|
25
|
+
VatRates::Fetcher.get
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/dmitry/vat_rates/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module VatRates
|
5
|
+
class Fetcher
|
6
|
+
URL = 'http://ec.europa.eu/taxation_customs/tic/public/vatRates/vatratesSearch.html'
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def get
|
10
|
+
html = open(URL)
|
11
|
+
|
12
|
+
doc = Nokogiri::HTML(html)
|
13
|
+
|
14
|
+
data = []
|
15
|
+
|
16
|
+
content = doc.css('#tic-content').first
|
17
|
+
|
18
|
+
content.children.each do |child|
|
19
|
+
if child.name == 'h2'
|
20
|
+
code, name = child.text.split(' - ')
|
21
|
+
|
22
|
+
data << {
|
23
|
+
code: code,
|
24
|
+
name: name,
|
25
|
+
rate: normalize_rate(child.next.next.next.next.css('td')[1].text)
|
26
|
+
}
|
27
|
+
elsif child.name == 'h4'
|
28
|
+
data.last[:regions] ||= []
|
29
|
+
region = {
|
30
|
+
name: child.text
|
31
|
+
}
|
32
|
+
|
33
|
+
standard = child.next.next.next.next
|
34
|
+
|
35
|
+
if standard.text.include?('No Standard Rate')
|
36
|
+
region[:rate] = 0
|
37
|
+
else
|
38
|
+
region[:rate] = normalize_rate(standard.css('td')[1].text)
|
39
|
+
end
|
40
|
+
|
41
|
+
reduced = standard.next.next.next.next.next.next
|
42
|
+
|
43
|
+
unless reduced.text.include?('No information available')
|
44
|
+
reduced.css('tr')[1..-1].each do |row|
|
45
|
+
columns = row.css('td')
|
46
|
+
region[:reduced_rates] = {
|
47
|
+
category: columns[0].text,
|
48
|
+
rate: normalize_rate(columns[1].text)
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
data.last[:regions] << region
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
data
|
58
|
+
end
|
59
|
+
|
60
|
+
def normalize_rate(number)
|
61
|
+
number.sub(',', '.').gsub(/[% ]/, '').to_f
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/vat_rates.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe VatRates::Fetcher do
|
5
|
+
it '#get' do
|
6
|
+
values = VatRates::Fetcher.get
|
7
|
+
|
8
|
+
france = {
|
9
|
+
code: 'FR',
|
10
|
+
name: 'France',
|
11
|
+
rate: 20.0,
|
12
|
+
regions: [
|
13
|
+
{name: 'Corsica', rate: 20.0, reduced_rates: {category: 'Taux particulier', rate: 10.0}},
|
14
|
+
{name: 'DOM', rate: 8.5, reduced_rates: {category: 'Taux réduit', rate: 1.05}},
|
15
|
+
{name: 'Monaco', rate: 20.0, :reduced_rates=>{:category=>"Taux intermédiaire", :rate=>10.0}}
|
16
|
+
]
|
17
|
+
}
|
18
|
+
|
19
|
+
expect(values.find { |v| 'France' == v[:name] }).to eq(france)
|
20
|
+
expect(values.count).to eq 28
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'vat_rates'
|
data/vat_rates.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vat_rates/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'vat_rates'
|
8
|
+
spec.version = VatRates::VERSION
|
9
|
+
spec.authors = ['Dmitry Polushkin']
|
10
|
+
spec.email = ['dmitry.polushkin@gmail.com']
|
11
|
+
spec.summary = %q{European VAT rates}
|
12
|
+
spec.description = %q{Take VAT rates from ec.europa.eu}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'nokogiri'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vat_rates
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Polushkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
prerelease: false
|
15
|
+
name: nokogiri
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
prerelease: false
|
29
|
+
name: bundler
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.6'
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.6'
|
40
|
+
type: :development
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
prerelease: false
|
43
|
+
name: rake
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
prerelease: false
|
57
|
+
name: rspec
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
description: Take VAT rates from ec.europa.eu
|
70
|
+
email:
|
71
|
+
- dmitry.polushkin@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .ruby-version
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/vat_rates.rb
|
84
|
+
- lib/vat_rates/fetcher.rb
|
85
|
+
- lib/vat_rates/version.rb
|
86
|
+
- spec/lib/fetcher_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- vat_rates.gemspec
|
89
|
+
homepage: ''
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.2.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: European VAT rates
|
113
|
+
test_files:
|
114
|
+
- spec/lib/fetcher_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
has_rdoc:
|