plugin 1.0 → 1.1

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.
data/HISTORY CHANGED
@@ -1,8 +1,33 @@
1
1
  = RELEASE HISTORY
2
2
 
3
- == 0.1 / 2009-11-19
3
+ == 1.1 / 2010-02-07
4
4
 
5
- This is the initial release of Plug.
5
+ This release includes two significant adjustments.
6
+
7
+ First, the conventional plugin directory has been renamed to 'plugins/',
8
+ instead of 'plugin/'. I frequently shy away from plural names
9
+ (as in the tendency in Ruby), but in this case I believe it helps
10
+ differentiate it from regular library directories. It also frees 'plugin/'
11
+ should any separate scripts be required for this project in the future.
12
+
13
+ Second, should one need to search outside of the conventional 'plugins/'
14
+ location, the #find method will accept a :directory option. This usage
15
+ is discouraged, but is made available for the rare cases in which it
16
+ might prove necessary.
17
+
18
+ Changes:
19
+
20
+ * Standard Plugin directory is 'plugins/' instead of 'plugin/'.
21
+ * Can specify an alternate plugin directory by passing an option to #find.
22
+ * $LOAD_PATHS are expanded, so all paths are returned as full path names.
23
+
24
+
25
+ == 1.0 / 2009-11-24
26
+
27
+ This is the first official public release of Plugin.
28
+ Plugin provides a very easy way to locate plugins, and
29
+ this making it super easy for your project to support
30
+ pluggable components.
6
31
 
7
32
  Changes:
8
33
 
@@ -16,12 +16,12 @@ a location in the ruby $LOAD_PATH for plugins. Second it provides
16
16
  an easy to use function for finding plugin scripts stored in the
17
17
  designated location.
18
18
 
19
+
19
20
  == USAGE
20
21
 
21
- Place all plugins for you projectt in <tt>lib/plugin/<name>/</tt>.
22
+ Place all plugins for your project in <tt>lib/plugins/<name>/</tt>.
22
23
  Or if you have altered the load path for your project, you can
23
- place it in the alternate location under <tt>plugin/<name></tt>.
24
- However, this is not a recommended practice.
24
+ place them in the alternate location, <tt><alternate-loadpath>/plugins/<name>/</tt>.[1]
25
25
 
26
26
  To find plugins, simply provide a glob to the <tt>Plugin.find</tt> function,
27
27
  and it will return all matches found within current and/or most recent versions
@@ -39,6 +39,8 @@ the plugins found:
39
39
  Alternately you might load plugins only as needed. For instance, if a command-line
40
40
  option calls for it.
41
41
 
42
+ [1] Alterating the conventional load path shoud be avoided whenever possible.
43
+
42
44
 
43
45
  == COPYRIGHTS
44
46
 
@@ -2,11 +2,17 @@
2
2
  #
3
3
  # Find plugins across various library managers.
4
4
  #
5
- # All plugins are expected to be within a libraries designated
6
- # loadpath(s) under a <tt>plugin/</tt> subdirectory. By using
7
- # this assigned space, ie. <tt>plugin/<tt>, plugins are kept
8
- # isolated from normal libary scripts. This helps prevent
9
- # inadvertent name clashes.
5
+ # All plugins are expected to be within a library's designated
6
+ # loadpath(s) under a toplevel <tt>plugins/</tt> subdirectory.
7
+ # By using this assigned space plugins are kept isolated from
8
+ # normal library scripts, which helps prevent inadvertent
9
+ # name clashes.
10
+ #
11
+ # For example, lets say we want to create a pluggable template
12
+ # system for our "luckyweb" project. Our <tt>lib/</tt>
13
+ # directory would have the usual <tt>luckyweb</tt> directory,
14
+ # but also now a <tt>plugins/luckyweb/</tt> path in which the
15
+ # plugin templates would be stored.
10
16
  #
11
17
  # == How To Use
12
18
  #
