Sha256: 100922e3f8fabf2b50feedfd520d6fa661a484cb05990deb549e7e3aa40267a8

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require 'fig/unparser'

module Fig; end
module Fig::Unparser; end

# Handles serializing of statements in the v1 grammar.
class Fig::Unparser::V1
  include Fig::Unparser

  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

  def command(statement)
    add_indent

    @text << %q<command ">
    @text << statement.command
    @text << %Q<"\n>

    return
  end

  def grammar_version(statement)
    add_indent

    @text << "grammar v1\n"

    return
  end

  def grammar_description()
    return 'v1'
  end

  private

  def asset(keyword, statement)
    quote = statement.glob_if_not_url? ? %q<"> : %q<'>
    path  =
      asset_path(statement).gsub('\\', ('\\' * 4)).gsub(quote, "\\#{quote}")

    add_indent
    @text << keyword
    @text << ' '
    @text << quote
    @text << path
    @text << quote
    @text << "\n"

    return
  end

  def environment_variable(statement, keyword)
    # TODO: temporarily hack v0 grammar in here so we can test asset
    # statements; proper implementation once asset statements are done.
    add_indent

    @text << keyword
    @text << ' '
    @text << statement.name
    @text << '='
    @text << statement.value
    @text << "\n"

    return
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fig-0.1.81 lib/fig/unparser/v1.rb
fig-0.1.79 lib/fig/unparser/v1.rb