autoreload 0.3.1 → 1.0.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.
@@ -1,91 +0,0 @@
1
- module AutoReload
2
-
3
- # = Library Lookup
4
- #
5
- # This library is a slightly modified copy of the +plugin+ library.
6
- #
7
- module Lookup
8
-
9
- extend self
10
-
11
- # Find plugins, searching through standard $LOAD_PATH,
12
- # Roll Libraries and RubyGems.
13
- #
14
- # Provide a +match+ file glob to find plugins.
15
- #
16
- # Lookup.find('syckle/*')
17
- #
18
- def find(match, options={})
19
- plugins = []
20
- plugins.concat find_roll(match, options)
21
- plugins.concat find_loadpath(match, options)
22
- plugins.concat find_gems(match, options)
23
- plugins.uniq
24
- end
25
-
26
- # Shortcut for #find.
27
- #
28
- # Lookup['syckle/*']
29
- #
30
- alias_method :[], :find
31
-
32
- # Search roll for current or latest libraries.
33
- def find_roll(match, options={})
34
- plugins = []
35
- #directory = options[:directory] || DIRECTORY
36
- if defined?(::Roll)
37
- # Not ::Roll::Library ?
38
- ::Library.ledger.each do |name, lib|
39
- lib = lib.sort.first if Array===lib
40
- lib.loadpath.each do |path|
41
- #find = File.join(lib.location, path, directory, match)
42
- find = File.join(lib.location, path, match)
43
- list = Dir.glob(find)
44
- list = list.map{ |d| d.chomp('/') }
45
- plugins.concat(list)
46
- end
47
- end
48
- end
49
- plugins
50
- end
51
-
52
- # Search standard $LOAD_PATH.
53
- #
54
- # Activated gem versions are in here too.
55
-
56
- def find_loadpath(match, options={})
57
- plugins = []
58
- #directory = options[:directory] || DIRECTORY
59
- $LOAD_PATH.uniq.each do |path|
60
- path = File.expand_path(path)
61
- #list = Dir.glob(File.join(path, directory, match))
62
- list = Dir.glob(File.join(path, match))
63
- list = list.map{ |d| d.chomp('/') }
64
- plugins.concat(list)
65
- end
66
- plugins
67
- end
68
-
69
- # Search latest gem versions.
70
- #
71
- # TODO: Is there anyway to skip active gems?
72
-
73
- def find_gems(match, options={})
74
- plugins = []
75
- #directory = options[:directory] || DIRECTORY
76
- if defined?(::Gem)
77
- ::Gem.latest_load_paths do |path|
78
- #list = Dir.glob(File.join(path, directory, match))
79
- list = Dir.glob(File.join(path, match))
80
- list = list.map{ |d| d.chomp('/') }
81
- plugins.concat(list)
82
- end
83
- end
84
- plugins
85
- end
86
-
87
- end
88
-
89
- end
90
-
91
- # Copyright (C) 2010 Thomas Sawyer