bsb 1.4.5 → 1.4.7

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.
@@ -7,7 +7,7 @@ module BSB
7
7
  class BankListGenerator < BaseGenerator
8
8
  def self.load_file(filename)
9
9
  hash = {}
10
- CSV.foreach(filename) do |row|
10
+ CSV.foreach(filename, headers: true) do |row|
11
11
  row[2].split(', ').each do |prefix|
12
12
  prefix = prefix.chomp.rjust(2, '0')
13
13
  hash[prefix] = row[1]
data/lib/bsb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BSB
4
- VERSION = '1.4.5'
4
+ VERSION = '1.4.7'
5
5
  end
@@ -4,6 +4,9 @@ require 'bsb'
4
4
  require 'bsb/database_generator'
5
5
  require 'bsb/bank_list_generator'
6
6
 
7
+ require 'fileutils'
8
+ require 'faraday/follow_redirects'
9
+
7
10
  namespace :bsb do
8
11
  desc 'Sync config/*.json.'
9
12
  task :sync_bsb_db_manual, [:bsbfile] do |_t, args|
@@ -17,6 +20,7 @@ namespace :bsb do
17
20
  end
18
21
  end
19
22
 
23
+ desc 'Sync bank list from a keyfile'
20
24
  task :sync_bank_list, [:keyfile] do |_t, args|
21
25
  bank_list_filename = args[:keyfile]
22
26
 
@@ -27,4 +31,29 @@ namespace :bsb do
27
31
  warn 'Missing bank list "KEY TO ABBREVIATIONS AND BSB NUMBERS"'
28
32
  end
29
33
  end
34
+
35
+ desc 'Fetch the BSB CSV from AusPayNet (default output: tmp/key.csv)'
36
+ task :fetch_key_file, [:output_path] do |_t, args|
37
+ args.with_defaults(output_path: 'tmp/key.csv')
38
+
39
+ url = 'https://bsb.auspaynet.com.au/Public/BSB_DB.NSF/getKeytoACSV?OpenAgent'
40
+ user_agent = 'CoinJarBSBUpdater/1.0 (https://github.com/coinjar/bsb)'
41
+
42
+ puts "Fetching CSV from #{url}..."
43
+
44
+ response = Faraday.new(url: url) do |f|
45
+ f.headers['User-Agent'] = user_agent
46
+ f.response :raise_error
47
+ f.response :follow_redirects
48
+ f.adapter Faraday.default_adapter
49
+ end.get
50
+
51
+ csv_data = response.body
52
+
53
+ output_path = args[:output_path]
54
+ FileUtils.mkdir_p(File.dirname(output_path))
55
+ File.binwrite(output_path, csv_data)
56
+
57
+ puts "Saved CSV to #{output_path}"
58
+ end
30
59
  end
