IBAN 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 935720b1afc0e9602d3e083e61d5f8055357bdb3
4
- data.tar.gz: 5ee9e17613f8f84ccd80be25061adad752cdb263
3
+ metadata.gz: 454a12c86cb6702c7d05c757e48d93f90d15a1a4
4
+ data.tar.gz: e10448ec9189e384306e427e04b9c89d95ffb203
5
5
  SHA512:
6
- metadata.gz: 6670867d84fcc2ad513dfcc512ede43c1af1191a3493b47e4da277cfde37e856e4776289026a69595a93c7b7d4f6fae24044add995052871c874cdaf90c3e61c
7
- data.tar.gz: 7f392388878fac70d02b3866c9830b60579d97e2a5029075f6f88d75133725b6c5cdbf623bc17bb82d20b60a9d07df1e21ae061c3754796f3ce1047f3efd7131
6
+ metadata.gz: 074f4b0a9540ed5ba0a6d3ed57feb878c2a6deab08f0ce0604353171cb391db5bd6133b0e2e133ca16cb04c85c6d90ab3b931672cd09175cf4d322618e298e91
7
+ data.tar.gz: f97cc073c5d44aac9167a74505ca1bec0857897b2cf264116ab1951deb11949699421065228d276aa83f9b5bb2a3d255a2c811cf3de0b3332c95b92ce1f14c0e
data/README.md CHANGED
@@ -41,6 +41,15 @@ Or install it yourself as:
41
41
 
42
42
  IBAN.valid? "DE89 3704 0044 0532 0130 00" # true
43
43
 
44
+ or as ActiveModel Validator (make sure you have 'active_model' before 'vat_id' in your Gemfile)
45
+
46
+ class Company
47
+ include ActiveModel::Model
48
+ attr_accessor :iban, :name
49
+ validates :iban, iban: true
50
+ end
51
+
52
+
44
53
 
45
54
  ## Contributing
46
55
 
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency 'minitest', "~> 4.2"
25
+ spec.add_development_dependency 'activemodel'
25
26
  end
@@ -1,8 +1,10 @@
1
- require 'yaml'
1
+ require "yaml"
2
+ require "iban/version"
3
+ require "iban/validator" if defined? ActiveModel
2
4
 
3
5
  class IBAN
4
6
  def self.specifications
5
- @@specs ||= YAML.load_file(File.expand_path('iban/specs.yml', File.dirname(__FILE__)))
7
+ @@specs ||= YAML.load_file(File.expand_path("iban/specs.yml", File.dirname(__FILE__)))
6
8
  end
7
9
 
8
10
  def self.valid?(code)
@@ -1,3 +1,5 @@
1
+ require 'active_model/validator'
2
+
1
3
  class IbanValidator < ActiveModel::EachValidator
2
4
  def validate_each(record, attribute, value)
3
5
  record.errors.add(attribute, :invalid) unless IBAN.valid?(value)
@@ -1,3 +1,3 @@
1
1
  class IBAN
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ class Company
4
+ include ActiveModel::Model
5
+
6
+ attr_accessor :iban, :name
7
+ validates :iban, iban: true
8
+
9
+ def persisted?
10
+ false
11
+ end
12
+ end
13
+
14
+ describe IbanValidator do
15
+ before {
16
+ @model = Company.new
17
+ }
18
+
19
+ it "should be valid" do
20
+ @model.iban = 'FR1420041010050500013M02606'
21
+ @model.valid?.must_equal true
22
+ end
23
+
24
+ it "should not be valid" do
25
+ @model.iban = 'FR1420041010050500013'
26
+ @model.valid?.must_equal false
27
+ @model.errors[:iban].must_include "is invalid"
28
+ end
29
+ end
@@ -5,4 +5,6 @@ require 'bundler/setup'
5
5
  require 'minitest/autorun'
6
6
  require 'minitest/spec'
7
7
  begin; require 'turn/autorun'; rescue LoadError; end
8
+
9
+ require 'active_model'
8
10
  require 'iban'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: IBAN
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-10 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activemodel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: 'IBAN: International Bank Account Number'
56
70
  email:
57
71
  - kevin.melchert@gmail.com
@@ -66,10 +80,11 @@ files:
66
80
  - README.md
67
81
  - Rakefile
68
82
  - iban.gemspec
69
- - lib/active_model/iban_validator.rb
70
83
  - lib/iban.rb
71
84
  - lib/iban/specs.yml
85
+ - lib/iban/validator.rb
72
86
  - lib/iban/version.rb
87
+ - spec/activemodel_spec.rb
73
88
  - spec/iban_spec.rb
74
89
  - spec/spec_helper.rb
75
90
  homepage: https://github.com/max-power/iban
@@ -97,6 +112,7 @@ signing_key:
97
112
  specification_version: 4
98
113
  summary: IBAN information, validation and formatting.
99
114
  test_files:
115
+ - spec/activemodel_spec.rb
100
116
  - spec/iban_spec.rb
101
117
  - spec/spec_helper.rb
102
118
  has_rdoc: