Class: Fig::Statement::IncludeFile

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

Overview

Like an include, but of an unpublished file.

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, path, config_name, containing_package_descriptor) ⇒ IncludeFile

Returns a new instance of IncludeFile.



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

def initialize(
  line_column,
  source_description,
  path,
  config_name,
  containing_package_descriptor
)
  super(line_column, source_description)

  @path                          = path
  @config_name                   = config_name
  @containing_package_descriptor = containing_package_descriptor
end

Instance Attribute Details

#config_nameObject (readonly)

Returns the value of attribute config_name.



50
51
52
# File 'lib/fig/statement/include_file.rb', line 50

def config_name
  @config_name
end

#containing_package_descriptorObject (readonly)

Returns the value of attribute containing_package_descriptor.



51
52
53
# File 'lib/fig/statement/include_file.rb', line 51

def containing_package_descriptor
  @containing_package_descriptor
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Class Method Details

.parse_path_with_config(path_with_config) {|'could not be understood as a path followed by a config name.'| ... } ⇒ Object

Yields:

  • ('could not be understood as a path followed by a config name.')


9
10
11
12
13
14
15
16
17
18
# File 'lib/fig/statement/include_file.rb', line 9

def self.parse_path_with_config(path_with_config, &block)
  if match = PATH_WITH_CONFIG_PATTERN.match(path_with_config)
    return validate_and_process_raw_path_and_config_name(
      match[:path], match[:config], &block
    )
  end

  yield 'could not be understood as a path followed by a config name.'
  return
end

.validate_and_process_raw_path_and_config_name(raw_path, config_name, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fig/statement/include_file.rb', line 20

def self.validate_and_process_raw_path_and_config_name(
  raw_path, config_name, &block
)
  if raw_path !~ /['"]/ && raw_path =~ /:/
    yield 'has an unquoted colon (:) in the path portion.'
    return
  end
  if (
    ! config_name.nil? &&
    config_name !~ Fig::PackageDescriptor::COMPONENT_PATTERN
  )
    yield "contains an invalid config name (#{config_name})."
    return
  end
  tokenized_path = validate_and_process_escapes_in_path(raw_path, &block)
  return if tokenized_path.nil?

  return tokenized_path.to_expanded_string, config_name
end

Instance Method Details

#deparse_as_version(deparser) ⇒ Object



71
72
73
# File 'lib/fig/statement/include_file.rb', line 71

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

#minimum_grammar_for_emitting_inputObject



75
76
77
# File 'lib/fig/statement/include_file.rb', line 75

def minimum_grammar_for_emitting_input()
  return [2, %q<didn't exist prior to v2>]
end

#minimum_grammar_for_publishingObject



79
80
81
# File 'lib/fig/statement/include_file.rb', line 79

def minimum_grammar_for_publishing()
  raise Fig::UserInputError.new 'Cannot publish an include-file statement.'
end

#statement_typeObject



67
68
69
# File 'lib/fig/statement/include_file.rb', line 67

def statement_type()
  return 'include-file'
end