pluginator 1.4.1 → 1.5.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,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2f6f47f0d693c563203fc44681649b38a96cd4ed
4
- data.tar.gz: a6c768ee9de70c1bdb77b321435f6a03c80ffd4a
5
- SHA512:
6
- metadata.gz: '08a0ec7df1937dd3e3e83bc0977c5cec827aa4e3d9922a1d3074abfe321abbf8b581e772acedea4fcf83dd5b02b787d51dd5e37ac995ad6ec17e97fa97c63fc4'
7
- data.tar.gz: d3c53fbace3c4dac9cc2ef106b4ea8be13d3f2ff35a4f2592d5863c56c282c4f5ac2920f5038e2501ef2d9e2e46a03deab1d9b22cf4f471c7cbbfb96442a56ab
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGRhZTE5NDM4MmRjNWI2MmZhNDE2ZDRiZTY3MjVlZWI4NmY5MjVkZQ==
5
+ data.tar.gz: !binary |-
6
+ NWM5MjgzMzI5ZTBhMGRhMWQ1ZDkwNjQ1MTUwNGJlM2Q4ZThiOTMxNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjJjMzQ0YzZmYmJmYTdlZDIxNWEzMDVlOWU4NjM1ZmU4NDllOGI0YmE0MjE1
10
+ YWM0Yjk4ODQ4YmViMjhmNjZiYmYzN2ZkMTg1YjhmNmU4MjM3ZTYyM2NjYjlk
11
+ Y2I3YjYyZmU2NWNlNDYyNTkzM2RkODM3ZDAzZjY4MGZhMjAxMmM=
12
+ data.tar.gz: !binary |-
13
+ NmUzMzVlMTAyYzQ3ZTI1MzJjZTU3NTQ4Y2Q3NjY5NmJlMmE1YzlkMjM1MTNj
14
+ ZjIzZjdiNjAzMGM5YWVhMmYyNDc5OTdjZjc0N2Y1NWJkN2QyNTk3MjZhZGQ2
15
+ MWViMWJmZjk5MDlmMTkxMDI0Njg4M2U2NmRhZTkzYzAzYmVjYjY=
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0
4
+ date: 2017-06-12
5
+
6
+ - add /lib prefix check, it can be changed with `prefix: "/(lib|local_lib)"`
7
+ - allow dashes in directory names for plugin paths
8
+ - fix older rubygems compatibility
9
+ - updated ruby and rubygems versions
10
+
3
11
  ## 1.4.1
4
12
  date: 2017-05-23
5
13
 
data/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  Gem plugin system management, detects plugins using `Gem.find_file`,
13
13
  `$LOAD_PATH` and `$LOADED_FEATURES`.
14
14
 
15
- It is only supposed to work with ruby 1.9.3+ (some tests fail on 1.9.2)
15
+ Pluginator works with *ruby 1.9.3+* and *rubygems 2.0.0+*.
16
16
 
17
17
  Pluginator tries to stay out of your way, you do not have to include or inherit anything.
18
18
  Pluginator only finds and groups plugins, rest is up to you,
@@ -46,14 +46,15 @@ types = rvm2plugins.types
46
46
 
47
47
  ```ruby
48
48
  Pluginator.find("<group>") => Pluginator object
49
- plugins = Pluginator.find("<group>", type: "<type>", extends: %i[<extensions>])
49
+ plugins = Pluginator.find("<group>", type: "<type>", prefix: "/(lib|local_lib)", extends: %i[<extensions>])
50
50
  plugins["<type>"] => Array of plugins
51
51
  plugins.type => Array of plugins for type defined with `type: "<type>"`
52
52
  plugins.types => Array of types
53
53
  ```
54
54
 
55
55
  - `"<group>"` - Load plugins for given group.
56
- - `type: "<type>"` - Load plugins only of given type, makes `type` method accessible.
56
+ - `type: "<type>"` - Load plugins only of given type, optional, makes `type` method accessible.
57
+ - `prefix: "/prefix"` - Load plugins only from this paths, optional, default `/lib`.
57
58
  - `extends: %i[<extensions>]` - Extend pluginator with given extensions.
58
59
 
59
60
  ## Extensions
@@ -18,6 +18,7 @@ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
18
  =end
19
19
 
20
20
  require "pluginator/extendable_autodetect"
21
+ require "pluginator/rubygems_fixes"
21
22
  require "pluginator/version"
22
23
 
23
24
  # A simple plugin system based on Gem.find_files
@@ -27,6 +28,9 @@ module Pluginator
27
28
  # @param group [String] name of plugins group
28
29
  # @param options [Hash] options to pass to creating Pluginator instance
29
30
  # @option type [String] name of type to load
31
+ # @option prefix [String] a prefix for finding plugins if forcing,
32
+ # by default only `/lib` is checked,
33
+ # regexp notation is allowed, for example `/(lib|local_lib)`
30
34
  # @option extend [Array<Symbol>|Symbol] list of extension to extend into pluginator instance
