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.
'_'.freeze
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.
31 32 33 34 |
# File 'lib/hanami/assets/config/sources.rb', line 31 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.
27 28 29 |
# File 'lib/hanami/assets/config/sources.rb', line 27 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.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hanami/assets/config/sources.rb', line 56 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.
48 49 50 51 52 |
# File 'lib/hanami/assets/config/sources.rb', line 48 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.
38 39 40 41 42 43 44 |
# File 'lib/hanami/assets/config/sources.rb', line 38 def map [].tap do |result| each do |source| result << yield(source) end end end |