redmine_plugins_helper 0.13.2 → 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: 68ddbe5f5a9e060a5df5c5fc027edb7afe1b614c59074d65dd0206d2672771f1
4
- data.tar.gz: 81b45849cd58e9f8f0c7a752494f67a9c422000a3de350f64008951328851c40
3
+ metadata.gz: 10df4dddf37c82e016961e56ff729e8cd21facfea4e91ca7021483d4ca23566f
4
+ data.tar.gz: d56fdb3a4410fd56251905ce5ca3c03ecde66b38af378e5b122d77030802448f
5
5
  SHA512:
6
- metadata.gz: 8c75dfd3760e1ec4fcebaf04a5d63359fffd6e0c112189e686f1e4ebf92c3d6aa3a9821993519e65f5a40ddfabb5bd4be6d845853fce4bf9ec33a507e772e2b5
7
- data.tar.gz: 0fce8c11427cb24137480cea24f1121c5c71b2b6e5dcfe20831ebf397a90c22abe74ed06d3e8dced02568429df3611f8991b204d11901a7856a6d0dd20fc460c
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
@@ -46,6 +46,6 @@ module RedminePluginsHelper
46
46
  end
47
47
  end
48
48
 
49
- patch = ::RedminePluginsHelper::Patches::Redmine::PluginPatch
50
- target = ::Redmine::Plugin
49
+ patch = RedminePluginsHelper::Patches::Redmine::PluginPatch
50
+ target = Redmine::Plugin
51
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.2'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_plugins_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
- - 0.13.2
7
+ - 0.14.0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 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
@@ -31,25 +31,33 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.4.4
33
33
  - !ruby/object:Gem::Dependency
34
- name: eac_ruby_utils
34
+ name: eac_rails_gem_support
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.119'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.119.2
39
+ version: '0.9'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
44
  - - "~>"
48
45
  - !ruby/object:Gem::Version
49
- version: '0.119'
50
- - - ">="
46
+ version: '0.9'
47
+ - !ruby/object:Gem::Dependency
48
+ name: eac_ruby_utils
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.120'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
51
59
  - !ruby/object:Gem::Version
52
- version: 0.119.2
60
+ version: '0.120'
53
61
  - !ruby/object:Gem::Dependency
54
62
  name: launchy
55
63
  requirement: !ruby/object:Gem::Requirement
@@ -74,44 +82,36 @@ dependencies:
74
82
  name: rspec-rails
75
83
  requirement: !ruby/object:Gem::Requirement
76
84
  requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '5.1'
77
88
  - - ">="
78
89
  - !ruby/object:Gem::Version
79
- version: '0'
90
+ version: 5.1.2
80
91
  type: :runtime
81
92
  prerelease: false
82
93
  version_requirements: !ruby/object:Gem::Requirement
83
94
  requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '5.1'
84
98
  - - ">="
85
99
  - !ruby/object:Gem::Version
86
- version: '0'
100
+ version: 5.1.2
87
101
  - !ruby/object:Gem::Dependency
88
102
  name: sass-rails
89
103
  requirement: !ruby/object:Gem::Requirement
90
104
  requirements:
91
105
  - - "~>"
92
106
  - !ruby/object:Gem::Version
93
- version: '5.0'
107
+ version: '5.1'
94
108
  type: :runtime
95
109
  prerelease: false
96
110
  version_requirements: !ruby/object:Gem::Requirement
97
111
  requirements:
98
112
  - - "~>"
99
113
  - !ruby/object:Gem::Version
100
- version: '5.0'
101
- - !ruby/object:Gem::Dependency
102
- name: eac_ruby_gem_support
103
- requirement: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - "~>"
106
- - !ruby/object:Gem::Version
107
- version: 0.5.1
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - "~>"
113
- - !ruby/object:Gem::Version
114
- version: 0.5.1
114
+ version: '5.1'
115
115
  description:
116
116
  email:
117
117
  executables: []
@@ -144,6 +144,8 @@ files:
144
144
  - lib/redmine_plugins_helper/status_migrations.rb
145
145
  - lib/redmine_plugins_helper/test_config.rb
146
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
147
149
  - lib/redmine_plugins_helper/test_tasks/base.rb
148
150
  - lib/redmine_plugins_helper/test_tasks/minitest.rb
149
151
  - lib/redmine_plugins_helper/test_tasks/rspec.rb
@@ -161,7 +163,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
163
  requirements:
162
164
  - - ">="
163
165
  - !ruby/object:Gem::Version
164
- version: '0'
166
+ version: '2.7'
165
167
  required_rubygems_version: !ruby/object:Gem::Requirement
166
168
  requirements:
167
169
  - - ">="