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.



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

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.



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

def config_name
  @config_name
end

#containing_package_descriptorObject (readonly)

Returns the value of attribute containing_package_descriptor.



53
54
55
# File 'lib/fig/statement/include_file.rb', line 53

def containing_package_descriptor
  @containing_package_descriptor
end

#pathObject (readonly)

Returns the value of attribute path.



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

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.')


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

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



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

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



77
78
79
# File 'lib/fig/statement/include_file.rb', line 77

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

#full_path_relative_to(including_package) ⇒ Object



73
74
75
# File 'lib/fig/statement/include_file.rb', line 73

def full_path_relative_to(including_package)
  return File.expand_path(path, including_package.include_file_base_directory)
end

#minimum_grammar_for_emitting_inputObject



81
82
83
# File 'lib/fig/statement/include_file.rb', line 81

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

#minimum_grammar_for_publishingObject



85
86
87
# File 'lib/fig/statement/include_file.rb', line 85

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

#statement_typeObject



69
70
71
# File 'lib/fig/statement/include_file.rb', line 69

def statement_type()
  return 'include-file'
end