redmine_plugins_helper 0.13.1 → 0.14.0

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: aaaaeded613ef8e1008c1132a077516083ccb224dd6c3e14762ec6b9ce57cd4f
4
- data.tar.gz: d554fd7dd558929f38e0c8c57b5bdfdcbc2e12dc903610b2477e30fe6e6b9e62
3
+ metadata.gz: 10df4dddf37c82e016961e56ff729e8cd21facfea4e91ca7021483d4ca23566f
4
+ data.tar.gz: d56fdb3a4410fd56251905ce5ca3c03ecde66b38af378e5b122d77030802448f
5
5
  SHA512:
6
- metadata.gz: dbed1ae45933b914612c964b232e8bd3ad15a5514b60fca9e2030ba9531e11fa9fa0dbe53acadaa7f8a3c005d1c723bf401f5167227da0af4e979c89379418ec
7
- data.tar.gz: 41b1c4b5899809adb2c2270ec6ff2f1c147197b9d3e278d9745997cfc837aed2b116765b2395229ffa615ed66f23751aae8d8e956cd417d660099042be286943
6
+ metadata.gz: 3afdf1c448537207c0b3d8ef8fb4c7237c04233accd10573c7e04c22bfac97d6385ca28bbd3a8c6fe469cfc7fa688a158418e42a61340950f8db99e41a23b072
7
+ data.tar.gz: 8f40961c8c50ebc8e961a7d69c8eb336299b760e202673792b6b0c57c976321050e912add9eaeb4ec60a3446dd5c976ddc67bc947dedb526558039d068cc7afe
@@ -13,7 +13,7 @@ module ActiveRecord
13
13
  module PostgreSQL
14
14
  module SchemaStatements
15
15
  # Resets the sequence of a table's primary key to the maximum value.
16
- def reset_pk_sequence!(table, pkey = nil, sequence = nil) #:nodoc:
16
+ def reset_pk_sequence!(table, pkey = nil, sequence = nil) # :nodoc:
17
17
  unless pkey && sequence
18
18
  default_pk, default_sequence = pk_and_sequence_for(table)
19
19
  pkey ||= default_pk
@@ -36,7 +36,7 @@ module ActiveRecord
36
36
 
37
37
  if postgresql_version >= 100_000
38
38
  select_value('SELECT seqmin FROM pg_sequence WHERE seqrelid = ' \
39
- "#{quote(quoted_sequence)}::regclass")
39
+ "#{quote(quoted_sequence)}::regclass")
40
40
  else
41
41
  select_value("SELECT min_value FROM #{quoted_sequence}")
42
42
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  # Reference: https://stackoverflow.com/questions/62570662/rails-4-ruby-2-7-1-schema-rb-shows-could-not-dump-table-because-of-following-f
4
4
 
5
- return unless RUBY_VERSION >= '2.7' && ::Rails.version < '5'
5
+ return unless RUBY_VERSION >= '2.7' && Rails.version < '5'
6
6
 
7
7
  module ActiveRecord
8
8
  module ConnectionAdapters
9
9
  module ColumnDumper
10
- def prepare_column_options(column, types) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
10
+ def prepare_column_options(column, types) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
11
11
  spec = {}
12
12
  spec[:name] = column.name.inspect
13
13
  spec[:type] = column.type.to_s
data/init.rb CHANGED
@@ -6,14 +6,14 @@ require 'redmine_plugins_helper/patches/test_case_patch'
6
6
 
7
7
  Redmine::Plugin.register :redmine_plugins_helper do
8
8
  name 'Redmine Plugins\' Helper'
9
- author ::RedminePluginsHelper::AUTHOR
10
- description ::RedminePluginsHelper::SUMMARY
11
- version ::RedminePluginsHelper::VERSION
9
+ author RedminePluginsHelper::AUTHOR
10
+ description RedminePluginsHelper::SUMMARY
11
+ version RedminePluginsHelper::VERSION
12
12
  end
13
13
 
14
14
  Rails.configuration.to_prepare do
15
15
  require_dependency 'redmine_plugins_helper/patches/redmine/plugin_patch'
