class Betterdoc::Support::Servicefile

Attributes

environment[RW]
service_name[RW]
version[RW]

Public Class Methods

new() click to toggle source
# File lib/betterdoc/support/servicefile.rb, line 12
def initialize
  @version = "1.0"
  @environment = {}
end

Public Instance Methods

add_environment(variable_name, description, optional = false, default = nil) click to toggle source
# File lib/betterdoc/support/servicefile.rb, line 17
def add_environment(variable_name, description, optional = false, default = nil)
  entry = ServicefileEnvironmentEntry.new
  entry.description = description
  entry.optional = optional
  entry.default = default
  @environment[variable_name] = entry
end
to_yaml() click to toggle source
# File lib/betterdoc/support/servicefile.rb, line 25
def to_yaml
  {
    'version' => '1.0',
    'service_name' => @app_name,
    'runtime' => {
      'env' => to_environment_hash
    }
  }.to_yaml
end

Private Instance Methods

to_environment_hash() click to toggle source
# File lib/betterdoc/support/servicefile.rb, line 37
def to_environment_hash
  environment = []
  @environment.each do |key, environment_entry|
    environment_item = { "name" => key }
    environment_item['description'] = environment_entry.description unless environment_entry.description.nil?
    environment_item['optional'] = true if environment_entry.optional
    environment_item['default'] = environment_entry.default unless environment_entry.default.nil?
    environment.push(environment_item)
  end
  environment
end