require_patch 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/require_patch.rb +11 -1
- data/lib/require_patch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 416d9932de697193eea187491bc6bb86390d3612
|
4
|
+
data.tar.gz: a849a6f7b57f9b3c4371534321a6074fb3530eb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f03e6db23afd0ea8ca1e215ac072035158751bcbaa7210195e4ca763a9f0026639a45e332219988290dcdb5a4a11fc7e1645f15d4094b704a40d2af698c27a
|
7
|
+
data.tar.gz: 99087c92ac21d6efc727c1e488605d5a73d6feb13b8a996cfc7f7afe10c33463e3d31b7ebfbbee0a5f9176b16569c449f6a6423ea5316f2a2b7e595e5f62db07
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Or install it yourself as:
|
|
23
23
|
plugins/awesome_plugin/lib/awesome_plugin/issue_patch.rb
|
24
24
|
plugins/awesome_plugin/lib/awesome_plugin/users_controller_patch.rb
|
25
25
|
plugins/awesome_plugin/lib/awesome_plugin/issues_helper_patch.rb
|
26
|
+
plugins/awesome_plugin/lib/awesome_plugin/form/builder_patch.rb
|
26
27
|
|
27
28
|
# plugins/awesome_plugin/init.rb
|
28
29
|
Rails.config.to_prepare do
|
@@ -31,9 +32,16 @@ Or install it yourself as:
|
|
31
32
|
# or require_patch 'awesome_plugin', 'form/builder', skip_require_dependency: true
|
32
33
|
end
|
33
34
|
|
35
|
+
## Options
|
36
|
+
|
37
|
+
skip_require_dependency - block require_dependency resource (default: false)
|
38
|
+
dir - directory for patches (default: nil)
|
39
|
+
prefix - for patch-file (default: nil)
|
40
|
+
postfix - for patch-file (default: 'patch')
|
41
|
+
|
34
42
|
## Contributing
|
35
43
|
|
36
|
-
1. Fork it ( http://github.com
|
44
|
+
1. Fork it ( http://github.com/shipiev/require_patch/fork )
|
37
45
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
46
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
47
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/require_patch.rb
CHANGED
@@ -4,15 +4,25 @@ module RequirePatch
|
|
4
4
|
# It include patches to plugin
|
5
5
|
# @param plugin_name [String] the plugin name
|
6
6
|
# @param resources [Array] names of resources which will need patching
|
7
|
+
# @param options [Hash] optional options
|
7
8
|
# @example
|
8
9
|
# Rails.config.to_prepare do
|
9
10
|
# require_patch 'awesome_plugin', ['user', 'issue', 'user_controller', 'issue_helper']
|
10
11
|
# end
|
11
12
|
def require_patch(plugin_name, resources, options = {})
|
13
|
+
default_options = {
|
14
|
+
dir: nil,
|
15
|
+
prefix: nil,
|
16
|
+
postfix: 'patch'
|
17
|
+
}
|
18
|
+
|
19
|
+
options = default_options.merge options
|
20
|
+
|
12
21
|
resources.to_a.each do |resource|
|
13
22
|
require_dependency resource unless options[:skip_require_dependency]
|
14
23
|
|
15
|
-
|
24
|
+
patch_name = [options[:prefix], resource, options[:postfix]].select(&:present?).join('_')
|
25
|
+
resource_patch = [plugin_name, options[:dir], patch_name].select(&:present?).join('/')
|
16
26
|
resource_constant, resource_patch_constant = [resource, resource_patch].map(&:camelize).map(&:constantize)
|
17
27
|
|
18
28
|
resource_constant.send(:include, resource_patch_constant) unless resource_constant.included_modules.include? resource_patch_constant
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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: 2015-
|
11
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.4.8
|
63
63
|
signing_key:
|
64
64
|
specification_version: 4
|
65
65
|
summary: The gem adds a command "require_patch" that includes plugin patches
|