@@ -19,6 +25,16 @@
19
25
  #
20
26
  # Plugin['syckle/*']
21
27
  #
28
+ # == Alternate Plugin Location
29
+ #
30
+ # By default <tt>plugins/</tt> is hardcoded into the system
31
+ # as a reliable convention. This is intentional. However,
32
+ # if you have specific need for serching for files outside
33
+ # that directory you can do so by supplying a <tt>:directory</tt>
34
+ # option to the <tt>#find</tt> command. Eg.
35
+ #
36
+ # Plugin.find('discover.rb', :directory=>'rdoc')
37
+ #
22
38
  # == A Note on RubyGems
23
39
  #
24
40
  # A way has not yet been devised to isolate the actived version
@@ -38,7 +54,7 @@ module Plugin
38
54
 
39
55
  extend self
40
56
 
41
- DIRECTORY = 'plugin'
57
+ DIRECTORY = 'plugins'
42
58
 
43
59
  # Find plugins, searching through standard $LOAD_PATH,
44
60
  # Roll Libraries and RubyGems.
@@ -47,11 +63,11 @@ module Plugin
47
63
  #
48
64
  # Plugins.find('syckle/*')
49
65
  #
50
- def find(match)
66
+ def find(match, options={})
51
67
  plugins = []
52
- plugins.concat find_roll(match)
53
- plugins.concat find_loadpath(match)
54
- plugins.concat find_gems(match)
68
+ plugins.concat find_roll(match, options)
69
+ plugins.concat find_loadpath(match, options)
70
+ plugins.concat find_gems(match, options)
55
71
  plugins.uniq
56
72
  end
57
73
 
@@ -64,13 +80,14 @@ module Plugin
64
80
 
65
81
  # Search roll for current or latest libraries.
66
82
 
67
- def find_roll(match)
83
+ def find_roll(match, options={})
68
84
  plugins = []
85
+ directory = options[:directory] || DIRECTORY
69
86
  if defined?(::Roll)
70
87
  ::Roll::Library.ledger.each do |name, lib|
71
88
  lib = lib.sort.first if Array===lib
72
89
  lib.loadpath.each do |path|
73
- find = File.join(lib.location, path, DIRECTORY, match)
90
+ find = File.join(lib.location, path, directory, match)
74
91
  list = Dir.glob(find)
75
92
  list = list.map{ |d| d.chomp('/') }
76
93
  plugins.concat(list)
@@ -84,10 +101,12 @@ module Plugin
84
101
  #
85
102
  # Activated gem versions are in here too.
86
103
 
87
- def find_loadpath(match)
104
+ def find_loadpath(match, options={})
88
105
  plugins = []
106
+ directory = options[:directory] || DIRECTORY
89
107
  $LOAD_PATH.uniq.each do |path|
90
- list = Dir.glob(File.join(path, DIRECTORY, match))
108
+ path = File.expand_path(path)
109
+ list = Dir.glob(File.join(path, directory, match))
91
110
  #dirs = dirs.select{ |d| File.directory?(d) }
92
111
  list = list.map{ |d| d.chomp('/') }
93
112
  plugins.concat(list)
@@ -99,11 +118,12 @@ module Plugin
99
118
  #
100
119
  # TODO: Is there anyway to skip active gems?
101
120
 
102
- def find_gems(match)
121
+ def find_gems(match, options={})
103
122
  plugins = []
123
+ directory = options[:directory] || DIRECTORY
104
124
  if defined?(::Gem)
105
125
  ::Gem.latest_load_paths do |path|
106
- list = Dir.glob(File.join(path, DIRECTORY, match))
126
+ list = Dir.glob(File.join(path, directory, match))
107
127
  list = list.map{ |d| d.chomp('/') }
108
128
  plugins.concat(list)
109
129
  end
