Class: Filament::FileList2

Inherits:
FileList
  • Object
show all
Defined in:
lib/filament/util/filelist2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ FileList2

Returns a new instance of FileList2.



8
9
10
11
12
13
# File 'lib/filament/util/filelist2.rb', line 8

def initialize(*args)
  super(*args)
  @target_resolver = $context[:target_resolver]
  @tag = :default
  @targets = []
end

Instance Attribute Details

#tagObject

Returns the value of attribute tag.



5
6
7
# File 'lib/filament/util/filelist2.rb', line 5

def tag
  @tag
end

#targetsObject (readonly)

Returns the value of attribute targets.



6
7
8
# File 'lib/filament/util/filelist2.rb', line 6

def targets
  @targets
end

Instance Method Details

#include(*entries) ⇒ Object



43
44
45
# File 'lib/filament/util/filelist2.rb', line 43

def include(*entries)
  super(*resolve_filament_uris(*entries))
end

#resolveObject



38
39
40
41
# File 'lib/filament/util/filelist2.rb', line 38

def resolve
  super
  @items.uniq!
end

#resolve_filament_uris(*entries) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/filament/util/filelist2.rb', line 15

def resolve_filament_uris(*entries)
  files = []
  entries.each do |entry|
    if entry.respond_to? :to_ary
      files += resolve_filament_uris(*entry.to_ary)
    else
      if @target_resolver.valid_uri?(entry)
        target = @target_resolver.resolve(entry)

        raise "target does not exist: #{entry}" if target.nil?
        @targets << target
        
        include(*target[@tag].to_a)
      else
        files << entry
      end
    end
  end
  
#      puts "resolve_uris(#{entries.join(', ')}) => #{files.join(':')}"
  return files
end