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

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, variable, tokenized_path) ⇒ Retrieve

Returns a new instance of Retrieve.



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

def initialize(line_column, source_description, variable, tokenized_path)
  super(line_column, source_description)

  @variable       = variable
  @tokenized_path = tokenized_path

  path = tokenized_path.to_escaped_string
  # 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

#tokenized_pathObject (readonly)

Returns the value of attribute tokenized_path.



18
19
20
# File 'lib/fig/statement/retrieve.rb', line 18

def tokenized_path
  @tokenized_path
end

#variableObject (readonly)

Returns the value of attribute variable.



17
18
19
# File 'lib/fig/statement/retrieve.rb', line 17

def variable
  @variable
end

Class Method Details

.tokenize_path(path, &error_block) ⇒ Object



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

def self.tokenize_path(path, &error_block)
  tokenizer = Fig::StringTokenizer.new TOKENIZING_SUBEXPRESSION_MATCHER, '\\['
  return tokenizer.tokenize path, &error_block
end

Instance Method Details

#added_to_environment(yea_or_nay) ⇒ Object



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

def added_to_environment(yea_or_nay)
  @added_to_environment = yea_or_nay
end

#added_to_environment?Boolean

Returns:

  • (Boolean)


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

def added_to_environment?()
  return @added_to_environment
end

#deparse_as_version(deparser) ⇒ Object



63
64
65
# File 'lib/fig/statement/retrieve.rb', line 63

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

#loaded_but_not_referenced?Boolean

Returns:

  • (Boolean)


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

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

#minimum_grammar_for_emitting_inputObject



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

def minimum_grammar_for_emitting_input()
  return minimum_grammar()
end

#minimum_grammar_for_publishingObject



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

def minimum_grammar_for_publishing()
  return minimum_grammar()
end

#referenced(yea_or_nay) ⇒ Object



59
60
61
# File 'lib/fig/statement/retrieve.rb', line 59

def referenced(yea_or_nay)
  @referenced = yea_or_nay
end

#referenced?Boolean

Returns:

  • (Boolean)


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

def referenced?()
  return @referenced
end

#statement_typeObject



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

def statement_type()
  return 'retrieve'
end