Class: Fig::Statement::Include

Inherits:
Fig::Statement show all
Defined in:
lib/fig/statement/include.rb

Overview

Dual role: “include :configname” incorporates one configuration into another; “include package” declares a dependency upon another package (with incorporation of the “default” configuration from that other package if no “:configname” is specified.

Constant Summary

Constants inherited from Fig::Statement

ENVIRONMENT_VARIABLE_NAME_REGEX

Instance Attribute Summary collapse

Attributes inherited from Fig::Statement

#column, #line, #source_description

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Fig::Statement

#is_asset?, #is_environment_variable?, position_description, #position_string, #urls, #walk_statements

Constructor Details

#initialize(line_column, source_description, descriptor, included_package, containing_package_descriptor) ⇒ Include

Returns a new instance of Include.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fig/statement/include.rb', line 23

def initialize(
  line_column,
  source_description,
  descriptor,
  included_package,  # For synthetic Package for command-line options.
  containing_package_descriptor
)
  super(line_column, source_description)

  @descriptor                    = descriptor
  @included_package              = included_package
  @containing_package_descriptor = containing_package_descriptor
end

Instance Attribute Details

#containing_package_descriptorObject (readonly)

Returns the value of attribute containing_package_descriptor.



15
16
17
# File 'lib/fig/statement/include.rb', line 15

def containing_package_descriptor
  @containing_package_descriptor
end

#descriptorObject (readonly)

Returns the value of attribute descriptor.



13
14
15
# File 'lib/fig/statement/include.rb', line 13

def descriptor
  @descriptor
end

#included_packageObject (readonly)

Returns the value of attribute included_package.



14
15
16
# File 'lib/fig/statement/include.rb', line 14

def included_package
  @included_package
end

Class Method Details

.parse_descriptor(raw_string, options = {}) ⇒ Object

Centralized definition of requirements for descriptors for include statements.



19
20
21
# File 'lib/fig/statement/include.rb', line 19

def self.parse_descriptor(raw_string, options = {})
  return Fig::PackageDescriptor.parse(raw_string, options)
end

Instance Method Details

#complain_if_version_missingObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fig/statement/include.rb', line 53

def complain_if_version_missing()
  if @descriptor.name && ! @descriptor.version
    message =
      %Q<No version in the package descriptor of "#{@descriptor.name}" in an include statement>
    if @containing_package_descriptor
      package_string = @containing_package_descriptor.to_string()
      if package_string && package_string != ''
        message += %Q< in the .fig file for "#{package_string}">
      end
    end
    message += %Q<#{position_string()}. Whether or not the include statement will work is dependent upon the recursive dependency load order.>

    Fig::Logging.warn(message)
  end
end

#config_nameObject



49
50
51
# File 'lib/fig/statement/include.rb', line 49

def config_name
  return @descriptor.config
end

#deparse_as_version(deparser) ⇒ Object



80
81
82
# File 'lib/fig/statement/include.rb', line 80

def deparse_as_version(deparser)
  return deparser.include(self)
end

#minimum_grammar_for_emitting_inputObject



84
85
86
# File 'lib/fig/statement/include.rb', line 84

def minimum_grammar_for_emitting_input()
  return minimum_grammar
end

#minimum_grammar_for_publishingObject



88
89
90
# File 'lib/fig/statement/include.rb', line 88

def minimum_grammar_for_publishing()
  return minimum_grammar
end

#package_nameObject



41
42
43
# File 'lib/fig/statement/include.rb', line 41

def package_name
  return @descriptor.name
end

#resolved_dependency_descriptor(containing_package, backtrace) ⇒ Object

Assume that this statement is part of the parameter and return a descriptor that represents the fully resolved dependency, taking into account that the version might have been overridden.



72
73
74
75
76
77
78
# File 'lib/fig/statement/include.rb', line 72

def resolved_dependency_descriptor(containing_package, backtrace)
  return Fig::PackageDescriptor.new(
    referenced_package_name(containing_package),
    referenced_version(containing_package, backtrace),
    referenced_config_name()
  )
end

#statement_typeObject



37
38
39
# File 'lib/fig/statement/include.rb', line 37

def statement_type()
  return 'include'
end

#versionObject



45
46
47
# File 'lib/fig/statement/include.rb', line 45

def version
  return @descriptor.version
end