31
35
  # @return [Pluginator::ExtendableAutodetect] instance of Pluginator
32
36
  def self.find(group, options={})
@@ -38,9 +38,14 @@ module Pluginator
38
38
  # @param group [String] name of the plugins group
39
39
  # @param options [Hash] options to pass to creating Pluginator instance
40
40
  # @option type [String] name of the plugin type
41
+ # @option prefix [String] a prefix for finding plugins if forcing,
42
+ # by default only `/lib` is checked,
43
+ # regexp notation is allowed, for example `/(lib|local_lib)`
44
+
41
45
  def initialize(group, options={})
42
46
  super(group)
43
- @force_type = options[:type]
47
+ @force_prefix = options[:prefix]
48
+ @force_type = options[:type]
44
49
  refresh
45
50
  end
46
51
 
@@ -50,7 +55,7 @@ module Pluginator
50
55
  #
51
56
  # Use it after gem list change, for example after `Gem.install("new_gem")`
52
57
  def refresh
53
- plugin_lists = FormattedFinder.new(@group, @force_type)
58
+ plugin_lists = FormattedFinder.new(@force_prefix, @group, @force_type)
54
59
  register_plugins(plugin_lists.loaded_plugins_path)
55
60
  load_plugins(plugin_lists.load_path_plugins_paths)
56
61
  activate_plugins(plugin_lists.gem_plugins_paths)
@@ -27,20 +27,24 @@ module Pluginator
27
27
 
28
28
  # Automatically load plugins for given group (and type)
29
29
  #
30
- # @param group [String] name of the plugins group
31
- # @param force_type [String] name of the plugin type if forcing
32
- def initialize(group, force_type)
33
- @group = group
34
- @force_type = force_type
35
- @pattern = file_name_pattern(@group, @force_type)
30
+ # @param force_prefix [String] a prefix for finding plugins if forcing,
31
+ # by default only `/lib` is checked,
32
+ # regexp notation is allowed, for example `/[lib|]`
33
+ # @param group [String] name of the plugins group
34
+ # @param force_type [String] name of the plugin type if forcing
35
+ def initialize(force_prefix, group, force_type)
36
+ @force_prefix = force_prefix
37
+ @group = group
38
+ @force_type = force_type
39
+ @pattern = file_name_pattern
36
40
  find_paths
37
41
  end
38
42
 
39
43
  private
40
44
 
41
45
  # group => pattern
42
- def file_name_pattern(group, type=nil)
43
- "plugins/#{group}/#{type || "**"}/*.rb"
46
+ def file_name_pattern
47
+ "plugins/#{@group}/#{@force_type || "**"}/*.rb"
44
48
  end
45
49
 
46
50
  def find_paths
@@ -69,15 +73,16 @@ module Pluginator
69
73
 
70
74
  def split_file_names(file_names)
71
75
  file_names.map do |file_name|
72
- split_file_name(file_name, @group, @force_type)
76
+ split_file_name(file_name)
73
77
  end
74
78
  end
75
79
 
