pluginator 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/Changelog.md +8 -0
- data/README.md +4 -3
- data/lib/pluginator.rb +4 -0
- data/lib/pluginator/autodetect.rb +7 -2
- data/lib/pluginator/autodetect/finder.rb +19 -14
- data/lib/pluginator/autodetect/formatted_finder.rb +1 -1
- data/lib/pluginator/name_converter.rb +1 -1
- data/lib/pluginator/rubygems_fixes.rb +15 -0
- data/lib/pluginator/version.rb +1 -1
- metadata +26 -39
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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=
|
data/Changelog.md
CHANGED
@@ -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
|
-
|
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
|
data/lib/pluginator.rb
CHANGED
@@ -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
|
-
@
|
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
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
43
|
-
"plugins/#{group}/#{
|
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
|
76
|
+
split_file_name(file_name)
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
# file_name
|
77
|
-
def split_file_name(file_name
|
78
|
-
|
79
|
-
|
80
|
-
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
|
@@ -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
|
data/lib/pluginator/version.rb
CHANGED
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
|
+
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-
|
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/
|
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/
|
75
|
+
- lib/pluginator/rubygems_fixes.rb
|
91
76
|
- lib/pluginator/extendable_autodetect.rb
|
92
|
-
- lib/pluginator/
|
93
|
-
- lib/pluginator/
|
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/
|
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.
|
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:
|
105
|
+
version: 2.0.0
|
119
106
|
requirements: []
|
120
107
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
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.
|