Sha256: 9def7bb03f38db0f268b26a86583fd0ac6c82c8b05f0365d69d53c024a8b22cc

Contents?: true

Size: 1.06 KB

Versions: 19

Compression:

Stored size: 1.06 KB

Contents

module Scrivito
  module Migrations
    class Installer
      def initialize(from)
        @to_load = from.blank? ? :all : from.split(',').map(&:strip)
      end

      def install
        Scrivito::Migrations::Migration.copy(destination, find_engines_with_migrations)
      end

      private

      def destination
        Scrivito::Migrations::Migrator.migrations_path
      end

      def find_engines_with_migrations
        Rails.application.railties.inject({}) do |railties, railtie|
          next railties unless @to_load == :all || @to_load.include?(railtie.railtie_name)

          if path = railtie_migration_path_for(railtie)
            railties[railtie.railtie_name] = path
          end

          railties
        end
      end

      def railtie_migration_path_for(railtie)
        if railtie.respond_to?(:paths)
          path = railtie.paths.path + relative_migration_path

          if File.exist?(path)
            path
          end
        end
      end

      def relative_migration_path
        Scrivito::Configuration.migration_path
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
scrivito_sdk-0.50.1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.60.0.rc1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.50.0 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.50.0.rc2 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.50.0.rc1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.42.1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.42.1.rc3 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.42.1.rc2 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.42.1.rc1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.42.0 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.41.1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.41.0 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.41.0.rc2 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.41.0.rc1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.40.0 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.40.0.rc2 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.40.0.rc1 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.30.0 lib/scrivito/migrations/installer.rb
scrivito_sdk-0.30.0.rc1 lib/scrivito/migrations/installer.rb