RequirePaths 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2007-09-24
2
+
3
+ * First release
4
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/require_paths
6
+ lib/require_paths.rb
7
+ test/test_require_paths.rb
data/README.txt ADDED
@@ -0,0 +1,56 @@
1
+ RequirePaths
2
+ by Gary McGhee
3
+ jesq.blogspot.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ This tiny plugin solves several issues with managing Ruby's $LOAD_PATH, which determines where files may be require'd from.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ 1) on one line, you specify all the paths you need
12
+ 2) Relative paths will be relative to the file you are in, absolute paths also supported
13
+ 3) Paths will be expanded, removing ../'s and eliminating logically equivalent but apparently different paths
14
+ 4) Paths will only be added if they don't already exist
15
+
16
+ == SYNOPSIS:
17
+
18
+ Example :
19
+
20
+ require_paths '.','../..','../lib' # These paths will be expanded and added to $LOAD_PATH relative to the calling file, unless already added
21
+ require 'project_one/lib/creditcard' # reference to another project, that would work from within any project
22
+ require 'ihl_ruby/thread_utils' # reference to common ruby library
23
+ require 'ihl_rails/database_utils' # reference to common rails library
24
+
25
+ == REQUIREMENTS:
26
+
27
+ none
28
+
29
+ == INSTALL:
30
+
31
+ * sudo gem install require_paths
32
+
33
+ == LICENSE:
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2007 FIX
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/require_paths.rb'
6
+
7
+ Hoe.new('RequirePaths', RequirePaths::VERSION) do |p|
8
+ p.rubyforge_name = 'require_paths'
9
+ # p.author = 'Gary McGhee'
10
+ # p.email = 'gazmcghee@yahoo.com.author'
11
+ # p.summary = 'Simply provides the require_paths method to all ruby files for cleanly adding paths to $LOAD_PATH, relative to the calling file.'
12
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ p.remote_rdoc_dir = '' # Release to root
16
+ end
17
+
18
+ # vim: syntax=Ruby
data/bin/require_paths ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ class RequirePaths
2
+ VERSION = '1.0.0'
3
+ end
4
+
5
+ # This sorts out the issues of require'ing files in Ruby
6
+ # 1) on one line, you specify all the paths you need
7
+ # 2) Relative paths will be relative to the file you are in, absolute paths also supported
8
+ # 3) Paths will be expanded
9
+ # 4) Paths will only be added if they don't already exist
10
+ #
11
+ module ::Kernel
12
+ def require_paths(*aArgs)
13
+ caller_dir = File.dirname(File.expand_path(caller.first.sub!(/:[0-9]+$/,'')))
14
+ aArgs.each do |aPath|
15
+ aPath = File.expand_path(aPath,caller_dir)
16
+ $LOAD_PATH << aPath unless $LOAD_PATH.include?(aPath)
17
+ end
18
+ end
19
+ end
File without changes
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: RequirePaths
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-09-24 00:00:00 +08:00
8
+ summary: The author was too lazy to write a summary
9
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: http://www.zenspider.com/ZSS/Products/RequirePaths/
13
+ rubyforge_project: require_paths
14
+ description: The author was too lazy to write a description
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Ryan Davis
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - bin/require_paths
37
+ - lib/require_paths.rb
38
+ - test/test_require_paths.rb
39
+ test_files:
40
+ - test/test_require_paths.rb
41
+ rdoc_options:
42
+ - --main
43
+ - README.txt
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ executables:
49
+ - require_paths
50
+ extensions: []
51
+
52
+ requirements: []
53
+
54
+ dependencies:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ version_requirement:
58
+ version_requirements: !ruby/object:Gem::Version::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.0
63
+ version: