class Prez::Files::Paths

Attributes

extension_alias[R]
extensions[R]
paths[R]

Public Class Methods

new(extension_alias, extensions, dirname, options = {}) click to toggle source
# File lib/prez/files.rb, line 12
def initialize(extension_alias, extensions, dirname, options = {})
  @extension_alias = extension_alias
  @extensions = extensions
  @binary = options.fetch :binary, false

  @paths = [].tap do |paths|
    paths << File.expand_path(".")
    paths << File.expand_path(File.join(".", dirname))
    paths << File.expand_path(File.join("../../../vendor", dirname), __FILE__)
  end
end

Public Instance Methods

binary?() click to toggle source
# File lib/prez/files.rb, line 44
def binary?
  @binary
end
find(name) click to toggle source
# File lib/prez/files.rb, line 24
def find(name)
  paths.each do |path|
    extensions.each do |extension|
      files = [File.join(path, "#{name}.#{extension}")]

      if name.end_with?(".#{extension}")
        files << File.join(path, name)
      end

      files.each do |file|
        if File.exists?(file)
          return file
        end
      end
    end
  end

  raise Prez::Files::MissingError.new(name, extension_alias)
end