Created
October 5, 2012 13:31
-
-
Save tomoyamkung/3839830 to your computer and use it in GitHub Desktop.
[Ruby]指定したディレクトリを再帰的に LOAD_PATH に追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! ruby | |
#-*- encoding: utf-8 -*- | |
require 'test/unit' | |
class RequireUtilTest< Test::Unit::TestCase | |
def self.add(dir) | |
dir = dir[0, dir.size - 1] if dir.end_with?('/') | |
Dir::glob(dir + '/**/*').each do |file| | |
$:.unshift(file) if FileTest::directory?(file) | |
end | |
end | |
def test_add | |
RequireUtilTest::add('../lib/') | |
assert_equal '../lib/util', $:[0] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment