Class: Fig::Command::PackageLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/fig/command/package_loader.rb

Overview

Loads the base package.

Constant Summary collapse

DEFAULT_PACKAGE_FILE =
'package.fig'
DEFAULT_APPLICATION_FILE =
'application.fig'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_configuration, descriptor, package_definition_file, base_config, repository) ⇒ PackageLoader

Returns a new instance of PackageLoader.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fig/command/package_loader.rb', line 17

def initialize(
  application_configuration,
  descriptor,
  package_definition_file,
  base_config,
  repository
)
  @application_configuration    = application_configuration
  @descriptor                   = descriptor
  @package_definition_file      = package_definition_file
  @base_config                  = base_config
  @repository                   = repository
end

Instance Attribute Details

#package_load_path_descriptionObject (readonly)

Returns the value of attribute package_load_path_description.



12
13
14
# File 'lib/fig/command/package_loader.rb', line 12

def package_load_path_description
  @package_load_path_description
end

Instance Method Details

#load_package_objectObject



39
40
41
42
43
44
45
46
47
# File 'lib/fig/command/package_loader.rb', line 39

def load_package_object()
  if @descriptor.nil?
    load_package_object_from_file()
  else
    set_base_package @repository.get_package(@descriptor)
  end

  return @base_package
end

#load_package_object_from_fileObject



31
32
33
34
35
36
37
# File 'lib/fig/command/package_loader.rb', line 31

def load_package_object_from_file()
  definition_text = load_package_definition_file_contents()

  parse_package_definition_file(definition_text)

  return @base_package
end

#package_source_descriptionObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fig/command/package_loader.rb', line 49

def package_source_description()
  if @package_load_path_description
    return @package_load_path_description
  elsif @descriptor
    return Fig::PackageDescriptor.format(
      @descriptor.name, @descriptor.version, nil
    )
  end

  return nil
end