class Fig::Statement::Path

A statement that specifies or modifies a path environment variable, e.g. “append”, “path”, “add” (though those are all synonyms).

Public Class Methods

new(line_column, source_description, name, tokenized_value) click to toggle source
Calls superclass method Fig::Statement::new
# File lib/fig/statement/path.rb, line 45
def initialize(line_column, source_description, name, tokenized_value)
  super(line_column, source_description)

  @name = name
  @tokenized_value = tokenized_value
end
parse_name_value(combined) { |%Q<The value of path variable #{variable} is empty.>| ... } click to toggle source

Yields on error.

# File lib/fig/statement/path.rb, line 14
def self.parse_name_value(combined, &error_block)
  variable, raw_value = seperate_name_and_value combined, &error_block

  tokenized_value = tokenize_value(raw_value, &error_block)

  if tokenized_value.to_escaped_string.length < 1
    yield %Q<The value of path variable #{variable} is empty.>
    return
  end

  return [variable, tokenized_value]
end
parse_v0_name_value(combined) { |%Q<The value of path variable #{variable} is empty.>| ... } click to toggle source
# File lib/fig/statement/path.rb, line 27
def self.parse_v0_name_value(combined, &error_block)
  variable, raw_value = seperate_name_and_value combined, &error_block

  if raw_value.length < 1
    yield %Q<The value of path variable #{variable} is empty.>
    return
  end

  base_v0_value_validation(variable, raw_value, &error_block)

  if raw_value =~ /([;:<>|])/
    yield %Q<The value of path variable #{variable} (#{raw_value}) contains a "#{$1}" character.>
    return
  end

  return [variable, tokenize_value(raw_value, &error_block)]
end

Public Instance Methods

deparse_as_version(deparser) click to toggle source
# File lib/fig/statement/path.rb, line 60
def deparse_as_version(deparser)
  return deparser.path(self)
end
is_environment_variable?() click to toggle source
# File lib/fig/statement/path.rb, line 56
def is_environment_variable?()
  return true
end
statement_type() click to toggle source
# File lib/fig/statement/path.rb, line 52
def statement_type()
  return 'path'
end

Private Instance Methods

minimum_grammar() click to toggle source
# File lib/fig/statement/path.rb, line 66
def minimum_grammar()
  base_grammar_version = standard_minimum_grammar
  return base_grammar_version if base_grammar_version[0] != 0

  value = tokenized_value.to_escaped_string
  if value =~ / ( [;:<>|] ) /x
    return [1, %Q<contains a "#{$1}" character>]
  end

  return [0]
end