banktools-se 2.6.3 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6df052c5e1e856bc395b39e9e9355817f5a0bcdb
4
- data.tar.gz: 82f54243c1e5ed41b80c4689d3c6e0cd7656aa21
3
+ metadata.gz: 38e5cf121c7e7407651ad63a42019ea082955b08
4
+ data.tar.gz: ce68adf193356960407508086df268b5dbc1e270
5
5
  SHA512:
6
- metadata.gz: 4cc99d6b3c4e554c68401414da3e8b679f552603654d42c4667e0a723ce730785f4b0c3ee7a0652e7bc30b610bec98681459df40f4cd5dc0548458cee03ce6dc
7
- data.tar.gz: 49557f51445e632e2f6ac97717d1a13c98696fcae3a865cf2a62a4918d3733fdbca7948642984b0e7102e1d8717a3f16dd529505ac6bcacefb3dcdf473ebe374
6
+ metadata.gz: f6bdae6a9abf7e6dd2ea17ffacfee12752374e5ae83f58310bfac8c4a78125b849a9daa13f862e5623ce914da28601f84378de3f0bc2bb7cea0ca7187aea9bf2
7
+ data.tar.gz: 902b07121e7aaad2450f9171092b4356ba5d283f9622c24ed34678b352c20daceca0b111d26ec69ba5767c0d5ac52b3fa4889b424c79632629c62d33c06f6355
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 3.0.0
4
+
5
+ - Change `BankTools::SE::OCR.find_all_in_string` default `max_length` from 19 to 18 to avoid out of range errors with Active Record.
6
+
7
+ ## 2.6.3 and earlier
8
+
9
+ - Please see commit history.
@@ -117,9 +117,9 @@ Possible improvements to make:
117
117
 
118
118
  ## Also see
119
119
 
120
- * [BankTools::DE (German)](https://github.com/barsoom/banktools-de)
121
- * [iban-tools](https://github.com/iulianu/iban-tools)
122
120
  * [Bankgirocentral documentation](https://www.bankgirot.se/kundservice/handbocker/)
121
+ * [Our other BankTools](https://github.com/barsoom?q=banktools)
122
+ * [iban-tools](https://github.com/iulianu/iban-tools)
123
123
 
124
124
 
125
125
  ## Credits and license
@@ -64,8 +64,8 @@ module BankTools
64
64
  ocr[0...-digits_to_chop]
65
65
  end
66
66
 
67
- # max_length is 19 because that's the longest allowed integer by default in a Postgres integer column with Ruby on Rails. So attempting some queries with longer OCRs may cause exceptions.
68
- def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 19)
67
+ # max_length is 18, because the biggest allowed integer by default in a Postgres integer column ("bigint") is 19 digits long, as is the next (disallowed) number. Attempting some queries with longer OCRs may cause Ruby on Rails exceptions.
68
+ def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 18)
69
69
  # First, treat the input as one long string of digits.
70
70
  # E.g. "1234 and 5678" becomes "12345678".
71
71
 
@@ -88,7 +88,7 @@ module BankTools
88
88
 
89
89
  # Get rid of any duplicates.
90
90
 
91
- candidates.uniq!
91
+ candidates = candidates.uniq
92
92
 
93
93
  # Finally, limit these substrings to ones that are actually valid OCRs.
94
94
 
@@ -1,5 +1,5 @@
1
1
  module BankTools
2
2
  module SE
3
- VERSION = "2.6.3"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
@@ -121,15 +121,17 @@ describe BankTools::SE::OCR do
121
121
  end
122
122
 
123
123
  it "lets you configure the accepted OCR max_length" do
124
- ocr_length_19 = "1234567890123456785"
125
- ocr_length_20 = "12345678901234567894"
126
- string = "#{ocr_length_19} #{ocr_length_20}"
124
+ # Add a check digit to the input.
125
+ ocr_length_18 = BankTools::SE::OCR.from_number("12345678901234567")
126
+ ocr_length_19 = BankTools::SE::OCR.from_number("123456789012345678")
127
127
 
128
- # Default max_length is 19.
129
- expect(BankTools::SE::OCR.find_all_in_string(string)).to include ocr_length_19
130
- expect(BankTools::SE::OCR.find_all_in_string(string)).not_to include ocr_length_20
128
+ string = "#{ocr_length_18} #{ocr_length_19}"
131
129
 
132
- expect(BankTools::SE::OCR.find_all_in_string(string, max_length: 20)).to include ocr_length_19, ocr_length_20
130
+ # Default max_length is 18.
131
+ expect(BankTools::SE::OCR.find_all_in_string(string)).to include ocr_length_18
132
+ expect(BankTools::SE::OCR.find_all_in_string(string)).not_to include ocr_length_19
133
+
134
+ expect(BankTools::SE::OCR.find_all_in_string(string, max_length: 19)).to include ocr_length_18, ocr_length_19
133
135
  end
134
136
 
135
137
  it "excludes duplicates" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banktools-se
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-30 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".travis.yml"
78
+ - CHANGELOG.md
78
79
  - Gemfile
79
80
  - README.markdown
80
81
  - Rakefile
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  version: '0'
114
115
  requirements: []
115
116
  rubyforge_project: banktools-se
116
- rubygems_version: 2.5.1
117
+ rubygems_version: 2.6.11
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Validate and normalize Swedish bank account numbers, plusgiro and bankgiro.