Class: Prez::Files::Paths

Inherits:
Object
  • Object
show all
Defined in:
lib/prez/files.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(extension, dirname) ⇒ Paths

Returns a new instance of Paths.



12
13
14
15
16
17
18
19
20
# File 'lib/prez/files.rb', line 12

def initialize(extension, dirname)
  @extension = extension

  @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

Instance Attribute Details

#extensionObject (readonly)

Returns the value of attribute extension.



10
11
12
# File 'lib/prez/files.rb', line 10

def extension
  @extension
end

#pathsObject (readonly)

Returns the value of attribute paths.



10
11
12
# File 'lib/prez/files.rb', line 10

def paths
  @paths
end

Instance Method Details

#find(name) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/prez/files.rb', line 22

def find(name)
  paths.each do |path|
    file = File.join path, "#{name}.#{extension}"

    if File.exists?(file)
      return file
    end
  end

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