need 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -2
- data/README.txt +6 -2
- data/lib/need.rb +2 -2
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
=== 1.0.1 / 2008-02-07
|
2
|
+
|
3
|
+
* 1 minor enhancement
|
4
|
+
* path creation now uses File.join to remain platform agnostic
|
5
|
+
|
1
6
|
=== 1.0.0 / 2008-02-07
|
2
7
|
|
3
8
|
* 1 major enhancement
|
4
|
-
* need can require files relative to the file in which you are calling need.
|
5
|
-
|
9
|
+
* need can require files relative to the file in which you are calling need.
|
data/README.txt
CHANGED
@@ -9,13 +9,17 @@ and the file will always be required correctly, regardless of what file your app
|
|
9
9
|
being launched through. Typically, ruby projects would unshift lib onto $PATH or use the
|
10
10
|
File.dirname(__FILE__) trick. Using need means you don't have to worry about either of these.
|
11
11
|
|
12
|
-
Assume you have two files, one directly in lib and the other in lib/extensions. Let's assume
|
12
|
+
Assume you have two files, one directly in lib and the other in lib/extensions. Let's assume
|
13
|
+
that file_a in lib requires file_b, in lib/extensions. Previously, you would doing some crazy
|
14
|
+
load path unshifting or use the __FILE__ trick to make these requires flexible enough to work
|
15
|
+
when your app is being accessed by rake, through a test suite, or required as a gem. Now, just
|
16
|
+
use need.
|
13
17
|
|
14
18
|
In file_a:
|
15
19
|
need{"extensions/file_b"}
|
16
20
|
|
17
21
|
Note that the block syntax is necessary. Need uses the binding of the block to determine the
|
18
|
-
location of your file and
|
22
|
+
location of your file and correctly perform your relative require for you.
|
19
23
|
|
20
24
|
== FEATURES/PROBLEMS:
|
21
25
|
|
data/lib/need.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Need
|
2
|
-
VERSION = '1.0.
|
2
|
+
VERSION = '1.0.1'
|
3
3
|
|
4
4
|
# need takes a block which should contain a string of the relative path to the file
|
5
5
|
# you wish to need.
|
6
6
|
def need(&block)
|
7
|
-
require File.expand_path(File.dirname(eval("__FILE__",block.binding))
|
7
|
+
require File.join(File.expand_path(File.dirname(eval("__FILE__",block.binding))),block.call)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: need
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Olson
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-14 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|