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.



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

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.



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

def tokenized_path
  @tokenized_path
end

#variableObject (readonly)

Returns the value of attribute variable.



15
16
17
# File 'lib/fig/statement/retrieve.rb', line 15

def variable
  @variable
end

Class Method Details

.tokenize_path(path, &error_block) ⇒ Object



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

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



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

def added_to_environment(yea_or_nay)
  @added_to_environment = yea_or_nay
end

#added_to_environment?Boolean

Returns:

  • (Boolean)


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

def added_to_environment?()
  return @added_to_environment
end

#deparse_as_version(deparser) ⇒ Object



61
62
63
# File 'lib/fig/statement/retrieve.rb', line 61

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

#loaded_but_not_referenced?Boolean

Returns:

  • (Boolean)


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

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

#minimum_grammar_for_emitting_inputObject



65
66
67
# File 'lib/fig/statement/retrieve.rb', line 65

def minimum_grammar_for_emitting_input()
  return minimum_grammar()
end

#minimum_grammar_for_publishingObject



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

def minimum_grammar_for_publishing()
  return minimum_grammar()
end

#referenced(yea_or_nay) ⇒ Object



57
58
59
# File 'lib/fig/statement/retrieve.rb', line 57

def referenced(yea_or_nay)
  @referenced = yea_or_nay
end

#referenced?Boolean

Returns:

  • (Boolean)


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

def referenced?()
  return @referenced
end

#statement_typeObject



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

def statement_type()
  return 'retrieve'
end