require_patch 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/require_patch.rb +26 -22
- data/lib/require_patch/version.rb +1 -1
- data/require_patch.gemspec +0 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663cdf26edc627f2d5a6c9f49489ece26ed811f4
|
4
|
+
data.tar.gz: 1c83a2e6317bcecf7a2af6526af890f7f3c662dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36822bcf253efc2f2c9ae56b219257bf1d66e6f7ec1bc31c890ae12d703c65ef3d6147ca89e734055001ccd196fe4873409f9c2e2c989f982fd42218dfe247ed
|
7
|
+
data.tar.gz: 5ae386176b7f66f91730c257ee2a45579589da26a626b1c7318c863c359634ab36c986eb562b8a9260c994946dff326220c48e9e2cc33a925eee586c86f718ab
|
data/lib/require_patch.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
require 'require_patch/version'
|
2
2
|
|
3
3
|
module RequirePatch
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
def self.included(base) # :nodoc:
|
5
|
+
base.class_eval do
|
6
|
+
# Method include patches to plugin
|
7
|
+
# @param plugin_name [String] the plugin name
|
8
|
+
# @param resources [Array] names of resources which will need patching
|
9
|
+
# @param options [Hash] optional options
|
10
|
+
# @example
|
11
|
+
# Rails.config.to_prepare do
|
12
|
+
# require_patch 'awesome_plugin', ['user', 'issue', 'user_controller', 'issue_helper']
|
13
|
+
# end
|
14
|
+
def require_patch(plugin_name, resources, options = {})
|
15
|
+
default_options = {
|
16
|
+
dir: nil,
|
17
|
+
prefix: nil,
|
18
|
+
postfix: 'patch'
|
19
|
+
}
|
18
20
|
|
19
|
-
|
21
|
+
options = default_options.merge options
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
resources.to_a.each do |resource|
|
24
|
+
require_dependency resource unless options[:skip_require_dependency]
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
patch_name = [options[:prefix], resource, options[:postfix]].select(&:present?).join('_')
|
27
|
+
resource_patch = [plugin_name, options[:dir], patch_name].select(&:present?).join('/')
|
28
|
+
resource_constant, resource_patch_constant = [resource, resource_patch].map(&:camelize).map(&:constantize)
|
27
29
|
|
28
|
-
|
30
|
+
resource_constant.send(:include, resource_patch_constant) unless resource_constant.included_modules.include? resource_patch_constant
|
31
|
+
end
|
32
|
+
end
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
33
|
-
|
37
|
+
Kernel.send(:include, ::RequirePatch) unless Kernel.included_modules.include? ::RequirePatch
|
data/require_patch.gemspec
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Shipiev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: The gem used by our team to develop Redmine plugins
|
28
14
|
email:
|
29
15
|
- roman@shipiev.pro
|