Class: Prez::Files::Paths
- Inherits:
-
Object
- Object
- Prez::Files::Paths
- Defined in:
- lib/prez/files.rb
Instance Attribute Summary collapse
-
#extension_alias ⇒ Object
readonly
Returns the value of attribute extension_alias.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #binary? ⇒ Boolean
- #find(name) ⇒ Object
-
#initialize(extension_alias, extensions, dirname, options = {}) ⇒ Paths
constructor
A new instance of Paths.
Constructor Details
#initialize(extension_alias, extensions, dirname, options = {}) ⇒ Paths
Returns a new instance of Paths.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/prez/files.rb', line 12 def initialize(extension_alias, extensions, dirname, = {}) @extension_alias = extension_alias @extensions = extensions @binary = .fetch :binary, false @paths = [].tap do |paths| paths << File.(".") paths << File.(File.join(".", dirname)) paths << File.(File.join("../../../vendor", dirname), __FILE__) end end |
Instance Attribute Details
#extension_alias ⇒ Object (readonly)
Returns the value of attribute extension_alias.
10 11 12 |
# File 'lib/prez/files.rb', line 10 def extension_alias @extension_alias end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
10 11 12 |
# File 'lib/prez/files.rb', line 10 def extensions @extensions end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
10 11 12 |
# File 'lib/prez/files.rb', line 10 def paths @paths end |
Instance Method Details
#binary? ⇒ Boolean
44 45 46 |
# File 'lib/prez/files.rb', line 44 def binary? @binary end |
#find(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |