Class: Fig::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/fig/statement.rb,
lib/fig/statement/asset.rb,
lib/fig/statement/archive.rb,
lib/fig/statement/resource.rb,
lib/fig/statement/environment_variable.rb

Overview

A statement within a package definition file (package.fig).

Defined Under Namespace

Modules: Asset, EnvironmentVariable Classes: Archive, Command, Configuration, GrammarVersion, Include, IncludeFile, Override, Path, Resource, Retrieve, Set, SyntheticRawText

Constant Summary collapse

ENVIRONMENT_VARIABLE_NAME_REGEX =
%r< \A \w+ \z >x

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_column, source_description) ⇒ Statement

This mess of getting these as a single array necessary is due to limitations of the “*” array splat operator in ruby v1.8.



31
32
33
34
35
36
37
# File 'lib/fig/statement.rb', line 31

def initialize(line_column, source_description)
  if line_column
    @line, @column = *line_column
  end

  @source_description = source_description
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



27
28
29
# File 'lib/fig/statement.rb', line 27

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



27
28
29
# File 'lib/fig/statement.rb', line 27

def line
  @line
end

#source_descriptionObject (readonly)

Returns the value of attribute source_description.



27
28
29
# File 'lib/fig/statement.rb', line 27

def source_description
  @source_description
end

Class Method Details

.position_description(line, column, source_description) ⇒ Object



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

def self.position_description(line, column, source_description)
  if not line or not column
    return '' if not source_description

    return " (#{source_description})"
  end

  description = " (line #{line}, column #{column}"
  if source_description
    description << ", #{source_description}"
  end
  description << ')'

  return description
end

Instance Method Details

#deparse_as_version(deparser) ⇒ Object

Raises:

  • (NotImplementedError)


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

def deparse_as_version(deparser)
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end

#is_asset?Boolean

Returns:

  • (Boolean)


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

def is_asset?()
  return false
end

#is_environment_variable?Boolean

Returns:

  • (Boolean)


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

def is_environment_variable?()
  return false
end

#minimum_grammar_for_emitting_inputObject

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.

Raises:

  • (NotImplementedError)


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

def minimum_grammar_for_emitting_input()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end

#minimum_grammar_for_publishingObject

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.

Raises:

  • (NotImplementedError)


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

def minimum_grammar_for_publishing()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end

#position_stringObject

Returns a representation of the position of this statement, if the position is known, empty string otherwise. This is written with the idea that you can do something like “puts %Q<Found a statement%Fig::Statement.statementstatement.position_string().>” and get nice looking output regardless of whether the position is actually known or not.



91
92
93
94
95
# File 'lib/fig/statement.rb', line 91

def position_string
  return Fig::Statement.position_description(
    @line, @column, @source_description
  )
end

#statement_typeObject

A name for this kind of Statement, usually a keyword for this statement as it appears in package definition files.

Raises:

  • (NotImplementedError)


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

def statement_type()
  raise NotImplementedError.new(
    "#{__callee__}() not implemented on #{self.class}."
  )
end

#urlsObject



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

def urls()
  return []
end

#walk_statements(&block) ⇒ Object

Block will receive a Statement.



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

def walk_statements(&block)
  return
end