ibandit 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36930d16f5443cccf34293a0cb6014b8dc33c337
4
- data.tar.gz: e8201ef2d1053ed3293ac3d620e0cd494e1f66a6
3
+ metadata.gz: eb2005426e8eca7ec2cf398a060fe361bb699d82
4
+ data.tar.gz: 9340e8905dbf91ea90e83fb09c2fa14e53ccf35f
5
5
  SHA512:
6
- metadata.gz: 98a90bb5ed4f7b50bf82abed4709bf919d7fad46f7695dc40e317d16c102aef3b097ef928806b0d3393a07e4d2701981727cf2c77b90427b41f485e449d5f437
7
- data.tar.gz: 7c02243b084a98aac05bd911bf527667b47cf98a362795fb6f7214018f563ce8ad3726f623201a34c3e6cd883b697c8531a3c08632b7f505446b908066a55a18
6
+ metadata.gz: 5a4bde497c40a9ca0aad45e89edbaae721fb72e60dcd023fbf1782c4a94308dbe0bb592d2fd846dc88568b2ce65f64f701050e25397efffa990b6386bdd7527c
7
+ data.tar.gz: 6a0ff40c72b3db4ba8a6606994cd172792786d91bd17aca2adf708722e01ff51ce0c66151ac0739a68c8cb17e4bad9898efb9148610a4f68eb685168b830b782
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+
3
+ matrix:
4
+ allow_failures:
5
+ - rvm: jruby
6
+ - rvm: rbx-2
7
+
8
+ rvm:
9
+ - 2.0
10
+ - 2.1
11
+ - 2.2
12
+ - jruby
13
+ - rbx-2
14
+
15
+ script:
16
+ - bundle exec rubocop
17
+ - bundle exec rspec spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.1 - January 8, 2014
2
+
3
+ - Add zero-padding to CheckDigit.spanish
4
+
1
5
  ## 0.1.0 - December 29, 2014
2
6
 
3
7
  - Initial public release
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Ibandit
1
+ Ibandit [![Build Status](https://travis-ci.org/gocardless/ibandit.svg?branch=master)](https://travis-ci.org/gocardless/ibandit)
2
+ =======
2
3
 
3
4
  Ibandit is a Ruby library for manipulating and validating
4
5
  [IBANs](http://en.wikipedia.org/wiki/International_Bank_Account_Number). It
@@ -301,3 +302,11 @@ iban.iban # => "SM88X0542811101000000123456"
301
302
  ```
302
303
 
303
304
  Support for Greece and Malta is coming soon.
305
+
306
+ ## Other libraries
307
+
308
+ Another gem, [iban-tools](https://github.com/alphasights/iban-tools), also
309
+ exists and is an excellent choice if you only require basic IBAN validation.
310
+ We built Ibandit because iban-tools doesn't provide a comprehensive, consistent
311
+ interface for the construction and deconstruction of IBANs into national
312
+ details.
@@ -54,9 +54,9 @@ end
54
54
 
55
55
  def convert_swift_convention(swift_string)
56
56
  swift_string.gsub(/(\d+)!([nac])/, '\2{\1}').
57
- gsub('n', '\d').
58
- gsub('a', '[A-Z]').
59
- gsub('c', '[A-Z0-9]')
57
+ tr('n', '\d').
58
+ tr('a', '[A-Z]').
59
+ tr('c', '[A-Z0-9]')
60
60
  end
61
61
 
62
62
  def merge_structures(structures, additions)
@@ -20,7 +20,8 @@ module Ibandit
20
20
  # digits are used in the 1st and 2nd digits of local Spanish
21
21
  # account numbers.
22
22
  def self.spanish(string)
23
- scaled_values = string.chars.map.with_index do |digit, index|
23
+ padded_string = string.rjust(10, '0')
24
+ scaled_values = padded_string.chars.map.with_index do |digit, index|
24
25
  unless digit.to_i.to_s == digit
25
26
  raise InvalidCharacterError,
26
27
  "Unexpected non-numeric character '#{digit}'"
@@ -65,7 +65,7 @@ module Ibandit
65
65
  # numbers and the IBAN structure file includes them in its definition of
66
66
  # the account number. As a result, this method ignores all arguments
67
67
  # other than the account number.
68
- opts[:account_number].gsub('-', '')
68
+ opts[:account_number].tr('-', '')
69
69
  end
70
70
 
71
71
  def self.build_cy_bban(opts)
@@ -192,7 +192,7 @@ module Ibandit
192
192
  opts[:account_number]
193
193
  ].join
194
194
  else
195
- opts[:account_number].gsub('-', '')
195
+ opts[:account_number].tr('-', '')
196
196
  end
197
197
  end
198
198
 
@@ -477,7 +477,7 @@ module Ibandit
477
477
  else
478
478
  [
479
479
  opts[:bank_code],
480
- opts[:account_number].gsub('-', '').rjust(16, '0')
480
+ opts[:account_number].tr('-', '').rjust(16, '0')
481
481
  ].join
482
482
  end
483
483
  end
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -29,6 +29,14 @@ describe Ibandit::CheckDigit do
29
29
  expect { subject }.to raise_error(Ibandit::InvalidCharacterError)
30
30
  end
31
31
  end
32
+
33
+ context 'with a string that is fewer than 10 characters' do
34
+ let(:account_number) { '20386010' }
35
+
36
+ it 'zero-pads the string to get the correct check digit' do
37
+ expect(subject).to eq('5')
38
+ end
39
+ end
32
40
  end
33
41
 
34
42
  describe '.lund' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-29 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -92,13 +92,13 @@ files:
92
92
  - .gitignore
93
93
  - .rubocop.yml
94
94
  - .rubocop_todo.yml
95
+ - .travis.yml
95
96
  - CHANGELOG.md
96
97
  - Gemfile
97
98
  - LICENSE
98
99
  - README.md
99
100
  - TODO.md
100
101
  - bin/build_structure_file.rb
101
- - circle.yml
102
102
  - data/IBANSTRUCTURE.xml
103
103
  - data/IBAN_Registry.txt
104
104
  - data/structure_additions.yml
data/circle.yml DELETED
@@ -1,19 +0,0 @@
1
- machine:
2
- ruby:
3
- version: 2.0.0-p353
4
-
5
- test:
6
- pre:
7
- - bundle exec rubocop:
8
- parallel: true
9
- files:
10
- - config.ru
11
- - Rakefile
12
- - app/**/*.rb
13
- - lib/**/*.rb
14
- - spec/**/*.rb
15
- override:
16
- - bundle exec rspec:
17
- parallel: true
18
- files:
19
- - spec/**/*_spec.rb