Sha256: be24ea2761620457877f2ad81c57b440d4cfae523a3d4c0fee2259cdbf18f170

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Loader

  module ObjectEXT

    # Offline repo activate
    #def mount_modules(target_folder= File.join(Dir.pwd,"{module,modules}","{gem,gems}") )
    #  Dir.glob(File.join(target_folder,"**","lib")).select{|f| File.directory?(f)}.each do |one_path|
    #    $LOAD_PATH.unshift one_path
    #  end
    #end

    # require sender relative directory's files
    # return the directory and the sub directories file names (rb/ru)
    def require_relative_directory( folder, *args )

      recursive= nil
      [:recursive,:r, :R, 'r', 'R', '-r', '-R'].each{|e| args.include?(e) ? recursive ||= true : nil }

      # opts[:extension] ||= opts[:extensions] || opts[:ex] || opts[:e] || []
      # raise(ArgumentError,"invalid extension object, must be array like") unless opts[:extension].class <= Array

      unless folder.to_s[0] == File::Separator
        folder= Loader.caller_folder,folder
      end

      path_parts= [folder]
      if recursive
        path_parts.push("**")
      end
      path_parts.push("*.{rb,ru}")


      return_value= false
      Dir.glob(File.join(*path_parts)).each do |one_path|
        require(one_path) ? return_value=( true ) : nil
      end

      return return_value
    end

    alias :require_directory :require_relative_directory

  end

end

Object.__send__ :include, Loader::ObjectEXT

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loader-1.1.0 lib/loader/require.rb