finder 0.3.0 → 0.4.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 → .index} +33 -32
- data/HISTORY.md +12 -0
- data/LICENSE.txt +1 -9
- data/README.md +29 -13
- data/lib/finder.rb +29 -3
- data/lib/finder.yml +57 -0
- data/lib/finder/import.rb +35 -0
- data/lib/finder/index.rb +24 -0
- data/lib/finder/roll.rb +1 -1
- metadata +29 -11
data/{.ruby → .index}
RENAMED
@@ -1,56 +1,57 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
2
|
+
type: ruby
|
3
|
+
revision: 2013
|
4
|
+
sources:
|
5
|
+
- Index.yml
|
4
6
|
authors:
|
5
7
|
- name: Trans
|
6
8
|
email: transfire@gmail.com
|
7
|
-
|
8
|
-
-
|
9
|
-
year: '2009'
|
10
|
-
license: BSD-2-Clause
|
9
|
+
organizations:
|
10
|
+
- name: rubyworks
|
11
11
|
requirements:
|
12
|
-
-
|
13
|
-
groups:
|
12
|
+
- groups:
|
14
13
|
- build
|
15
14
|
development: true
|
16
|
-
|
17
|
-
|
15
|
+
name: detroit
|
16
|
+
- groups:
|
18
17
|
- test
|
19
18
|
development: true
|
20
|
-
|
21
|
-
|
19
|
+
name: qed
|
20
|
+
- groups:
|
22
21
|
- test
|
23
22
|
development: true
|
24
|
-
|
25
|
-
alternatives: []
|
23
|
+
name: ae
|
26
24
|
conflicts: []
|
27
|
-
|
28
|
-
- uri: git://github.com/rubyworks/plugin.git
|
29
|
-
scm: git
|
30
|
-
name: upstream
|
25
|
+
alternatives: []
|
31
26
|
resources:
|
32
|
-
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
27
|
+
- type: home
|
28
|
+
uri: http://rubyworks.github.com/finder
|
29
|
+
label: Homepage
|
30
|
+
- type: code
|
31
|
+
uri: http://github.com/rubyworks/finder
|
36
32
|
label: Source Code
|
37
|
-
|
38
|
-
|
33
|
+
- type: mail
|
34
|
+
uri: http://groups.google.com/rubyworks-mailinglist
|
39
35
|
label: Mailing List
|
40
|
-
|
36
|
+
repositories:
|
37
|
+
- name: upstream
|
38
|
+
scm: git
|
39
|
+
uri: git://github.com/rubyworks/finder.git
|
41
40
|
categories: []
|
42
|
-
|
43
|
-
|
44
|
-
- lib
|
45
|
-
|
41
|
+
paths:
|
42
|
+
load:
|
43
|
+
- lib
|
44
|
+
copyrights:
|
45
|
+
- holder: Rubyworks
|
46
|
+
year: '2009'
|
47
|
+
license: BSD-2-Clause
|
46
48
|
name: finder
|
47
49
|
title: Finder
|
48
|
-
version: 0.
|
50
|
+
version: 0.4.0
|
49
51
|
summary: Robust library file locator
|
50
52
|
created: '2009-11-24'
|
51
53
|
description: Finder is a general purpose file finder for Ruby. Finder can search RubyGems,
|
52
54
|
Roll libraries and Ruby's standard $LOAD_PATH and system data directory for the
|
53
55
|
active or the most current library files. It is especially useful for implementing
|
54
56
|
library-based plugin systems.
|
55
|
-
|
56
|
-
date: '2012-05-22'
|
57
|
+
date: '2012-12-24'
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# RELEASE HISTORY
|
2
2
|
|
3
|
+
## 0.4.0 / 2012-12-25
|
4
|
+
|
5
|
+
New release adds Kernel#import and #import_relative core extensions.
|
6
|
+
The methods load code directly into the calling scope, unlike
|
7
|
+
the #require and #load methods which do so at the toplevel.
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
* Add Kernel#import and #import_relative.
|
12
|
+
* Add dynamic project metadata lookup.
|
13
|
+
|
14
|
+
|
3
15
|
## 0.3.0 / 2012-05-22
|
4
16
|
|
5
17
|
This is a significant release in that the behavior of `Find.load_path` has
|
data/LICENSE.txt
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Copyright (c) 2012 Rubyworks. All rights reserved.
|
4
|
-
|
5
|
-
License (spdx) BSD-2-Clause
|
1
|
+
BSD-2-Clause License
|
6
2
|
|
7
3
|
Redistribution and use in source and binary forms, with or without
|
8
4
|
modification, are permitted provided that the following conditions are met:
|
@@ -25,7 +21,3 @@ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
25
21
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
26
22
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
23
|
|
28
|
-
-----
|
29
|
-
* http://rubyworks.github.com/finder
|
30
|
-
* http://spdx.com/licenses/BSD-2_clause
|
31
|
-
|
data/README.md
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
# Finder
|
2
|
-
|
3
1
|
[Homepage](http://rubyworks.github.com/finder) /
|
4
2
|
[Report Issue](http://github.com/rubyworks/finder/issues) /
|
5
|
-
[
|
6
|
-
[
|
7
|
-
[IRC Channel](irc://chat.us.freenode.net/rubyworks)
|
8
|
-
|
9
|
-
[](http://travis-ci.org/rubyworks/finder)
|
3
|
+
[Source Code](http://github.com/rubyworks/finder)
|
4
|
+
( [](http://travis-ci.org/rubyworks/finder) )
|
10
5
|
|
11
6
|
|
12
|
-
|
7
|
+
# Finder
|
13
8
|
|
14
9
|
Finder is a straight-forward file finder for searching Ruby library paths.
|
15
10
|
It can handle RubyGems, Rolls and Ruby's standard site locals. It is both
|
@@ -17,7 +12,7 @@ more flexible and more robust the using Gem.find_files or searching the
|
|
17
12
|
$LOAD_PATH manually.
|
18
13
|
|
19
14
|
|
20
|
-
##
|
15
|
+
## Instructions
|
21
16
|
|
22
17
|
To find paths, simply provide a glob to the appropriate Finder function,
|
23
18
|
and it will return all matches found within current or most recent
|
@@ -41,12 +36,33 @@ This is basically equivalent to:
|
|
41
36
|
Alternately you might load files only as needed. For instance, if a
|
42
37
|
command-line option calls for it.
|
43
38
|
|
39
|
+
In addition Finder has two optional Kernel extensions: `#import`
|
40
|
+
and `#import_relative`. These methods can be used like `#require`
|
41
|
+
and `#require_relative`, but load code directory into the
|
42
|
+
current scope instead of the toplevel.
|
44
43
|
|
45
|
-
|
44
|
+
require 'finder/import'
|
46
45
|
|
47
|
-
|
46
|
+
module My
|
47
|
+
import('abbrev.rb')
|
48
|
+
emd
|
48
49
|
|
49
|
-
|
50
|
+
My::Abbrev::abbrev(['ruby'])
|
51
|
+
=> {"rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby", "ruby"=>"ruby"}
|
52
|
+
|
53
|
+
It is important to be careful when using `#import` to make sure loaded
|
54
|
+
scripts behave as intended. For example, if `abbrev.rb` were to define
|
55
|
+
itself using `::` toplevel namespace indicators, i.e. `::Abbrev`, then
|
56
|
+
the above import would not work as demonstrated.
|
50
57
|
|
51
|
-
See LICENSE.txt file for details.
|
52
58
|
|
59
|
+
## Copyrights
|
60
|
+
|
61
|
+
Finder is copyrighted opensource software.
|
62
|
+
|
63
|
+
Copyright (c) 2009 Rubyworks
|
64
|
+
|
65
|
+
It can be modified and redistributed in accordance with the terms of
|
66
|
+
the **BSD-2-Clause** license.
|
67
|
+
|
68
|
+
See LICENSE.txt file for details.
|
data/lib/finder.rb
CHANGED
@@ -1,9 +1,35 @@
|
|
1
|
+
# Finder (http://rubyworks.github.com/finder)
|
2
|
+
#
|
3
|
+
# (c) 2012 Rubyworks
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
16
|
+
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
18
|
+
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
19
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
20
|
+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
21
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
22
|
+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
23
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
24
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
26
|
+
require 'finder/index'
|
1
27
|
require 'finder/find'
|
2
28
|
|
3
|
-
|
29
|
+
# TODO: Import is optional for the time bing.
|
30
|
+
#require 'finder/import'
|
4
31
|
|
5
|
-
|
6
|
-
VERSION = '0.2.0'
|
32
|
+
module Finder
|
7
33
|
|
8
34
|
# Clean module that can be included elsewhere, to proved #path, #load_path
|
9
35
|
# and #data_path methods without including the Gem, Roll, and Site constants.
|
data/lib/finder.yml
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
type: ruby
|
3
|
+
revision: 2013
|
4
|
+
sources:
|
5
|
+
- Index.yml
|
6
|
+
authors:
|
7
|
+
- name: Trans
|
8
|
+
email: transfire@gmail.com
|
9
|
+
organizations:
|
10
|
+
- name: rubyworks
|
11
|
+
requirements:
|
12
|
+
- groups:
|
13
|
+
- build
|
14
|
+
development: true
|
15
|
+
name: detroit
|
16
|
+
- groups:
|
17
|
+
- test
|
18
|
+
development: true
|
19
|
+
name: qed
|
20
|
+
- groups:
|
21
|
+
- test
|
22
|
+
development: true
|
23
|
+
name: ae
|
24
|
+
conflicts: []
|
25
|
+
alternatives: []
|
26
|
+
resources:
|
27
|
+
- type: home
|
28
|
+
uri: http://rubyworks.github.com/finder
|
29
|
+
label: Homepage
|
30
|
+
- type: code
|
31
|
+
uri: http://github.com/rubyworks/finder
|
32
|
+
label: Source Code
|
33
|
+
- type: mail
|
34
|
+
uri: http://groups.google.com/rubyworks-mailinglist
|
35
|
+
label: Mailing List
|
36
|
+
repositories:
|
37
|
+
- name: upstream
|
38
|
+
scm: git
|
39
|
+
uri: git://github.com/rubyworks/finder.git
|
40
|
+
categories: []
|
41
|
+
paths:
|
42
|
+
load:
|
43
|
+
- lib
|
44
|
+
copyrights:
|
45
|
+
- holder: Rubyworks
|
46
|
+
year: '2009'
|
47
|
+
license: BSD-2-Clause
|
48
|
+
name: finder
|
49
|
+
title: Finder
|
50
|
+
version: 0.4.0
|
51
|
+
summary: Robust library file locator
|
52
|
+
created: '2009-11-24'
|
53
|
+
description: Finder is a general purpose file finder for Ruby. Finder can search RubyGems,
|
54
|
+
Roll libraries and Ruby's standard $LOAD_PATH and system data directory for the
|
55
|
+
active or the most current library files. It is especially useful for implementing
|
56
|
+
library-based plugin systems.
|
57
|
+
date: '2012-12-24'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Kernel
|
2
|
+
|
3
|
+
private
|
4
|
+
|
5
|
+
#
|
6
|
+
# Evaluate script directly into current scope.
|
7
|
+
#
|
8
|
+
def import(feature)
|
9
|
+
file = Find.feature(feature, :absolute=>true).first
|
10
|
+
raise LoadError, "no such file -- #{feature}" unless file
|
11
|
+
instance_eval(::File.read(file), file) if file
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Evaluate script directly into current scope relative to
|
16
|
+
# the current script.
|
17
|
+
#
|
18
|
+
# Note this is implemented via #caller.first.
|
19
|
+
#
|
20
|
+
def import_relative(fname)
|
21
|
+
call = caller.first
|
22
|
+
fail "Can't parse #{call}" unless call.rindex(/:\d+(:in `.*')?$/)
|
23
|
+
path = $` # File.dirname(call)
|
24
|
+
if /\A\((.*)\)/ =~ path # eval, etc.
|
25
|
+
raise LoadError, "import_relative is called in #{$1}"
|
26
|
+
end
|
27
|
+
file = File.expand_path(fname, File.dirname(path))
|
28
|
+
|
29
|
+
raise LoadError, "no such file -- #{file}" unless File.file?(file)
|
30
|
+
|
31
|
+
instance_eval(::File.read(file), file) #if file
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
data/lib/finder/index.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Finder
|
2
|
+
|
3
|
+
#
|
4
|
+
# Cached access to project metadata.
|
5
|
+
#
|
6
|
+
def index
|
7
|
+
@index ||=(
|
8
|
+
require 'yaml'
|
9
|
+
file = File.expand_path('../finder.yml', File.dirname(__FILE__))
|
10
|
+
YAML.load_file(file)
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Access to project metadata via constants.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# Finder::VERSION #=> '0.2.0'
|
19
|
+
#
|
20
|
+
def const_missing(name)
|
21
|
+
index[name.to_s.downcase] || super(name)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/finder/roll.rb
CHANGED
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.4.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-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: detroit
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: qed
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: ae
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: Finder is a general purpose file finder for Ruby. Finder can search RubyGems,
|
48
63
|
Roll libraries and Ruby's standard $LOAD_PATH and system data directory for the
|
49
64
|
active or the most current library files. It is especially useful for implementing
|
@@ -57,7 +72,7 @@ extra_rdoc_files:
|
|
57
72
|
- HISTORY.md
|
58
73
|
- README.md
|
59
74
|
files:
|
60
|
-
- .
|
75
|
+
- .index
|
61
76
|
- .yardopts
|
62
77
|
- demo/00_intro.md
|
63
78
|
- demo/01_load_path.md
|
@@ -68,12 +83,15 @@ files:
|
|
68
83
|
- lib/finder/base.rb
|
69
84
|
- lib/finder/find.rb
|
70
85
|
- lib/finder/gem.rb
|
86
|
+
- lib/finder/import.rb
|
87
|
+
- lib/finder/index.rb
|
71
88
|
- lib/finder/roll.rb
|
72
89
|
- lib/finder/site.rb
|
73
90
|
- lib/finder.rb
|
74
|
-
-
|
91
|
+
- lib/finder.yml
|
75
92
|
- HISTORY.md
|
76
93
|
- README.md
|
94
|
+
- LICENSE.txt
|
77
95
|
homepage: http://rubyworks.github.com/finder
|
78
96
|
licenses:
|
79
97
|
- BSD-2-Clause
|
@@ -95,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
113
|
version: '0'
|
96
114
|
requirements: []
|
97
115
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.23
|
99
117
|
signing_key:
|
100
118
|
specification_version: 3
|
101
119
|
summary: Robust library file locator
|