class Plat::Layout

Public Class Methods

new(options={},&block) click to toggle source
# File lib/plat/layout.rb, line 6
def initialize(options={},&block)
  configure(options,&block)
  configuration.lock
end

Public Instance Methods

aws_options() click to toggle source
# File lib/plat/layout/aws.rb, line 14
def aws_options
  @aws_options ||= 
  {
    access_key_id: configuration.aws_access_key_id,
    secret_access_key: configuration.aws_secret_access_key
  }
end
aws_resource_name(role,id=0) click to toggle source
# File lib/plat/layout/aws.rb, line 30
def aws_resource_name(role,id=0)
  aws_role_name_prefix(role)+'-'+id.to_s
end
aws_role_name_prefix(role) click to toggle source
# File lib/plat/layout/aws.rb, line 22
def aws_role_name_prefix(role)
  @aws_role_name_prefix ||= {}
  @aws_role_name_prefix[role] ||= 
    [ configuration.name_prefix, 
      configuration.app_name, 
      configuration.env, 
      role ].map(&:to_s).delete_if{|s| s==''}.join('-').gsub(/\s/,'_')
end
convert_roles(roles_def) click to toggle source
# File lib/plat/role.rb, line 5
def convert_roles(roles_def)
  case roles_def
    when Hash then roles_def
    when Array 
      roles_def.inject({}) do |result,elem|
        result.merge! convert_roles(elem)
      end
    when IO, StringIO, Tempfile then YAML.load(roles_def)
    when String, Pathname
      output = {}
      File.open(roles_def,"r") { |f| output = YAML.load(f) }
      output
    else
      raise ArgumentError.new("Wrong class for 'roles' value: #{roles_def.class}")
  end
end
inspect() click to toggle source
# File lib/plat/layout.rb, line 11
def inspect
  "<#{self.class} #{configuration.to_s}>"
end
roles() click to toggle source
# File lib/plat/role.rb, line 27
def roles
  @roles ||= begin
    configuration.roles.map do |role,options|
      [ role, Plat::Role.create(self,role,options) ]
    end.to_h
  end
end