Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Formatting: removes trailing spaces, adds newlines at end of files #5

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  .gitignore
@@ -1,3 +1,3 @@
.DS_Store
Thumbs.db
-*.gem
+*.gem
View
6 README.rdoc
@@ -26,14 +26,14 @@ Example :
class Invoice < ActiveRecord::Base
validates :vat_number, :vat => { :country_method => :country_code }
-
+
# Logic to return the country code
def country_code
case country.downcase
when 'belgium' then 'BE'
when 'france' then 'FR'
when 'sweden' then 'SE'
- # ...
+ # ...
else nil
end
end
@@ -66,4 +66,4 @@ If you want to run the specs :
This plugin in released under MIT license by Aurélien Malisart (see MIT-LICENSE
file).
-(c) http://aurelien.malisart.be
+(c) http://aurelien.malisart.be
View
4 Rakefile
@@ -5,5 +5,5 @@ desc "Run specs"
task :spec do
puts `rspec spec/vat_validator/*_spec.rb`
end
-
-task :default => :spec
+
+task :default => :spec
View
6 lib/vies_checker.rb
@@ -21,7 +21,7 @@ def self.check(complete_vat_number, return_extra_infos = false, vies_host='http:
begin
response = client.request :check_vat do
soap.body = {
- :country_code => country_code,
+ :country_code => country_code,
:vat_number => vat_number
}
end
@@ -37,7 +37,7 @@ def self.check(complete_vat_number, return_extra_infos = false, vies_host='http:
else
return false
end
-
+
else
raise ViesContactError
end
@@ -60,4 +60,4 @@ def self.check(complete_vat_number, return_extra_infos = false, vies_host='http:
end
end
end
-end
+end
View
14 spec/spec_helper.rb
@@ -3,25 +3,25 @@
require 'active_model'
require File.dirname(__FILE__) + '/../lib/vat_validator.rb'
-
+
# Utils models =================================================================
class BaseTestModel
include ActiveModel::Serialization
include ActiveModel::Validations
-
+
attr_accessor :attributes
-
+
def initialize(attributes = {})
@attributes = attributes
end
-
+
def read_attribute_for_validation(key)
@attributes[key]
end
end
-class Invoice < BaseTestModel
+class Invoice < BaseTestModel
validates :vat_number, :vat => true
end
@@ -31,12 +31,12 @@ class OptionalVatInvoice < BaseTestModel
class CountryCheckedInvoice < BaseTestModel
validates :vat_number, :vat => { :country_method => :country_code }
-
+
# Fake attribute accessor
def country
@attributes[:country]
end
-
+
# Logic to return the country code
def country_code
case country.downcase
View
10 spec/vat_validator/vies_checker_spec.rb
@@ -5,20 +5,20 @@
describe ViesCheckedInvoice do
it "should be valid if vat number is correct" do
- VatValidations::ViesChecker.check('BE0817331995').should be_true
+ VatValidations::ViesChecker.check('BE0817331995').should be_true
ViesCheckedInvoice.new(:vat_number => 'BE0817331995').should be_valid
end
-
+
it "should not be valid if vat number is correct" do
- VatValidations::ViesChecker.check('BE000678345').should_not be_true
+ VatValidations::ViesChecker.check('BE000678345').should_not be_true
ViesCheckedInvoice.new(:vat_number => 'BE000678345').should_not be_valid
end
it "should not be valid if the input is not valid" do
- VatValidations::ViesChecker.check('blop').should_not be_true
+ VatValidations::ViesChecker.check('blop').should_not be_true
end
it "should raise an exception if VIES is unreachable" do
lambda {WrongViesCheckedInvoice.new(:vat_number => 'BE0817331995').valid?}.should raise_error(VatValidations::ViesContactError)
end
-end
+end
View
10 vat_validator.gemspec
@@ -3,17 +3,17 @@ Gem::Specification.new do |s|
s.summary = "Validator for european countries VAT numbers for ActiveModel"
s.description = "Validator for european countries VAT numbers for ActiveModel"
s.homepage = "http://github.com/aurels/vat_validator"
-
+
s.version = "1.2"
s.date = "2011-09-30"
-
+
s.authors = ["Aurelien Malisart", "Francois Stephany"]
s.email = "aurelien.malisart@gmail.com"
-
+
s.require_paths = ["lib"]
s.files = Dir["lib/**/*"] + Dir["spec/**/*"] + ["README.rdoc", "Rakefile"]
s.extra_rdoc_files = ["README.rdoc"]
-
+
s.has_rdoc = false
s.rubygems_version = "1.6.2"
@@ -22,4 +22,4 @@ Gem::Specification.new do |s|
s.add_dependency('activemodel')
s.add_dependency('savon', ">= 0.9.7")
s.add_development_dependency('rspec', ">= 2.0.0")
-end
+end
Something went wrong with that request. Please try again.