Sha256: 5e07650bf8ff5525593283c3f2b69379264d087b2782acf0a04e09135cd8751b

Contents?: true

Size: 880 Bytes

Versions: 7

Compression:

Stored size: 880 Bytes

Contents

module RedminePluginsHelper
  class Migrations
    class << self
      def local_versions
        r = {}
        Redmine::Plugin.registered_plugins.values.each do |p|
          p.migrations.each do |ts|
            r[p.id] ||= []
            r[p.id] << ts
          end
        end
        r
      end

      def db_versions
        r = {}
        db_all_versions.each do |v|
          pv = parse_plugin_version(v)
          next unless pv
          r[pv[:plugin]] ||= []
          r[pv[:plugin]] << pv[:timestamp]
        end
        r
      end

      def db_all_versions
        ::ActiveRecord::SchemaMigration.create_table
        ::ActiveRecord::SchemaMigration.all.pluck(:version)
      end

      def parse_plugin_version(v)
        m = v.match(/^(\d+)\-(\S+)$/)
        return nil unless m
        { plugin: m[2].to_sym, timestamp: m[1].to_i }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.7.0 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.6.4 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.6.3 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.6.2 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.6.1 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.6.0 lib/redmine_plugins_helper/migrations.rb
redmine_plugins_helper-0.5.2 lib/redmine_plugins_helper/migrations.rb