Sha256: c9ee764c395dc5b51a205962afe2294108eda08c29363b9d7816acc50e62b0c8

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 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

6 entries across 6 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.13.2 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.13.1 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.13.0 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.12.2 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.12.1 lib/redmine_plugins_helper/migration/code.rb
redmine_plugins_helper-0.12.0 lib/redmine_plugins_helper/migration/code.rb