bsb 1.2.1 → 1.2.2

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.
@@ -6,10 +6,8 @@ require 'bsb/base_generator'
6
6
  module BSB
7
7
  class BankListGenerator < BaseGenerator
8
8
  def self.load_file(filename)
9
- client = ::Auspaynet::Client.new('bsb.hostedftp.com')
10
- content = client.get('~auspaynetftp/BSB', filename)
11
9
  hash = {}
12
- CSV.parse(content) do |row|
10
+ CSV.foreach(filename) do |row|
13
11
  row[2].split(', ').each do |prefix|
14
12
  prefix = prefix.chomp.rjust(2, '0')
15
13
  hash[prefix] = row[1]
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'auspaynet/client'
5
4
 
6
5
  module BSB
7
6
  class BaseGenerator
@@ -12,10 +11,5 @@ module BSB
12
11
  def json
13
12
  JSON.pretty_generate(@hash)
14
13
  end
15
-
16
- def self.latest_file(matching_filename:, file_format:)
17
- client = ::Auspaynet::Client.new('bsb.hostedftp.com')
18
- client.list(dir: '~auspaynetftp/BSB', matching_filename: matching_filename, file_format: file_format)&.last
19
- end
20
14
  end
21
15
  end
@@ -5,10 +5,8 @@ require 'bsb/base_generator'
5
5
  module BSB
6
6
  class DatabaseGenerator < BaseGenerator
7
7
  def self.load_file(filename)
8
- client = ::Auspaynet::Client.new('bsb.hostedftp.com')
9
- content = client.get('~auspaynetftp/BSB', filename)
10
8
  hash = {}
11
- content.each_line do |line|
9
+ File.foreach(filename) do |line|
12
10
  next if line[3] != '-'
13
11
 
14
12
  bsb = line[0, 3] + line[4, 3]
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.2.1'
4
+ VERSION = '1.2.2'
5
5
  end
@@ -2,21 +2,10 @@
2
2
 
3
3
  namespace :bsb do
4
4
  desc 'Sync config/*.json.'
5
- task :sync do
5
+ task :sync, [:keyfile, :bsbfile] do |_t, args|
6
6
  require 'bsb/base_generator'
7
- bank_list_filename = BSB::BaseGenerator.latest_file(
8
- matching_filename: 'KEY TO ABBREVIATIONS AND BSB NUMBERS',
9
- file_format: '.csv'
10
- )
11
- db_list_filename = BSB::BaseGenerator.latest_file(
12
- matching_filename: 'BSBDirectory',
13
- file_format: '.txt'
14
- )
15
-
16
- raise 'No bank list or bsb found' unless bank_list_filename || db_list_filename
17
-
18
- puts "Bank list file: '#{bank_list_filename}'"
19
- puts "DB file: '#{db_list_filename}'"
7
+ bank_list_filename = args[:keyfile]
8
+ db_list_filename = args[:bsbfile]
20
9
 
21
10
  if bank_list_filename
22
11
  require 'bsb/bank_list_generator'
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.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Zhou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-08 00:00:00.000000000 Z
11
+ date: 2024-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -33,7 +33,6 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - ".github/workflows/ci.yml"
35
35
  - ".github/workflows/release.yml"
36
- - ".github/workflows/update-database.yml"
37
36
  - ".gitignore"
38
37
  - ".release-please-manifest.json"
39
38
  - ".rubocop.yml"
@@ -46,7 +45,6 @@ files:
46
45
  - bsb.gemspec
47
46
  - config/bsb_bank_list.json
48
47
  - config/bsb_db.json
49
- - lib/auspaynet/client.rb
50
48
  - lib/bsb.rb
51
49
  - lib/bsb/bank_list_generator.rb
52
50
  - lib/bsb/base_generator.rb
@@ -77,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
75
  - !ruby/object:Gem::Version
78
76
  version: '0'
79
77
  requirements: []
80
- rubygems_version: 3.5.9
78
+ rubygems_version: 3.5.11
81
79
  signing_key:
82
80
  specification_version: 4
83
81
  summary: BSB number validator with built-in database.
@@ -1,30 +0,0 @@
1
- name: Update BSB Database
2
-
3
- on:
4
- schedule:
5
- # https://crontab.guru/every-month
6
- # At 00:00 on day-of-month 1.
7
- - cron: "0 0 1 * *"
8
- workflow_dispatch:
9
-
10
- jobs:
11
- build:
12
- name: Update BSB Database & Version
13
- runs-on: ubuntu-latest
14
- steps:
15
- - uses: actions/checkout@v4
16
- - name: Set up Ruby
17
- uses: ruby/setup-ruby@v1
18
- with:
19
- bundler-cache: true
20
- - name: Update BSB Database & Version
21
- run: bundle exec rake bsb:sync
22
- - id: get-date
23
- run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
24
- - uses: peter-evans/create-pull-request@v6
25
- id: raise-pr
26
- with:
27
- branch: "bot/${{ steps.get-date.outputs.date }}"
28
- base: master
29
- title: "fix: ${{ steps.get-date.outputs.date }} periodic update of config/*.json database files."
30
- delete-branch: true
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/ftp'
4
-
5
- module Auspaynet
6
- class Client
7
- def initialize(host)
8
- @host = host
9
- @ftp = Net::FTP.new(@host)
10
- @ftp.login
11
- @ftp.passive = true
12
- end
13
-
14
- def get(dir, filename)
15
- @ftp.chdir(dir)
16
- @ftp.gettextfile(filename, nil)
17
- ensure
18
- @ftp.chdir('/')
19
- end
20
-
21
- def list(dir:, matching_filename:, file_format: 'csv')
22
- @ftp.chdir(dir)
23
- files = @ftp.nlst.select do |f|
24
- f.include?(matching_filename) && f.end_with?(file_format)
25
- end
26
-
27
- files.sort_by { |fname| @ftp.mtime(fname) }
28
- ensure
29
- @ftp.chdir('/')
30
- end
31
- end
32
- end