redmine_plugins_helper 0.13.0 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa73ff7cd5b471c099d4e260d1ba1f63b78c499ee57868db67b4d323e906c784
4
- data.tar.gz: 5b6a7e536e9943aceed8a4e662ba59990020b21ede74976f345922f4a648b3ef
3
+ metadata.gz: 68ddbe5f5a9e060a5df5c5fc027edb7afe1b614c59074d65dd0206d2672771f1
4
+ data.tar.gz: 81b45849cd58e9f8f0c7a752494f67a9c422000a3de350f64008951328851c40
5
5
  SHA512:
6
- metadata.gz: 64c685dcc238edd5d61865d24bd19a48a1e202f6fa317f565157d9c675dad44b466e4a3e0e075a9b06297adc96a35a7f0cd7dd260ca9f1d95a03d5bb231be1e1
7
- data.tar.gz: e43b6bbe100eb0b3475cdca99b6c8d3ba2ed64f8a79f7fb9b450b29f8db00f412998c376d0ee69821e58c7dd5b4d0bcf97477bced69a986e913abb7a64cc1470
6
+ metadata.gz: 8c75dfd3760e1ec4fcebaf04a5d63359fffd6e0c112189e686f1e4ebf92c3d6aa3a9821993519e65f5a40ddfabb5bd4be6d845853fce4bf9ec33a507e772e2b5
7
+ data.tar.gz: 0fce8c11427cb24137480cea24f1121c5c71b2b6e5dcfe20831ebf397a90c22abe74ed06d3e8dced02568429df3611f8991b204d11901a7856a6d0dd20fc460c
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
4
+
3
5
  module RedminePluginsHelper
4
6
  class Migrate
5
- attr_reader :plugin_name, :migration_version
6
-
7
- def initialize(plugin_name, migration_version)
8
- @plugin_name = plugin_name
9
- @migration_version = migration_version
7
+ common_constructor :plugin_name, :migration_version do
10
8
  run
11
9
  end
12
10
 
@@ -21,41 +19,21 @@ module RedminePluginsHelper
21
19
  end
22
20
 
23
21
  def run_all
24
- versions_sorted.each do |v|
25
- migrate_plugin_version(v)
26
- end
22
+ versions_sorted.each(&:apply)
27
23
  end
28
24
 
29
25
  def run_version
30
26
  ::Redmine::Plugin.migrate(plugin_name, migration_version)
31
27
  end
32
28
 
33
- def migrate_plugin_version(version)
34
- return if migrated?(version)
35
-
36
- ::Redmine::Plugin.registered_plugins[version[:plugin]].migrate(version[:timestamp])
37
- end
38
-
29
+ # @return [Enumerable<RedminePluginsHelper::Migration>]
39
30
  def versions_sorted
40
- versions.sort_by { |e| [e[:timestamp]] }
31
+ versions.sort
41
32
  end
42
33
 
34
+ # @return [Enumerable<RedminePluginsHelper::Migration>]
43
35
  def versions
44
- r = []
45
- ::RedminePluginsHelper::Migrations.local_versions.each do |plugin, ts|
46
- ts.each { |t| r << { plugin: plugin, timestamp: t } }
47
- end
48
- r
49
- end
50
-
51
- def migrated?(version)
52
- return false unless db_versions.key?(version[:plugin])
53
-
54
- db_versions[version[:plugin]].include?(version[:timestamp])
55
- end
56
-
57
- def db_versions
58
- @db_versions ||= ::RedminePluginsHelper::Migrations.db_versions
36
+ ::RedminePluginsHelper::Migration.from_code.select(&:plugin?)
59
37
  end
60
38
  end
61
39
  end
@@ -10,6 +10,19 @@ module RedminePluginsHelper
10
10
  self.plugin_id = plugin_id.to_sym
11
11
  self.version = version.to_i
12
12
  end
13
+ compare_by :version, :plugin_id
14
+
15
+ # @return [void]
16
+ def apply
17
+ return if applied?
18
+
19
+ nyi unless plugin?
20
+
21
+ ::Redmine::Plugin::Migrator.current_plugin = plugin
22
+ ::Redmine::Plugin::MigrationContext.new(plugin.migration_directory).up do |m|
23
+ m.version == version
24
+ end
25
+ end
13
26
 
14
27
  # @return [Boolean]
15
28
  def applied?
@@ -27,6 +40,11 @@ module RedminePluginsHelper
27
40
  plugin_id == PLUGIN_ID_CORE_VALUE
28
41
  end
29
42
 
43
+ # @return [Redmine::Plugin]
44
+ def plugin
45
+ plugin? ? ::Redmine::Plugin.find(plugin_id) : nil
46
+ end
47
+
30
48
  # @return [Boolean]
31
49
  def plugin?
32
50
  !core?
@@ -10,7 +10,6 @@ module RedminePluginsHelper
10
10
 
11
11
  included do
12
12
  extend ClassMethods
13
- include InstanceMethods
14
13
  include ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Assets
15
14
  prepend ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Dependencies
16
15
  include ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Initializers
@@ -40,6 +39,8 @@ module RedminePluginsHelper
40
39
  plugin.instance_eval(&block)
41
40
  end
42
41
  end
42
+
43
+ require_sub __FILE__
43
44
  end
44
45
  end
45
46
  end
@@ -3,5 +3,5 @@
3
3
  module RedminePluginsHelper
4
4
  AUTHOR = 'Eduardo Henrique Bogoni'
5
5
  SUMMARY = 'Helper for Redmine plugins'
6
- VERSION = '0.13.0'
6
+ VERSION = '0.13.2'
7
7
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugins_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
- - 0.13.0
7
+ - 0.13.2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<"
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: '2'
22
+ version: 1.4.4
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "<"
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
- version: '2'
32
+ version: 1.4.4
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_ruby_utils
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -48,16 +54,22 @@ dependencies:
48
54
  name: launchy
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.5'
51
60
  - - ">="
52
61
  - !ruby/object:Gem::Version
53
- version: '0'
62
+ version: 2.5.2
54
63
  type: :runtime
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
66
  requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.5'
58
70
  - - ">="
59
71
  - !ruby/object:Gem::Version
60
- version: '0'
72
+ version: 2.5.2
61
73
  - !ruby/object:Gem::Dependency
62
74
  name: rspec-rails
63
75
  requirement: !ruby/object:Gem::Requirement