GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — master ( 7ecb70...bf77b3 )
by Leonardo
54s
created

IbanBic.configuration()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
# frozen_string_literal: true
2
3
require "iban_bic/version"
4
require "iban_bic/railtie" if defined?(Rails)
5
require "iban_bic/configuration"
6
require "iban_bic/iban_parts"
7
require "iban_bic/models/bic"
8
9
module IbanBic
10
  def configuration
11
    @configuration ||= Configuration.new
12
  end
13
14
  def configure
15
    configuration.instance_eval(&Proc.new)
16
  end
17
18
  def calculate_check(iban)
19
    98 - "#{iban[4..-1]}#{iban[0..3]}".each_char.map do |char|
20
      case char
21
      when "0".."9" then char
22
      when "A".."Z" then (char.ord - 55).to_s
23
      else raise("Invalid IBAN")
24
      end
25
    end .join.to_i % 97
26
  end
27
28
  def calculate_bic(iban)
29
    country = iban[0..1]
30
    parts = IbanParser.partser[country].match(iban)
31
    return nil unless parts&.fetch(:bank, nil)
32
33
    if ActiveRecord::Base.connection.table_exists? "bics"
34
      Bic.find_by(country: country, bank_code: parts[:bank]).pluck(:bic)
35
    else
36
      configuration.static_bics.dig(country, parts[:bank])
37
    end
38
  end
39
40
  module_function :configuration, :configure, :calculate_check, :calculate_bic
41
end
42
43
require "iban_bic/defaults"
44