module Finder::Find::Base

Base module provides helper methods to other finders.

Public Class Methods

included(mod) click to toggle source

When included into a module, that module is atuomatically self extended.

# File lib/finder/base.rb, line 13
def self.included(mod)
  mod.extend(mod)
end

Public Instance Methods

feature(match, options={}) click to toggle source

Like load_path but searches only for requirable feature files and returns relative paths by default.

# File lib/finder/base.rb, line 32
def feature(match, options={})
  options[:relative] = true unless options.key?(:relative) or options.key?(:absolute)
  match = append_extensions(match, options)
  load_path(match, options)
end

Private Instance Methods

append_extensions(match, options={}) click to toggle source

Append requirable extensions to match glob.

# File lib/finder/base.rb, line 59
def append_extensions(match, options={})
  unless Find::EXTENSIONS.include?(File.extname(match))
    match = match + '{' + Find::EXTENSIONS.join(',') + '}'
  end
  match
end
valid_load_options(options) click to toggle source

Validate and normalize load options.

@param [Hash] options

# File lib/finder/base.rb, line 45
def valid_load_options(options)
  if options.key?(:relative) && options.key?(:absolute)
    raise ArgumentError, "must be either relative or absolute" unless options[:relative] ^ options[:absolute]
  end

  options[:relative] = false if options[:absolute]

  options
end