Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
Created October 5, 2012 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyamkung/3839830 to your computer and use it in GitHub Desktop.
Save tomoyamkung/3839830 to your computer and use it in GitHub Desktop.
[Ruby]指定したディレクトリを再帰的に LOAD_PATH に追加する
#! 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