Sha256: cdd94b209235f9a9b5df43db93bcc4c905922ad17ced5a55e34a934a072743b2

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module RedminePluginsHelper
  class Migration
    module Code
      common_concern

      module ClassMethods
        # @return [Enumerable<RedminePluginsHelper::Migration>]
        def from_code
          from_core_code + from_plugins_code
        end

        # @return [Enumerable<RedminePluginsHelper::Migration>]
        def from_core_code
          ::Rails.application.paths['db/migrate'].flat_map do |path|
            from_path_code(path)
          end
        end

        # @return [Enumerable<RedminePluginsHelper::Migration>]
        def from_path_code(path)
          ::Dir["#{path}/*.rb"].map { |p| File.basename(p).match(/0*(\d+)_/)[1].to_i }.sort
            .map { |version| new(PLUGIN_ID_CORE_VALUE, version) }
        end

        # @return [Enumerable<RedminePluginsHelper::Migration>]
        def from_plugins_code
          ::Redmine::Plugin.registered_plugins.values.flat_map do |plugin|
            plugin.migrations.map { |version| new(plugin.id, version) }
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.15.3 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.15.2 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.15.1 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.15.0 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.14.0 lib/redmine_plugins_helper/migration/code.rb