lib/muflax/library.rb in muflax-0.3.22 vs lib/muflax/library.rb in muflax-0.3.23
- old
+ new
@@ -1,16 +1,13 @@
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# Copyright muflax <mail@muflax.com>, 2013
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
-def require_local lib_name, location=__FILE__
- file = File.symlink?(location) ? File.readlink(location) : location
- lib = File.join File.dirname(file), "/../lib/#{lib_name}.rb"
+def require_local lib_name, location=caller_locations.first.path
+ file = File.symlink?(location) ? File.readlink(location) : location
+ dir = File.dirname(file)
+ lib = File.join(dir, "#{lib_name}.rb")
- if File.exists? lib
- # using local version
- require lib
- else
- require lib_name
- end
+ raise "couldn't find local module: «#{lib_name}» in «#{dir}»" if not File.exists? lib
+ require lib
end