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 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
- mkdir "docs/require_relative"
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
 
@@ -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
- # 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.
19
- def require_relative(relative_feature)
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
- file = caller.first.split(/:\d/,2).first
24
+ file = caller.first.split(/:\d/,2).first
22
25
 
23
- raise LoadError, "require_relative is called in #{$1}" if /\A\((.*)\)/ =~ file
26
+ raise LoadError, "require_relative is called in #{$1}" if /\A\((.*)\)/ =~ file
24
27
 
25
- require File.expand_path(relative_feature, File.dirname(file))
28
+ require File.expand_path(relative_feature, File.dirname(file))
29
+ end
26
30
  end
@@ -1,5 +1,5 @@
1
1
  # This is simply the version number. Splitting it off into a different
2
2
  # file is generally considered to be good practice. :)
3
3
  module RequireRelative
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
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-05-16 00:00:00 -04:00
19
+ date: 2011-06-18 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency