lib/zemax.rb in zemax-0.2.0 vs lib/zemax.rb in zemax-2.3.4.bui2

- old
+ new

@@ -2,29 +2,21 @@ require 'pathname' VERSION_FILE = Pathname.new(__FILE__).dirname + '../VERSION' # :nodoc: VERSION = VERSION_FILE.exist? ? VERSION_FILE.read.strip : nil - # Require ruby source file(s). Lib should be either file name or glob + # Requires ruby source file(s). Accepts either single filename/glob or Array of filenames/globs. # Accepts following options: - # :file:: Libs are required relative to this file - defaults to __FILE__ - # :dir:: Required libs are located under this dir name - defaults to gem name + # :*file*:: Lib(s) required relative to this file - defaults to __FILE__ + # :*dir*:: Required lib(s) located under this dir name - defaults to gem name # - def self.require_lib( lib, opts={} ) + def self.require_libs( libs, opts={} ) file = Pathname.new(opts[:file] || __FILE__) - name = file.dirname + (opts[:dir] || file.basename('.*')) + lib.gsub(/(?<!.rb)$/, '.rb') - Pathname.glob(name.to_s).sort.each {|rb| require rb} + [libs].flatten.each do |lib| + name = file.dirname + (opts[:dir] || file.basename('.*')) + lib.gsub(/(?<!.rb)$/, '.rb') + Pathname.glob(name.to_s).sort.each {|rb| require rb} + end end - - # Requires ruby source file(s). Accepts either single name or Array of filenames/globs - # Accepts following options: - # :file:: Libs are required relative to this file - defaults to __FILE__ - # :dir:: Required libs are located under this dir name - defaults to gem name - # - def self.require_libs( libs, opts={} ) - [libs].flatten.each {|lib| require_lib lib, opts } - end - end # module Zemax # Require all ruby source files located under directory lib/zemax # If you need files in specific order, you should specify it here before the glob Zemax.require_libs %W[**/*]