Class: Lotus::Assets::Config::Sources Private

Inherits:
Utils::LoadPaths
  • Object
show all
Defined in:
lib/lotus/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.

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



26
27
28
29
# File 'lib/lotus/assets/config/sources.rb', line 26

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



22
23
24
# File 'lib/lotus/assets/config/sources.rb', line 22

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



51
52
53
54
55
56
57
58
59
60
# File 'lib/lotus/assets/config/sources.rb', line 51

def files(name = nil)
  result = []

  Dir.glob(map {|source| "#{ source }#{ ::File::SEPARATOR }**#{ ::File::SEPARATOR }#{ name }*"}).each do |file|
    next if ::File.directory?(file) || ::File.basename(file).match(/\A\_/)
    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



43
44
45
46
47
# File 'lib/lotus/assets/config/sources.rb', line 43

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



33
34
35
36
37
38
39
# File 'lib/lotus/assets/config/sources.rb', line 33

def map
  Array.new.tap do |result|
    each do |source|
      result << yield(source)
    end
  end
end

#to_aObject

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



64
65
66
# File 'lib/lotus/assets/config/sources.rb', line 64

def to_a
  map {|s| s }
end