Class: Hanami::Assets::Config::Sources Private
- Inherits:
-
Utils::LoadPaths
- Object
- Utils::LoadPaths
- Hanami::Assets::Config::Sources
- Defined in:
- lib/hanami/assets/config/sources.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Source directories for a specific application
TODO The perf of this class is poor, consider to improve it.
Constant Summary collapse
- SKIPPED_FILE_PREFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_"
Instance Attribute Summary collapse
- #root ⇒ Object writeonly private
Instance Method Summary collapse
- #files(name = nil) ⇒ Object private
- #find(filename) ⇒ Object private
-
#initialize(root) ⇒ Sources
constructor
private
A new instance of Sources.
- #map ⇒ Object private
Constructor Details
#initialize(root) ⇒ Sources
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Sources.
33 34 35 36 |
# File 'lib/hanami/assets/config/sources.rb', line 33 def initialize(root) super() @root = root end |
Instance Attribute Details
#root=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/hanami/assets/config/sources.rb', line 29 def root=(value) @root = value end |
Instance Method Details
#files(name = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hanami/assets/config/sources.rb', line 58 def files(name = nil) result = [] Utils::FileList[map { |source| "#{source}#{::File::SEPARATOR}**#{::File::SEPARATOR}#{name}*" }].each do |file| next if ::File.directory?(file) || ::File.basename(file).start_with?(SKIPPED_FILE_PREFIX) result << file end result end |
#find(filename) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 |
# File 'lib/hanami/assets/config/sources.rb', line 50 def find(filename) result = files(filename).first result = Pathname.new(result) unless result.nil? result end |
#map ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 |
# File 'lib/hanami/assets/config/sources.rb', line 40 def map [].tap do |result| each do |source| result << yield(source) end end end |