bank_account_tools 1.0.0
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +140 -0
- data/Rakefile +6 -0
- data/bank_account_tools.gemspec +23 -0
- data/data/iban.yml +550 -0
- data/lib/bank_account_tools/bban.rb +44 -0
- data/lib/bank_account_tools/bic.rb +67 -0
- data/lib/bank_account_tools/contact.rb +33 -0
- data/lib/bank_account_tools/iban.rb +47 -0
- data/lib/bank_account_tools/matchers/active_model/have_valid_bic.rb +9 -0
- data/lib/bank_account_tools/matchers/active_model/have_valid_iban.rb +9 -0
- data/lib/bank_account_tools/matchers/rspec.rb +2 -0
- data/lib/bank_account_tools/validators/bic_validator.rb +7 -0
- data/lib/bank_account_tools/validators/iban_validator.rb +7 -0
- data/lib/bank_account_tools/version.rb +3 -0
- data/lib/bank_account_tools.rb +19 -0
- data/spec/activemodel_spec.rb +34 -0
- data/spec/bic_spec.rb +47 -0
- data/spec/contact_spec.rb +27 -0
- data/spec/iban_spec.rb +160 -0
- data/spec/spec_helper.rb +4 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 363262bef106d232634f2d4d64891dc2c46cecf8
|
4
|
+
data.tar.gz: 5a9cfafc4a65c69ab002152113c5dd5d44762358
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d89926b830a14c81a39dfcd7565fb9fa013a3c592fed7749fca6e750bd241dc320ad354127b66f151fa2570d266fa675b29714ba9d91e011a7658d9e024c36f
|
7
|
+
data.tar.gz: 9ba8a4d21fd781383601f2af45d08dc0628f3639e8ee5d504b94189b29549bb8a93fd197534dfc43467cba3d36529543a6c9ac16f267279bdde11974d3e4cc7d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Dimitar Kostov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# BankAccountTools
|
2
|
+
|
3
|
+
IBAN & BIC information, validation and formatting. Ships with ActiveModel validators.
|
4
|
+
|
5
|
+
Fork of [https://github.com/max-power/bank](max-power/bank) with rspec and custom matchers
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'bank_account_tools'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
### BankAccountTools::IBAN
|
20
|
+
|
21
|
+
#### General usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'bank_account_tools/iban'
|
25
|
+
|
26
|
+
iban = BankAccountTools::IBAN.new('DE89 3704 0044 0532 0130 00')
|
27
|
+
|
28
|
+
iban.country_code # 'DE'
|
29
|
+
iban.check_digits # '89'
|
30
|
+
iban.bban # <BankAccountTools::BBAN...>
|
31
|
+
iban.bban.to_s # '370400440532013000'
|
32
|
+
iban.account_number # '0532013000'
|
33
|
+
iban.bank_identifier # '37040044'
|
34
|
+
|
35
|
+
iban.valid? # true
|
36
|
+
|
37
|
+
iban.to_s # 'DE89370400440532013000'
|
38
|
+
iban.to_s(true) # 'DE89 3704 0044 0532 0130 00'
|
39
|
+
|
40
|
+
iban.to_i # 370400440532013000131489
|
41
|
+
|
42
|
+
# or
|
43
|
+
|
44
|
+
BankAccountTools::IBAN.valid? 'DE89 3704 0044 0532 0130 00' # true
|
45
|
+
```
|
46
|
+
|
47
|
+
#### ActiveModel Validator
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class BankAccount
|
51
|
+
include ActiveModel::Model
|
52
|
+
|
53
|
+
validates :iban, iban: true
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
#### RSpec matcher
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
describe BankAccount do
|
61
|
+
it { should validae_iban(:iban) }
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
---
|
66
|
+
|
67
|
+
### BankAccountTools::BIC
|
68
|
+
|
69
|
+
#### General usage
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require 'bank_account_tools/bic'
|
73
|
+
|
74
|
+
bic = BankAccountTools::BIC.new('BYLADEM1203')
|
75
|
+
bic.bank_code # "BYLA"
|
76
|
+
bic.country_code # "DE"
|
77
|
+
bic.location_code # "M1"
|
78
|
+
bic.branch_code # "203"
|
79
|
+
bic.to_s # "BYLADEM1203"
|
80
|
+
bic.to_s(true) # "BYLA DE M1 203"
|
81
|
+
bic.valid? # true
|
82
|
+
|
83
|
+
# or
|
84
|
+
|
85
|
+
BankAccountTools::IBAN.valid? 'DE89 3704 0044 0532 0130 00' # true
|
86
|
+
```
|
87
|
+
|
88
|
+
#### ActiveModel Validator
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
class BankAccount
|
92
|
+
include ActiveModel::Model
|
93
|
+
|
94
|
+
validates :bic, bic: true
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
#### RSpec matcher
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
describe BankAccount do
|
102
|
+
it { should validae_bic(:bic) }
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
### BankAccountTools::Contact
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
require 'bank_account_tools/contact' # this requires 'iban' and 'bic'
|
110
|
+
|
111
|
+
# paramters: IBAN, BIC
|
112
|
+
contact = BankAccountTools::Contact.new('DE89 3704 0044 0532 0130 00', 'BYLADEM1203')
|
113
|
+
contact.iban # <BankAccountTools::IBAN...>
|
114
|
+
contact.bic # <BankAccountTools::BIC...>
|
115
|
+
contact.to_h # {:iban=>"DE89370400440532013000", :bic=>"BYLADEM1203"}
|
116
|
+
contact.to_a # ["DE89370400440532013000", "BYLADEM1203"]
|
117
|
+
contact.valid? # true
|
118
|
+
```
|
119
|
+
|
120
|
+
## Testing
|
121
|
+
|
122
|
+
The default rake task will run the rspec suite
|
123
|
+
|
124
|
+
```sh
|
125
|
+
$ rake
|
126
|
+
```
|
127
|
+
|
128
|
+
## Contributing
|
129
|
+
|
130
|
+
1. Fork it ( http://github.com/mytrile/bank_account_tools/fork )
|
131
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
132
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
133
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
134
|
+
5. Create new Pull Request
|
135
|
+
|
136
|
+
## Credits
|
137
|
+
|
138
|
+
Enhanced and maintained by [Dimitar Kostov](https://github.com/mytrile) [mitko.kostov@gmail.com](mailto:mitko.kostov@gmail.com)
|
139
|
+
|
140
|
+
Many thanks to original - [https://github.com/max-power/bank](max-power/bank)
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bank_account_tools/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'bank_account_tools'
|
7
|
+
spec.version = BankAccountTools::VERSION
|
8
|
+
spec.authors = ['Dimitar Kostov', 'Kevin']
|
9
|
+
spec.email = ['mitko.kostov@gmail.com', 'kevin.melchert@gmail.com']
|
10
|
+
spec.summary = %q{Bank account tools for dealing with IBANs/BICs}
|
11
|
+
spec.description = %q{Bank account tools for dealing with IBANs/BICs: information, validation and formatting.}
|
12
|
+
spec.homepage = 'https://github.com/mytrile/bank_account_tools'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
20
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
21
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
22
|
+
spec.add_development_dependency 'activemodel', '~> 4.0'
|
23
|
+
end
|