Module: RedminePluginsHelper::Migration::Code::ClassMethods

Defined in:
lib/redmine_plugins_helper/migration/code.rb

Instance Method Summary collapse

Instance Method Details

#from_codeEnumerable<RedminePluginsHelper::Migration>

Returns:



10
11
12
# File 'lib/redmine_plugins_helper/migration/code.rb', line 10

def from_code
  from_core_code + from_plugins_code
end

#from_core_codeEnumerable<RedminePluginsHelper::Migration>

Returns:



15
16
17
18
19
# File 'lib/redmine_plugins_helper/migration/code.rb', line 15

def from_core_code
  ::Rails.application.paths['db/migrate'].flat_map do |path|
    from_path_code(path)
  end
end

#from_path_code(path) ⇒ Enumerable<RedminePluginsHelper::Migration>

Returns:



22
23
24
25
# File 'lib/redmine_plugins_helper/migration/code.rb', line 22

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

#from_plugins_codeEnumerable<RedminePluginsHelper::Migration>

Returns:



28
29
30
31
32
# File 'lib/redmine_plugins_helper/migration/code.rb', line 28

def from_plugins_code
  ::Redmine::Plugin.registered_plugins.values.flat_map do |plugin|
    plugin.migrations.map { |version| new(plugin.id, version) }
  end
end