ibandit 0.3.4 → 0.3.5

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: 1d395f9c98c2624ae5fb316baa0c29f66f392ec8
4
- data.tar.gz: 6ece4a67e949d1845941a5eaa131fddb0d60d20a
3
+ metadata.gz: 88b94ddf1d92608eb6b2139998ef10a94aed471f
4
+ data.tar.gz: 7ef91de41d5f0e5441c5172cb83c32c28b0b7c4d
5
5
  SHA512:
6
- metadata.gz: f2759545860494377394eabaffb74020c9c96e8b726459c5aaa5ad51ec1bd7cb741dba1e8c230dbece8fe462e33802a2d88e5858533d88a80c877799ec831e1c
7
- data.tar.gz: d70cabba73c7e4e9ad8023a84e26e5f1381caedc7d1d215dc91a70fd98f28a4b6838c23fa586ef76de7eca76a22c903eed24c325737479b485b7eadce95f8a28
6
+ metadata.gz: 0787d58ded4a0b90315183c9a1fca92c89ccb3d3b53c2fb53b696c1b16da54df7fd53bf8dbd562a5e0f879bbe435f065e7413a81e18e0258e48dd404e7eb3aeb
7
+ data.tar.gz: 1ea5256cecbdbbd870c829f5f77e34b9c4b35daa6837d1872720d34084eb6fc3794971954de2488762955c580af80577624262206fc0ccbfa4dbcac3e42f8c1e
@@ -1,3 +1,7 @@
1
+ # 0.3.5 - March 23, 2015
2
+
3
+ - Use I18n for internationalised validation messages (patch by [@isaacseymour](https://github.com/isaacseymour))
4
+
1
5
  ## 0.3.4 - March 6, 2015
2
6
 
3
7
  - Update BLZ data
@@ -0,0 +1,13 @@
1
+ en:
2
+ ibandit:
3
+ invalid_country_code: "'%{country_code}' is not a valid ISO 3166-1 IBAN country code"
4
+ invalid_check_digits: "Check digits failed modulus check. Expected '%{expected_check_digits}', received '%{check_digits}'."
5
+ invalid_length: "Length doesn't match SWIFT specification (expected %{expected_length} characters, received %{length})"
6
+ is_required: "is required"
7
+ wrong_length: "is the wrong length (should be %{expected} characters)"
8
+ not_used_in_country: "is not used in %{country_code}"
9
+ non_alphanumeric_characters: "Non-alphanumeric characters found: %{characters}"
10
+ invalid_format: "Unexpected format for a %{country_code} IBAN."
11
+ is_invalid: "is invalid"
12
+
13
+
@@ -0,0 +1,12 @@
1
+ fr:
2
+ ibandit:
3
+ invalid_country_code: "'%{country_code} n'est pas le code pays ISO 3166-1 de l'IBAN"
4
+ invalid_check_digits: "Les chiffres de vérification ont échoué les tests de modulo. '%{expected_check_digits}' attendu, '%{check_digits}' reçu."
5
+ invalid_length: "La longueur ne correspond pas aux spécifications SWIFT (%{expected_length} caractères attendus, %{length} reçus)"
6
+ is_required: "est requis"
7
+ wrong_length: "n'a pas la bonne longueur (doit avoir %{expected} caractères)"
8
+ not_used_in_country: "n'est pas utilisé en %{country_code}"
9
+ non_alphanumeric_characters: "Caractères non alphanumériques présents : %{characters}"
10
+ invalid_format: "Format inconnu pour l'IBAN %{country_code}."
11
+ is_invalid: "est invalide"
12
+
@@ -7,6 +7,8 @@ Gem::Specification.new do |gem|
7
7
  gem.add_development_dependency 'sax-machine', '~> 1.1'
8
8
  gem.add_development_dependency 'nokogiri', '~> 1.6'
9
9
 
10
+ gem.add_runtime_dependency 'i18n', '~> 0.7.0'
11
+
10
12
  gem.authors = ['Grey Baker']
11
13
  gem.description = 'Ibandit is a Ruby library for manipulating and ' \
12
14
  'validating IBANs. It allows you to construct an IBAN ' \
@@ -1,3 +1,4 @@
1
+ require 'i18n'
1
2
  require 'ibandit/version'
2
3
  require 'ibandit/errors'
3
4
  require 'ibandit/iban'
@@ -7,6 +8,8 @@ require 'ibandit/iban_assembler'
7
8
  require 'ibandit/local_details_cleaner'
8
9
  require 'ibandit/check_digit'
9
10
 
11
+ I18n.load_path += Dir['config/locale/*.yml']
12
+
10
13
  module Ibandit
11
14
  class << self
12
15
  attr_accessor :bic_finder, :modulus_checker
@@ -21,5 +24,9 @@ module Ibandit
21
24
  File.expand_path('../../data/structures.yml', __FILE__)
22
25
  )
23
26
  end
27
+
28
+ def translate(key, options = {})
29
+ I18n.translate(key, { scope: [:ibandit] }.merge(options))
30
+ end
24
31
  end
25
32
  end
@@ -76,8 +76,8 @@ module Ibandit
76
76
  if Ibandit.structures.key?(country_code)
77
77
  true
78
78
  else
79
- @errors[:country_code] = "'#{country_code}' is not a valid " \
80
- 'ISO 3166-1 IBAN country code'
79
+ @errors[:country_code] = Ibandit.translate(:invalid_country_code,
80
+ country_code: country_code)
81
81
  false
82
82
  end
83
83
  end
@@ -89,9 +89,10 @@ module Ibandit
89
89
  if check_digits == expected_check_digits
90
90
  true
91
91
  else
92
- @errors[:check_digits] = 'Check digits failed modulus check. ' \
93
- "Expected '#{expected_check_digits}', " \
94
- "received '#{check_digits}'"
92
+ @errors[:check_digits] =
93
+ Ibandit.translate(:invalid_check_digits,
94
+ expected_check_digits: expected_check_digits,
95
+ check_digits: check_digits)
95
96
  false
96
97
  end
97
98
  end
@@ -102,9 +103,10 @@ module Ibandit
102
103
  if iban.length == structure[:total_length]
103
104
  true
104
105
  else
105
- @errors[:length] = "Length doesn't match SWIFT specification " \
106
- "(expected #{structure[:total_length]} " \
107
- "characters, received #{iban.size})"
106
+ @errors[:length] =
107
+ Ibandit.translate(:invalid_length,
108
+ expected_length: structure[:total_length],
109
+ length: iban.size)
108
110
  false
109
111
  end
110
112
  end
@@ -113,14 +115,14 @@ module Ibandit
113
115
  return unless valid_country_code?
114
116
 
115
117
  if bank_code.nil? || bank_code.length == 0
116
- @errors[:bank_code] = 'is required'
118
+ @errors[:bank_code] = Ibandit.translate(:is_required)
117
119
  return false
118
120
  end
119
121
 
120
122
  return true if bank_code.length == structure[:bank_code_length]
121
123
 
122
- @errors[:bank_code] = 'is the wrong length (should be ' \
123
- "#{structure[:bank_code_length]} characters)"
124
+ @errors[:bank_code] =
125
+ Ibandit.translate(:wrong_length, expected: structure[:bank_code_length])
124
126
  false
125
127
  end
126
128
 
@@ -129,12 +131,14 @@ module Ibandit
129
131
  return true if branch_code.to_s.length == structure[:branch_code_length]
130
132
 
131
133
  if structure[:branch_code_length] == 0
132
- @errors[:branch_code] = "is not used in #{country_code}"
134
+ @errors[:branch_code] = Ibandit.translate(:not_used_in_country,
135
+ country_code: country_code)
133
136
  elsif branch_code.nil? || branch_code.length == 0
134
- @errors[:branch_code] = 'is required'
137
+ @errors[:branch_code] = Ibandit.translate(:is_required)
135
138
  else
136
- @errors[:branch_code] = 'is the wrong length (should be ' \
137
- "#{structure[:branch_code_length]} characters)"
139
+ @errors[:branch_code] =
140
+ Ibandit.translate(:wrong_length,
141
+ expected: structure[:branch_code_length])
138
142
  end
139
143
  false
140
144
  end
@@ -143,23 +147,24 @@ module Ibandit
143
147
  return unless valid_country_code?
144
148
 
145
149
  if account_number.nil?
146
- @errors[:account_number] = 'is required'
150
+ @errors[:account_number] = Ibandit.translate(:is_required)
147
151
  return false
148
152
  end
149
153
 
150
154
  return true if account_number.length == structure[:account_number_length]
151
155
 
152
- @errors[:account_number] = 'is the wrong length (should be ' \
153
- "#{structure[:account_number_length]} " \
154
- 'characters)'
156
+ @errors[:account_number] =
157
+ Ibandit.translate(:wrong_length,
158
+ expected: structure[:account_number_length])
155
159
  false
156
160
  end
157
161
 
158
162
  def valid_characters?
159
163
  return if iban.nil?
160
164
  if iban.scan(/[^A-Z0-9]/).any?
161
- @errors[:characters] = 'Non-alphanumeric characters found: ' \
162
- "#{iban.scan(/[^A-Z\d]/).join(' ')}"
165
+ @errors[:characters] =
166
+ Ibandit.translate(:non_alphanumeric_characters,
167
+ characters: iban.scan(/[^A-Z\d]/).join(' '))
163
168
  false
164
169
  else
165
170
  true
@@ -172,7 +177,8 @@ module Ibandit
172
177
  if bban =~ Regexp.new(structure[:bban_format])
173
178
  true
174
179
  else
175
- @errors[:format] = "Unexpected format for a #{country_code} IBAN."
180
+ @errors[:format] = Ibandit.translate(:invalid_format,
181
+ country_code: country_code)
176
182
  false
177
183
  end
178
184
  end
@@ -183,7 +189,7 @@ module Ibandit
183
189
  if bank_code =~ Regexp.new(structure[:bank_code_format])
184
190
  true
185
191
  else
186
- @errors[:bank_code] = 'is invalid'
192
+ @errors[:bank_code] = Ibandit.translate(:is_invalid)
187
193
  false
188
194
  end
189
195
  end
@@ -195,7 +201,7 @@ module Ibandit
195
201
  if branch_code =~ Regexp.new(structure[:branch_code_format])
196
202
  true
197
203
  else
198
- @errors[:branch_code] = 'is invalid'
204
+ @errors[:branch_code] = Ibandit.translate(:is_invalid)
199
205
  false
200
206
  end
201
207
  end
@@ -206,7 +212,7 @@ module Ibandit
206
212
  if account_number =~ Regexp.new(structure[:account_number_format])
207
213
  true
208
214
  else
209
- @errors[:account_number] = 'is invalid'
215
+ @errors[:account_number] = Ibandit.translate(:is_invalid)
210
216
  false
211
217
  end
212
218
  end
@@ -266,14 +272,14 @@ module Ibandit
266
272
  def valid_modulus_check_bank_code?
267
273
  return true if Ibandit.modulus_checker.valid_bank_code?(iban.to_s)
268
274
 
269
- @errors[modulus_check_bank_code_field] = 'is invalid'
275
+ @errors[modulus_check_bank_code_field] = Ibandit.translate(:is_invalid)
270
276
  false
271
277
  end
272
278
 
273
279
  def valid_modulus_check_account_number?
274
280
  return true if Ibandit.modulus_checker.valid_account_number?(iban.to_s)
275
281
 
276
- @errors[:account_number] = 'is invalid'
282
+ @errors[:account_number] = Ibandit.translate(:is_invalid)
277
283
  false
278
284
  end
279
285
 
@@ -1,3 +1,3 @@
1
1
  module Ibandit
2
- VERSION = '0.3.4'.freeze
2
+ VERSION = '0.3.5'.freeze
3
3
  end
@@ -111,12 +111,17 @@ describe Ibandit::IBAN do
111
111
  end
112
112
 
113
113
  context 'with an unknown country code' do
114
+ before { iban.valid_country_code? }
114
115
  let(:iban_code) { 'AA123456789123456' }
115
116
  it { is_expected.to eq(false) }
116
117
 
117
- it 'sets errors on the IBAN' do
118
- iban.valid_country_code?
119
- expect(iban.errors).to include(:country_code)
118
+ context 'locale en', locale: :en do
119
+ it 'sets errors on the IBAN' do
120
+ iban.valid_country_code?
121
+ expect(iban.errors).
122
+ to include(country_code: "'AA' is not a valid ISO 3166-1 IBAN " \
123
+ 'country code')
124
+ end
120
125
  end
121
126
  end
122
127
  end
@@ -138,9 +143,23 @@ describe Ibandit::IBAN do
138
143
  let(:iban_code) { 'GB12WEST12345698765432' }
139
144
  it { is_expected.to eq(false) }
140
145
 
141
- it 'sets errors on the IBAN' do
142
- iban.valid_check_digits?
143
- expect(iban.errors).to include(:check_digits)
146
+ context 'locale en', locale: :en do
147
+ it 'sets errors on the IBAN' do
148
+ iban.valid_check_digits?
149
+ expect(iban.errors).
150
+ to include(check_digits: 'Check digits failed modulus check. ' \
151
+ "Expected '82', received '12'.")
152
+ end
153
+ end
154
+
155
+ context 'locale fr', locale: :fr do
156
+ it 'sets errors on the IBAN' do
157
+ iban.valid_check_digits?
158
+ expect(iban.errors).
159
+ to include(check_digits: 'Les chiffres de vérification ont ' \
160
+ "échoué les tests de modulo. '82' " \
161
+ "attendu, '12' reçu.")
162
+ end
144
163
  end
145
164
  end
146
165
 
@@ -176,9 +195,23 @@ describe Ibandit::IBAN do
176
195
  let(:iban_code) { 'GB82WEST123456987654' }
177
196
  it { is_expected.to eq(false) }
178
197
 
179
- it 'sets errors on the IBAN' do
180
- iban.valid_length?
181
- expect(iban.errors).to include(:length)
198
+ context 'locale en', locale: :en do
199
+ it 'sets errors on the IBAN' do
200
+ iban.valid_length?
201
+ expect(iban.errors).
202
+ to include(length: "Length doesn't match SWIFT specification " \
203
+ '(expected 22 characters, received 20)')
204
+ end
205
+ end
206
+
207
+ context 'locale fr', locale: :fr do
208
+ it 'sets errors on the IBAN' do
209
+ iban.valid_length?
210
+ expect(iban.errors).
211
+ to include(length: 'La longueur ne correspond pas aux ' \
212
+ 'spécifications SWIFT (22 caractères ' \
213
+ 'attendus, 20 reçus)')
214
+ end
182
215
  end
183
216
  end
184
217
 
@@ -204,9 +237,22 @@ describe Ibandit::IBAN do
204
237
  before { allow(iban).to receive(:bank_code).and_return('WES') }
205
238
  it { is_expected.to eq(false) }
206
239
 
207
- it 'sets errors on the IBAN' do
208
- iban.valid_bank_code_length?
209
- expect(iban.errors).to include(:bank_code)
240
+ context 'locale en', locale: :en do
241
+ it 'sets errors on the IBAN' do
242
+ iban.valid_bank_code_length?
243
+ expect(iban.errors).
244
+ to include(bank_code: 'is the wrong length (should be 4 ' \
245
+ 'characters)')
246
+ end
247
+ end
248
+
249
+ context 'locale fr', locale: :fr do
250
+ it 'sets errors on the IBAN' do
251
+ iban.valid_bank_code_length?
252
+ expect(iban.errors).
253
+ to include(bank_code: "n'a pas la bonne longueur (doit avoir 4 " \
254
+ 'caractères)')
255
+ end
210
256
  end
211
257
  end
212
258
 
@@ -232,9 +278,22 @@ describe Ibandit::IBAN do
232
278
  before { allow(iban).to receive(:branch_code).and_return('12345') }
233
279
  it { is_expected.to eq(false) }
234
280
 
235
- it 'sets errors on the IBAN' do
236
- iban.valid_branch_code_length?
237
- expect(iban.errors).to include(:branch_code)
281
+ context 'locale en', locale: :en do
282
+ it 'sets errors on the IBAN' do
283
+ iban.valid_branch_code_length?
284
+ expect(iban.errors).
285
+ to include(branch_code: 'is the wrong length (should be 6 ' \
286
+ 'characters)')
287
+ end
288
+ end
289
+
290
+ context 'locale fr', locale: :fr do
291
+ it 'sets errors on the IBAN' do
292
+ iban.valid_branch_code_length?
293
+ expect(iban.errors).
294
+ to include(branch_code: "n'a pas la bonne longueur (doit avoir 6 " \
295
+ 'caractères)')
296
+ end
238
297
  end
239
298
  end
240
299
 
@@ -242,9 +301,18 @@ describe Ibandit::IBAN do
242
301
  before { allow(iban).to receive(:branch_code).and_return(nil) }
243
302
  it { is_expected.to eq(false) }
244
303
 
245
- it 'sets errors on the IBAN' do
246
- iban.valid_branch_code_length?
247
- expect(iban.errors).to include(:branch_code)
304
+ context 'locale en', locale: :en do
305
+ it 'sets errors on the IBAN' do
306
+ iban.valid_branch_code_length?
307
+ expect(iban.errors).to include(branch_code: 'is required')
308
+ end
309
+ end
310
+
311
+ context 'locale fr', locale: :fr do
312
+ it 'sets errors on the IBAN' do
313
+ iban.valid_branch_code_length?
314
+ expect(iban.errors).to include(branch_code: 'est requis')
315
+ end
248
316
  end
249
317
  end
250
318
 
@@ -270,9 +338,22 @@ describe Ibandit::IBAN do
270
338
  before { allow(iban).to receive(:account_number).and_return('1234567') }
271
339
  it { is_expected.to eq(false) }
272
340
 
273
- it 'sets errors on the IBAN' do
274
- iban.valid_account_number_length?
275
- expect(iban.errors).to include(:account_number)
341
+ context 'locale en', locale: :en do
342
+ it 'sets errors on the IBAN' do
343
+ iban.valid_account_number_length?
344
+ expect(iban.errors).
345
+ to include(account_number: 'is the wrong length (should be 8 ' \
346
+ 'characters)')
347
+ end
348
+ end
349
+
350
+ context 'locale fr', locale: :fr do
351
+ it 'sets errors on the IBAN' do
352
+ iban.valid_account_number_length?
353
+ expect(iban.errors).
354
+ to include(account_number: "n'a pas la bonne longueur (doit " \
355
+ 'avoir 8 caractères)')
356
+ end
276
357
  end
277
358
  end
278
359
 
@@ -299,9 +380,21 @@ describe Ibandit::IBAN do
299
380
  let(:iban_code) { 'GB-123ABCD' }
300
381
  it { is_expected.to eq(false) }
301
382
 
302
- it 'sets errors on the IBAN' do
303
- iban.valid_characters?
304
- expect(iban.errors).to include(:characters)
383
+ context 'locale en', locale: :en do
384
+ it 'sets errors on the IBAN' do
385
+ iban.valid_characters?
386
+ expect(iban.errors).
387
+ to include(characters: 'Non-alphanumeric characters found: -')
388
+ end
389
+ end
390
+
391
+ context 'locale fr', locale: :fr do
392
+ it 'sets errors on the IBAN' do
393
+ iban.valid_characters?
394
+ expect(iban.errors).
395
+ to include(characters: 'Caractères non alphanumériques présents ' \
396
+ ': -')
397
+ end
305
398
  end
306
399
  end
307
400
  end
@@ -318,9 +411,20 @@ describe Ibandit::IBAN do
318
411
  let(:iban_code) { 'GB82WEST12AAAAAA7654' }
319
412
  it { is_expected.to eq(false) }
320
413
 
321
- it 'sets errors on the IBAN' do
322
- iban.valid_format?
323
- expect(iban.errors).to include(:format)
414
+ context 'locale en', locale: :en do
415
+ it 'sets errors on the IBAN' do
416
+ iban.valid_format?
417
+ expect(iban.errors).
418
+ to include(format: 'Unexpected format for a GB IBAN.')
419
+ end
420
+ end
421
+
422
+ context 'locale fr', locale: :fr do
423
+ it 'sets errors on the IBAN' do
424
+ iban.valid_format?
425
+ expect(iban.errors).
426
+ to include(format: "Format inconnu pour l'IBAN GB.")
427
+ end
324
428
  end
325
429
  end
326
430
 
@@ -350,9 +454,18 @@ describe Ibandit::IBAN do
350
454
 
351
455
  it { is_expected.to eq(false) }
352
456
 
353
- it 'sets errors on the IBAN' do
354
- iban.valid_bank_code_format?
355
- expect(iban.errors).to include(:bank_code)
457
+ context 'locale en', locale: :en do
458
+ it 'sets errors on the IBAN' do
459
+ iban.valid_bank_code_format?
460
+ expect(iban.errors).to include(bank_code: 'is invalid')
461
+ end
462
+ end
463
+
464
+ context 'locale fr', locale: :fr do
465
+ it 'sets errors on the IBAN' do
466
+ iban.valid_bank_code_format?
467
+ expect(iban.errors).to include(bank_code: 'est invalide')
468
+ end
356
469
  end
357
470
  end
358
471
 
@@ -391,9 +504,18 @@ describe Ibandit::IBAN do
391
504
 
392
505
  it { is_expected.to eq(false) }
393
506
 
394
- it 'sets errors on the IBAN' do
395
- iban.valid_branch_code_format?
396
- expect(iban.errors).to include(:branch_code)
507
+ context 'locale en', locale: :en do
508
+ it 'sets errors on the IBAN' do
509
+ iban.valid_branch_code_format?
510
+ expect(iban.errors).to include(branch_code: 'is invalid')
511
+ end
512
+ end
513
+
514
+ context 'locale fr', locale: :fr do
515
+ it 'sets errors on the IBAN' do
516
+ iban.valid_branch_code_format?
517
+ expect(iban.errors).to include(branch_code: 'est invalide')
518
+ end
397
519
  end
398
520
  end
399
521
 
@@ -431,9 +553,18 @@ describe Ibandit::IBAN do
431
553
 
432
554
  it { is_expected.to eq(false) }
433
555
 
434
- it 'sets errors on the IBAN' do
435
- iban.valid_account_number_format?
436
- expect(iban.errors).to include(:account_number)
556
+ context 'locale en', locale: :en do
557
+ it 'sets errors on the IBAN' do
558
+ iban.valid_account_number_format?
559
+ expect(iban.errors).to include(account_number: 'is invalid')
560
+ end
561
+ end
562
+
563
+ context 'locale fr', locale: :fr do
564
+ it 'sets errors on the IBAN' do
565
+ iban.valid_account_number_format?
566
+ expect(iban.errors).to include(account_number: 'est invalide')
567
+ end
437
568
  end
438
569
  end
439
570
 
@@ -478,7 +609,13 @@ describe Ibandit::IBAN do
478
609
  let(:valid_account_number) { true }
479
610
 
480
611
  it { is_expected.to be(false) }
481
- specify { expect(iban.errors).to include(bank_code: 'is invalid') }
612
+ context 'locale en', locale: :en do
613
+ specify { expect(iban.errors).to include(bank_code: 'is invalid') }
614
+ end
615
+
616
+ context 'locale fr', locale: :fr do
617
+ specify { expect(iban.errors).to include(bank_code: 'est invalide') }
618
+ end
482
619
 
483
620
  context 'when the bank code is not required' do
484
621
  let(:iban_code) { 'GB60BARC20000055779911' }
@@ -487,7 +624,17 @@ describe Ibandit::IBAN do
487
624
  before { iban.valid_local_modulus_check? }
488
625
 
489
626
  it { is_expected.to be(false) }
490
- specify { expect(iban.errors).to include(branch_code: 'is invalid') }
627
+ context 'locale en', locale: :en do
628
+ specify do
629
+ expect(iban.errors).to include(branch_code: 'is invalid')
630
+ end
631
+ end
632
+
633
+ context 'locale fr', locale: :fr do
634
+ specify do
635
+ expect(iban.errors).to include(branch_code: 'est invalide')
636
+ end
637
+ end
491
638
  end
492
639
  end
493
640
 
@@ -496,7 +643,17 @@ describe Ibandit::IBAN do
496
643
  let(:valid_account_number) { false }
497
644
 
498
645
  it { is_expected.to be(false) }
499
- specify { expect(iban.errors).to include(account_number: 'is invalid') }
646
+ context 'locale en', locale: :en do
647
+ specify do
648
+ expect(iban.errors).to include(account_number: 'is invalid')
649
+ end
650
+ end
651
+
652
+ context 'locale fr', locale: :fr do
653
+ specify do
654
+ expect(iban.errors).to include(account_number: 'est invalide')
655
+ end
656
+ end
500
657
  end
501
658
  end
502
659
  end
@@ -10,3 +10,11 @@ end
10
10
  def json_fixture(filename)
11
11
  JSON.parse(File.read("spec/fixtures/#{filename}.json"))
12
12
  end
13
+
14
+ RSpec.shared_context 'locale en', locale: :en do
15
+ around { |example| I18n.with_locale(:en) { example.run } }
16
+ end
17
+
18
+ RSpec.shared_context 'locale fr', locale: :fr do
19
+ around { |example| I18n.with_locale(:fr) { example.run } }
20
+ end
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.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.7.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.7.0
83
97
  description: Ibandit is a Ruby library for manipulating and validating IBANs. It allows
84
98
  you to construct an IBAN from national banking details; deconstruct an IBAN into
85
99
  national banking details; and validate an IBAN's check digits and format.
@@ -100,6 +114,8 @@ files:
100
114
  - TODO.md
101
115
  - bin/build_german_iban_rules.rb
102
116
  - bin/build_structure_file.rb
117
+ - config/locale/en.yml
118
+ - config/locale/fr.yml
103
119
  - data/german_iban_rules.yml
104
120
  - data/raw/BLZ2.txt
105
121
  - data/raw/IBANSTRUCTURE.xml