Class: RedminePluginsHelper::Migrations
- Inherits:
-
Object
- Object
- RedminePluginsHelper::Migrations
- Defined in:
- lib/redmine_plugins_helper/migrations.rb
Class Method Summary collapse
- .db_all_versions ⇒ Object
- .db_versions ⇒ Object
- .local_versions ⇒ Object
- .parse_plugin_version(v) ⇒ Object
Class Method Details
.db_all_versions ⇒ Object
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_versions ⇒ Object
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_versions ⇒ Object
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 |