redmine_extensions 0.6.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -32
- data/Rakefile +0 -8
- data/app/assets/javascripts/redmine_extensions/blocking.js +0 -2
- data/app/assets/javascripts/redmine_extensions/blocking_namespace.js +1 -2
- data/app/assets/javascripts/redmine_extensions/blocking_render.js +1 -27
- data/app/assets/javascripts/redmine_extensions/redmine_extensions.js +1 -33
- data/config/routes.rb +0 -7
- data/lib/redmine_extensions/easy_settings.rb +5 -5
- data/lib/redmine_extensions/engine.rb +12 -32
- data/lib/redmine_extensions/hooks.rb +6 -35
- data/lib/redmine_extensions/version.rb +1 -1
- data/lib/redmine_extensions.rb +5 -2
- data/spec/spec_helper.rb +10 -2
- metadata +3 -75
- data/app/assets/javascripts/redmine_extensions/blocking_schedule.js +0 -280
- data/app/assets/javascripts/redmine_extensions/event_bus.js +0 -61
- data/app/assets/stylesheets/redmine_extensions/application.css +0 -15
- data/lib/generators/redmine_extensions/entity/USAGE +0 -11
- data/lib/generators/redmine_extensions/entity/entity_generator.rb +0 -418
- data/lib/generators/redmine_extensions/entity/templates/_form.html.erb.erb +0 -51
- data/lib/generators/redmine_extensions/entity/templates/_list.html.erb.erb +0 -70
- data/lib/generators/redmine_extensions/entity/templates/_sidebar.html.erb.erb +0 -9
- data/lib/generators/redmine_extensions/entity/templates/app/models/%model_name_underscored%_query.rb.tt +0 -42
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/_%model_name_underscored%.api.rsb.tt +0 -18
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/_form.html.erb.tt +0 -62
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/edit.html.erb.tt +0 -8
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/new.html.erb.tt +0 -8
- data/lib/generators/redmine_extensions/entity/templates/context_menu.html.erb.erb +0 -20
- data/lib/generators/redmine_extensions/entity/templates/controller.rb.erb +0 -208
- data/lib/generators/redmine_extensions/entity/templates/custom_field.rb.erb +0 -11
- data/lib/generators/redmine_extensions/entity/templates/easy_query.rb.erb +0 -37
- data/lib/generators/redmine_extensions/entity/templates/edit.html.erb.erb +0 -19
- data/lib/generators/redmine_extensions/entity/templates/edit.js.erb.erb +0 -18
- data/lib/generators/redmine_extensions/entity/templates/en.yml.erb +0 -16
- data/lib/generators/redmine_extensions/entity/templates/entity_attribute_helper_patch.rb.erb +0 -10
- data/lib/generators/redmine_extensions/entity/templates/helper.rb.erb +0 -3
- data/lib/generators/redmine_extensions/entity/templates/hooks.rb.erb +0 -5
- data/lib/generators/redmine_extensions/entity/templates/index.api.rsb.erb +0 -3
- data/lib/generators/redmine_extensions/entity/templates/index.html.erb.erb +0 -30
- data/lib/generators/redmine_extensions/entity/templates/index.js.erb.erb +0 -12
- data/lib/generators/redmine_extensions/entity/templates/mail_added.html.erb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/mail_added.text.erb.erb +0 -2
- data/lib/generators/redmine_extensions/entity/templates/mail_updated.html.erb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/mail_updated.text.erb.erb +0 -2
- data/lib/generators/redmine_extensions/entity/templates/mailer.rb.erb +0 -41
- data/lib/generators/redmine_extensions/entity/templates/migration.rb.erb +0 -16
- data/lib/generators/redmine_extensions/entity/templates/model.rb.erb +0 -143
- data/lib/generators/redmine_extensions/entity/templates/new.html.erb.erb +0 -19
- data/lib/generators/redmine_extensions/entity/templates/new.js.erb.erb +0 -18
- data/lib/generators/redmine_extensions/entity/templates/query.rb.erb +0 -67
- data/lib/generators/redmine_extensions/entity/templates/routes.rb.erb +0 -15
- data/lib/generators/redmine_extensions/entity/templates/show.api.rsb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/show.html.erb.erb +0 -50
- data/lib/generators/redmine_extensions/entity/templates/show.js.erb.erb +0 -12
- data/lib/generators/redmine_extensions/entity/templates/spec/controllers/%model_name_underscored%_controller_spec.rb.tt +0 -94
- data/lib/generators/redmine_extensions/entity/templates/spec/factories.rb.erb +0 -11
- data/lib/generators/redmine_extensions/entity/templates/spec/requests/%model_name_underscored%_spec.rb.tt +0 -19
- data/lib/generators/redmine_extensions/plugin/USAGE +0 -13
- data/lib/generators/redmine_extensions/plugin/plugin_generator.rb +0 -74
- data/lib/generators/redmine_extensions/plugin/templates/Gemfile.erb +0 -1
- data/lib/generators/redmine_extensions/plugin/templates/after_init.rb.erb +0 -23
- data/lib/generators/redmine_extensions/plugin/templates/en.yml.erb +0 -3
- data/lib/generators/redmine_extensions/plugin/templates/gitkeep.erb +0 -0
- data/lib/generators/redmine_extensions/plugin/templates/hooks.rb.erb +0 -5
- data/lib/generators/redmine_extensions/plugin/templates/init.rb.erb +0 -20
- data/lib/generators/redmine_extensions/plugin/templates/internals.rb.erb +0 -4
- data/lib/generators/redmine_extensions/plugin/templates/issue_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/issues_controller_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/issues_helper_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/javascript.js +0 -1
- data/lib/generators/redmine_extensions/plugin/templates/routes.rb.erb +0 -0
- data/lib/generators/redmine_extensions/plugin/templates/stylesheet.css +0 -3
- data/lib/redmine_extensions/core_ext/date_range.rb +0 -152
- data/lib/redmine_extensions/core_ext/object.rb +0 -19
- data/lib/redmine_extensions/core_ext/string.rb +0 -5
- data/lib/redmine_extensions/core_ext.rb +0 -3
- data/lib/redmine_extensions/deprecator.rb +0 -11
- data/lib/redmine_extensions/migration.rb +0 -9
- data/lib/redmine_extensions/patch_manager.rb +0 -440
- data/lib/redmine_extensions/rails_patches/route_set_generator_patch.rb +0 -10
- data/lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb +0 -65
- data/lib/redmine_extensions/redmine_patches/models/custom_field_patch.rb +0 -11
- data/lib/redmine_extensions/redmine_patches/models/project_patch.rb +0 -10
- data/lib/tasks/redmine_extensions_tasks.rake +0 -4
- data/spec/init_rails.rb +0 -13
@@ -1,440 +0,0 @@
|
|
1
|
-
module RedmineExtensions
|
2
|
-
|
3
|
-
class PatchManager
|
4
|
-
|
5
|
-
PERSISTING_PATCHES = [:force_first, :ruby, :rails, :redmine_plugins, :others]
|
6
|
-
|
7
|
-
@@patches_locations = {}
|
8
|
-
|
9
|
-
@@reloading_code = false
|
10
|
-
@@reloadable_patches_applied = 0
|
11
|
-
|
12
|
-
# is called after EasyPatchesSection load
|
13
|
-
def self.initialize_sections
|
14
|
-
@@registered_patches ||= ActiveSupport::OrderedHash.new
|
15
|
-
@@registered_patches[:force_first] ||= EasyPatchesSection.new
|
16
|
-
@@registered_patches[:ruby] ||= EasyPatchesSection.new
|
17
|
-
@@registered_patches[:rails] ||= EasyPatchesSection.new
|
18
|
-
@@registered_patches[:redmine_plugins] ||= EasyPatchesSection.new
|
19
|
-
@@registered_patches[:others] ||= EasyPatchesSection.new
|
20
|
-
@@registered_patches[:concerns] ||= EasyPatchesSection.new
|
21
|
-
@@registered_patches[:controllers] ||= EasyPatchesSection.new
|
22
|
-
@@registered_patches[:helpers] ||= EasyPatchesSection.new
|
23
|
-
@@registered_patches[:models] ||= EasyPatchesSection.new
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.patches_locations
|
27
|
-
@@patches_locations
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.with_reloading_code
|
31
|
-
@@reloading_code = true
|
32
|
-
yield
|
33
|
-
ensure
|
34
|
-
@@reloading_code = false
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.reloadable_patches_applied
|
38
|
-
@@reloadable_patches_applied
|
39
|
-
end
|
40
|
-
|
41
|
-
# register_patch
|
42
|
-
# => original_klass_to_patch: 'Project', 'CustomField'
|
43
|
-
# => patching_module: 'EasyPatch::MembersHelperPatch'
|
44
|
-
# => options:
|
45
|
-
# => :first
|
46
|
-
# => :before => 'CustomField'
|
47
|
-
# => :after => 'Project'
|
48
|
-
# => :last
|
49
|
-
# => :if => Proc.new{ Object.const_defined?(:EasyBudgetSheetQuery) }
|
50
|
-
def self.register_patch(original_klasses_to_patch, patching_module, options = {})
|
51
|
-
return if @@reloading_code
|
52
|
-
|
53
|
-
options ||= {}
|
54
|
-
|
55
|
-
begin
|
56
|
-
const = patching_module.constantize
|
57
|
-
@@patches_locations[patching_module] = const.methods(false).map { |m| const.method(m) }.first.source_location.first
|
58
|
-
rescue
|
59
|
-
# [0] is register_*_patch
|
60
|
-
from_location = caller_locations(2..2).first
|
61
|
-
@@patches_locations[patching_module] = from_location.absolute_path
|
62
|
-
end
|
63
|
-
|
64
|
-
raise ArgumentError, 'EasyPatchManager->register_patch: The \'patching_module\' have to be a string!' unless patching_module.is_a?(String)
|
65
|
-
|
66
|
-
if original_klasses_to_patch.is_a?(String)
|
67
|
-
original_klasses_to_patch = [original_klasses_to_patch]
|
68
|
-
elsif original_klasses_to_patch.is_a?(Array)
|
69
|
-
original_klasses_to_patch = original_klasses_to_patch.collect(&:to_s)
|
70
|
-
else
|
71
|
-
raise ArgumentError, 'EasyPatchManager->register_patch: The \'original_klass_to_patch\' have to be a string or array of strings!'
|
72
|
-
end
|
73
|
-
|
74
|
-
raise ArgumentError, "EasyPatchManager->register_patch: The \'patching_module\' (#{patching_module}) already exists!" if EasyPatch.all_patching_modules.include?(patching_module)
|
75
|
-
|
76
|
-
if options[:section]
|
77
|
-
section = options.delete(:section).to_sym
|
78
|
-
end
|
79
|
-
section ||= :others
|
80
|
-
|
81
|
-
raise ArgumentError, "EasyPatchManager->register_patch: The section (#{section}) must be one of x#{@@registered_patches.keys.join(', ')}x " unless @@registered_patches.key?(section)
|
82
|
-
|
83
|
-
original_klasses_to_patch.each do |original_klass_to_patch|
|
84
|
-
pcollection = @@registered_patches[section].move_and_get_or_insert(original_klass_to_patch, options)
|
85
|
-
pcollection << EasyPatch.new(original_klass_to_patch, patching_module, options)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
private_class_method :register_patch
|
90
|
-
|
91
|
-
def self.register_ruby_patch(original_klass_to_patch, patching_module, options = {})
|
92
|
-
register_patch(original_klass_to_patch, patching_module, { section: :ruby }.merge(options))
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.register_rails_patch(original_klass_to_patch, patching_module, options = {})
|
96
|
-
register_patch(original_klass_to_patch, patching_module, { section: :rails }.merge(options))
|
97
|
-
end
|
98
|
-
|
99
|
-
def self.register_redmine_plugin_patch(original_klass_to_patch, patching_module, options = {})
|
100
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :redmine_plugins }.merge(options))
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.register_other_patch(original_klass_to_patch, patching_module, options = {})
|
104
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :others }.merge(options))
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.register_concern_patch(original_klass_to_patch, patching_module, options = {})
|
108
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :concerns }.merge(options))
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.register_controller_patch(original_klass_to_patch, patching_module, options = {})
|
112
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :controllers }.merge(options))
|
113
|
-
end
|
114
|
-
|
115
|
-
def self.register_helper_patch(original_klass_to_patch, patching_module, options = {})
|
116
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :helpers }.merge(options))
|
117
|
-
end
|
118
|
-
|
119
|
-
def self.register_model_patch(original_klass_to_patch, patching_module, options = {})
|
120
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :models }.merge(options))
|
121
|
-
end
|
122
|
-
|
123
|
-
def self.register_patch_to_be_first(original_klass_to_patch, patching_module, options = {})
|
124
|
-
register_patch(original_klass_to_patch, patching_module, { :section => :force_first }.merge(options))
|
125
|
-
end
|
126
|
-
|
127
|
-
def self.register_easy_page_helper(*helper_or_helpers_klass_name)
|
128
|
-
@registered_easy_page_helpers ||= []
|
129
|
-
helper_or_helpers_klass_name.each do |helper_klass_name|
|
130
|
-
@registered_easy_page_helpers << helper_klass_name if !@registered_easy_page_helpers.include?(helper_klass_name)
|
131
|
-
end
|
132
|
-
@registered_easy_page_helpers
|
133
|
-
end
|
134
|
-
|
135
|
-
def self.register_easy_page_controller(*controller_or_controllers_klass_name)
|
136
|
-
@registered_easy_page_controllers ||= []
|
137
|
-
controller_or_controllers_klass_name.each do |controller_klass_name|
|
138
|
-
@registered_easy_page_controllers << controller_klass_name if !@registered_easy_page_controllers.include?(controller_klass_name)
|
139
|
-
end
|
140
|
-
@registered_easy_page_controllers
|
141
|
-
end
|
142
|
-
|
143
|
-
def self.apply_easy_page_patches
|
144
|
-
return if @registered_easy_page_controllers.nil? || @registered_easy_page_helpers.nil?
|
145
|
-
@registered_easy_page_controllers.each do |controller_klass_name|
|
146
|
-
controller_klass = controller_klass_name.constantize
|
147
|
-
|
148
|
-
@registered_easy_page_helpers.each do |helper_klass_name|
|
149
|
-
if helper_klass_name.end_with?('Helper')
|
150
|
-
helper_klass_symbol = helper_klass_name[0, helper_klass_name.index('Helper')]
|
151
|
-
end
|
152
|
-
|
153
|
-
controller_klass.class_eval "helper :#{helper_klass_symbol.underscore}" if helper_klass_symbol
|
154
|
-
controller_klass.class_eval "include #{helper_klass_name}"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def self.apply_persisting_patches
|
160
|
-
PERSISTING_PATCHES.each do |section|
|
161
|
-
@@registered_patches[section].apply_all_patches
|
162
|
-
end
|
163
|
-
|
164
|
-
true
|
165
|
-
end
|
166
|
-
|
167
|
-
def self.apply_reloadable_patches
|
168
|
-
(@@registered_patches.keys - PERSISTING_PATCHES).each do |section|
|
169
|
-
reloading_log "Applying #{section} patches (#{@@registered_patches[section].count})"
|
170
|
-
@@registered_patches[section].apply_all_patches
|
171
|
-
end
|
172
|
-
|
173
|
-
reloading_log("Applying page module patches")
|
174
|
-
apply_easy_page_patches
|
175
|
-
|
176
|
-
@@reloadable_patches_applied += 1
|
177
|
-
true
|
178
|
-
end
|
179
|
-
|
180
|
-
def self.reloading_log(message)
|
181
|
-
return if @@reloadable_patches_applied <= 1
|
182
|
-
puts "PatchManager: #{message}"
|
183
|
-
end
|
184
|
-
|
185
|
-
class EasyPatchesSection
|
186
|
-
include Enumerable
|
187
|
-
|
188
|
-
# attr_reader :name, :order
|
189
|
-
|
190
|
-
def initialize #( name = nil, order = nil )
|
191
|
-
# raise ArgumentError, 'Section order has to be a integer!' unless order.is_a?(Numeric)
|
192
|
-
# @name = name
|
193
|
-
# @order = order
|
194
|
-
@patches_collections = []
|
195
|
-
@last_order = 0
|
196
|
-
end
|
197
|
-
|
198
|
-
def each(&block)
|
199
|
-
@patches_collections.each do |patch_collection|
|
200
|
-
yield patch_collection
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def apply_all_patches
|
205
|
-
@patches_collections.each do |patch_collection|
|
206
|
-
patch_collection.apply_all_patches
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def [](name)
|
211
|
-
pcollection = @patches_collections.detect { |patch_col| patch_col.name == name }
|
212
|
-
end
|
213
|
-
|
214
|
-
def include_patch?(name)
|
215
|
-
!!@patches_collections.detect { |patch_col| patch_col.name == name }
|
216
|
-
end
|
217
|
-
|
218
|
-
def move_and_get_or_insert(name, options)
|
219
|
-
pcollection = @patches_collections.detect { |patch_col| patch_col.name == name }
|
220
|
-
founded_order = find_order(options)
|
221
|
-
if pcollection
|
222
|
-
if founded_order
|
223
|
-
pcollection.order = founded_order
|
224
|
-
update_order_by(pcollection)
|
225
|
-
end
|
226
|
-
else
|
227
|
-
pcollection = insert(name, founded_order)
|
228
|
-
end
|
229
|
-
pcollection
|
230
|
-
end
|
231
|
-
|
232
|
-
def find_order(options)
|
233
|
-
if options.delete(:first)
|
234
|
-
return 1
|
235
|
-
elsif before = options.delete(:before)
|
236
|
-
|
237
|
-
if before.is_a? Array
|
238
|
-
min = nil
|
239
|
-
before.each do |before_class_name|
|
240
|
-
actual = nil
|
241
|
-
before_patch = self[before_class_name]
|
242
|
-
actual = before_patch.order if before_patch
|
243
|
-
if actual && (!min || actual < min)
|
244
|
-
min = actual
|
245
|
-
end
|
246
|
-
end
|
247
|
-
return min
|
248
|
-
else
|
249
|
-
before_patch = self[before]
|
250
|
-
return before_patch.order + 1 if before_patch
|
251
|
-
end
|
252
|
-
|
253
|
-
elsif after = options.delete(:after)
|
254
|
-
|
255
|
-
if after.is_a? Array
|
256
|
-
max = -1
|
257
|
-
after.each do |after_class_name|
|
258
|
-
actual = nil
|
259
|
-
after_patch = self[after_class_name]
|
260
|
-
actual = after_patch.order + 1 if after_patch
|
261
|
-
if actual && actual > max
|
262
|
-
max = actual
|
263
|
-
end
|
264
|
-
end
|
265
|
-
return max
|
266
|
-
else
|
267
|
-
after_patch = self[after]
|
268
|
-
return after_patch.order + 1 if after_patch
|
269
|
-
end
|
270
|
-
|
271
|
-
elsif options.delete(:last)
|
272
|
-
# do nothing
|
273
|
-
end
|
274
|
-
|
275
|
-
nil
|
276
|
-
end
|
277
|
-
|
278
|
-
private
|
279
|
-
|
280
|
-
def push_back(collection)
|
281
|
-
# => ambitious, if it is private method...
|
282
|
-
# raise ArgumentError, "Section already contains a collection #{collection.name}" if @patches_collections.detect{ |coll| collection.name == coll.name }
|
283
|
-
@patches_collections << collection
|
284
|
-
end
|
285
|
-
|
286
|
-
def last_order
|
287
|
-
@last_order += 1
|
288
|
-
end
|
289
|
-
|
290
|
-
def insert(name, order = nil)
|
291
|
-
final_order = order || last_order
|
292
|
-
collection = EasyPatchesCollection.new(name, final_order)
|
293
|
-
push_back(collection)
|
294
|
-
update_order_by(collection) if order
|
295
|
-
collection
|
296
|
-
end
|
297
|
-
|
298
|
-
def update_order_by(collection)
|
299
|
-
@patches_collections.select { |patch_coll| (patch_coll.name != collection.name) && (patch_coll.order >= collection.order) }.each do |col|
|
300
|
-
col.order = col.order + 1
|
301
|
-
end
|
302
|
-
@patches_collections.sort!
|
303
|
-
end
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
initialize_sections
|
308
|
-
|
309
|
-
class EasyPatchesCollection
|
310
|
-
|
311
|
-
include Comparable
|
312
|
-
include Enumerable
|
313
|
-
|
314
|
-
attr_reader :name, :patches
|
315
|
-
attr_accessor :order
|
316
|
-
|
317
|
-
def initialize(name, order = nil)
|
318
|
-
@name = name
|
319
|
-
@patches = []
|
320
|
-
@order = order || 0
|
321
|
-
end
|
322
|
-
|
323
|
-
alias_method :original_klass_to_patch, :name
|
324
|
-
|
325
|
-
def apply_all_patches
|
326
|
-
@patches.each do |ep|
|
327
|
-
ep.apply_patch
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
def each(&block)
|
332
|
-
|
333
|
-
@patches.each do |patch|
|
334
|
-
yield patch
|
335
|
-
end
|
336
|
-
|
337
|
-
end
|
338
|
-
|
339
|
-
def <<(ep)
|
340
|
-
raise ArgumentError, 'patch class have to be a EasyPatch!' unless ep.is_a?(EasyPatch)
|
341
|
-
@patches << ep
|
342
|
-
end
|
343
|
-
|
344
|
-
def <=> other
|
345
|
-
self.order <=> other.order
|
346
|
-
end
|
347
|
-
|
348
|
-
end
|
349
|
-
|
350
|
-
class EasyPatch
|
351
|
-
|
352
|
-
def self.all_patching_modules
|
353
|
-
@@all_patching_modules ||= []
|
354
|
-
end
|
355
|
-
|
356
|
-
def all_patching_modules
|
357
|
-
self.class.all_patching_modules
|
358
|
-
end
|
359
|
-
|
360
|
-
attr_accessor :original_klass_to_patch, :patching_module, :options
|
361
|
-
|
362
|
-
def initialize(original_klass_to_patch, patching_module, options = {})
|
363
|
-
@original_klass_to_patch, @patching_module, @options = original_klass_to_patch, patching_module, options
|
364
|
-
all_patching_modules << patching_module
|
365
|
-
end
|
366
|
-
|
367
|
-
def to_s
|
368
|
-
"#{@original_klass_to_patch} <= #{@patching_module}"
|
369
|
-
end
|
370
|
-
|
371
|
-
def inspect
|
372
|
-
to_s
|
373
|
-
end
|
374
|
-
|
375
|
-
def apply_patch
|
376
|
-
return if (cond = @options[:if]) && cond.respond_to?(:call) && !cond.call
|
377
|
-
|
378
|
-
pm_klass = easy_constantize(patching_module)
|
379
|
-
# pm_klass.class_eval { unloadable }
|
380
|
-
|
381
|
-
oktp_klass = easy_constantize(original_klass_to_patch)
|
382
|
-
|
383
|
-
if oktp_klass.include?(pm_klass)
|
384
|
-
puts "Patch (#{oktp_klass} #{pm_klass}) is already included!"
|
385
|
-
else
|
386
|
-
if @options[:prepend]
|
387
|
-
oktp_klass.prepend pm_klass
|
388
|
-
else
|
389
|
-
oktp_klass.include pm_klass
|
390
|
-
end
|
391
|
-
end
|
392
|
-
rescue NameError => e
|
393
|
-
patch_location = Module.const_source_location(patching_module)
|
394
|
-
raise NameError, "#{e.message} in #{patch_location}"
|
395
|
-
end
|
396
|
-
|
397
|
-
def easy_constantize(name)
|
398
|
-
name.constantize
|
399
|
-
rescue NameError
|
400
|
-
if RedmineExtensions::PatchManager.patches_locations.has_key?(name)
|
401
|
-
RedmineExtensions::PatchManager.with_reloading_code do
|
402
|
-
load RedmineExtensions::PatchManager.patches_locations[patching_module]
|
403
|
-
end
|
404
|
-
|
405
|
-
name.constantize
|
406
|
-
else
|
407
|
-
raise
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
end
|
414
|
-
|
415
|
-
module Reloader
|
416
|
-
def self.to_prepare(*args, &block)
|
417
|
-
if defined? ActiveSupport::Reloader
|
418
|
-
ActiveSupport::Reloader.to_prepare(*args, &block)
|
419
|
-
else
|
420
|
-
ActionDispatch::Reloader.to_prepare(*args, &block)
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
def self.to_cleanup(*args, &block)
|
425
|
-
if defined? ActiveSupport::Reloader
|
426
|
-
ActiveSupport::Reloader.to_complete(*args, &block)
|
427
|
-
else
|
428
|
-
ActionDispatch::Reloader.to_cleanup(*args, &block)
|
429
|
-
end
|
430
|
-
end
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
ActiveSupport.on_load(:easyproject, yield: true) do
|
435
|
-
RedmineExtensions::PatchManager.apply_persisting_patches
|
436
|
-
end
|
437
|
-
|
438
|
-
RedmineExtensions::Reloader.to_prepare do
|
439
|
-
RedmineExtensions::PatchManager.apply_reloadable_patches
|
440
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
module RedmineExtensions
|
2
|
-
module ApplicationControllerPatch
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.extend ClassMethods
|
6
|
-
base.include InstanceMethods
|
7
|
-
|
8
|
-
base.class_eval do
|
9
|
-
helper_method :easy_extensions?
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module InstanceMethods
|
14
|
-
|
15
|
-
def index_for_easy_query(query_klass, *)
|
16
|
-
@query = query_klass.new(name: '_')
|
17
|
-
@query.project = @project
|
18
|
-
@query.build_from_params(params)
|
19
|
-
|
20
|
-
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
|
21
|
-
sort_update(@query.sortable_columns)
|
22
|
-
|
23
|
-
@entities = @query.entities
|
24
|
-
end
|
25
|
-
|
26
|
-
def easy_extensions?
|
27
|
-
self.class.easy_extensions?
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def save_easy_settings(project = nil)
|
33
|
-
if params[:easy_setting]
|
34
|
-
wrapper = EasySettings::ParamsWrapper.from_params(params.require(:easy_setting).permit!, project: project)
|
35
|
-
wrapper.save
|
36
|
-
wrapper
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
module ClassMethods
|
43
|
-
|
44
|
-
def easy_extensions?
|
45
|
-
Redmine::Plugin.installed?(:easy_extensions)
|
46
|
-
end
|
47
|
-
|
48
|
-
def include_query_helpers
|
49
|
-
if easy_extensions?
|
50
|
-
helper :easy_query
|
51
|
-
include EasyQueryHelper
|
52
|
-
else
|
53
|
-
helper :queries
|
54
|
-
include QueriesHelper
|
55
|
-
end
|
56
|
-
|
57
|
-
helper :sort
|
58
|
-
include SortHelper
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
RedmineExtensions::PatchManager.register_controller_patch 'ApplicationController', 'RedmineExtensions::ApplicationControllerPatch'
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module RedmineExtensions
|
2
|
-
module CustomFieldPatch
|
3
|
-
|
4
|
-
def translated_name
|
5
|
-
self.name
|
6
|
-
end
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
RedmineExtensions::PatchManager.register_model_patch 'CustomField', 'RedmineExtensions::CustomFieldPatch', if: -> { !Redmine::Plugin.installed?(:easy_extensions) }
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module RedmineExtensions
|
2
|
-
module ProjectPatch
|
3
|
-
def self.included(base)
|
4
|
-
base.class_eval do
|
5
|
-
has_many :easy_settings, :class_name => 'EasySetting', :dependent => :destroy
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
RedmineExtensions::PatchManager.register_model_patch 'Project', 'RedmineExtensions::ProjectPatch'
|
data/spec/init_rails.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
possible_app_dirs = [
|
2
|
-
ENV['DUMMY_PATH'],
|
3
|
-
File.join(Dir.pwd, 'test/dummy'),
|
4
|
-
Bundler.root.join('test/dummy'),
|
5
|
-
]
|
6
|
-
|
7
|
-
possible_app_dirs.each do |dir|
|
8
|
-
next if !dir
|
9
|
-
next if !Dir.exist?(dir)
|
10
|
-
|
11
|
-
require File.join(dir, 'plugins/easyproject/easy_plugins/easy_extensions/test/spec/rails_helper')
|
12
|
-
break
|
13
|
-
end
|