76
- # file_name, group, type => [ path, full_name, type ]
77
- def split_file_name(file_name, group, type=nil)
78
- type ||= ".*"
79
- match = file_name.match(%r{.*/(plugins/(#{group}/(#{type})/[^/]*)\.rb)$})
80
- match[1..3] if match
80
+ # file_name => [ path, full_name, type ]
81
+ def split_file_name(file_name)
82
+ prefix = @force_prefix || "/lib"
83
+ type = @force_type || ".*"
84
+ match = file_name.match(%r{.*#{prefix}/(plugins/(#{@group}/(#{type})/[^/]*)\.rb)$})
85
+ match[-3..-1] if match
81
86
  end
82
87
 
83
88
  end
@@ -27,7 +27,7 @@ module Pluginator
27
27
  class FormattedFinder < Finder
28
28
 
29
29
  # Reformat plugin lists
30
- def initialize(group, force_type)
30
+ def initialize(force_prefix, group, force_type)
31
31
  super
32
32
  map_loaded_plugins
33
33
  map_gem_plugins
@@ -27,7 +27,7 @@ module Pluginator
27
27
  klass = Kernel
28
28
  name.to_s.split(%r{/}).each do |part|
29
29
  klass = klass.const_get(
30
- part.capitalize.gsub(/_(.)/) { |match| match[1].upcase }
30
+ part.capitalize.gsub(/[_-](.)/) { |match| match[1].upcase }
31
31
  )
32
32
  end
33
33
  klass
@@ -0,0 +1,15 @@
1
+ unless Gem.respond_to? :find_files_from_load_path
2
+ # older versions of rubygems od not have separate method for finding only on $LOAD_PATH
3
+ # this is copy/paste from rubygems 2.0.0 code
4
+ # :nocov: not testing as it runs only on old rubygems, it's not even our code
5
+ module Gem
6
+ def self.find_files_from_load_path(glob)
7
+ $LOAD_PATH.map do |load_path|
8
+ Dir["#{File.expand_path glob, load_path}#{Gem.suffix_pattern}"]
9
+ end.flatten.select do |file| # rubocop:disable Style/MultilineBlockChain
10
+ File.file? file.untaint
11
+ end
12
+ end
13
+ end
14
+ # :nocov:
15
+ end
@@ -19,5 +19,5 @@ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module Pluginator
21
21
  # Version of Pluginator
22
- VERSION = "1.4.1".freeze
22
+ VERSION = "1.5.0".freeze
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluginator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis
@@ -11,62 +11,48 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-05-25 00:00:00.000000000 Z
14
+ date: 2017-06-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ">="
20
+ - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rubocop
32
- requirement: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: '0'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
27
+ - - ! '>='
42
28
  - !ruby/object:Gem::Version
43
29
  version: '0'
44
30
  - !ruby/object:Gem::Dependency
45
31
  name: minitest
46
32
  requirement: !ruby/object:Gem::Requirement
47
33
  requirements:
48
- - - ">="
34
+ - - ! '>='
49
35
  - !ruby/object:Gem::Version
50
36
  version: '0'
51
37
  type: :development
52
38
  prerelease: false
53
39
  version_requirements: !ruby/object:Gem::Requirement
54
40
  requirements:
55
- - - ">="
41
+ - - ! '>='
56
42
  - !ruby/object:Gem::Version
57
43
  version: '0'
58
44
  - !ruby/object:Gem::Dependency
59
45
  name: minitest-reporters
60
46
  requirement: !ruby/object:Gem::Requirement
61
47
  requirements:
62
- - - ">="
48
+ - - ! '>='
63
49
  - !ruby/object:Gem::Version
64
50
  version: '0'
65
51
  type: :development
66
52
  prerelease: false
67
53
  version_requirements: !ruby/object:Gem::Requirement
68
54
  requirements:
69
- - - ">="
55
+ - - ! '>='
70
56
  - !ruby/object:Gem::Version
71
57
  version: '0'
72
58
  description:
@@ -79,25 +65,26 @@ executables: []
79
65
  extensions: []
80
66
  extra_rdoc_files: []
81
67
  files:
82
- - COPYING
83
- - COPYING.LESSER
84
- - Changelog.md
85
- - README.md
86
68
  - lib/pluginator.rb
87
- - lib/pluginator/autodetect.rb
69
+ - lib/pluginator/version.rb
70
+ - lib/pluginator/group.rb
71
+ - lib/pluginator/name_converter.rb
72
+ - lib/pluginator/errors.rb
88
73
  - lib/pluginator/autodetect/finder.rb
89
74
  - lib/pluginator/autodetect/formatted_finder.rb
90
- - lib/pluginator/errors.rb
75
+ - lib/pluginator/rubygems_fixes.rb
91
76
  - lib/pluginator/extendable_autodetect.rb
92
- - lib/pluginator/group.rb
93
- - lib/pluginator/name_converter.rb
94
- - lib/pluginator/version.rb
95
- - lib/plugins/pluginator/extensions/class_exist.rb
96
- - lib/plugins/pluginator/extensions/conversions.rb
77
+ - lib/pluginator/autodetect.rb
78
+ - lib/plugins/pluginator/extensions/matching.rb
97
79
  - lib/plugins/pluginator/extensions/first_ask.rb
98
80
  - lib/plugins/pluginator/extensions/first_class.rb
99
- - lib/plugins/pluginator/extensions/matching.rb
81
+ - lib/plugins/pluginator/extensions/class_exist.rb
100
82
  - lib/plugins/pluginator/extensions/plugins_map.rb
83
+ - lib/plugins/pluginator/extensions/conversions.rb
84
+ - README.md
85
+ - Changelog.md
86
+ - COPYING.LESSER
87
+ - COPYING
101
88
  homepage: https://github.com/rvm/pluginator
102
89
  licenses:
103
90
  - LGPL v3
@@ -108,17 +95,17 @@ require_paths:
108
95
  - lib
109
96
  required_ruby_version: !ruby/object:Gem::Requirement
110
97
  requirements:
111
- - - ">="
98
+ - - ! '>='
112
99
  - !ruby/object:Gem::Version
113
- version: 1.8.7
100
+ version: 1.9.3
114
101
  required_rubygems_version: !ruby/object:Gem::Requirement
115
102
  requirements:
116
- - - ">="
103
+ - - ! '>='
117
104
  - !ruby/object:Gem::Version
118
- version: '0'
105
+ version: 2.0.0
119
106
  requirements: []
120
107
  rubyforge_project:
121
- rubygems_version: 2.6.11
108
+ rubygems_version: 2.0.0
122
109
  signing_key:
123
110
  specification_version: 4
124
111
  summary: Rubygems plugin system using Gem.find_files, $LOAD_PATH and $LOADED_FEATURES.