Class: Hanami::Assets::Config::Sources Private

Inherits:
Utils::LoadPaths
  • Object
show all
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.

Since:

  • 0.3.0

'_'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



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

#mapObject

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.

Since:

  • 0.1.0



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