Class: Fig::Statement::Include
- Inherits:
-
Fig::Statement
- Object
- Fig::Statement
- Fig::Statement::Include
- 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
-
#containing_package_descriptor ⇒ Object
readonly
Returns the value of attribute containing_package_descriptor.
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
Attributes inherited from Fig::Statement
#column, #line, #source_description
Class Method Summary collapse
-
.parse_descriptor(raw_string, options = {}) ⇒ Object
Centralized definition of requirements for descriptors for include statements.
Instance Method Summary collapse
- #complain_if_version_missing ⇒ Object
- #config_name ⇒ Object
-
#initialize(line_column, source_description, descriptor, containing_package_descriptor) ⇒ Include
constructor
A new instance of Include.
- #package_name ⇒ Object
-
#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.
- #unparse(indent) ⇒ Object
- #version ⇒ Object
Methods inherited from Fig::Statement
#is_asset?, position_description, #position_string, #urls, #walk_statements
Constructor Details
#initialize(line_column, source_description, descriptor, containing_package_descriptor) ⇒ Include
Returns a new instance of Include.
19 20 21 22 23 24 |
# File 'lib/fig/statement/include.rb', line 19 def initialize(line_column, source_description, descriptor, containing_package_descriptor) super(line_column, source_description) @descriptor = descriptor @containing_package_descriptor = containing_package_descriptor end |
Instance Attribute Details
#containing_package_descriptor ⇒ Object (readonly)
Returns the value of attribute containing_package_descriptor.
11 12 13 |
# File 'lib/fig/statement/include.rb', line 11 def containing_package_descriptor @containing_package_descriptor end |
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
11 12 13 |
# File 'lib/fig/statement/include.rb', line 11 def descriptor @descriptor end |
Class Method Details
.parse_descriptor(raw_string, options = {}) ⇒ Object
Centralized definition of requirements for descriptors for include statements.
15 16 17 |
# File 'lib/fig/statement/include.rb', line 15 def self.parse_descriptor(raw_string, = {}) return Fig::PackageDescriptor.parse(raw_string, ) end |
Instance Method Details
#complain_if_version_missing ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fig/statement/include.rb', line 38 def complain_if_version_missing() if @descriptor.name && ! @descriptor.version = %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 != '' += %Q< in the .fig file for "#{package_string}"> end end += %Q<#{position_string()}. Whether or not the include statement will work is dependent upon the recursive dependency load order.> Fig::Logging.warn() end end |
#config_name ⇒ Object
34 35 36 |
# File 'lib/fig/statement/include.rb', line 34 def config_name return @descriptor.config end |
#package_name ⇒ Object
26 27 28 |
# File 'lib/fig/statement/include.rb', line 26 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.
57 58 59 60 61 62 63 |
# File 'lib/fig/statement/include.rb', line 57 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 |
#unparse(indent) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/fig/statement/include.rb', line 65 def unparse(indent) text = '' text += package_name() if package_name() text += "/#{version()}" if version() text += ":#{config_name()}" if config_name() return "#{indent}include #{text}" end |
#version ⇒ Object
30 31 32 |
# File 'lib/fig/statement/include.rb', line 30 def version return @descriptor.version end |