require_relative 1.0.1 → 1.0.2
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/Rakefile +1 -1
- data/lib/require_relative.rb +18 -14
- data/lib/require_relative/version.rb +1 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -28,7 +28,7 @@ begin
|
|
28
28
|
end
|
29
29
|
|
30
30
|
file 'docs/require_relative/version.html' => 'lib/require_relative/version.rb' do |f|
|
31
|
-
|
31
|
+
mkdir_p "docs/require_relative"
|
32
32
|
cp "docs/lib/require_relative/version.html", "docs/require_relative/version.html"
|
33
33
|
end
|
34
34
|
|
data/lib/require_relative.rb
CHANGED
@@ -6,21 +6,25 @@
|
|
6
6
|
# for more information on how to build your own copy of the gem, as well as
|
7
7
|
# contribute fixes.
|
8
8
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
9
|
+
# require_relative has no effect on Ruby 1.9 (or other versions that provide Kernel#require_relative
|
10
|
+
# out of the box)
|
11
|
+
unless Object.new.respond_to?(:require_relative, true)
|
12
|
+
# Yep, you're looking at it! This gem is pretty small, and for good reason.
|
13
|
+
# There's not much to do! We use split to find the filename that we're
|
14
|
+
# looking to require, raise a LoadError if it's called in a context (like eval)
|
15
|
+
# that it shouldn't be, and then require it via regular old require.
|
16
|
+
#
|
17
|
+
# Now, in 1.9, "." is totally removed from the $LOAD_PATH. We don't do that
|
18
|
+
# here, because that would break a lot of other code! You're still vulnerable
|
19
|
+
# to the security hole that caused this change to happen in the first place.
|
20
|
+
# You will be able to use this gem to transition the code you write over to
|
21
|
+
# the 1.9 syntax, though.
|
22
|
+
def require_relative(relative_feature)
|
20
23
|
|
21
|
-
|
24
|
+
file = caller.first.split(/:\d/,2).first
|
22
25
|
|
23
|
-
|
26
|
+
raise LoadError, "require_relative is called in #{$1}" if /\A\((.*)\)/ =~ file
|
24
27
|
|
25
|
-
|
28
|
+
require File.expand_path(relative_feature, File.dirname(file))
|
29
|
+
end
|
26
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_relative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Klabnik
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-06-18 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|