Class: Fig::Statement::Retrieve

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

Overview

Specifies that files from a package should be copied into the current directory when an environment variable has its value changed.

Constant Summary

Constants inherited from Fig::Statement

ENVIRONMENT_VARIABLE_NAME_REGEX

Instance Attribute Summary collapse

Attributes inherited from Fig::Statement

#column, #line, #source_description

Instance Method Summary collapse

Methods inherited from Fig::Statement

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

Constructor Details

#initialize(line_column, source_description, var, path) ⇒ Retrieve

Returns a new instance of Retrieve.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fig/statement/retrieve.rb', line 12

def initialize(line_column, source_description, var, path)
  super(line_column, source_description)

  @var = var
  @path = path

  # Yeah, it's not cross-platform, but File doesn't have an #absolute? method
  # and this is better than nothing.
  if (
        path =~ %r< ^ [\\/] >x \
    ||  Fig::OperatingSystem.windows? && path =~ %r< ^ [a-z] : >xi
  )
    Fig::Logging.warn(
      %Q<The retrieve path "#{path}"#{position_string()} looks like it is intended to be absolute; retrieve paths are always treated as relative.>
    )
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/fig/statement/retrieve.rb', line 10

def path
  @path
end

#varObject (readonly)

Returns the value of attribute var.



10
11
12
# File 'lib/fig/statement/retrieve.rb', line 10

def var
  @var
end

Instance Method Details

#added_to_environment(yea_or_nay) ⇒ Object



38
39
40
# File 'lib/fig/statement/retrieve.rb', line 38

def added_to_environment(yea_or_nay)
  @added_to_environment = yea_or_nay
end

#added_to_environment?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fig/statement/retrieve.rb', line 34

def added_to_environment?()
  return @added_to_environment
end

#loaded_but_not_referenced?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fig/statement/retrieve.rb', line 30

def loaded_but_not_referenced?()
  return added_to_environment? && ! referenced?
end

#minimum_grammar_version_requiredObject



54
55
56
# File 'lib/fig/statement/retrieve.rb', line 54

def minimum_grammar_version_required()
  return 0
end

#referenced(yea_or_nay) ⇒ Object



46
47
48
# File 'lib/fig/statement/retrieve.rb', line 46

def referenced(yea_or_nay)
  @referenced = yea_or_nay
end

#referenced?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fig/statement/retrieve.rb', line 42

def referenced?()
  return @referenced
end

#unparse_as_version(unparser) ⇒ Object



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

def unparse_as_version(unparser)
  return unparser.retrieve(self)
end