valvat-core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3f1c3ac61821e5dda76536c5bf4f24413ba4ff2b
4
+ data.tar.gz: 1d33a51ed76f49a85a1966e66c0be2255b3279ee
5
+ SHA512:
6
+ metadata.gz: 2cccbf512f0aa01895fa8fca654172dfedea9d171246d5acf979f91e4fcd098da3a7d5751ded86e379710cfe7f35b33c62d039795f4852421a8af7a1b9f36b29
7
+ data.tar.gz: e81b500fc096cfa3b259c7a83ab12ed8bbf1e194a70981ec31900f32bab99446dea5a233dadee79268e065f4e81b00eec8a714207762e34a52e6a79c4c719ddd
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ tmp
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ plugin
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.2
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - jruby-19mode
7
+ gemfile:
8
+ - gemfiles/activemodel-4
9
+ - gemfiles/activemodel-3-2
10
+ - gemfiles/standalone
data/CHANGES.md ADDED
@@ -0,0 +1,223 @@
1
+ ### dev
2
+
3
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.7...master)
4
+
5
+ * Removed all circular require-statements - fixed #34 (by [Julik Tarkhanov](https://github.com/julik))
6
+ * Fixed segfault with activemodel requiring files with .rb-suffix - fixed #34 (by [Julik Tarkhanov](https://github.com/julik))
7
+
8
+ ### 0.6.7 / 2014-11-03
9
+
10
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.6...v0.6.7)
11
+
12
+ * Fixed SOAP issue with current wasabi 3.3 - fixed #33
13
+ * Several minor travis/guard fixes
14
+
15
+ ### 0.6.6 / 2014-10-02
16
+
17
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.5...v0.6.6)
18
+
19
+ * Added czech translations (by [Dawid Cichuta](https://github.com/cichaczem))
20
+ * Fixed polish translations (by [Dawid Cichuta](https://github.com/cichaczem))
21
+
22
+ ### 0.6.5 / 2014-06-19
23
+
24
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.4...v0.6.5)
25
+
26
+ * Added french, spanish and danish translations (by [Roman Lehnert](https://github.com/romanlehnert))
27
+ * Specs: Fixed issues with rspec 3
28
+ * Specs: Switched to :expect syntax
29
+
30
+ ### 0.6.4 / 2014-04-09
31
+
32
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.3...v0.6.4)
33
+
34
+ * Added dutch translations (by [0scarius](https://github.com/0scarius))
35
+
36
+ ### 0.6.3 / 2014-04-05
37
+
38
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.2...v0.6.3)
39
+
40
+ * Fixed portuguese translations (by [Davidslv](https://github.com/Davidslv))
41
+
42
+ ### 0.6.2 / 2013-11-10
43
+
44
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.1...v0.6.2)
45
+
46
+ * Added blank? method to Valvat object
47
+
48
+ ### 0.6.1 / 2013-09-02
49
+
50
+ [full changelog](http://github.com/yolk/valvat/compare/v0.6.0...v0.6.1)
51
+
52
+ * Valvat::Lockup: require savon on load
53
+
54
+ ### 0.6.0 / 2013-08-01
55
+
56
+ [full changelog](http://github.com/yolk/valvat/compare/v0.5.0...v0.6.0)
57
+
58
+ * Works now with current version of savon gem (2.3.0) (by [liggitt](https://github.com/liggitt))
59
+ * Corrected regex for IE VAT numbers (by [brianphillips](https://github.com/brianphillips))
60
+ * Improved PT translation
61
+ * Some code refactorings
62
+ * Spec improvments
63
+
64
+ ### 0.5.0 / 2013-07-18
65
+
66
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.7...v0.5.0)
67
+
68
+ * Added experimental checksum verification for 17 european countries (with help from [kirichkov](https://github.com/kirichkov))
69
+ * Works now with current version of savon gem (2.2.0) (by [nevesenin](https://github.com/nevesenin))
70
+
71
+ ### 0.4.7 / 2013-07-18
72
+
73
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.6...v0.4.7)
74
+
75
+ * Added I18n locales for Polish, Romanian, Italian, Portuguese and Latvian (by [shaundaley39](https://github.com/shaundaley39))
76
+
77
+ ### 0.4.6 / 2013-07-01
78
+
79
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.5...v0.4.6)
80
+
81
+ * Added support for croatian vat numbers (by [mowli](https://github.com/mowli))
82
+
83
+ ### 0.4.5 / 2013-02-16
84
+
85
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.4...v0.4.5)
86
+
87
+ * Added I18n locales in bulgarian (by [kirichkov](https://github.com/kirichkov))
88
+
89
+ ### 0.4.4 / 2013-01-07
90
+
91
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.3...v0.4.4)
92
+
93
+ * Fixed dependency on savon version 1.2 (2.0 uses new api)
94
+ * Convert to string before normalize (by [borodiychuk](https://github.com/borodiychuk))
95
+
96
+ ### 0.4.3 / 2012-12-11
97
+
98
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.2...v0.4.3)
99
+
100
+ * Fixed error handling in Lookup (by [bmurzeau](https://github.com/bmurzeau))
101
+
102
+ ### 0.4.2 / 2012-11-16
103
+
104
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.1...v0.4.2)
105
+
106
+ * Fixed usage with savon version 1.2
107
+ * Require version 1.2 of the savon gem from now on
108
+ * Added :raise_error option to throw errors instead of returning nil
109
+
110
+ ### 0.4.1 / 2012-07-17
111
+
112
+ [full changelog](http://github.com/yolk/valvat/compare/v0.4.0...v0.4.1)
113
+
114
+ * Fixed issue with current savon version & required more recent savon version
115
+
116
+ ### 0.4.0 / 2012-07-17
117
+
118
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.6...v0.4.0)
119
+
120
+ * Added support for company details and requester identifiers in successful responses
121
+ (by [lcx](https://github.com/lcx))
122
+ * Added Valvat::Lookup.last_error for debugging
123
+
124
+ ### 0.3.6 / 2012-04-10
125
+
126
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.5...v0.3.6)
127
+
128
+ * Fixed wrong regexp for Belgium numbers (by [opsidao](https://github.com/opsidao))
129
+
130
+ ### 0.3.5 / 2012-02-02
131
+
132
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.4...v0.3.5)
133
+
134
+ * Swedish translation (by [henrik](https://github.com/henrik))
135
+ * English fixes (by [henrik](https://github.com/henrik))
136
+
137
+ ### 0.3.4 / 2011-08-01
138
+
139
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.3...v0.3.4)
140
+
141
+ * Normalize all input on initialization (by [SpoBo](https://github.com/SpoBo))
142
+
143
+ ### 0.3.3 / 2011-06-02
144
+
145
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.2...v0.3.3)
146
+
147
+ * Add Valvat::Utils.iso_country_to_vat_country (by [Deb Bassett](https://github.com/urbanwide))
148
+
149
+ ### 0.3.2 / 2011-01-14
150
+
151
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.1...v0.3.2)
152
+
153
+ * Fixed localization strings (en/de)
154
+ * Moved locales folder to lib/valvat/locales
155
+
156
+ ### 0.3.1 / 2011-01-12
157
+
158
+ [full changelog](http://github.com/yolk/valvat/compare/v0.3.0...v0.3.1)
159
+
160
+ * ActiveModel validation: Failed validations with _match_country_ now use error message with country from given attribute
161
+ * ActiveModel validation: Failed validations with _match_country_ skip lookup and syntax checks
162
+
163
+ ### 0.3.0 / 2011-01-12
164
+
165
+ [full changelog](http://github.com/yolk/valvat/compare/v0.2.3...v0.3.0)
166
+
167
+ * ActiveModel validation: added _match_country_ option to validate if iso country code of vat number matches another attribute.
168
+
169
+ ### 0.2.3 / 2011-01-10
170
+
171
+ [full changelog](http://github.com/yolk/valvat/compare/v0.2.2...v0.2.3)
172
+
173
+ * Valvat::Utils.normalize now removes spaces and special chars anywhere
174
+
175
+ ### 0.2.2 / 2011-01-10
176
+
177
+ [full changelog](http://github.com/yolk/valvat/compare/v0.2.1...v0.2.2)
178
+
179
+ * Using vies directly via soap/savon again; isvat.appspot.com is not _really_ reliable.
180
+ * Added support for Valvat#exist? as an alias of Valvat#exists?
181
+
182
+ ### 0.2.1 / 2011-01-07
183
+
184
+ [full changelog](http://github.com/yolk/valvat/compare/v0.2.0...v0.2.1)
185
+
186
+ * Fixed blocker in valvat/lookup
187
+
188
+ ### 0.2.0 / 2011-01-07
189
+
190
+ [full changelog](http://github.com/yolk/valvat/compare/v0.1.1...v0.2.0)
191
+
192
+ * Rewrote Valvat module to a vat number class for convenience + internal use of Valvat instances
193
+ * I18n: Default error messages in german
194
+
195
+ ### 0.1.1 / 2011-01-07
196
+
197
+ [full changelog](http://github.com/yolk/valvat/compare/v0.1.0...v0.1.1)
198
+
199
+ * Fixed issue with country web service down and added spec
200
+ * Stubbed web service specs with fakeweb
201
+ * Added documentation for ActiveModel support
202
+
203
+ ### 0.1.0 / 2011-01-07
204
+
205
+ [full changelog](http://github.com/yolk/valvat/compare/v0.0.3...v0.1.0)
206
+
207
+ * ActiveModel validation: added optional lookup support
208
+ * ActiveModel validation: I18n support with country specific messages
209
+ * ActiveModel validation: I18n locales in english and german
210
+ * Fixed bug with wrong iso country code on greek vat number (EL != GR)
211
+ * Valvat::Util.split only returns countries from europe
212
+
213
+ ### 0.0.3 / 2011-01-06
214
+
215
+ [full changelog](http://github.com/yolk/valvat/compare/v0.0.2...v0.0.3)
216
+
217
+ * Basic support for ActiveModel validation
218
+
219
+ ### 0.0.2 / 2011-01-06
220
+
221
+ [full changelog](http://github.com/yolk/valvat/compare/v0.0.1...v0.0.2)
222
+
223
+ * Use REST-wrapper for accessing VIES web service; this removes dependency on savon and some lines of code. See http://isvat.appspot.com/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in valvat-core.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ watch(/^spec\/(.*)_spec.rb/)
3
+ watch(/^lib\/(.*)\.rb/) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch(/^spec\/spec_helper.rb/) { "spec" }
5
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Yolk Sebastian Munz & Julia Soergel GbR
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ valvat-core
2
+ ===========
3
+
4
+ Core functionality extraction from the [valvat gem](http://github.com/yolk/valvat) - Validates european vat numbers.
5
+
6
+ ## Features
7
+
8
+ * Simple syntax verification
9
+
10
+ valvat-core is tested and works with ruby MRI 1.9.3/2.0/2.1, jruby (in 1.9 mode) and rubinius 2.2
11
+
12
+ ## Installation
13
+
14
+ gem install valvat-core
15
+
16
+ ## Basic Usage
17
+
18
+ To verify the syntax of a vat number:
19
+
20
+ Valvat.new("DE345789003").valid?
21
+ => true or false
22
+
23
+ It is also possible to bypass initializing a Valvat instance and check the syntax of a var number string directly with:
24
+
25
+ Valvat::Syntax.validate("DE345789003")
26
+ => true or false
27
+
28
+
29
+ ## Utilities
30
+
31
+ To split a vat number into the country code and the remaining chars:
32
+
33
+ Valvat::Utils.split("ATU345789003")
34
+ => ["AT", "U345789003"]
35
+
36
+ or
37
+
38
+ Valvat.new("ATU345789003").to_a
39
+ => ["AT", "U345789003"]
40
+
41
+ Both methods always return an array. If it can not detect the country or the given country is located outside of europe it returns `[nil, nil]`. Please note that this does not strictly return the ISO country code: for greek vat numbers this returns the ISO language code 'EL' instead of the ISO country code 'GR'.
42
+
43
+ To extract the ISO country code of a given vat number:
44
+
45
+ Valvat.new("EL7345789003").iso_country_code
46
+ => "GR"
47
+
48
+ To extract the vat country code (first two chars in every european vat number):
49
+
50
+ Valvat.new("EL7345789003").vat_country_code
51
+ => "EL"
52
+
53
+ To normalize a vat number:
54
+
55
+ Valvat::Utils.normalize("atu345789003")
56
+ => "ATU345789003"
57
+
58
+ This basically just removes trailing spaces and ensures all chars are uppercase.
59
+
60
+ ## Links
61
+ [valvat](http://github.com/yolk/valvat)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rspec', '~> 3.0'
4
+ gem 'rake'
data/lib/valvat.rb ADDED
@@ -0,0 +1,44 @@
1
+ class Valvat
2
+ def initialize(raw)
3
+ @raw = Valvat::Utils.normalize(raw || "")
4
+ @vat_country_code, @to_s_wo_country = to_a
5
+ end
6
+
7
+ attr_reader :raw, :vat_country_code, :to_s_wo_country
8
+
9
+ def blank?
10
+ raw.nil? || raw.strip == ""
11
+ end
12
+
13
+ def valid?
14
+ Valvat::Syntax.validate(self)
15
+ end
16
+
17
+ def iso_country_code
18
+ Valvat::Utils.vat_country_to_iso_country(vat_country_code)
19
+ end
20
+
21
+ def european?
22
+ Valvat::Utils::EU_COUNTRIES.include?(iso_country_code)
23
+ end
24
+
25
+ def to_a
26
+ Valvat::Utils.split(raw)
27
+ end
28
+
29
+ def to_s
30
+ raw
31
+ end
32
+
33
+ def inspect
34
+ "#<Valvat #{[raw, iso_country_code].compact.join(" ")}>"
35
+ end
36
+ end
37
+
38
+ def Valvat(vat)
39
+ vat.is_a?(Valvat) ? vat : Valvat.new(vat)
40
+ end
41
+
42
+ require 'valvat/utils'
43
+ require 'valvat/syntax'
44
+
@@ -0,0 +1 @@
1
+ require 'valvat'
@@ -0,0 +1,5 @@
1
+ class Valvat
2
+ module Core
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ bg:
2
+ errors:
3
+ messages:
4
+ invalid_vat: не е валиден %{country_adjective} ДДС номер
5
+ valvat:
6
+ country_adjectives:
7
+ eu: европейски
8
+ at: австрийски
9
+ be: белгийски
10
+ bg: български
11
+ cy: кипърски
12
+ cz: чешки
13
+ de: германски
14
+ dk: датски
15
+ ee: естонски
16
+ es: испански
17
+ fi: финландски
18
+ fr: френски
19
+ gb: британски
20
+ gr: гръцки
21
+ hu: унгарски
22
+ ie: ирландски
23
+ it: италиански
24
+ lt: литовски
25
+ lu: люксембургски
26
+ lv: латвийски
27
+ mt: малтийски
28
+ nl: холандски
29
+ pl: полски
30
+ pt: португалски
31
+ ro: румънски
32
+ se: шведски
33
+ si: словенски
34
+ sk: словашки