Class: RedminePluginsHelper::Migrations

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine_plugins_helper/migrations.rb

Class Method Summary collapse

Class Method Details

.db_all_versionsObject



26
27
28
29
# File 'lib/redmine_plugins_helper/migrations.rb', line 26

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

.db_versionsObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/redmine_plugins_helper/migrations.rb', line 15

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

.local_versionsObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/redmine_plugins_helper/migrations.rb', line 4

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

.parse_plugin_version(v) ⇒ Object



31
32
33
34
35
# File 'lib/redmine_plugins_helper/migrations.rb', line 31

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