Module: Fig::Unparser

Included in:
V0, V1
Defined in:
lib/fig/unparser.rb,
lib/fig/unparser/v0.rb,
lib/fig/unparser/v1.rb

Defined Under Namespace

Classes: V0, V1

Instance Method Summary collapse

Instance Method Details

#archive(statement) ⇒ Object



17
18
19
20
21
# File 'lib/fig/unparser.rb', line 17

def archive(statement)
  asset 'archive', statement

  return
end

#command(statement) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/fig/unparser.rb', line 23

def command(statement)
  raise NotImplementedError
end

#configuration(configuration_statement) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fig/unparser.rb', line 27

def configuration(configuration_statement)
  if ! @text.empty?
    @text << "\n"
  end

  add_indent
  @text << 'config '
  @text << configuration_statement.name
  @text << "\n"

  @indent_level += 1
  begin
    configuration_statement.statements.each do
      |statement|

      statement.unparse_as_version(self)
    end
  ensure
    @indent_level -= 1
  end

  add_indent
  @text << "end\n"

  return
end

#grammar_version(statement) ⇒ Object

Raises:

  • (NotImplementedError)


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

def grammar_version(statement)
  raise NotImplementedError
end

#include(statement) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fig/unparser.rb', line 58

def include(statement)
  add_indent

  @text << 'include '
  @text << Fig::PackageDescriptor.format(
    statement.package_name, statement.version, statement.config_name
  )
  @text << "\n"

  return
end

#override(statement) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fig/unparser.rb', line 70

def override(statement)
  add_indent

  @text << 'override '
  @text << Fig::PackageDescriptor.format(
    statement.package_name, statement.version, nil
  )
  @text << "\n"

  return
end

#path(statement) ⇒ Object



82
83
84
85
86
# File 'lib/fig/unparser.rb', line 82

def path(statement)
  environment_variable(statement, 'append')

  return
end

#resource(statement) ⇒ Object



88
89
90
91
92
# File 'lib/fig/unparser.rb', line 88

def resource(statement)
  asset 'resource', statement

  return
end

#retrieve(statement) ⇒ Object

Raises:

  • (NotImplementedError)


94
95
96
# File 'lib/fig/unparser.rb', line 94

def retrieve(statement)
  raise NotImplementedError
end

#set(statement) ⇒ Object



98
99
100
101
102
# File 'lib/fig/unparser.rb', line 98

def set(statement)
  environment_variable(statement, 'set')

  return
end

#unparse(statements) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fig/unparser.rb', line 4

def unparse(statements)
  @text         = ''
  @indent_level = @initial_indent_level

  statements.each { |statement| statement.unparse_as_version(self) }

  text          = @text
  @text         = nil
  @indent_level = nil

  return text
end