redmine_plugins_helper 0.12.2 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/init.rb +2 -2
- data/lib/redmine_plugins_helper/patches/redmine/plugin_patch/assets.rb +54 -0
- data/lib/redmine_plugins_helper/patches/redmine/plugin_patch/dependencies.rb +89 -0
- data/lib/redmine_plugins_helper/patches/redmine/plugin_patch/initializers.rb +23 -0
- data/lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb +3 -49
- data/lib/redmine_plugins_helper/test_tasks/base.rb +36 -0
- data/lib/redmine_plugins_helper/test_tasks/minitest.rb +21 -0
- data/lib/redmine_plugins_helper/test_tasks/rspec.rb +24 -0
- data/lib/redmine_plugins_helper/version.rb +1 -1
- data/lib/tasks/redmine_plugins_helper.rake +2 -2
- metadata +13 -8
- data/lib/redmine_plugins_helper/plugin_rake_task.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa73ff7cd5b471c099d4e260d1ba1f63b78c499ee57868db67b4d323e906c784
|
4
|
+
data.tar.gz: 5b6a7e536e9943aceed8a4e662ba59990020b21ede74976f345922f4a648b3ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c685dcc238edd5d61865d24bd19a48a1e202f6fa317f565157d9c675dad44b466e4a3e0e075a9b06297adc96a35a7f0cd7dd260ca9f1d95a03d5bb231be1e1
|
7
|
+
data.tar.gz: e43b6bbe100eb0b3475cdca99b6c8d3ba2ed64f8a79f7fb9b450b29f8db00f412998c376d0ee69821e58c7dd5b4d0bcf97477bced69a986e913abb7a64cc1470
|
data/init.rb
CHANGED
@@ -14,6 +14,6 @@ end
|
|
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.
|
18
|
-
::Redmine::Plugin.
|
17
|
+
::Redmine::Plugin.all.each(&:add_assets_paths)
|
18
|
+
::Redmine::Plugin.all.each(&:load_initializers)
|
19
19
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module RedminePluginsHelper
|
6
|
+
module Patches
|
7
|
+
module Redmine
|
8
|
+
module PluginPatch
|
9
|
+
module Assets
|
10
|
+
common_concern
|
11
|
+
|
12
|
+
ASSETS_SUBDIRS = %w[stylesheets javascripts images].freeze
|
13
|
+
|
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}')
|
18
|
+
end
|
19
|
+
RUBY_EVAL
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_assets_paths
|
23
|
+
ASSETS_SUBDIRS.each do |assert_subdir|
|
24
|
+
assets_directory = send("#{assert_subdir}_directory")
|
25
|
+
next unless ::File.directory?(assets_directory)
|
26
|
+
|
27
|
+
Rails.application.config.assets.paths << assets_directory
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def main_javascript_asset_path
|
32
|
+
find_asset(javascripts_directory, %w[js coffee js.coffee])
|
33
|
+
end
|
34
|
+
|
35
|
+
def main_stylesheet_asset_path
|
36
|
+
find_asset(stylesheets_directory, %w[css scss])
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def find_asset(assets_directory, extensions)
|
42
|
+
extensions.each do |extension|
|
43
|
+
['', '.erb'].each do |erb_extension|
|
44
|
+
path = ::File.join(assets_directory, "#{id}.#{extension}#{erb_extension}")
|
45
|
+
return id if ::File.exist?(path)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module RedminePluginsHelper
|
6
|
+
module Patches
|
7
|
+
module Redmine
|
8
|
+
module PluginPatch
|
9
|
+
module Dependencies
|
10
|
+
common_concern
|
11
|
+
|
12
|
+
DEPENDENCIES_FILE_BASENAMES = %w[yml yaml].map { |e| "dependencies.#{e}" }
|
13
|
+
|
14
|
+
# @param other [Redmine::Plugin]
|
15
|
+
# @return [Integer]
|
16
|
+
def <=>(other)
|
17
|
+
so = dependency?(other)
|
18
|
+
os = other.dependency?(self)
|
19
|
+
|
20
|
+
return 1 if so && !os
|
21
|
+
return -1 if !so && os
|
22
|
+
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Array<Symbol>]
|
27
|
+
def dependencies_ids
|
28
|
+
load_dependencies_from_file
|
29
|
+
dependencies_hash.keys
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param other [Redmine::Plugin]
|
33
|
+
# @return [Boolean]
|
34
|
+
def dependency?(other)
|
35
|
+
load_dependencies_from_file
|
36
|
+
recursive_dependencies_ids.include?(other.id)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param plugin_name [Symbol]
|
40
|
+
# @param arg [Hash, String]
|
41
|
+
# @return [Boolean]
|
42
|
+
def requires_redmine_plugin(plugin_name, arg)
|
43
|
+
r = super
|
44
|
+
dependencies_hash[plugin_name.to_sym] = arg
|
45
|
+
r
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# @return [Hash<Symbol, Object>]
|
51
|
+
def dependencies_hash
|
52
|
+
@dependencies_hash ||= {}
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Hash<Symbol, Object>]
|
56
|
+
def dependencies_from_file
|
57
|
+
r = dependencies_file.if_present({}) { |path| ::EacRubyUtils::Yaml.load_file(path) }
|
58
|
+
r = r.map do |plugin_name, arg|
|
59
|
+
[plugin_name.to_sym, (arg.is_a?(::Hash) ? arg.symbolize_keys : arg)]
|
60
|
+
end
|
61
|
+
r.to_h
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [Pathname, nil]
|
65
|
+
def dependencies_file
|
66
|
+
DEPENDENCIES_FILE_BASENAMES
|
67
|
+
.lazy
|
68
|
+
.map { |b| directory.to_pathname.join(b) }.select(&:file?).first
|
69
|
+
end
|
70
|
+
|
71
|
+
# @return [void]
|
72
|
+
def load_dependencies_from_file
|
73
|
+
return if @dependencies_from_file_loaded
|
74
|
+
|
75
|
+
dependencies_from_file
|
76
|
+
.each { |plugin_name, arg| requires_redmine_plugin(plugin_name, arg) }
|
77
|
+
@dependencies_from_file_loaded = true
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Set<Symbol>]
|
81
|
+
def recursive_dependencies_ids
|
82
|
+
::EacRubyUtils::RecursiveBuilder
|
83
|
+
.new(id) { |plugin_id| ::Redmine::Plugin.find(plugin_id).dependencies_ids }.result
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module RedminePluginsHelper
|
6
|
+
module Patches
|
7
|
+
module Redmine
|
8
|
+
module PluginPatch
|
9
|
+
module Initializers
|
10
|
+
def load_initializers
|
11
|
+
Dir["#{initializers_directory}/*.rb"].sort.each { |f| require f }
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def initializers_directory
|
17
|
+
File.join(directory, 'config', 'initializers')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -11,10 +11,11 @@ module RedminePluginsHelper
|
|
11
11
|
included do
|
12
12
|
extend ClassMethods
|
13
13
|
include InstanceMethods
|
14
|
+
include ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Assets
|
15
|
+
prepend ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Dependencies
|
16
|
+
include ::RedminePluginsHelper::Patches::Redmine::PluginPatch::Initializers
|
14
17
|
end
|
15
18
|
|
16
|
-
ASSETS_SUBDIRS = %w[stylesheets javascripts images].freeze
|
17
|
-
|
18
19
|
module ClassMethods
|
19
20
|
def by_path(path)
|
20
21
|
plugin_id_from_path(path).if_present do |v|
|
@@ -39,53 +40,6 @@ module RedminePluginsHelper
|
|
39
40
|
plugin.instance_eval(&block)
|
40
41
|
end
|
41
42
|
end
|
42
|
-
|
43
|
-
module InstanceMethods
|
44
|
-
def load_initializers
|
45
|
-
Dir["#{initializers_directory}/*.rb"].sort.each { |f| require f }
|
46
|
-
end
|
47
|
-
|
48
|
-
ASSETS_SUBDIRS.each do |assert_subdir|
|
49
|
-
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
50
|
-
def #{assert_subdir}_directory
|
51
|
-
::File.join(directory, 'app', 'assets', '#{assert_subdir}')
|
52
|
-
end
|
53
|
-
RUBY_EVAL
|
54
|
-
end
|
55
|
-
|
56
|
-
def add_assets_paths
|
57
|
-
ASSETS_SUBDIRS.each do |assert_subdir|
|
58
|
-
assets_directory = send("#{assert_subdir}_directory")
|
59
|
-
next unless ::File.directory?(assets_directory)
|
60
|
-
|
61
|
-
Rails.application.config.assets.paths << assets_directory
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def main_javascript_asset_path
|
66
|
-
find_asset(javascripts_directory, %w[js coffee js.coffee])
|
67
|
-
end
|
68
|
-
|
69
|
-
def main_stylesheet_asset_path
|
70
|
-
find_asset(stylesheets_directory, %w[css scss])
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def initializers_directory
|
76
|
-
File.join(directory, 'config', 'initializers')
|
77
|
-
end
|
78
|
-
|
79
|
-
def find_asset(assets_directory, extensions)
|
80
|
-
extensions.each do |extension|
|
81
|
-
['', '.erb'].each do |erb_extension|
|
82
|
-
path = ::File.join(assets_directory, "#{id}.#{extension}#{erb_extension}")
|
83
|
-
return id if ::File.exist?(path)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
nil
|
87
|
-
end
|
88
|
-
end
|
89
43
|
end
|
90
44
|
end
|
91
45
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module RedminePluginsHelper
|
6
|
+
module TestTasks
|
7
|
+
class Base
|
8
|
+
acts_as_abstract :register
|
9
|
+
DEFAULT_TASK_NAME_LAST_PART = 'test'
|
10
|
+
PREPARE_TASK_NAME = 'db:test:prepare'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def register(plugin_id, task_name_last_part = DEFAULT_TASK_NAME_LAST_PART)
|
14
|
+
new(plugin_id, task_name_last_part).register
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
common_constructor :plugin_id, :task_name_last_part
|
19
|
+
|
20
|
+
# @return [Pathname]
|
21
|
+
def plugin_root
|
22
|
+
::Rails.root.join('plugins', plugin_id.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String]
|
26
|
+
def prepare_task_name
|
27
|
+
PREPARE_TASK_NAME
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def task_full_name
|
32
|
+
"#{plugin_id}:#{task_name_last_part}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'redmine_plugins_helper/test_tasks/base'
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
module RedminePluginsHelper
|
8
|
+
module TestTasks
|
9
|
+
class Minitest < ::RedminePluginsHelper::TestTasks::Base
|
10
|
+
def register
|
11
|
+
::Rake::TestTask.new(task_full_name => 'db:test:prepare') do |t|
|
12
|
+
t.description = "Run plugin #{plugin_id}\'s tests."
|
13
|
+
t.libs << 'test'
|
14
|
+
t.test_files = ::FileList["#{plugin_root}/test/**/*_test.rb"]
|
15
|
+
t.verbose = false
|
16
|
+
t.warning = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'redmine_plugins_helper/test_tasks/base'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
module RedminePluginsHelper
|
8
|
+
module TestTasks
|
9
|
+
class Rspec < ::RedminePluginsHelper::TestTasks::Base
|
10
|
+
def register
|
11
|
+
::RSpec::Core::RakeTask.new(task_full_name) do |t|
|
12
|
+
t.rspec_opts = ::Shellwords.join(rspec_opts)
|
13
|
+
end
|
14
|
+
::Rake::Task[task_full_name].enhance [prepare_task_name]
|
15
|
+
end
|
16
|
+
|
17
|
+
def rspec_opts
|
18
|
+
['--pattern', plugin_root.join('spec/**/*_spec.rb'),
|
19
|
+
'--default-path', 'plugins/redmine_plugins_helper/spec',
|
20
|
+
'--require', 'spec_helper']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'redmine_plugins_helper/
|
4
|
-
::RedminePluginsHelper::
|
3
|
+
require 'redmine_plugins_helper/test_tasks/rspec'
|
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.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- 0.
|
7
|
+
- 0.13.0
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -30,20 +30,20 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.119'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.119.2
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0.
|
43
|
+
version: '0.119'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.119.2
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: launchy
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,12 +124,17 @@ files:
|
|
124
124
|
- lib/redmine_plugins_helper/migrations.rb
|
125
125
|
- lib/redmine_plugins_helper/patches/redmine/plugin_migration_context.rb
|
126
126
|
- lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb
|
127
|
+
- lib/redmine_plugins_helper/patches/redmine/plugin_patch/assets.rb
|
128
|
+
- lib/redmine_plugins_helper/patches/redmine/plugin_patch/dependencies.rb
|
129
|
+
- lib/redmine_plugins_helper/patches/redmine/plugin_patch/initializers.rb
|
127
130
|
- lib/redmine_plugins_helper/patches/test_case_patch.rb
|
128
|
-
- lib/redmine_plugins_helper/plugin_rake_task.rb
|
129
131
|
- lib/redmine_plugins_helper/settings.rb
|
130
132
|
- lib/redmine_plugins_helper/status_migrations.rb
|
131
133
|
- lib/redmine_plugins_helper/test_config.rb
|
132
134
|
- lib/redmine_plugins_helper/test_helper.rb
|
135
|
+
- lib/redmine_plugins_helper/test_tasks/base.rb
|
136
|
+
- lib/redmine_plugins_helper/test_tasks/minitest.rb
|
137
|
+
- lib/redmine_plugins_helper/test_tasks/rspec.rb
|
133
138
|
- lib/redmine_plugins_helper/version.rb
|
134
139
|
- lib/tasks/redmine.rake
|
135
140
|
- lib/tasks/redmine_plugins_helper.rake
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'eac_ruby_utils/core_ext'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
require 'shellwords'
|
6
|
-
|
7
|
-
module RedminePluginsHelper
|
8
|
-
class PluginRakeTask
|
9
|
-
DEFAULT_TASK_NAME_LAST_PART = 'rspec'
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def register(plugin_id, task_name_last_part = DEFAULT_TASK_NAME_LAST_PART)
|
13
|
-
new(plugin_id, task_name_last_part).register
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
common_constructor :plugin_id, :task_name_last_part
|
18
|
-
|
19
|
-
def register
|
20
|
-
::RSpec::Core::RakeTask.new(task_full_name) do |t|
|
21
|
-
t.rspec_opts = ::Shellwords.join(rspec_opts)
|
22
|
-
end
|
23
|
-
Rake::Task[task_full_name].enhance ['db:test:prepare']
|
24
|
-
end
|
25
|
-
|
26
|
-
def task_full_name
|
27
|
-
"#{plugin_id}:#{task_name_last_part}"
|
28
|
-
end
|
29
|
-
|
30
|
-
def rspec_opts
|
31
|
-
['--pattern', "plugins/#{plugin_id}/spec/**/*_spec.rb",
|
32
|
-
'--default-path', 'plugins/redmine_plugins_helper/spec',
|
33
|
-
'--require', 'spec_helper']
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|