Skip to content

Commit f3bc68f

Browse files
committed
Use require_relative.
1 parent 9d7944e commit f3bc68f

File tree

56 files changed

+93
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+93
-93
lines changed

lib/redis.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "monitor"
2-
require "redis/errors"
2+
require_relative "redis/errors"
33

44
class Redis
55

@@ -2612,8 +2612,8 @@ def _subscription(method, channels, block)
26122612

26132613
end
26142614

2615-
require "redis/version"
2616-
require "redis/connection"
2617-
require "redis/client"
2618-
require "redis/pipeline"
2619-
require "redis/subscribe"
2615+
require_relative "redis/version"
2616+
require_relative "redis/connection"
2617+
require_relative "redis/client"
2618+
require_relative "redis/pipeline"
2619+
require_relative "redis/subscribe"

lib/redis/client.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "redis/errors"
1+
require_relative "errors"
22
require "socket"
33
require "cgi"
44

@@ -517,11 +517,16 @@ def _parse_driver(driver)
517517

518518
if driver.kind_of?(String)
519519
begin
520-
require "redis/connection/#{driver}"
521-
driver = Connection.const_get(driver.capitalize)
522-
rescue LoadError, NameError
523-
raise RuntimeError, "Cannot load driver #{driver.inspect}"
520+
require_relative "connection/#{driver}"
521+
rescue LoadError, NameError => e
522+
begin
523+
require "connection/#{driver}"
524+
rescue LoadError, NameError => e
525+
raise RuntimeError, "Cannot load driver #{driver.inspect}: #{e.message}"
526+
end
524527
end
528+
529+
driver = Connection.const_get(driver.capitalize)
525530
end
526531

527532
driver

lib/redis/connection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require "redis/connection/registry"
1+
require_relative "connection/registry"
22

33
# If a connection driver was required before this file, the array
44
# Redis::Connection.drivers will contain one or more classes. The last driver
55
# in this array will be used as default driver. If this array is empty, we load
66
# the plain Ruby driver as our default. Another driver can be required at a
77
# later point in time, causing it to be the last element of the #drivers array
88
# and therefore be chosen by default.
9-
require "redis/connection/ruby" if Redis::Connection.drivers.empty?
9+
require_relative "connection/ruby" if Redis::Connection.drivers.empty?

lib/redis/connection/ruby.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require "redis/connection/registry"
2-
require "redis/connection/command_helper"
3-
require "redis/errors"
1+
require_relative "registry"
2+
require_relative "command_helper"
3+
require_relative "../errors"
44
require "socket"
55

66
class Redis

lib/redis/distributed.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "redis/hash_ring"
1+
require_relative "hash_ring"
22

33
class Redis
44
class Distributed

redis.gemspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
$:.unshift File.expand_path("../lib", __FILE__)
2-
3-
require "redis/version"
1+
require_relative "lib/redis/version"
42

53
Gem::Specification.new do |s|
64
s.name = "redis"

test/bitpos_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path("helper", File.dirname(__FILE__))
1+
require_relative "helper"
22

33
unless defined?(Enumerator)
44
Enumerator = Enumerable::Enumerator

test/blocking_commands_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require File.expand_path("helper", File.dirname(__FILE__))
2-
require "lint/blocking_commands"
1+
require_relative "helper"
2+
require_relative "lint/blocking_commands"
33

44
class TestBlockingCommands < Test::Unit::TestCase
55

test/command_map_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.expand_path("helper", File.dirname(__FILE__))
1+
require_relative "helper"
22

33
class TestCommandMap < Test::Unit::TestCase
44

test/commands_on_hashes_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require File.expand_path("helper", File.dirname(__FILE__))
2-
require "lint/hashes"
1+
require_relative "helper"
2+
require_relative "lint/hashes"
33

44
class TestCommandsOnHashes < Test::Unit::TestCase
55

0 commit comments

Comments
 (0)