Sha256: dc2b8ff928cb8a1a573876e24a933c9e41e2fbb1044e4faf5f313ec3db6174d8

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require "rails/generators/migration"

module Sail
  module Generators
    # InstallGenerator
    # This is the install generator for Sail
    # which creates the necessary migrations
    class InstallGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration

      source_root File.expand_path("templates", __dir__)
      desc "Create Sail migrations"

      def self.next_migration_number(_path)
        if @prev_migration_nr
          @prev_migration_nr += 1
        else
          @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
        end

        @prev_migration_nr.to_s
      end

      def copy_migrations
        migration_template "create_sail_settings.rb",
                           "db/migrate/create_sail_settings.rb",
                           migration_version: migration_version

        migration_template "create_sail_profiles.rb",
                           "db/migrate/create_sail_profiles.rb",
                           migration_version: migration_version
      end

      def migration_version
        "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if Rails.version.start_with?("5")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sail-3.2.3 lib/generators/sail/install/install_generator.rb
sail-3.2.2 lib/generators/sail/install/install_generator.rb
sail-3.2.1 lib/generators/sail/install/install_generator.rb
sail-3.2.0 lib/generators/sail/install/install_generator.rb
sail-3.1.0 lib/generators/sail/install/install_generator.rb
sail-3.0.1 lib/generators/sail/install/install_generator.rb
sail-3.0.0 lib/generators/sail/install/install_generator.rb