banktools-se 2.4.0 → 2.5.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: 2e925fd3ed8cc9466d3349621bbd04324592ef67
4
- data.tar.gz: 10ae31638c8fb1951f00c9faec6c5d2a14b9ddd3
3
+ metadata.gz: 3d35e823a3680d5f4f656ab0849199916b481110
4
+ data.tar.gz: 558d9b9047b302a807e28171fc515274c2461263
5
5
  SHA512:
6
- metadata.gz: f765f7fca94f5590d5b4a123bb020d4ebf3b42d46d5f6e20343544faab6ae80df0dfcbcb17c0dc93a2ea0533391ec00a91b756d58d9fd05c3fecea63aca86a3a
7
- data.tar.gz: d19a541703158bf3671ab61f6d44f1af364d23d44c907c96f4d2b14fd15c203af7f63df8b59129d63a2b3dd9d1af771f276f44ecf8924bfe50c942a8708a8165
6
+ metadata.gz: af1599d7f2669a938268f304b4d104202b19aba78db344ef6affcfabca4c30c25895efe47c764111453b8a10b1cdc99778c5be87e57c63009dd689fb74dff44f
7
+ data.tar.gz: e5eda874826d7e49d22cbf46e1102d45eb0cc451021e4d6f3e401d6027c3c7e99e5f394226d83ba305ad6243cf03f3c8b25fb81b4c139f4264bff812339fd145
@@ -66,7 +66,7 @@ module BankTools
66
66
 
67
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
68
  def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 19)
69
- expanded_string = string + " " + string.gsub("\n", "") + " " + string.gsub(";", "")
69
+ expanded_string = [ string, *[ "\n", ";", "." ].map { |x| string.gsub(x, "") } ].join(" ")
70
70
 
71
71
  numbers = expanded_string.scan(/\d+/)
72
72
 
@@ -1,5 +1,5 @@
1
1
  module BankTools
2
2
  module SE
3
- VERSION = "2.4.0"
3
+ VERSION = "2.5.0"
4
4
  end
5
5
  end
data/spec/ocr_spec.rb CHANGED
@@ -97,6 +97,11 @@ describe BankTools::SE::OCR do
97
97
  expect(BankTools::SE::OCR.find_all_in_string("45;64")).to eq [ "4564" ]
98
98
  end
99
99
 
100
+ it "handles OCR numbers both separated and split by '.'" do
101
+ expect(BankTools::SE::OCR.find_all_in_string("1230.4564")).to include "1230", "4564", "12304564"
102
+ expect(BankTools::SE::OCR.find_all_in_string("45.64")).to eq [ "4564" ]
103
+ end
104
+
100
105
  it "handles numbers smushed together" do
101
106
  # "Ref 1: 1230" with characters gone missing.
102
107
  expect(BankTools::SE::OCR.find_all_in_string("REF 11230")).to include "1230"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: banktools-se
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh