require_patch 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 416d9932de697193eea187491bc6bb86390d3612
4
- data.tar.gz: a849a6f7b57f9b3c4371534321a6074fb3530eb8
3
+ metadata.gz: 663cdf26edc627f2d5a6c9f49489ece26ed811f4
4
+ data.tar.gz: 1c83a2e6317bcecf7a2af6526af890f7f3c662dc
5
5
  SHA512:
6
- metadata.gz: 00f03e6db23afd0ea8ca1e215ac072035158751bcbaa7210195e4ca763a9f0026639a45e332219988290dcdb5a4a11fc7e1645f15d4094b704a40d2af698c27a
7
- data.tar.gz: 99087c92ac21d6efc727c1e488605d5a73d6feb13b8a996cfc7f7afe10c33463e3d31b7ebfbbee0a5f9176b16569c449f6a6423ea5316f2a2b7e595e5f62db07
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
- # It include patches to plugin
5
- # @param plugin_name [String] the plugin name
6
- # @param resources [Array] names of resources which will need patching
7
- # @param options [Hash] optional options
8
- # @example
9
- # Rails.config.to_prepare do
10
- # require_patch 'awesome_plugin', ['user', 'issue', 'user_controller', 'issue_helper']
11
- # end
12
- def require_patch(plugin_name, resources, options = {})
13
- default_options = {
14
- dir: nil,
15
- prefix: nil,
16
- postfix: 'patch'
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
- options = default_options.merge options
21
+ options = default_options.merge options
20
22
 
21
- resources.to_a.each do |resource|
22
- require_dependency resource unless options[:skip_require_dependency]
23
+ resources.to_a.each do |resource|
24
+ require_dependency resource unless options[:skip_require_dependency]
23
25
 
24
- patch_name = [options[:prefix], resource, options[:postfix]].select(&:present?).join('_')
25
- resource_patch = [plugin_name, options[:dir], patch_name].select(&:present?).join('/')
26
- resource_constant, resource_patch_constant = [resource, resource_patch].map(&:camelize).map(&:constantize)
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
- resource_constant.send(:include, resource_patch_constant) unless resource_constant.included_modules.include? resource_patch_constant
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
- ActionDispatch::Reloader.send(:include, ::RequirePatch) unless ActionDispatch::Reloader.included_modules.include? ::RequirePatch
37
+ Kernel.send(:include, ::RequirePatch) unless Kernel.included_modules.include? ::RequirePatch
@@ -1,3 +1,3 @@
1
1
  module RequirePatch
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -17,6 +17,4 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
-
21
- spec.add_development_dependency 'rails'
22
20
  end
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.2.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: 2015-08-14 00:00:00.000000000 Z
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