lib/inochi/util.rb in inochi-0.3.0 vs lib/inochi/util.rb in inochi-1.0.0

- old
+ new

@@ -1,5 +1,10 @@ +#-- +# Copyright 2008 Suraj N. Kurapati +# See the LICENSE file for details. +#++ + class << Inochi ## # Returns the name of the main program executable, which # is the same as the project name fully in lowercase. # @@ -30,20 +35,37 @@ end input end + ## + # Establishes version requirements for the given gem. + # + # Returns the sanitized Gem version requirements. + # + def require_gem_version gem_name, version_reqs + version_reqs = Array(version_reqs).compact + + begin + gem gem_name.to_s, *version_reqs + rescue Gem::Exception, Gem::LoadError => e + warn e.inspect + end + + version_reqs + end + private INOCHI_LIBRARY_PATH = File.dirname(__FILE__) ## # Returns the path of the first file outside # Inochi's core from which this method was called. # def first_caller_file caller.each do |step| - if file = step[/^.+(?=:\d+$)/] + if file = step[/^.+(?=:\d+(?::|\z))/] file = File.expand_path(file) base = File.dirname(file) break file unless base.index(INOCHI_LIBRARY_PATH) == 0 end