Sha256: 3ce676a61660bef0573716d0a1e0a67f33f2e29bd0f8614b0e5f4f8d1bb840ca

Contents?: true

Size: 1.47 KB

Versions: 15

Compression:

Stored size: 1.47 KB

Contents

require 'socket'
require 'time'

module Heirloom

  class Builder

    attr_writer :local_build

    def initialize(args)
      @config = args[:config]
      @name   = args[:name]
      @id     = args[:id]
      @domain = "heirloom_#{@name}"
      @logger = @config.logger
    end

    def build(args)
      @source        = args[:directory] ||= '.'
      @secret        = args[:secret]
      @bucket_prefix = args[:bucket_prefix]
      @file          = args[:file]
      @exclude       = args[:exclude]

      directory = Directory.new :path    => @source,
                                :file    => @file,
                                :exclude => @exclude,
                                :config  => @config

      unless directory.build_artifact_from_directory :secret => @secret
        return false
      end

      create_artifact_record
    end

    private

    def create_artifact_record
      attributes = { 'built_by'      => "#{user}@#{hostname}",
                     'built_at'      => Time.now.utc.iso8601,
                     'encrypted'     => encrypted?,
                     'bucket_prefix' => @bucket_prefix,
                     'id'            => @id }
      @logger.info "Adding entry #{@id}."
      sdb.put_attributes @domain, @id, attributes
    end

    def encrypted?
      @secret != nil
    end

    def user
      ENV['USER']
    end

    def hostname
      Socket.gethostname
    end

    def sdb
      @sdb ||= AWS::SimpleDB.new :config => @config
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
heirloom-0.12.7 lib/heirloom/archive/builder.rb
heirloom-0.12.5 lib/heirloom/archive/builder.rb
heirloom-0.12.4 lib/heirloom/archive/builder.rb
heirloom-0.12.3 lib/heirloom/archive/builder.rb
heirloom-0.12.2 lib/heirloom/archive/builder.rb
heirloom-0.12.1 lib/heirloom/archive/builder.rb
heirloom-0.12.0 lib/heirloom/archive/builder.rb
heirloom-0.11.2 lib/heirloom/archive/builder.rb
heirloom-0.11.1 lib/heirloom/archive/builder.rb
heirloom-0.11.0 lib/heirloom/archive/builder.rb
heirloom-0.11.0.beta.2 lib/heirloom/archive/builder.rb
heirloom-0.11.0.beta.1 lib/heirloom/archive/builder.rb
heirloom-0.10.1 lib/heirloom/archive/builder.rb
heirloom-0.10.0 lib/heirloom/archive/builder.rb
heirloom-0.9.0 lib/heirloom/archive/builder.rb