Class: Bootscale::CacheBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bootscale/cache_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeCacheBuilder

Returns a new instance of CacheBuilder.



3
4
5
# File 'lib/bootscale/cache_builder.rb', line 3

def initialize
  @entries = {}
end

Instance Method Details

#clear!Object



7
8
9
# File 'lib/bootscale/cache_builder.rb', line 7

def clear!
  @entries = {}
end

#generate(load_path, rescan = false) ⇒ Object

generate the requireables cache from all current load-path entries each load-path is cached individually, so new ones can be added or removed but added/removed files will not be discovered



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bootscale/cache_builder.rb', line 14

def generate(load_path, rescan = false)
  requireables = load_path.reverse_each.flat_map do |path|
    path = path.to_s
    if rescan
      entries[path] = Entry.new(path).requireables
    else
      entries[path] ||= Entry.new(path).requireables
    end
  end
  Hash[requireables]
end