Sha256: cd05359e5f89178f8c529c528d9b383d8493463d0e4f44e831a4f01483069e4a

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

require 'shipitron'

module Shipitron
  class PostBuild < Hashie::Dash
    property :ecs_task
    property :container_name
    property :command

    # String is of the format:
    # 'ecs_task:task,container_name:name,command:command
    def self.parse(str)
      PostBuild.new.tap do |post_build|
        str.split(',').each do |part|
          part.match(/([^:]+):(.+)/) do |m|
            prop = m[1].to_sym
            if property?(prop)
              post_build[prop] = m[2]
            end
          end
        end

        properties.each do |prop|
          raise "post build argument missing '#{prop}'" if post_build[prop].nil?
        end
      end
    end

    def to_s
      "ecs_task:#{ecs_task},container_name:#{container_name},command:#{command}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shipitron-0.2.1 lib/shipitron/post_build.rb
shipitron-0.2.0 lib/shipitron/post_build.rb