kontoapi-rails 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/README.markdown +9 -0
- data/Rakefile +1 -5
- data/VERSION +1 -1
- data/kontoapi-rails.gemspec +34 -34
- data/lib/kontoapi-rails/orm/active_record_extension.rb +32 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0fb0f92dbe49be53fac806e06637bbc3cf27aad
|
4
|
+
data.tar.gz: da292419b8473328386a5af8bb32f1fae1294989
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d414e4eab909fa495bd949e5a322c5924445fd05912e8c9ea66ea15e2edeff4109a0924e30a8352028aae839a4aa69b291962663e810893005293d4dca0c97
|
7
|
+
data.tar.gz: 9abe9d7cec8d07bbedff08e2c7fe9b804f02b8407224a7907e711932fc1d4b17ed7170c579e756c1fa8962d2a1674d63a3fb565fe2422160d9d0d9b99bd95775
|
data/README.markdown
CHANGED
@@ -65,6 +65,15 @@ Then, in one of the models you want to validate bank account data with:
|
|
65
65
|
# :fail <-- throw a validation error
|
66
66
|
# :retry <-- (not supported yet)
|
67
67
|
validates_bic :bic
|
68
|
+
|
69
|
+
# Combined IBAN & BIC validation
|
70
|
+
# Check if the given BIC exists, the IBAN is valid and if they match
|
71
|
+
# Takes any of the following options (the defaults are shown here):
|
72
|
+
# :allow_nil => true, <-- don't validate if both are nil
|
73
|
+
# :on_timeout => :ignore <-- do nothing if a timeout occurs, others:
|
74
|
+
# :fail <-- throw a validation error
|
75
|
+
# :retry <-- (not supported yet)
|
76
|
+
validates_iban_and_bic :iban, :bic
|
68
77
|
|
69
78
|
end
|
70
79
|
|
data/Rakefile
CHANGED
@@ -18,11 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.summary = %Q{A wrapper for the Konto API (https://www.kontoapi.de/) providing model validation.}
|
19
19
|
gem.description = %Q{This library is a wrapper for the Konto API (https://www.kontoapi.de/). It provides a validation method for models that checks if a given account number and bank code represent a valid combination.}
|
20
20
|
gem.email = "jan@schwenzien.org"
|
21
|
-
gem.authors = ["Jan Schwenzien"]
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
21
|
+
gem.authors = ["Jan Schwenzien", "Jiayi Zheng"]
|
26
22
|
end
|
27
23
|
Jeweler::RubygemsDotOrgTasks.new
|
28
24
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/kontoapi-rails.gemspec
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: kontoapi-rails 0.3.
|
5
|
+
# stub: kontoapi-rails 0.3.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "kontoapi-rails"
|
9
|
-
s.version = "0.3.
|
8
|
+
s.name = "kontoapi-rails"
|
9
|
+
s.version = "0.3.1"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0"
|
12
|
-
s.require_paths = ["lib"
|
13
|
-
s.authors = ["Jan Schwenzien"
|
14
|
-
s.date = "
|
15
|
-
s.description = "This library is a wrapper for the Konto API (https://www.kontoapi.de/). It provides a validation method for models that checks if a given account number and bank code represent a valid combination."
|
16
|
-
s.email = "jan@schwenzien.org"
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Jan Schwenzien", "Jiayi Zheng"]
|
14
|
+
s.date = "2017-03-08"
|
15
|
+
s.description = "This library is a wrapper for the Konto API (https://www.kontoapi.de/). It provides a validation method for models that checks if a given account number and bank code represent a valid combination."
|
16
|
+
s.email = "jan@schwenzien.org"
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
19
|
"README.markdown"
|
@@ -38,39 +38,39 @@ Gem::Specification.new do |s|
|
|
38
38
|
"spec/kontoapi-rails_spec.rb",
|
39
39
|
"spec/spec_helper.rb"
|
40
40
|
]
|
41
|
-
s.homepage = "http://github.com/GeneralScripting/kontoapi-rails"
|
42
|
-
s.licenses = ["MIT"
|
43
|
-
s.rubygems_version = "2.
|
44
|
-
s.summary = "A wrapper for the Konto API (https://www.kontoapi.de/) providing model validation."
|
41
|
+
s.homepage = "http://github.com/GeneralScripting/kontoapi-rails"
|
42
|
+
s.licenses = ["MIT"]
|
43
|
+
s.rubygems_version = "2.4.8"
|
44
|
+
s.summary = "A wrapper for the Konto API (https://www.kontoapi.de/) providing model validation."
|
45
45
|
|
46
46
|
if s.respond_to? :specification_version then
|
47
47
|
s.specification_version = 4
|
48
48
|
|
49
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<rails
|
51
|
-
s.add_runtime_dependency(%q<kontoapi-ruby
|
52
|
-
s.add_development_dependency(%q<rspec
|
53
|
-
s.add_development_dependency(%q<bundler
|
54
|
-
s.add_development_dependency(%q<jeweler
|
55
|
-
s.add_development_dependency(%q<simplecov
|
56
|
-
s.add_development_dependency(%q<rdoc
|
50
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
51
|
+
s.add_runtime_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
|
53
|
+
s.add_development_dependency(%q<bundler>, [">= 1.1.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
|
55
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
57
57
|
else
|
58
|
-
s.add_dependency(%q<rails
|
59
|
-
s.add_dependency(%q<kontoapi-ruby
|
60
|
-
s.add_dependency(%q<rspec
|
61
|
-
s.add_dependency(%q<bundler
|
62
|
-
s.add_dependency(%q<jeweler
|
63
|
-
s.add_dependency(%q<simplecov
|
64
|
-
s.add_dependency(%q<rdoc
|
58
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
59
|
+
s.add_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
60
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
61
|
+
s.add_dependency(%q<bundler>, [">= 1.1.0"])
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
63
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
65
65
|
end
|
66
66
|
else
|
67
|
-
s.add_dependency(%q<rails
|
68
|
-
s.add_dependency(%q<kontoapi-ruby
|
69
|
-
s.add_dependency(%q<rspec
|
70
|
-
s.add_dependency(%q<bundler
|
71
|
-
s.add_dependency(%q<jeweler
|
72
|
-
s.add_dependency(%q<simplecov
|
73
|
-
s.add_dependency(%q<rdoc
|
67
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
68
|
+
s.add_dependency(%q<kontoapi-ruby>, [">= 0.2.0"])
|
69
|
+
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
70
|
+
s.add_dependency(%q<bundler>, [">= 1.1.0"])
|
71
|
+
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
72
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -80,7 +80,7 @@ module KontoAPI
|
|
80
80
|
return true if respond_to?(:"encrypted_#{field}_changed?") && !send(:"encrypted_#{field}_changed?")
|
81
81
|
return true if options[:allow_nil] && value.nil?
|
82
82
|
begin
|
83
|
-
errors.add(field, :invalid) unless KontoAPI::valid?( :bic =>
|
83
|
+
errors.add(field, :invalid) unless KontoAPI::valid?( :bic => value )
|
84
84
|
rescue Timeout::Error => ex
|
85
85
|
case options[:on_timeout]
|
86
86
|
when :fail
|
@@ -92,6 +92,37 @@ module KontoAPI
|
|
92
92
|
end
|
93
93
|
validate :bic_validation
|
94
94
|
end
|
95
|
+
|
96
|
+
def validates_iban_and_bic(iban_field, bic_field, options={})
|
97
|
+
return if KontoAPI::Config.disable_for.include?(::Rails.env)
|
98
|
+
options.symbolize_keys!
|
99
|
+
options.reverse_merge!( :allow_nil => true, :on_timeout => :ignore )
|
100
|
+
define_method :iban_and_bic_validation do
|
101
|
+
iban_value = send(iban_field)
|
102
|
+
bic_value = send(bic_field)
|
103
|
+
return true if [iban_field, bic_field].all? do |field|
|
104
|
+
respond_to?(:"#{field}_changed?") && !send(:"#{field}_changed?")
|
105
|
+
end
|
106
|
+
return true if [iban_field, bic_field].all? do |field|
|
107
|
+
respond_to?(:"encrypted_#{field}_changed?") && !send(:"encrypted_#{field}_changed?")
|
108
|
+
end
|
109
|
+
return true if options[:allow_nil] && iban_value.nil? && bic_value.nil?
|
110
|
+
begin
|
111
|
+
unless KontoAPI::valid?( :iban => iban_value, :bic => bic_value )
|
112
|
+
errors.add(iban_field, :invalid)
|
113
|
+
errors.add(bic_field, :invalid)
|
114
|
+
end
|
115
|
+
rescue Timeout::Error => ex
|
116
|
+
case options[:on_timeout]
|
117
|
+
when :fail
|
118
|
+
errors.add(field, :timeout)
|
119
|
+
when :ignore
|
120
|
+
# nop
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
validate :iban_and_bic_validation
|
125
|
+
end
|
95
126
|
end
|
96
127
|
|
97
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontoapi-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Schwenzien
|
8
|
+
- Jiayi Zheng
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.4.8
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: A wrapper for the Konto API (https://www.kontoapi.de/) providing model validation.
|