iban_bic 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/iban_bic/core.rb +9 -0
- data/lib/iban_bic/random.rb +0 -2
- data/lib/iban_bic/validators/countries/pt.rb +1 -1
- data/lib/iban_bic/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbba9bbccde215ba50dbd29a909f2c9e01968e7a
|
4
|
+
data.tar.gz: 710aad2c5fa749eb059d3eb33d3832c4a202d792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a183e9f254b0b2b97573cc398c9949fdd850617b4a0eace66c4d36bf7ed51ee0c138528d8854fe83ddb72b63963a84eaf2c23627bd9890c733860a6d23e8a2f
|
7
|
+
data.tar.gz: 7cae3dec5fbc0a6a218ad71b94482a53288a488763a944767f64a0dc69cde1e528a2bdda068ae9262284bd35e039c259b601bba613f82dacc20815ecd1affbe2
|
data/README.md
CHANGED
@@ -63,6 +63,8 @@ validates :iban, iban: { tags: [:sepa] }
|
|
63
63
|
```ruby
|
64
64
|
2.4.1 :001 > IbanBic.like_pattern("ES8700030000300000000000", :country, :bank)
|
65
65
|
=> "ES__0003________________"
|
66
|
+
2.4.1 :002 > IbanBic.like_pattern_from_parts(country: "ES", bank: "0003")
|
67
|
+
=> "ES__0003________________"
|
66
68
|
```
|
67
69
|
|
68
70
|
7. Random IBAN generation
|
@@ -124,6 +126,10 @@ $ bundle exec rails generate iban_bic:install --with-static-data
|
|
124
126
|
4. Customize initializer if needed, adding validations for new countries, or overriding YAML files.
|
125
127
|
|
126
128
|
## Changelog
|
129
|
+
#### 1.2.0
|
130
|
+
|
131
|
+
* Added `like_pattern_from_parts` method. Not a very performant version.
|
132
|
+
* Fixed portuguese IBAN validation.
|
127
133
|
|
128
134
|
#### 1.1.0
|
129
135
|
|
data/lib/iban_bic/core.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "regexp-examples"
|
4
|
+
|
3
5
|
module IbanBic
|
4
6
|
@cached_variables = []
|
5
7
|
|
@@ -98,6 +100,13 @@ module IbanBic
|
|
98
100
|
parts.map { |part, value| keep_parts.include?(part.to_sym) ? value : value.tr("^_", "_") } .join
|
99
101
|
end
|
100
102
|
|
103
|
+
def like_pattern_from_parts(country:, **parts)
|
104
|
+
ia_parts = parts.with_indifferent_access
|
105
|
+
parser[country].to_s.scan(/\(?\<([^\>]+)\>([^\)]*)\)/).map do |part, regex|
|
106
|
+
(part == "country" && country) || ia_parts[part] || Regexp.new(regex).examples.first.tr("^_", "_")
|
107
|
+
end.join
|
108
|
+
end
|
109
|
+
|
101
110
|
def clear_cache
|
102
111
|
@cached_variables.each { |variable| instance_variable_set(variable, nil) }
|
103
112
|
@cached_variables.clear
|
data/lib/iban_bic/random.rb
CHANGED
@@ -6,6 +6,6 @@ IbanBic.configure do
|
|
6
6
|
add "PT" do |parts|
|
7
7
|
nib = "#{parts[:bank]}#{parts[:branch]}#{parts[:account]}"
|
8
8
|
sum = nib.chars.map(&:to_i).zip(IBAN_BIC_PT_WEIGHTS_INDEX).map { |a| a.inject(:*) } .sum
|
9
|
-
parts[:check] = 98 - sum % 97
|
9
|
+
parts[:check] = (98 - sum % 97).to_s.rjust(2, "0")
|
10
10
|
end
|
11
11
|
end
|
data/lib/iban_bic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban_bic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Diez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -67,33 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec-rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.6'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0.50'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0.50'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sqlite3
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|