@@ -1 +1 @@
1
- 2009-11-20
1
+ 2010-02-07
@@ -1 +1 @@
1
- 1.0
1
+ 1.1
@@ -0,0 +1,3 @@
1
+ # add the fixtures directory to the $LOAD_PATH
2
+ # $:.unshift(File.dirname(File.dirname(__FILE__)) + '/fixtures')
3
+
@@ -0,0 +1 @@
1
+ $proof = "plugin loading worked"
@@ -0,0 +1,26 @@
1
+ = Plugin Demonstrandum
2
+
3
+ To use the Plugin library first we need to require it.
4
+
5
+ require 'plugin'
6
+
7
+ Now use +Plugin.find+ to seach for a file pattern of our
8
+ choosing within the +plugins+ loadpath.
9
+
10
+ files = Plugin.find('example.rb')
11
+ file = files.first
12
+
13
+ The +find+ method returns full path names.
14
+
15
+ File.expand_path(file).assert == file
16
+ file.assert.ends_with?('plugins/example.rb')
17
+
18
+ As with any Ruby script we can require it.
19
+
20
+ require file
21
+
22
+ Our example.rb script defines the global variable $proof.
23
+ We can see that it loaded just fine.
24
+
25
+ $proof.assert == "plugin loading worked"
26
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ version: "1.1"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Sawyer
@@ -9,24 +9,20 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-24 00:00:00 -05:00
12
+ date: 2010-02-07 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
16
  description: |-
17
17
  Plugins is a general purpose plugin handler for Ruby.
18
18
  (Note: This has nothing to do with Rails plugins.)
19
- email: proutils@librelist.com
19
+ email:
20
20
  executables: []
21
21
 
22
22
  extensions: []
23
23
 
24
- extra_rdoc_files:
25
- - README
26
- - MANIFEST
27
- - HISTORY
28
- - Syckfile
29
- - COPYING
24
+ extra_rdoc_files: []
25
+
30
26
  files:
31
27
  - lib/plugin.rb
32
28
  - meta/authors
@@ -43,11 +39,12 @@ files:
43
39
  - meta/summary
44
40
  - meta/title
45
41
  - meta/version
46
- - README
42
+ - test/demos/helper.rb
43
+ - test/demos/plugins/example.rb
44
+ - test/demos/usage.rdoc
45
+ - README.rdoc
47
46
  - HISTORY
48
47
  - COPYING
49
- - MANIFEST
50
- - Syckfile
51
48
  has_rdoc: true
52
49
  homepage: http://rubyworks.github.com/plugin
53
50
  licenses: []
@@ -56,8 +53,6 @@ post_install_message:
56
53
  rdoc_options:
57
54
  - --title
58
55
  - Plugin API
59
- - --main
60
- - README
61
56
  require_paths:
62
57
  - lib
63
58
  required_ruby_version: !ruby/object:Gem::Requirement
data/MANIFEST DELETED
@@ -1,19 +0,0 @@
1
- #!mast -x Syckfile bin lib meta test [A-Z]*
2
- lib/plugin.rb
3
- meta/authors
4
- meta/collection
5
- meta/contact
6
- meta/created
7
- meta/description
8
- meta/homepage
9
- meta/license
10
- meta/name
11
- meta/released
12
- meta/repository
13
- meta/ruby
14
- meta/summary
15
- meta/title
16
- meta/version
17
- README
18
- HISTORY
19
- COPYING
data/Syckfile DELETED
@@ -1,25 +0,0 @@
1
- ---
2
- automatic: true
3
-
4
- box:
5
- types : [ gem, gz ]
6
- include: [ bin, doc, lib, meta, test, "[A-Z]*" ]
7
- exclude: [ doc/rdoc, doc/ri ]
8
- spec : true
9
-
10
- dnote:
11
- priority: -1
12
- active : true
13
-
14
- stats:
15
- priority: -1
16
- active : true
17
-
18
- #ridoc:
19
- # exclude: []
20
- # active : true
21
-
22
- email:
23
- mailto : transfire@gmail.com
24
- active : true
25
-