Class: Fig::Deparser::V2

Inherits:
Object
  • Object
show all
Includes:
Fig::Deparser, V1Base
Defined in:
lib/fig/deparser/v2.rb

Overview

Handles serializing of statements in the v2 grammar.

Instance Method Summary collapse

Methods included from V1Base

#command, #retrieve

Methods included from Fig::Deparser

#archive, class_for_statements, #command, #configuration, #deparse, determine_version_and_deparse, #include, #override, #path, #resource, #retrieve, #set, #synthetic_raw_text

Constructor Details

#initialize(emit_as_input_or_to_be_published_values, indent_string = ' ' * 2, initial_indent_level = 0) ⇒ V2

Returns a new instance of V2.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fig/deparser/v2.rb', line 12

def initialize(
  emit_as_input_or_to_be_published_values,
  indent_string = ' ' * 2,
  initial_indent_level = 0
)
  @emit_as_input_or_to_be_published_values =
    emit_as_input_or_to_be_published_values
  @indent_string        = indent_string
  @initial_indent_level = initial_indent_level

  return
end

Instance Method Details

#grammar_descriptionObject



52
53
54
# File 'lib/fig/deparser/v2.rb', line 52

def grammar_description()
  return 'v2'
end

#grammar_version(statement) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fig/deparser/v2.rb', line 25

def grammar_version(statement)
  add_indent

  @text << "grammar v2\n"

  return
end

#include_file(statement) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fig/deparser/v2.rb', line 33

def include_file(statement)
  path = statement.path
  quote = (path.include?(%q<'>) && ! path.include?(%q<">)) ? %q<"> : %q<'>

  add_indent

  @text << 'include-file '
  @text << quote
  @text << path.gsub('\\', ('\\' * 4)).gsub(quote, "\\\\#{quote}")
  @text << quote
  if ! statement.config_name.nil?
    @text << ':'
    @text << statement.config_name
  end
  @text << "\n"

  return
end