dfg59-need 1.0.3

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.
@@ -0,0 +1,19 @@
1
+ === 1.0.3 / 2008-05-23
2
+
3
+ * 1 minor enhancement
4
+ * removed unnecessary call to binding on block
5
+
6
+ === 1.0.2 / 2008-03-18
7
+
8
+ * 1 minor enhancement
9
+ * path creation now uses File.expand_path after joining to give the absolute path
10
+
11
+ === 1.0.1 / 2008-02-07
12
+
13
+ * 1 minor enhancement
14
+ * path creation now uses File.join to remain platform agnostic
15
+
16
+ === 1.0.0 / 2008-02-07
17
+
18
+ * 1 major enhancement
19
+ * need can require files relative to the file in which you are calling need.
@@ -0,0 +1,8 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/need.rb
6
+ test/test_files/file_a.rb
7
+ test/test_files/file_b.rb
8
+ test/test_need.rb
@@ -0,0 +1,61 @@
1
+ = need
2
+
3
+ * http://need.rubyforge.org
4
+ * source code - http://github.com/dfg59/need/tree/master
5
+
6
+ == DESCRIPTION:
7
+
8
+ Need makes ruby relative requires just work. Simply need a file with a relative path
9
+ and the file will always be required correctly, regardless of what file your application is
10
+ being launched through. Typically, ruby projects would unshift lib onto $PATH or use the
11
+ File.dirname(__FILE__) trick. Using need means you don't have to worry about either of these.
12
+
13
+ Assume you have two files, one directly in lib and the other in lib/extensions. Let's assume
14
+ that file_a in lib requires file_b, in lib/extensions. Previously, you would doing some crazy
15
+ load path unshifting or use the __FILE__ trick to make these requires flexible enough to work
16
+ when your app is being accessed by rake, through a test suite, or required as a gem. Now, just
17
+ use need.
18
+
19
+ In file_a:
20
+ need{"extensions/file_b"}
21
+
22
+ Note that the block syntax is necessary. Need uses the binding of the block to determine the
23
+ location of your file and correctly perform your relative require for you.
24
+
25
+ == FEATURES/PROBLEMS:
26
+
27
+ == SYNOPSIS:
28
+
29
+ need{"relative/path/to/file"}
30
+
31
+ == REQUIREMENTS:
32
+
33
+ == INSTALL:
34
+
35
+ * rubyforge - sudo gem install need
36
+ * github - sudo gem install dfg59-need --source=http://gems.github.com
37
+
38
+ == LICENSE:
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2008 FIX
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/need.rb'
6
+
7
+ Hoe.new('need', Need::VERSION) do |p|
8
+ p.rubyforge_name = 'need'
9
+ p.author = 'Drew Olson'
10
+ p.email = 'drew@drewolson.org'
11
+ p.summary = 'Need makes relative requries just work'
12
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ p.url = "http://need.rubyforge.org"
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.remote_rdoc_dir = ''
16
+ end
17
+
18
+ # vim: syntax=Ruby
@@ -0,0 +1,13 @@
1
+ module Need
2
+ VERSION = '1.0.3'
3
+
4
+ # need takes a block which should contain a string of the relative path to the file
5
+ # you wish to need.
6
+ def need(&block)
7
+ require File.expand_path(File.join(File.dirname(eval("__FILE__",block)),block.call))
8
+ end
9
+ end
10
+
11
+ class Object
12
+ include Need
13
+ end
@@ -0,0 +1 @@
1
+ need{"file_b"}
@@ -0,0 +1,3 @@
1
+ def file_b_method?
2
+ true
3
+ end
@@ -0,0 +1,9 @@
1
+ require "test/unit"
2
+ require "need"
3
+ need {"test_files/file_a"}
4
+
5
+ class TestNeed < Test::Unit::TestCase
6
+ def test_need
7
+ assert file_b_method?, "file_b was not needed correctly"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dfg59-need
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Drew Olson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-23 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.1
23
+ version:
24
+ description: "== DESCRIPTION: Need makes ruby relative requires just work. Simply need a file with a relative path and the file will always be required correctly, regardless of what file your application is being launched through. Typically, ruby projects would unshift lib onto $PATH or use the File.dirname(__FILE__) trick. Using need means you don't have to worry about either of these. Assume you have two files, one directly in lib and the other in lib/extensions. Let's assume that file_a in lib requires file_b, in lib/extensions. Previously, you would doing some crazy load path unshifting or use the __FILE__ trick to make these requires flexible enough to work when your app is being accessed by rake, through a test suite, or required as a gem. Now, just use need. In file_a: need{\"extensions/file_b\"}"
25
+ email: olsonas@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - History.txt
32
+ - Manifest.txt
33
+ - README.txt
34
+ files:
35
+ - History.txt
36
+ - Manifest.txt
37
+ - README.txt
38
+ - Rakefile
39
+ - lib/need.rb
40
+ - test/test_files/file_a.rb
41
+ - test/test_files/file_b.rb
42
+ - test/test_need.rb
43
+ has_rdoc: true
44
+ homepage: http://need.rubyforge.org
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --main
48
+ - README.txt
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project: need
66
+ rubygems_version: 1.0.1
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Need makes relative requries just work
70
+ test_files:
71
+ - test/test_need.rb