require_relative 0.0.3 → 1.0.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/.gitignore +1 -0
- data/README.md +23 -1
- data/Rakefile +36 -0
- data/lib/require_relative.rb +22 -3
- data/lib/require_relative/version.rb +3 -1
- data/require_relative.gemspec +3 -2
- metadata +33 -4
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require\_relative
|
2
2
|
================
|
3
3
|
|
4
4
|
In Ruby 1.9.2, "." was removed from the $LOAD_PATH. require_relative was
|
@@ -13,3 +13,25 @@ This gem backports both of these features to earlier Rubies.
|
|
13
13
|
|
14
14
|
require 'foo' #=> LoadError
|
15
15
|
require_relative 'foo' #=> works!
|
16
|
+
|
17
|
+
If you're intending to use this gem to transition from Ruby 1.8.x to
|
18
|
+
1.9.2, do this:
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'require_relative' if RUBY_VERSION =~ /1\.8/
|
22
|
+
|
23
|
+
And then it should run just fine on both.
|
24
|
+
|
25
|
+
## Other Documentation
|
26
|
+
|
27
|
+
This gem is pretty straightforward, but we do have source documentation,
|
28
|
+
generated by rocco. You can find it in the gh-pages branch of this
|
29
|
+
repository or on [the
|
30
|
+
website](http://steveklabnik.github.com/require_relative).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Please fork the project, make your commits, push them to GitHub, and
|
35
|
+
make a pull request. Patches should have documentation and/or tests.
|
36
|
+
Don't be afraid to make a pull request without them, if you don't know
|
37
|
+
how to test something we can work on it in the comments. :)
|
data/Rakefile
CHANGED
@@ -7,3 +7,39 @@ require 'rake/testtask'
|
|
7
7
|
Rake::TestTask.new do |t|
|
8
8
|
t.pattern = "test/*_test.rb"
|
9
9
|
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'rocco/tasks'
|
13
|
+
require 'rake/clean'
|
14
|
+
Rocco::make 'docs/'
|
15
|
+
|
16
|
+
desc 'Build rocco docs'
|
17
|
+
task :docs => :rocco
|
18
|
+
directory 'docs/'
|
19
|
+
|
20
|
+
desc 'Build docs and open in browser for the reading'
|
21
|
+
task :read => :docs do
|
22
|
+
sh 'open docs/index.html'
|
23
|
+
end
|
24
|
+
|
25
|
+
file 'docs/index.html' => 'lib/require_relative.rb' do |f|
|
26
|
+
cp "docs/lib/require_relative.html", "docs/index.html"
|
27
|
+
cp "docs/lib/require_relative.html", "docs/require_relative.html"
|
28
|
+
end
|
29
|
+
|
30
|
+
file 'docs/require_relative/version.html' => 'lib/require_relative/version.rb' do |f|
|
31
|
+
mkdir "docs/require_relative"
|
32
|
+
cp "docs/lib/require_relative/version.html", "docs/require_relative/version.html"
|
33
|
+
end
|
34
|
+
|
35
|
+
task :docs => 'docs/index.html'
|
36
|
+
task :docs => 'docs/require_relative/version.html'
|
37
|
+
CLEAN.include 'docs/index.html'
|
38
|
+
|
39
|
+
# Alias for docs task
|
40
|
+
task :doc => :docs
|
41
|
+
|
42
|
+
rescue LoadError
|
43
|
+
warn "#$! -- rocco tasks not loaded."
|
44
|
+
end
|
45
|
+
|
data/lib/require_relative.rb
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This is the source code for require_relative, a Ruby gem that backports that
|
3
|
+
# particular feature to Ruby 1.8.
|
4
|
+
#
|
5
|
+
# Please check out the [README](https://github.com/steveklabnik/require_relative/blob/master/README.md)
|
6
|
+
# for more information on how to build your own copy of the gem, as well as
|
7
|
+
# contribute fixes.
|
8
|
+
|
9
|
+
# Yep, you're looking at it! This gem is pretty small, and for good reason.
|
10
|
+
# There's not much to do! We use split to find the filename that we're
|
11
|
+
# looking to require, raise a LoadError if it's called in a context (like eval)
|
12
|
+
# that it shouldn't be, and then require it via regular old require.
|
13
|
+
#
|
14
|
+
# Now, in 1.9, "." is totally removed from the $LOAD_PATH. We don't do that
|
15
|
+
# here, because that would break a lot of other code! You're still vulnerable
|
16
|
+
# to the security hole that caused this change to happen in the first place.
|
17
|
+
# You will be able to use this gem to transition the code you write over to
|
18
|
+
# the 1.9 syntax, though.
|
1
19
|
def require_relative(relative_feature)
|
20
|
+
|
2
21
|
file = caller.first.split(/:\d/,2).first
|
3
|
-
|
4
|
-
|
5
|
-
|
22
|
+
|
23
|
+
raise LoadError, "require_relative is called in #{$1}" if /\A\((.*)\)/ =~ file
|
24
|
+
|
6
25
|
require File.expand_path(relative_feature, File.dirname(file))
|
7
26
|
end
|
data/require_relative.gemspec
CHANGED
@@ -6,13 +6,14 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "require_relative"
|
7
7
|
s.version = RequireRelative::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Steve Klabnik"]
|
9
|
+
s.authors = ["Steve Klabnik <steve@steveklabnik.com>", "Brendan Taylor <whateley@gmail.com>"]
|
10
10
|
s.email = ["steve@steveklabnik.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://steveklabnik.github.com/require_relative"
|
12
12
|
s.summary = %q{This backports require_relative to Ruby 1.8.}
|
13
13
|
s.description = %q{In Ruby 1.9.2, "." was removed from $:. This is a good idea, for security reasons. This gem backports this to Ruby 1.8.}
|
14
14
|
|
15
15
|
s.add_development_dependency "minitest"
|
16
|
+
s.add_development_dependency "rocco"
|
16
17
|
|
17
18
|
s.files = `git ls-files`.split("\n")
|
18
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_relative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
|
-
- Steve Klabnik
|
13
|
+
- Steve Klabnik <steve@steveklabnik.com>
|
14
|
+
- Brendan Taylor <whateley@gmail.com>
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
18
|
|
13
|
-
date: 2011-
|
19
|
+
date: 2011-05-10 00:00:00 -04:00
|
14
20
|
default_executable:
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
@@ -21,9 +27,26 @@ dependencies:
|
|
21
27
|
requirements:
|
22
28
|
- - ">="
|
23
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
24
33
|
version: "0"
|
25
34
|
type: :development
|
26
35
|
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rocco
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
27
50
|
description: In Ruby 1.9.2, "." was removed from $:. This is a good idea, for security reasons. This gem backports this to Ruby 1.8.
|
28
51
|
email:
|
29
52
|
- steve@steveklabnik.com
|
@@ -46,7 +69,7 @@ files:
|
|
46
69
|
- test/require_relative_test.rb
|
47
70
|
- test/subdir/bar.rb
|
48
71
|
has_rdoc: true
|
49
|
-
homepage:
|
72
|
+
homepage: https://steveklabnik.github.com/require_relative
|
50
73
|
licenses: []
|
51
74
|
|
52
75
|
post_install_message:
|
@@ -59,12 +82,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
82
|
requirements:
|
60
83
|
- - ">="
|
61
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
62
88
|
version: "0"
|
63
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
90
|
none: false
|
65
91
|
requirements:
|
66
92
|
- - ">="
|
67
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
68
97
|
version: "0"
|
69
98
|
requirements: []
|
70
99
|
|