16
16
  require_dependency 'redmine_plugins_helper/patches/redmine/plugin_migration_context'
17
- ::Redmine::Plugin.all.each(&:add_assets_paths)
18
- ::Redmine::Plugin.all.each(&:load_initializers)
17
+ Redmine::Plugin.all.each(&:add_assets_paths) # rubocop:disable Rails/FindEach
18
+ Redmine::Plugin.all.each(&:load_initializers) # rubocop:disable Rails/FindEach
19
19
  end
@@ -40,7 +40,7 @@ module RedminePluginsHelper
40
40
  def move_plugin_version(source_version, target_version)
41
41
  Rails.logger.info("Moving #{source_version} to plugin \"#{target_version}\"")
42
42
  ::ActiveRecord::SchemaMigration.where(version: source_version)
43
- .update_all(version: target_version) # rubocop:disable Rails/SkipsModelValidations
43
+ .update_all(version: target_version)
44
44
  end
45
45
 
46
46
  def local_version(timestamp)
@@ -64,7 +64,7 @@ module RedminePluginsHelper
64
64
 
65
65
  def database_plugins_versions
66
66
  @database_plugins_versions ||= ::RedminePluginsHelper::Migration
67
- .from_database.select(&:plugin?).map do |m|
67
+ .from_database.select(&:plugin?).map do |m|
68
68
  { plugin: m.plugin_id, timestamp: m.version, version: m.database_version }
69
69
  end
70
70
  end
@@ -10,8 +10,8 @@ module RedminePluginsHelper
10
10
  private
11
11
 
12
12
  def plugins_autoload_stylesheet_tag
13
- tag('link', media: 'all', rel: 'stylesheet',
14
- href: asset_path('assets/plugins_autoload.css'))
13
+ tag.link(media: 'all', rel: 'stylesheet',
14
+ href: asset_path('assets/plugins_autoload.css'))
15
15
  end
16
16
 
17
17
  def plugins_autoload_script_tag
@@ -20,8 +20,8 @@ module RedminePluginsHelper
20
20
 
21
21
  # @return [Enumerable<RedminePluginsHelper::Migration>]
22
22
  def from_path_code(path)
23
- ::Dir["#{path}/*.rb"].map { |p| File.basename(p).match(/0*(\d+)\_/)[1].to_i }.sort
24
- .map { |version| new(PLUGIN_ID_CORE_VALUE, version) }
23
+ ::Dir["#{path}/*.rb"].map { |p| File.basename(p).match(/0*(\d+)_/)[1].to_i }.sort
24
+ .map { |version| new(PLUGIN_ID_CORE_VALUE, version) }
25
25
  end
26
26
 
27
27
  # @return [Enumerable<RedminePluginsHelper::Migration>]
@@ -6,15 +6,15 @@ module RedminePluginsHelper
6
6
  common_concern
7
7
 
8
8
  DATABASE_CORE_VERSION_PARSER = /^(\d+)$/.to_parser { |m| [PLUGIN_ID_CORE_VALUE, m[1]] }
9
- DATABASE_PLUGIN_VERSION_PARSER = /^(\d+)\-(\S+)$/.to_parser { |m| [m[2], m[1]] }
9
+ DATABASE_PLUGIN_VERSION_PARSER = /^(\d+)-(\S+)$/.to_parser { |m| [m[2], m[1]] }
10
10
  DATABASE_VERSION_PARSERS = [DATABASE_PLUGIN_VERSION_PARSER, DATABASE_CORE_VERSION_PARSER]
11
- .freeze
11
+ .freeze
12
12
 
13
13
  module ClassMethods
14
14
  # @return [Enumerable<RedminePluginsHelper::Migration>]
15
15
  def from_database
16
16
  ::ActiveRecord::SchemaMigration.create_table
17
- ::ActiveRecord::SchemaMigration.all.pluck(:version).map do |version|
17
+ ::ActiveRecord::SchemaMigration.pluck(:version).map do |version|
18
18
  from_database_version(version)
19
19
  end
20
20
  end
@@ -15,10 +15,8 @@ module RedminePluginsHelper
15
15
  private
16
16
 
17
17
  def plugin
18
- @plugin ||= begin
19
- ::Redmine::Plugin.registered_plugins.values.find do |plugin|
20
- ::File.join(plugin.directory, 'db', 'migrate') == migrations_paths
21
- end
18
+ @plugin ||= ::Redmine::Plugin.registered_plugins.values.find do |plugin|
19
+ ::File.join(plugin.directory, 'db', 'migrate') == migrations_paths
22
20
  end
23
21
  end
24
22
  end
@@ -26,8 +24,8 @@ module RedminePluginsHelper
26
24
  end
27
25
  end
28
26
 
29
- if ::Redmine::Plugin.const_defined?('MigrationContext')
30
- ::Redmine::Plugin::MigrationContext.prepend(
31
- ::RedminePluginsHelper::Patches::Redmine::PluginMigrationContextPatch
27
+ if Redmine::Plugin.const_defined?('MigrationContext')
28
+ Redmine::Plugin::MigrationContext.prepend(
29
+ RedminePluginsHelper::Patches::Redmine::PluginMigrationContextPatch
32
30
  )
33
31
  end
@@ -12,11 +12,9 @@ module RedminePluginsHelper
12
12
  ASSETS_SUBDIRS = %w[stylesheets javascripts images].freeze
13
13
 
14
14
  ASSETS_SUBDIRS.each do |assert_subdir|
15
- class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
16
- def #{assert_subdir}_directory
17
- ::File.join(directory, 'app', 'assets', '#{assert_subdir}')
15
+ define_method "#{assert_subdir}_directory" do
16
+ ::File.join(directory, 'app', 'assets', assert_subdir)
18
17
  end
19
- RUBY_EVAL
20
18
  end
21
19
 
22
20
  def add_assets_paths
@@ -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,11 +39,13 @@ 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
46
47
  end
47
48
 
48
- patch = ::RedminePluginsHelper::Patches::Redmine::PluginPatch
49
- target = ::Redmine::Plugin
49
+ patch = RedminePluginsHelper::Patches::Redmine::PluginPatch
50
+ target = Redmine::Plugin
50
51
  target.send(:include, patch) unless target.include?(patch)
@@ -26,5 +26,7 @@ end
26
26
  unless ActiveSupport::TestCase.included_modules.include?(
27
27
  RedminePluginsHelper::Patches::TestCasePatch
28
28
  )
29
- ActiveSupport::TestCase.include RedminePluginsHelper::Patches::TestCasePatch
29
+ ActiveSupport.on_load(:active_support_test_case) do
30
+ include RedminePluginsHelper::Patches::TestCasePatch
31
+ end
30
32
  end
@@ -20,8 +20,7 @@ module RedminePluginsHelper
20
20
  def plugin_current_setting_value(plugin)
21
21
  p = ::Setting.send("plugin_#{plugin}")
22
22
  p = {} unless p.is_a?(::Hash)
23
- p = p.with_indifferent_access
24
- p
23
+ p.with_indifferent_access
25
24
  end
26
25
  end
27
26
  end
@@ -12,7 +12,7 @@ module RedminePluginsHelper
12
12
  local_versions.each do |plugin, timestamps|
13
13
  timestamps.each do |timestamp|
14
14
  m = migrated_version?(plugin, timestamp) ? 'up' : 'down'
15
- puts "#{m}\t#{plugin}\t#{timestamp}" # rubocop:disable Rails/Output
15
+ puts "#{m}\t#{plugin}\t#{timestamp}"
16
16
  end
17
17
  end
18
18
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'redmine_plugins_helper/test_tasks/base'
5
+ require 'redmine_plugins_helper/test_tasks/minitest'
6
+ require 'redmine_plugins_helper/test_tasks/rspec'
7
+
8
+ module RedminePluginsHelper
9
+ module TestTasks
10
+ class Auto < ::RedminePluginsHelper::TestTasks::Base
11
+ class Tester
12
+ enable_simple_cache
13
+ common_constructor :owner, :name, :tests_pattern
14
+ delegate :register, to: :sub
15
+
16
+ # @return [Boolean]
17
+ def available?
18
+ owner.plugin_root.glob(tests_pattern).any?
19
+ end
20
+
21
+ private
22
+
23
+ # @!method sub
24
+ # @return [RedminePluginsHelper::TestTasks::Base]
25
+ def sub_uncached
26
+ ::RedminePluginsHelper::TestTasks.const_get(name.to_s.camelize).new(owner.plugin_id, name)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'redmine_plugins_helper/test_tasks/base'
5
+ require 'rake/task'
6
+
7
+ module RedminePluginsHelper
8
+ module TestTasks
9
+ class Auto < ::RedminePluginsHelper::TestTasks::Base
10
+ TESTERS = {
11
+ minitest: 'test/**/*_test.rb',
12
+ rspec: 'spec/**/*_spec.rb'
13
+ }.freeze
14
+
15
+ enable_simple_cache
16
+
17
+ # @return [void]
18
+ def register
19
+ return unless available_testers.any?(&:available?)
20
+
21
+ available_testers.each(&:register)
22
+ ::Rake::Task.define_task(task_full_name => available_testers.map(&:name))
23
+ end
24
+
25
+ private
26
+
27
+ # @return [Array<String>]
28
+ def available_testers_uncached
29
+ TESTERS.map do |name, tests_pattern|
30
+ ::RedminePluginsHelper::TestTasks::Auto::Tester.new(self, name, tests_pattern)
31
+ end.select(&:available?)
32
+ end
33
+
34
+ require_sub __FILE__
35
+ end
36
+ end
37
+ end
@@ -9,7 +9,7 @@ module RedminePluginsHelper
9
9
  class Minitest < ::RedminePluginsHelper::TestTasks::Base
10
10
  def register
11
11
  ::Rake::TestTask.new(task_full_name => 'db:test:prepare') do |t|
12
- t.description = "Run plugin #{plugin_id}\'s tests."
12
+ t.description = "Run plugin #{plugin_id}'s tests."
13
13
  t.libs << 'test'
14
14
  t.test_files = ::FileList["#{plugin_root}/test/**/*_test.rb"]
15
15
  t.verbose = false
@@ -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.1'
6
+ VERSION = '0.14.0'
7
7
  end
@@ -2,26 +2,25 @@
2
2
 
3
3
  Rake::Task['redmine:plugins:migrate'].clear
4
4
 
5
- namespace :redmine do
5
+ namespace :redmine do # rubocop:disable Metrics/BlockLength
6
6
  desc 'Run migrations of core Redmine and installed plugins.'
7
- task migrate: ['db:migrate', 'redmine:plugins:migrate:fix', 'redmine:plugins:migrate'] do
8
- end
7
+ task migrate: ['db:migrate', 'redmine:plugins:migrate:fix', 'redmine:plugins:migrate']
9
8
 
10
9
  namespace :version do
11
10
  desc 'Shows Redmine\'s version.'
12
11
  task show: :environment do
13
- puts ::Redmine::VERSION::STRING
12
+ puts Redmine::VERSION::STRING
14
13
  end
15
14
  end
16
15
 
17
16
  task version: 'version:show'
18
17
 
19
- namespace :plugins do
18
+ namespace :plugins do # rubocop:disable Metrics/BlockLength
20
19
  desc 'Migrates installed plugins.'
21
20
  task migrate: :environment do
22
- name = ENV['NAME']
21
+ name = ENV.fetch('NAME', nil)
23
22
  version = nil
24
- version_string = ENV['VERSION']
23
+ version_string = ENV.fetch('VERSION', nil)
25
24
  if version_string
26
25
  if version_string =~ /^\d+$/
27
26
  version = version_string.to_i
@@ -42,7 +41,7 @@ namespace :redmine do
42
41
  namespace :migrate do
43
42
  desc 'Fix migrations moved from a plugin to another'
44
43
  task fix: :environment do
45
- ::RedminePluginsHelper::FixMigrations.new.perform
44
+ RedminePluginsHelper::FixMigrations.new.perform
46
45
  end
47
46
 
48
47
  desc 'Show migrations status of all plugins'
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'redmine_plugins_helper/test_tasks/rspec'
4
- ::RedminePluginsHelper::TestTasks::Rspec.register(:redmine_plugins_helper, :test)
4
+ RedminePluginsHelper::TestTasks::Rspec.register(:redmine_plugins_helper, :test)
metadata CHANGED
@@ -1,105 +1,117 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugins_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
- - 0.13.1
7
+ - 0.14.0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-22 00:00:00.000000000 Z
11
+ date: 2023-12-09 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
+ - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '2'
29
+ version: '1.4'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.4.4
27
33
  - !ruby/object:Gem::Dependency
28
- name: eac_ruby_utils
34
+ name: eac_rails_gem_support
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0.119'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.119.2
39
+ version: '0.9'
37
40
  type: :runtime
38
41
  prerelease: false
39
42
  version_requirements: !ruby/object:Gem::Requirement
40
43
  requirements:
41
44
  - - "~>"
42
45
  - !ruby/object:Gem::Version
43
- version: '0.119'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.119.2
46
+ version: '0.9'
47
47
  - !ruby/object:Gem::Dependency
48
- name: launchy
48
+ name: eac_ruby_utils
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: '0.120'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0'
60
+ version: '0.120'
61
61
  - !ruby/object:Gem::Dependency
62
- name: rspec-rails
62
+ name: launchy
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.5'
65
68
  - - ">="
66
69
  - !ruby/object:Gem::Version
67
- version: '0'
70
+ version: 2.5.2
68
71
  type: :runtime
69
72
  prerelease: false
70
73
  version_requirements: !ruby/object:Gem::Requirement
71
74
  requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.5'
72
78
  - - ">="
73
79
  - !ruby/object:Gem::Version
74
- version: '0'
80
+ version: 2.5.2
75
81
  - !ruby/object:Gem::Dependency
76
- name: sass-rails
82
+ name: rspec-rails
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
79
85
  - - "~>"
80
86
  - !ruby/object:Gem::Version
81
- version: '5.0'
87
+ version: '5.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 5.1.2
82
91
  type: :runtime
83
92
  prerelease: false
84
93
  version_requirements: !ruby/object:Gem::Requirement
85
94
  requirements:
86
95
  - - "~>"
87
96
  - !ruby/object:Gem::Version
88
- version: '5.0'
97
+ version: '5.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 5.1.2
89
101
  - !ruby/object:Gem::Dependency
90
- name: eac_ruby_gem_support
102
+ name: sass-rails
91
103
  requirement: !ruby/object:Gem::Requirement
92
104
  requirements:
93
105
  - - "~>"
94
106
  - !ruby/object:Gem::Version
95
- version: 0.5.1
96
- type: :development
107
+ version: '5.1'
108
+ type: :runtime
97
109
  prerelease: false
98
110
  version_requirements: !ruby/object:Gem::Requirement
99
111
  requirements:
100
112
  - - "~>"
101
113
  - !ruby/object:Gem::Version
102
- version: 0.5.1
114
+ version: '5.1'
103
115
  description:
104
116
  email:
105
117
  executables: []
@@ -132,6 +144,8 @@ files:
132
144
  - lib/redmine_plugins_helper/status_migrations.rb
133
145
  - lib/redmine_plugins_helper/test_config.rb
134
146
  - lib/redmine_plugins_helper/test_helper.rb
147
+ - lib/redmine_plugins_helper/test_tasks/auto.rb
148
+ - lib/redmine_plugins_helper/test_tasks/auto/tester.rb
135
149
  - lib/redmine_plugins_helper/test_tasks/base.rb
136
150
  - lib/redmine_plugins_helper/test_tasks/minitest.rb
137
151
  - lib/redmine_plugins_helper/test_tasks/rspec.rb
@@ -149,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - ">="
151
165
  - !ruby/object:Gem::Version
152
- version: '0'
166
+ version: '2.7'
153
167
  required_rubygems_version: !ruby/object:Gem::Requirement
154
168
  requirements:
155
169
  - - ">="