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 ( a71dff...666e4a )
by Leonardo
01:03
created

InstallGenerator.bics_table_name()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
# frozen_string_literal: true
2
3
require "rails/generators"
4
require "rails/generators/active_record"
5
6
module IbanBic
7
  # Installs Iban+Bic in a rails app.
8
  class InstallGenerator < ::Rails::Generators::Base
9
    include ::Rails::Generators::Migration
10
11
    source_root File.expand_path("../templates", __FILE__)
12
    class_option(
13
      :with_static_bics,
14
      type: :boolean,
15
      default: false,
16
      desc: "Don't create bics table, use static bics."
17
    )
18
19
    class_option(
20
      :bics_table_name,
21
      type: :string,
22
      default: "bics",
23
      desc: "BICs table name, `bics` by default."
24
    )
25
26
    desc "Generates an initializer file for configuring IbanBic." \
27
         " Also can generate a migration to add a bics table."
28
29
    def create_migration_file
30
      add_iban_bic_migration "create_bics" unless options.with_static_bics?
31
    end
32
33
    def create_initializer
34
      initializer_dir = File.expand_path("config/initializers")
35
      if File.exist?(File.join(initializer_dir, "iban_bic.rb"))
36
        ::Kernel.warn "Initializer already exists"
37
      else
38
        template "iban_bic.rb.erb", "config/initializers/iban_bic.rb"
39
      end
40
    end
41
42
    def self.next_migration_number(dirname)
43
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
44
    end
45
46
    def migration_version
47
      "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
48
    end
49
50
    def bics_table_name
51
      options.bics_table_name
52
    end
53
54
    protected
55
56
    def add_iban_bic_migration(template)
57
      migration_dir = File.expand_path("db/migrate")
58
      if self.class.migration_exists?(migration_dir, template)
59
        ::Kernel.warn "Migration already exists: #{template}"
60
      else
61
        migration_template "#{template}.rb.erb", "db/migrate/#{template}.rb"
62
      end
63
    end
64
  end
65
end
66