Sha256: 01437d6caecbe5eab174c503a1667ab1a1eb5c27d271e6b1365338ec58b34ec0

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

module Loader

  module ObjectRequireEXT

    # 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

    def require_relative_directory_r folder
      require_relative_directory folder,:r
    end
    alias :require_directory_r :require_relative_directory_r

  end

end

Object.__send__ :include, Loader::ObjectRequireEXT

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loader-1.2.1 lib/loader/require.rb
loader-1.2.0.rc lib/loader/require.rb