finder 0.1.1 → 0.2.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.
- data/.ruby +3 -4
- data/HISTORY.md +13 -0
- data/README.md +7 -7
- data/lib/finder/find.rb +1 -1
- data/lib/finder/gem.rb +34 -6
- data/lib/finder/roll.rb +32 -3
- data/lib/finder/site.rb +9 -0
- metadata +8 -10
- data/COPYING.rdoc +0 -38
data/.ruby
CHANGED
@@ -8,8 +8,6 @@ copyrights:
|
|
8
8
|
- holder: Rubyworks
|
9
9
|
year: '2009'
|
10
10
|
license: BSD-2-Clause
|
11
|
-
replacements: []
|
12
|
-
alternatives: []
|
13
11
|
requirements:
|
14
12
|
- name: detroit
|
15
13
|
groups:
|
@@ -24,6 +22,7 @@ requirements:
|
|
24
22
|
- test
|
25
23
|
development: true
|
26
24
|
dependencies: []
|
25
|
+
alternatives: []
|
27
26
|
conflicts: []
|
28
27
|
repositories:
|
29
28
|
- uri: git://github.com/rubyworks/plugin.git
|
@@ -39,7 +38,7 @@ load_path:
|
|
39
38
|
revision: 0
|
40
39
|
name: finder
|
41
40
|
title: Finder
|
42
|
-
version: 0.
|
41
|
+
version: 0.2.0
|
43
42
|
summary: Robust library file locator
|
44
43
|
created: '2009-11-24'
|
45
44
|
description: Finder is a general purpose file finder for Ruby. Finder can search RubyGems,
|
@@ -47,4 +46,4 @@ description: Finder is a general purpose file finder for Ruby. Finder can search
|
|
47
46
|
active or the most current library files. It is especially useful for implementing
|
48
47
|
library-based plugin systems.
|
49
48
|
organization: rubyworks
|
50
|
-
date: '2012-
|
49
|
+
date: '2012-03-14'
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# RELEASE HISTORY
|
2
2
|
|
3
|
+
## 0.2.0 / 2012-03-14
|
4
|
+
|
5
|
+
This release adds the `:from` option which allows searching
|
6
|
+
to be limited to a specific library/gem. It also fixes
|
7
|
+
a bug with the Find.path method where one of the arguments
|
8
|
+
was mis-named.
|
9
|
+
|
10
|
+
Changes:
|
11
|
+
|
12
|
+
* Add support for `:from` option.
|
13
|
+
* Fix typo in `Find.path` arguments.
|
14
|
+
|
15
|
+
|
3
16
|
## 0.1.1 / 2012-02-11
|
4
17
|
|
5
18
|
Fixes a few oversites in last release.
|
data/README.md
CHANGED
@@ -23,14 +23,14 @@ To find finders, simply provide a glob to the appropriate Finder function,
|
|
23
23
|
and it will return all matches found within current and/or most recent versions
|
24
24
|
of a library.
|
25
25
|
|
26
|
-
For example, a common use case is for a
|
26
|
+
For example, a common use case is for a plugin-in enabled application is to require all
|
27
27
|
the finders found in library load paths:
|
28
28
|
|
29
|
-
|
29
|
+
require 'finder'
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
Find.load_path('myapp/*.rb').each do |file|
|
32
|
+
require(file)
|
33
|
+
end
|
34
34
|
|
35
35
|
Alternately you might load finders only as needed. For instance, if a command-line
|
36
36
|
option calls for it.
|
@@ -38,9 +38,9 @@ option calls for it.
|
|
38
38
|
|
39
39
|
## COPYRIGHTS
|
40
40
|
|
41
|
-
Copyright (c) 2009
|
41
|
+
Copyright (c) 2009 Rubyworks
|
42
42
|
|
43
43
|
Finder is release under the terms of the **BSD-2-Clause** license.
|
44
44
|
|
45
|
-
See
|
45
|
+
See LICENSE.txt file for details.
|
46
46
|
|
data/lib/finder/find.rb
CHANGED
data/lib/finder/gem.rb
CHANGED
@@ -15,18 +15,31 @@ module Finder
|
|
15
15
|
# @param [Hash] options
|
16
16
|
# Search options.
|
17
17
|
#
|
18
|
+
# @option options [String] :from
|
19
|
+
# Specific gem to search.
|
20
|
+
#
|
18
21
|
# @return [Array<String>] List of absolute paths.
|
19
22
|
#
|
20
23
|
def path(match, options={})
|
24
|
+
if from = options[:from] || options[:gem]
|
25
|
+
begin
|
26
|
+
specs = ::Gem::Specification.find_by_name(from.to_s)
|
27
|
+
rescue ::Gem::LoadError
|
28
|
+
return []
|
29
|
+
end
|
30
|
+
else
|
31
|
+
specs = ::Gem::Specification.current_specs
|
32
|
+
end
|
33
|
+
|
21
34
|
matches = []
|
22
|
-
|
35
|
+
specs.each do |spec|
|
23
36
|
list = []
|
24
37
|
glob = File.join(spec.full_gem_path, match)
|
25
38
|
list = Dir[glob] #.map{ |f| f.untaint }
|
26
39
|
list = list.map{ |d| d.chomp('/') }
|
27
40
|
matches.concat(list)
|
28
41
|
# activate the library if activate flag
|
29
|
-
|
42
|
+
spec.activate if options[:activate] && !list.empty?
|
30
43
|
end
|
31
44
|
matches
|
32
45
|
end
|
@@ -40,6 +53,9 @@ module Finder
|
|
40
53
|
# @param [Hash] options
|
41
54
|
# Search options.
|
42
55
|
#
|
56
|
+
# @option options [String] :from
|
57
|
+
# Specific gem to search.
|
58
|
+
#
|
43
59
|
# @option options [true,false] :absolute
|
44
60
|
# Return absolute paths instead of relative to load path.
|
45
61
|
#
|
@@ -49,8 +65,14 @@ module Finder
|
|
49
65
|
# @return [Array<String>] List of paths.
|
50
66
|
#
|
51
67
|
def load_path(match, options={})
|
68
|
+
if from = options[:from] || options[:gem]
|
69
|
+
specs = ::Gem::Specification.find_by_name(from.to_s)
|
70
|
+
else
|
71
|
+
specs = ::Gem::Specification.current_specs
|
72
|
+
end
|
73
|
+
|
52
74
|
matches = []
|
53
|
-
|
75
|
+
specs.each do |spec|
|
54
76
|
list = []
|
55
77
|
spec.require_paths.each do |path|
|
56
78
|
glob = File.join(spec.full_gem_path, path, match)
|
@@ -64,7 +86,7 @@ module Finder
|
|
64
86
|
matches.concat(list)
|
65
87
|
end
|
66
88
|
# activate the library if activate flag
|
67
|
-
|
89
|
+
spec.activate if options[:activate] && !list.empty?
|
68
90
|
end
|
69
91
|
matches
|
70
92
|
end
|
@@ -81,15 +103,21 @@ module Finder
|
|
81
103
|
# @return [Array<String>] List of absolute paths.
|
82
104
|
#
|
83
105
|
def data_path(match, options={})
|
106
|
+
if from = options[:from] || options[:gem]
|
107
|
+
specs = ::Gem::Specification.find_by_name(from.to_s)
|
108
|
+
else
|
109
|
+
specs = ::Gem::Specification.current_specs
|
110
|
+
end
|
111
|
+
|
84
112
|
matches = []
|
85
|
-
|
113
|
+
specs.each do |spec|
|
86
114
|
list = []
|
87
115
|
glob = File.join(spec.full_gem_path, 'data', match)
|
88
116
|
list = Dir[glob] #.map{ |f| f.untaint }
|
89
117
|
list = list.map{ |d| d.chomp('/') }
|
90
118
|
matches.concat(list)
|
91
119
|
# activate the library if activate flag
|
92
|
-
|
120
|
+
spec.activate if options[:activate] && !list.empty?
|
93
121
|
end
|
94
122
|
matches
|
95
123
|
end
|
data/lib/finder/roll.rb
CHANGED
@@ -19,14 +19,23 @@ module Finder
|
|
19
19
|
#
|
20
20
|
def path(match, options={})
|
21
21
|
return [] unless defined?(::Library)
|
22
|
+
|
23
|
+
if from = options[:from]
|
24
|
+
ledger = {from.to_s => ::Library.ledger[from.to_s]}
|
25
|
+
else
|
26
|
+
ledger = ::Library.ledger
|
27
|
+
end
|
28
|
+
|
22
29
|
matches = []
|
23
|
-
|
30
|
+
|
31
|
+
ledger.each do |name, lib|
|
24
32
|
lib = lib.sort.first if Array===lib
|
25
33
|
find = File.join(lib.location, match)
|
26
34
|
list = Dir.glob(find)
|
27
35
|
list = list.map{ |d| d.chomp('/') }
|
28
36
|
matches.concat(list)
|
29
37
|
end
|
38
|
+
|
30
39
|
matches
|
31
40
|
end
|
32
41
|
|
@@ -52,8 +61,17 @@ module Finder
|
|
52
61
|
# @return [Array<String>] List of paths.
|
53
62
|
#
|
54
63
|
def load_path(match, options={})
|
64
|
+
return [] unless defined?(::Library)
|
65
|
+
|
66
|
+
if from = options[:from]
|
67
|
+
ledger = {from.to_s => ::Library.ledger[from.to_s]}
|
68
|
+
else
|
69
|
+
ledger = ::Library.ledger
|
70
|
+
end
|
71
|
+
|
55
72
|
matches = []
|
56
|
-
|
73
|
+
|
74
|
+
ledger.each do |name, lib|
|
57
75
|
list = []
|
58
76
|
lib = lib.sort.first if Array===lib
|
59
77
|
lib.loadpath.each do |path|
|
@@ -70,6 +88,7 @@ module Finder
|
|
70
88
|
# activate the library if activate flag
|
71
89
|
lib.activate if options[:activate] && !list.empty?
|
72
90
|
end
|
91
|
+
|
73
92
|
matches
|
74
93
|
end
|
75
94
|
|
@@ -82,8 +101,17 @@ module Finder
|
|
82
101
|
#end
|
83
102
|
|
84
103
|
def data_path(match, options={})
|
104
|
+
return [] unless defined?(::Library)
|
105
|
+
|
106
|
+
if from = options[:from]
|
107
|
+
ledger = {from.to_s => ::Library.ledger[from.to_s]}
|
108
|
+
else
|
109
|
+
ledger = ::Library.ledger
|
110
|
+
end
|
111
|
+
|
85
112
|
matches = []
|
86
|
-
|
113
|
+
|
114
|
+
ledger.each do |name, lib|
|
87
115
|
list = []
|
88
116
|
lib = lib.sort.first if Array===lib
|
89
117
|
find = File.join(lib.location, 'data', match)
|
@@ -93,6 +121,7 @@ module Finder
|
|
93
121
|
# activate the library if activate flag
|
94
122
|
lib.activate if options[:activate] && !list.empty?
|
95
123
|
end
|
124
|
+
|
96
125
|
matches
|
97
126
|
end
|
98
127
|
|
data/lib/finder/site.rb
CHANGED
@@ -10,6 +10,9 @@ module Finder
|
|
10
10
|
|
11
11
|
DATA_PATH = RbConfig::CONFIG['datadir']
|
12
12
|
|
13
|
+
# TODO: Might this support `:from` option via
|
14
|
+
# `File.join(options[:from], match)`?
|
15
|
+
|
13
16
|
#
|
14
17
|
# Search load path for matching patterns.
|
15
18
|
#
|
@@ -22,6 +25,8 @@ module Finder
|
|
22
25
|
# @return [Array<String>] List of paths.
|
23
26
|
#
|
24
27
|
def path(match, options={})
|
28
|
+
return [] if options[:from]
|
29
|
+
|
25
30
|
found = []
|
26
31
|
$LOAD_PATH.uniq.map do |path|
|
27
32
|
list = Dir.glob(File.join(File.expand_path(path), match))
|
@@ -46,6 +51,8 @@ module Finder
|
|
46
51
|
# @return [Array<String>] List of paths.
|
47
52
|
#
|
48
53
|
def load_path(match, options={})
|
54
|
+
return [] if options[:from]
|
55
|
+
|
49
56
|
found = []
|
50
57
|
$LOAD_PATH.uniq.map do |path|
|
51
58
|
list = Dir.glob(File.join(File.expand_path(path), match))
|
@@ -63,6 +70,8 @@ module Finder
|
|
63
70
|
# Search data path.
|
64
71
|
#
|
65
72
|
def data_path(match, options={})
|
73
|
+
return [] if options[:from]
|
74
|
+
|
66
75
|
Dir.glob(File.join(DATA_PATH, match)).uniq
|
67
76
|
end
|
68
77
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: detroit
|
16
|
-
requirement: &
|
16
|
+
requirement: &17355120 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *17355120
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: qed
|
27
|
-
requirement: &
|
27
|
+
requirement: &17352400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *17352400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ae
|
38
|
-
requirement: &
|
38
|
+
requirement: &17350740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *17350740
|
47
47
|
description: Finder is a general purpose file finder for Ruby. Finder can search RubyGems,
|
48
48
|
Roll libraries and Ruby's standard $LOAD_PATH and system data directory for the
|
49
49
|
active or the most current library files. It is especially useful for implementing
|
@@ -53,7 +53,6 @@ email:
|
|
53
53
|
executables: []
|
54
54
|
extensions: []
|
55
55
|
extra_rdoc_files:
|
56
|
-
- COPYING.rdoc
|
57
56
|
- HISTORY.md
|
58
57
|
- README.md
|
59
58
|
files:
|
@@ -70,7 +69,6 @@ files:
|
|
70
69
|
- lib/finder.rb
|
71
70
|
- HISTORY.md
|
72
71
|
- README.md
|
73
|
-
- COPYING.rdoc
|
74
72
|
homepage: http://rubyworks.github.com/finder
|
75
73
|
licenses:
|
76
74
|
- BSD-2-Clause
|
data/COPYING.rdoc
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
= COPYRIGHT
|
2
|
-
|
3
|
-
== NOTICES
|
4
|
-
|
5
|
-
=== Finder
|
6
|
-
|
7
|
-
Copyright:: (c) 2012 RubyWorks
|
8
|
-
License:: (r) BSD-2-Clause
|
9
|
-
Website:: http://rubyworks.github.com/finder
|
10
|
-
|
11
|
-
== LICENSES
|
12
|
-
|
13
|
-
=== BSD-2-Clause License
|
14
|
-
|
15
|
-
Assay
|
16
|
-
|
17
|
-
Copyright (c) 2012 Rubyworks. All rights reserved.
|
18
|
-
|
19
|
-
Redistribution and use in source and binary forms, with or without
|
20
|
-
modification, are permitted provided that the following conditions are met:
|
21
|
-
|
22
|
-
1. Redistributions of source code must retain the above copyright notice,
|
23
|
-
this list of conditions and the following disclaimer.
|
24
|
-
|
25
|
-
2. Redistributions in binary form must reproduce the above copyright
|
26
|
-
notice, this list of conditions and the following disclaimer in the
|
27
|
-
documentation and/or other materials provided with the distribution.
|
28
|
-
|
29
|
-
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
30
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
31
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
32
|
-
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
33
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
34
|
-
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
35
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
36
|
-
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
37
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
38
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|