@@ -0,0 +1,156 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://bsb.auspaynet.com.au/Public/BSB_DB.NSF/getKeytoACSV?OpenAgent
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - CoinJarBSBUpdater/1.0 (https://github.com/coinjar/bsb)
12
+ response:
13
+ status:
14
+ code: 302
15
+ message: Found
16
+ headers:
17
+ date:
18
+ - Fri, 07 Nov 2025 02:35:40 GMT
19
+ content-length:
20
+ - '0'
21
+ connection:
22
+ - keep-alive
23
+ server:
24
+ - cloudflare
25
+ location:
26
+ - https://bsb.auspaynet.com.au/Public/BSB_DB.NSF/0/9B80EBFA44A993E6CA2579650017682A/$File/key%20to%20abbreviations%20and%20bsb%20numbers%20(october%202025).csv
27
+ strict-transport-security:
28
+ - max-age=604800
29
+ x-frame-options:
30
+ - SAMEORIGIN
31
+ x-content-type-options:
32
+ - sniff
33
+ cf-cache-status:
34
+ - DYNAMIC
35
+ cf-ray:
36
+ - 99a9704cbf57e6ce-MEL
37
+ body:
38
+ encoding: UTF-8
39
+ string: ''
40
+ recorded_at: Fri, 07 Nov 2025 02:35:40 GMT
41
+ - request:
42
+ method: get
43
+ uri: https://bsb.auspaynet.com.au/Public/BSB_DB.NSF/0/9B80EBFA44A993E6CA2579650017682A/$File/key%20to%20abbreviations%20and%20bsb%20numbers%20(october%202025).csv
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ''
47
+ headers:
48
+ User-Agent:
49
+ - CoinJarBSBUpdater/1.0 (https://github.com/coinjar/bsb)
50
+ response:
51
+ status:
52
+ code: 200
53
+ message: OK
54
+ headers:
55
+ date:
56
+ - Fri, 07 Nov 2025 02:35:41 GMT
57
+ content-type:
58
+ - application/octet-stream
59
+ content-length:
60
+ - '5719'
61
+ connection:
62
+ - keep-alive
63
+ server:
64
+ - cloudflare
65
+ last-modified:
66
+ - Sun, 02 Nov 2025 21:07:11 GMT
67
+ etag:
68
+ - W/"MTAtMDAwMi0wLUNBMjU4RDM2MDA3NDAzNUEtOUI4MEVCRkE0NEE5OTNFNkNBMjU3OTY1MDAxNzY4MkE="
69
+ strict-transport-security:
70
+ - max-age=604800
71
+ x-frame-options:
72
+ - SAMEORIGIN
73
+ x-content-type-options:
74
+ - sniff
75
+ cf-cache-status:
76
+ - DYNAMIC
77
+ cf-ray:
78
+ - 99a9704dadb89344-MEL
79
+ body:
80
+ encoding: UTF-8
81
+ string: "BSB Owner,Owner Name,BSB Prefix\r\nABA,Auswide Bank Ltd,645\r\nABA,Auswide
82
+ Bank Ltd,656\r\nADC,Australian Military Bank Limited,642\r\nADL,Adelaide Bank
83
+ (a division of Bendigo and Adelaide Bank Limited),610\r\nADV,Advance Bank
84
+ Australia (a division of Westpac Banking Corp),46\r\nAFT,AFT AU Pty Ltd,771\r\nALX,Alex
85
+ Bank Pty Ltd,259\r\nAMP,AMP Bank Limited,939\r\nANZ,Australia & New Zealand
86
+ Banking Group Limited,1\r\nAPO,Australia Post (Money Orders),90\r\nARA,Arab
87
+ Bank Australia Limited,917\r\nASL,Australian Settlements Limited,57\r\nAVE,Avenue
88
+ Bank Ltd,890\r\nBAE,B&E Ltd trading as Bank of Us,632\r\nBAL,Bank of America
89
+ National Association,23\r\nBAU,Bank Australia Limited,313\r\nBBL,Bendigo and
90
+ Adelaide Bank Limited,633\r\nBCA,Bank of China (Australia) Limited,980\r\nBCC,Police
91
+ & Nurses Limited,533\r\nBCP,BC Payments Australia Pty Ltd,252\r\nBML,Bank
92
+ of Melbourne (a division of Westpac Banking Corp),55\r\nBNK,BNK Banking Corporation
93
+ Ltd ,369\r\nBNO,Bano Pty Ltd,585\r\nBNP,BNP Paribas,22\r\nBOC,Bank of China,35\r\nBOM,Bank
94
+ of Melbourne (a division of Westpac Banking Corp),19\r\nBOT,\"MUFG Bank, Ltd.\",29\r\nBPS,BNP
95
+ Paribas Securities Services,255\r\nBQL,Bank of Queensland Limited,12\r\nBSA,BankSA
96
+ (a division of Westpac Banking Corp),10\r\nBTA,Bankers Trust Australia (a
97
+ division of Westpac Banking Corp),26\r\nBWA,Bankwest (a division of Commonwealth
98
+ Bank of Australia),30\r\nBYB,Beyond Bank Australia Limited,325\r\nCAG,Corporate
99
+ Alliance Group Pty Ltd,599\r\nCAP,Capricornian Ltd (The),813\r\nCBA,Commonwealth
100
+ Bank of Australia,6\r\nCBA,Commonwealth Bank of Australia,76\r\nCBL,Challenge
101
+ Bank (a division of Westpac Banking Corp),47\r\nCCB,\"China Construction Bank
102
+ Corporation, Sydney Branch\",888\r\nCEB,China Everbright Bank Co Ltd,681\r\nCFC,Community
103
+ First Credit Union Limited,512\r\nCMB,\"JP Morgan Chase Bank, National Association\",21\r\nCNA,Citibank
104
+ N.A.,510\r\nCOM,\"Bank of Communications Co., Ltd Sydney Branch\",818\r\nCRU,Cuscal
105
+ Limited,80\r\nCSA,Credit Union SA Ltd,855\r\nCST,Colonial State Bank,40\r\nCTI,Citibank
106
+ N.A.,24\r\nCUA,Credit Union Australia Ltd (trading as Great Southern Bank),814\r\nCUS,Indue
107
+ Ltd,70\r\nDBA,Deutsche Bank Aktiengesellschaft,41\r\nDBL,Defence Bank Limited,833\r\nDBS,DBS
108
+ Bank Ltd. (Australia Branch),889\r\nENC,Australian Mutual Bank Limited,823\r\nFMO,Paynow
109
+ Technology Pty Ltd,850\r\nFPX,Flash Partners Pty Ltd,370\r\nGBS,Greater Bank
110
+ (a division of Newcastle Greater Mutual Group Ltd),630\r\nGBS,Greater Bank
111
+ (a division of Newcastle Greater Mutual Group Ltd),637\r\nGBS,Greater Bank
112
+ (a division of Newcastle Greater Mutual Group Ltd),680\r\nGCB,G&C Mutual Bank
113
+ Limited,659\r\nGNI,\"ING Bank, NV (Sydney Branch)\",936\r\nGPA,Global Payments
114
+ Australia 1 Pty Ltd,820\r\nGSB,Credit Union Australia Ltd (trading as Great
115
+ Southern Bank),834\r\nGTW,Gateway Bank Ltd,676\r\nHAY,Cuscal Limited,636\r\nHBA,HSBC
116
+ Bank Australia Limited,34\r\nHBS,Heritage and People's Choice Limited,638\r\nHBS,Heritage
117
+ and People's Choice Limited,880\r\nHCC,Regional Australia Bank Limited,721\r\nHIC,\"Bank
118
+ of Heritage Isle, a division of Police Bank Ltd\",723\r\nHOM,Home Building
119
+ Society (a division of Bank of Queensland Limited),639\r\nHPC,Cuscal Limited,671\r\nHSB,\"Hongkong
120
+ & Shanghai Banking Corporation Limited (The), Australian Branch\",985\r\nHUM,Hume
121
+ Bank Limited,640\r\nIBA,International Bank of Australia Pty Limited,688\r\nIBK,Industrial
122
+ and Commercial Bank of China Limited,819\r\nICB,\"Mega International Commercial
123
+ Bank Co, Ltd\",931\r\nIMB,IMB Ltd,641\r\nIMB,IMB Ltd,647\r\nING,ING Bank (Australia)
124
+ Limited (trading as ING),923\r\nINV,BOQ Specialist (a division of Bank of
125
+ Queensland Limited),951\r\nJUD,Judo Bank Pty Ltd,725\r\nKEB,KEB Hana Bank,323\r\nLBA,Bank
126
+ of Sydney Ltd,942\r\nMBL,Macquarie Bank Limited,18\r\nMCB,\"Mizuho Bank, Ltd\",918\r\nMEB,Bank
127
+ of Queensland Limited,944\r\nMET,Norfina Limited,48\r\nMMB,Maitland Mutual
128
+ Limited trading as The Mutual Bank,646\r\nMMP,Unity Bank Limited,882\r\nMON,Monoova
129
+ Payments Pty Ltd,257\r\nMSL,Tyro Payments Limited,969\r\nNAB,National Australia
130
+ Bank Limited,8\r\nNEW,Newcastle Greater Mutual Group Ltd,650\r\nOCB,Oversea-Chinese
131
+ Banking Corporation Limited,45\r\nONE,in1bank Limited,311\r\nPCU,Police Bank
132
+ Ltd (trading as Police Bank),815\r\nPIB,Rabobank Australia Limited,14\r\nPNB,Police
133
+ & Nurses Limited,777\r\nPPB,Pioneer Permanent Building Society (a division
134
+ of Bank of Queensland Limited),653\r\nQCB,Queensland Country Bank Limited,654\r\nQTM,Members
135
+ Banking Group Limited Trading as RACQ Bank,514\r\nRAB,Regional Australia Bank
136
+ Limited,932\r\nRBA,Reserve Bank of Australia,9\r\nRCU,Railways Credit Union
137
+ Limited t/a MOVE Bank,724\r\nREV,Revolut Payments Australia Pty Ltd,772\r\nROK,MyState
138
+ Bank Limited,655\r\nSCB,\"Standard Chartered Bank, Australia Branch\",43\r\nSCU,Summerland
139
+ Financial Servces Limited (Trading as Summerland Bank),728\r\nSEL,Australian
140
+ Mutual Bank Limited,611\r\nSGP,St.George Bank (a division of Westpac Banking
141
+ Corp),33\r\nSHP,Australian Settlements Limited,635\r\nSKY,Australian Unity
142
+ Bank Limited,825\r\nSMB,Sumitomo Mitsui Banking Corporation,911\r\nSNX,Southern
143
+ Cross Credit Union Ltd,722\r\nSPL,Zepto Payments Pty Ltd,840\r\nSSB,State
144
+ Street Bank and Trust Company,913\r\nSTG,St.George Bank (a division of Westpac
145
+ Banking Corp) ,11\r\nSTH,IMB Ltd,824\r\nSUN,Norfina Limited,66\r\nT&C,Town
146
+ & Country Bank (a division of Australia & New Zealand Banking Group Limited),15\r\nTBB,\"Taiwan
147
+ Business Bank, Sydney Branch\",943\r\nTBT,Colonial Trust Bank,42\r\nTBT,Colonial
148
+ Trust Bank,52\r\nTCU,Teachers Mutual Bank Limited,812\r\nUBS,\"UBS AG, Australia
149
+ Branch\",946\r\nUFS,Uniting Financial Services,634\r\nUOB,United Overseas
150
+ Bank Limited,922\r\nVOL,Volt Bank Limited,517\r\nWBC,Westpac Banking Corporation,3\r\nWBC,Westpac
151
+ Banking Corporation,4\r\nWBC,Westpac Banking Corporation,73\r\nWBC,Westpac
152
+ Banking Corporation,74\r\nWCU,Warwick Credit Union Ltd (Trading as Darling
153
+ Downs Bank),817\r\nWSE,Wise Australia Pty Ltd,774\r\nYOU,National Australia
154
+ Bank Limited,670\r\n"
155
+ recorded_at: Fri, 07 Nov 2025 02:35:41 GMT
156
+ recorded_with: VCR 6.3.1
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'rake'
5
+ require 'fileutils'
6
+
7
+ describe 'bsb tasks rake task', type: :task do
8
+ before(:all) do
9
+ Rake.application.rake_require('../lib/tasks/bsb_tasks')
10
+ Rake::Task.define_task(:environment)
11
+ end
12
+
13
+ describe 'fetch_key_file' do
14
+ let(:task_name) { 'bsb:fetch_key_file' }
15
+ let(:task) { Rake::Task[task_name] }
16
+ let(:output_path) { 'tmp/test_key.csv' }
17
+
18
+ before do
19
+ FileUtils.rm_f(output_path)
20
+ task.reenable # so it can be invoked multiple times
21
+ end
22
+
23
+ after { FileUtils.rm_f(output_path) }
24
+
25
+ describe 'when fetching the CSV', :vcr do
26
+ it 'downloads and saves the file successfully' do
27
+ VCR.use_cassette('fetch_key_file') do
28
+ assert(!File.exist?(output_path))
29
+
30
+ output = capture_stdout { task.invoke(output_path) }
31
+
32
+ assert(output.include?('Fetching CSV'))
33
+ assert(File.exist?(output_path))
34
+
35
+ content = File.read(output_path)
36
+ assert(output.include?('BSB'))
37
+ assert(!content.empty?)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ # Helper to capture puts output
44
+ def capture_stdout
45
+ original_stdout = $stdout
46
+ $stdout = StringIO.new
47
+ yield
48
+ $stdout.string
49
+ ensure
50
+ $stdout = original_stdout
51
+ end
52
+ end
data/test/test_helper.rb CHANGED
@@ -13,7 +13,9 @@ VCR.configure do |config|
13
13
  config.cassette_library_dir = 'test/fixtures/vcr_cassettes'
14
14
  config.hook_into :faraday
15
15
  config.filter_sensitive_data('<AUSPAYNET_SUB_KEY>') do |interaction|
16
- interaction.request.headers['Ocp-apim-subscription-key'][0]
16
+ if interaction.request.headers['Ocp-apim-subscription-key']
17
+ interaction.request.headers['Ocp-apim-subscription-key'][0]
18
+ end
17
19
  end
18
20
  end
19
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-08 00:00:00.000000000 Z
11
+ date: 2025-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -63,6 +63,8 @@ files:
63
63
  - test/bsb_test.rb
64
64
  - test/fixtures/bsb_db.json
65
65
  - test/fixtures/vcr_cassettes/auspaynet_fetch_all_bsbs.yml
66
+ - test/fixtures/vcr_cassettes/fetch_key_file.yml
67
+ - test/tasks/bsb_tasks_test.rb
66
68
  - test/tasks/sync_bsb_db_test.rb
67
69
  - test/test_helper.rb
68
70
  - test/tmp/.keep