diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index feea55a..41caaae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: bump-patch-for-minor-pre-major: true - if: ${{ steps.release.outputs.release_created }} - uses: actions/checkout@v3 + uses: actions/checkout@v4 - if: ${{ steps.release.outputs.release_created }} name: Set up Ruby diff --git a/.github/workflows/update-database.yml b/.github/workflows/update-database.yml index fa737d4..37fbc57 100644 --- a/.github/workflows/update-database.yml +++ b/.github/workflows/update-database.yml @@ -12,7 +12,7 @@ jobs: name: Update BSB Database & Version runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -21,13 +21,10 @@ jobs: run: bundle exec rake bsb:sync - id: get-date run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - uses: peter-evans/create-pull-request@v4 + - uses: peter-evans/create-pull-request@v6 id: raise-pr with: branch: "bot/${{ steps.get-date.outputs.date }}" base: master title: "fix: ${{ steps.get-date.outputs.date }} periodic update of config/*.json database files." - committer: GitHub Actions - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false delete-branch: true diff --git a/.ruby-version b/.ruby-version index ef538c2..bea438e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.3.1 diff --git a/Gemfile b/Gemfile index 44a74fb..99aebac 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,4 @@ gemspec gem 'bundler', '~> 2.0' gem 'net-ftp', '~> 0.1.3' gem 'rake', '~> 13.0' -gem 'rubocop', '~> 1.26' +gem 'rubocop' diff --git a/bsb.gemspec b/bsb.gemspec index 76ca231..d810fb6 100644 --- a/bsb.gemspec +++ b/bsb.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.7.0' + spec.required_ruby_version = '>= 2.7.7' spec.add_dependency 'activemodel' diff --git a/lib/auspaynet/client.rb b/lib/auspaynet/client.rb index d0be30e..c837a58 100644 --- a/lib/auspaynet/client.rb +++ b/lib/auspaynet/client.rb @@ -4,8 +4,6 @@ module Auspaynet class Client - MONTHS = %w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec].freeze - def initialize(host) @host = host @ftp = Net::FTP.new(@host) @@ -23,35 +21,12 @@ def get(dir, filename) def list(dir:, matching_filename:, file_format: 'csv') @ftp.chdir(dir) files = @ftp.nlst.select do |f| - f.include?(matching_filename) && - f.include?(file_format) && - (f.include?("#{current_year}-") || f.include?("#{current_year})")) + f.include?(matching_filename) && f.end_with?(file_format) end - extract_latest_files(files: files, file_format: file_format) + files.sort_by { |fname| @ftp.mtime(fname) } ensure @ftp.chdir('/') end - - private - - def current_year - Time.now.strftime('%y') - end - - def extract_latest_files(files:, file_format:) - files.sort_by do |filename| - file_for_month(filename: filename, file_format: file_format) - end - end - - def file_for_month(filename:, file_format:) - month_from_filename = filename.gsub(/(#{filename}|#{file_format}|\W|\d)/, '') - month_number(month_from_filename) - end - - def month_number(month_from_filename) - MONTHS.find_index(month_from_filename) - end end end