pluginator 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA512:
|
3
|
+
data.tar.gz: 8978e772d2d9611da6f0237fceff4349308c1b882d9a677a1b7a98f03671e1b9c2d130656c9283027bddcc4e28a03ac092fdb27e020ef04deb4eaf4aa650c36a
|
4
|
+
metadata.gz: 9d61123257259cdd06fa87e89063aebb068bef8611ba0bdb2838e93580dec662e9a79423c42f832781e54a8000d061aa408fa683e5703d7ab1794aa9967470c9
|
5
|
+
SHA1:
|
6
|
+
data.tar.gz: 5681dfc0f9982ecb005834e0aa96fa832895bdda
|
7
|
+
metadata.gz: 3e87d0ef8aa32713ffc2e72eae88224c5f1cf227
|
data/Changelog.md
ADDED
data/lib/pluginator/version.rb
CHANGED
@@ -14,21 +14,29 @@ module Pluginator::Extensions
|
|
14
14
|
# @return The first plugin that method call returns true
|
15
15
|
def first_ask(type, method_name, *params)
|
16
16
|
@plugins[type] or return nil
|
17
|
-
|
18
|
-
plugin.public_methods.map(&:to_sym).include?(method_name.to_sym) &&
|
19
|
-
plugin.send(method_name.to_sym, *params)
|
20
|
-
end
|
17
|
+
try_to_find(type, method_name, params)
|
21
18
|
end
|
22
19
|
|
23
20
|
# Call a method on plugin and return first one that returns `true`.
|
24
21
|
# Behaves like `first_ask` but throws exceptions if can not find anything.
|
25
22
|
def first_ask!(type, method_name, *params)
|
26
23
|
@plugins[type] or raise Pluginator::MissingType.new(type, @plugins.keys)
|
24
|
+
try_to_find(type, method_name, params) or
|
25
|
+
raise Pluginator::MissingPlugin.new(type, "first_ask: #{method_name}", plugins_map(type).keys)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def try_to_find(type, method_name, params)
|
27
31
|
@plugins[type].detect do |plugin|
|
28
|
-
|
29
|
-
plugin.send(method_name, *params)
|
30
|
-
end
|
31
|
-
|
32
|
+
has_public_method?(plugin, method_name) &&
|
33
|
+
plugin.send(method_name.to_sym, *params)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# need to use this trick because of old rubies support
|
38
|
+
def has_public_method?(plugin, method_name)
|
39
|
+
plugin.public_methods.map(&:to_sym).include?(method_name.to_sym)
|
32
40
|
end
|
33
41
|
|
34
42
|
end
|
@@ -1,6 +1,10 @@
|
|
1
|
+
require "plugins/pluginator/extensions/conversions"
|
2
|
+
|
1
3
|
module Pluginator::Extensions
|
2
4
|
# extend Pluginator with map of plugins: name => klass
|
3
5
|
module PluginsMap
|
6
|
+
include Conversions
|
7
|
+
|
4
8
|
# provide extra map of plugins with symbolized names as keys
|
5
9
|
#
|
6
10
|
# @param type [String] name of type to generate the map for
|
@@ -8,7 +12,7 @@ module Pluginator::Extensions
|
|
8
12
|
def plugins_map( type )
|
9
13
|
@plugins_map ||= {}
|
10
14
|
type = type.to_s
|
11
|
-
@plugins_map[type] ||= Hash[ @plugins[type].map{|plugin| [plugin
|
15
|
+
@plugins_map[type] ||= Hash[ @plugins[type].map{|plugin| [class2name(plugin), plugin] } ]
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
metadata
CHANGED
@@ -1,52 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluginator
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Michal Papis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
date: 2013-12-25 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
14
15
|
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
16
|
prerelease: false
|
22
|
-
|
23
|
-
requirements:
|
24
|
-
-
|
25
|
-
-
|
26
|
-
|
27
|
-
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- &id002
|
20
|
+
- ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
34
23
|
type: :development
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: minitest
|
35
27
|
prerelease: false
|
36
|
-
|
37
|
-
requirements:
|
38
|
-
-
|
39
|
-
|
40
|
-
|
28
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- *id002
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id003
|
41
33
|
description:
|
42
|
-
email:
|
34
|
+
email:
|
43
35
|
- mpapis@gmail.com
|
44
36
|
executables: []
|
37
|
+
|
45
38
|
extensions: []
|
39
|
+
|
46
40
|
extra_rdoc_files: []
|
47
|
-
|
41
|
+
|
42
|
+
files:
|
48
43
|
- .gitignore
|
49
44
|
- .travis.yml
|
45
|
+
- Changelog.md
|
50
46
|
- Gemfile
|
51
47
|
- README.md
|
52
48
|
- Rakefile
|
@@ -82,28 +78,30 @@ files:
|
|
82
78
|
- test/test_helper.rb
|
83
79
|
homepage: https://github.com/rvm/pluginator
|
84
80
|
licenses: []
|
81
|
+
|
85
82
|
metadata: {}
|
83
|
+
|
86
84
|
post_install_message:
|
87
85
|
rdoc_options: []
|
88
|
-
|
86
|
+
|
87
|
+
require_paths:
|
89
88
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
94
93
|
version: 1.8.7
|
95
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
-
requirements:
|
97
|
-
-
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- *id002
|
100
97
|
requirements: []
|
98
|
+
|
101
99
|
rubyforge_project:
|
102
100
|
rubygems_version: 2.0.14
|
103
101
|
signing_key:
|
104
102
|
specification_version: 4
|
105
103
|
summary: Rubygems plugin system using Gem.find_files.
|
106
|
-
test_files:
|
104
|
+
test_files:
|
107
105
|
- test/pluginator/autodetect_test.rb
|
108
106
|
- test/pluginator/extendable_autodetect_test.rb
|
109
107
|
- test/pluginator/group_test.rb
|