Sha256: 49e9e13712083210ea15adc38904fd3ce11e1658df199d15ba4c46b0b274d74f

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

require "rails/generators"

module Tanshuku
  # A generator class for Tanshuku configuration files.
  #
  # @api private
  class InstallGenerator < Rails::Generators::Base
    source_root File.expand_path("../templates", __dir__)

    # Generates a configuration file +config/initializers/tanshuku.rb+.
    #
    # @return [void]
    def copy_initializer_file
      copy_file "initializer.rb", "config/initializers/tanshuku.rb"
    end

    # Generates a migration file +db/migrate/20230220123456_create_tanshuku_urls.rb+.
    #
    # @return [void]
    def copy_migration_file
      # rubocop:disable Rails/TimeZone
      old_filename = "20230220123456_create_tanshuku_urls.rb"
      new_filename = old_filename.sub("20230220123456", Time.now.strftime("%Y%m%d%H%M%S"))
      copy_file "../../../db/migrate/#{old_filename}", "db/migrate/#{new_filename}"
      # rubocop:enable Rails/TimeZone
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tanshuku-2.0.1 lib/generators/tanshuku/install_generator.rb
tanshuku-1.0.1 lib/generators/tanshuku/install_generator.rb
tanshuku-2.0.0 lib/generators/tanshuku/install_generator.rb
tanshuku-1.0.0 lib/generators/tanshuku/install_generator.rb
tanshuku-0.0.18 lib/generators/tanshuku/install_generator.rb