Sha256: d7b9341e656ac3e9161c6d33424690e8b46d30fa005af4ea3e606c92036d57a0

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 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 create_config_file
        template "sail.yml", "config/sail.yml"
      end

      def migration_version
        "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sail-3.6.1 lib/generators/sail/install/install_generator.rb
sail-3.6.0 lib/generators/sail/install/install_generator.rb
sail-3.5.1 lib/generators/sail/install/install_generator.rb
sail-3.5.0 lib/generators/sail/install/install_generator.rb