Class: Ree::PackageLoader

Inherits:
Object show all
Defined in:
lib/ree/core/package_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(packages_store) ⇒ PackageLoader

Returns a new instance of PackageLoader.



7
8
9
10
11
# File 'lib/ree/core/package_loader.rb', line 7

def initialize(packages_store)
  @packages_store = packages_store
  @loaded_paths = {}
  @loaded_packages = {}
end

Instance Method Details

#call(name) ⇒ Object

Parameters:

  • name (Symbol)

    Package name



18
19
20
21
22
23
24
# File 'lib/ree/core/package_loader.rb', line 18

def call(name)
  return @loaded_packages[name] if @loaded_packages.has_key?(name)

  Ree.logger.debug("full_package_load(:#{name})")
  recursively_load_package(name, Hash.new(false))
  @loaded_packages[name]
end

#load_file(path, package_name) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/ree/core/package_loader.rb', line 26

def load_file(path, package_name)
  @loaded_paths[package_name] ||= {}
  return if @loaded_paths[package_name][path]
  @loaded_paths[package_name][path] = true

  Ree.logger.debug("load_file(:#{package_name}, '#{path}')")
  Kernel.require(path)
end

#resetObject



13
14
15
# File 'lib/ree/core/package_loader.rb', line 13

def reset
  @loaded_paths = {}
end