pluginator 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -7
  2. data/.travis.yml +2 -0
  3. data/COPYING +674 -0
  4. data/COPYING.LESSER +165 -0
  5. data/Changelog.md +5 -0
  6. data/Gemfile +19 -5
  7. data/README.md +20 -0
  8. data/Rakefile +21 -0
  9. data/demo/plugins/something/math/decrease.rb +19 -0
  10. data/demo/plugins/something/math/increase.rb +19 -0
  11. data/demo/plugins/something/nested/structure/test.rb +19 -0
  12. data/demo/plugins/something/stats/max.rb +19 -0
  13. data/lib/pluginator.rb +19 -0
  14. data/lib/pluginator/autodetect.rb +37 -3
  15. data/lib/pluginator/errors.rb +19 -0
  16. data/lib/pluginator/extendable_autodetect.rb +19 -0
  17. data/lib/pluginator/group.rb +19 -0
  18. data/lib/pluginator/name_converter.rb +19 -0
  19. data/lib/pluginator/version.rb +20 -1
  20. data/lib/plugins/pluginator/extensions/class_exist.rb +19 -0
  21. data/lib/plugins/pluginator/extensions/conversions.rb +19 -0
  22. data/lib/plugins/pluginator/extensions/first_ask.rb +19 -0
  23. data/lib/plugins/pluginator/extensions/first_class.rb +19 -0
  24. data/lib/plugins/pluginator/extensions/matching.rb +19 -0
  25. data/lib/plugins/pluginator/extensions/plugins_map.rb +19 -0
  26. data/pluginator.gemspec +24 -2
  27. data/test/pluginator/autodetect_test.rb +19 -0
  28. data/test/pluginator/extendable_autodetect_test.rb +19 -0
  29. data/test/pluginator/group_test.rb +19 -0
  30. data/test/pluginator/name_converter_test.rb +19 -0
  31. data/test/pluginator_test.rb +19 -0
  32. data/test/plugins_test/extensions/class_exist_test.rb +19 -0
  33. data/test/plugins_test/extensions/conversions_test.rb +19 -0
  34. data/test/plugins_test/extensions/first_ask_test.rb +19 -0
  35. data/test/plugins_test/extensions/first_class_test.rb +19 -0
  36. data/test/plugins_test/extensions/matching_test.rb +19 -0
  37. data/test/plugins_test/extensions/plugins_map_test.rb +19 -0
  38. data/test/test_helper.rb +21 -0
  39. metadata +52 -42
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+ date: 2014-06-06
5
+
6
+ - register only plugins that can be loaded from activated gems, fix #3
7
+
3
8
  ## 1.0.1
4
9
  date: 2013-12-25
5
10
 
data/Gemfile CHANGED
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  source "https://rubygems.org"
2
21
 
3
22
  #ruby=2.0.0
@@ -9,9 +28,4 @@ group :development do
9
28
  gem "redcarpet", :platforms => [:mri_20]
10
29
  gem "simplecov", :platforms => [:mri_20]
11
30
  gem "coveralls", :platforms => [:mri_20]
12
-
13
- # rubinius support
14
- gem "rubysl-json", :platforms => [:rbx]
15
- gem "rubysl-mutex_m", :platforms => [:rbx]
16
- gem "rubysl-singleton", :platforms => [:rbx]
17
31
  end
data/README.md CHANGED
@@ -190,3 +190,23 @@ Pluginator.find("rvm2", type: "hooks/after_install").type.each{ |plugin|
190
190
  plugin.execute(name, path)
191
191
  }
192
192
  ```
193
+
194
+ ## License
195
+
196
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
197
+
198
+ pluginator is free software: you can redistribute it and/or modify
199
+ it under the terms of the GNU Lesser General Public License as published
200
+ by the Free Software Foundation, either version 3 of the License, or
201
+ (at your option) any later version.
202
+
203
+ pluginator is distributed in the hope that it will be useful,
204
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
205
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206
+ GNU Lesser General Public License for more details.
207
+
208
+ You should have received a copy of the GNU Lesser General Public License
209
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
210
+
211
+ For details on adding copyright visit:
212
+ https://www.gnu.org/licenses/gpl-howto.html
data/Rakefile CHANGED
@@ -1,3 +1,24 @@
1
+ =begin
2
+ Copyright 2013
3
+ - Michal Papis <mpapis@gmail.com>
4
+ - Jordon Bedwell <envygeeks@gmail.com>
5
+
6
+ This file is part of pluginator.
7
+
8
+ pluginator is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published
10
+ by the Free Software Foundation, either version 3 of the License, or
11
+ (at your option) any later version.
12
+
13
+ pluginator is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
20
+ =end
21
+
1
22
  require "rake/testtask"
2
23
 
3
24
  task :default => [:test]
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  class Something::Math::Decrease
2
21
  def self.type
3
22
  "decrease"
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  class Something::Math::Increase
2
21
  def self.type
3
22
  "increase"
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  class Something::Nested::Structure::Test
2
21
 
3
22
  def self.action
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  class Something::Stats::Max
2
21
 
3
22
  def self.handles?(what)
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  require "pluginator/extendable_autodetect"
2
21
  require "pluginator/version"
3
22
 
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  require "pluginator/errors"
2
21
  require "pluginator/group"
3
22
  require "pluginator/name_converter"
@@ -40,15 +59,30 @@ module Pluginator
40
59
  def load_files(file_names)
41
60
  file_names.each do |file_name|
42
61
  path, name, type = split_file_name(file_name, @group)
43
- load_plugin path
62
+ load_plugin(path) and
44
63
  register_plugin(type, name2class(name))
45
64
  end
46
65
  end
47
66
 
48
67
  def load_plugin(path)
49
68
  gemspec = Gem::Specification.find_by_path(path)
50
- gemspec.activate if gemspec && !gemspec.activated?
51
- require path
69
+ if
70
+ gemspec
71
+ then
72
+ activated =
73
+ Gem::Specification.find do |spec|
74
+ spec.name == gemspec.name && spec.activated?
75
+ end
76
+ gemspec.activate if !gemspec.activated? && activated.nil?
77
+ if
78
+ activated.nil? || activated == gemspec
79
+ then
80
+ require path
81
+ true
82
+ else
83
+ nil
84
+ end
85
+ end
52
86
  end
53
87
 
54
88
  end
@@ -1,3 +1,22 @@
1
+ =begin
2
+ Copyright 2013 Michal Papis <mpapis@gmail.com>
3
+
4
+ This file is part of pluginator.
5
+
6
+ pluginator is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published
8
+ by the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ pluginator is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with pluginator. If not, see <http://www.gnu.org/licenses/>.
18
+ =end
19
+
1
20
  module Pluginator
2
21
 
3
22
  # base error for all Pluginator errors