Class: Infrastructure::Formatters::BashSource

Inherits:
Base
  • Object
show all
Defined in:
lib/infrastructure/formatters/bash_source.rb

Overview

transform hashes to bash source format

Instance Method Summary collapse

Methods inherited from Base

format

Instance Method Details

#format(hash) ⇒ String

Parameters:

  • hash (Hash)

Returns:

  • (String)


11
12
13
14
15
16
# File 'lib/infrastructure/formatters/bash_source.rb', line 11

def format(hash)
  hash.map do |key, value|
    val = value.gsub(/[']/, "'" => "\\'")
    "export #{key}='#{val}'\n"
  end.join
end