lib/knj/knj.rb in knjrbfw-0.0.101 vs lib/knj/knj.rb in knjrbfw-0.0.102
- old
+ new
@@ -45,11 +45,22 @@
end
end
#Loads a gem by a given name. First tries to load the gem from a custom parent directory to enable loading of development-gems.
def self.gem_require(gem_const, gem_name = nil)
+ #Support given an array for multiple gem-names in one call.
+ if gem_const.is_a?(Array) and gem_name == nil
+ gem_const.each do |gem_i|
+ self.gem_require(gem_i)
+ end
+
+ return nil
+ end
+
+ #Set correct names.
gem_name = gem_const.to_s.downcase.strip if !gem_name
+ gem_const = "#{gem_const.to_s[0].upcase}#{gem_const.to_s[1, gem_name.length]}"
#Return false if the constant is already loaded.
return false if ::Kernel.const_defined?(gem_const)
#Try to load gem from custom development-path.
@@ -66,9 +77,10 @@
end
end
#Custom-path could not be loaded - load gem normally.
if !found_custom
+ require "rubygems"
require gem_name
end
#Return true to enable detection of that something was loaded.
return true
\ No newline at end of file