Sha256: b8e18ee8fe0f922ecfe308dfee9a4d82f4d149ff2acbb8bb3381b7cae57cb4ee

Contents?: true

Size: 1.06 KB

Versions: 31

Compression:

Stored size: 1.06 KB

Contents

require 'erb'
require 'ostruct'

module Dockly
  class BashBuilder
    SNIPPET_PATH = File.expand_path("../../../snippets", __FILE__)

    def self.generate_snippet_for(name, opts, defaults={})
      define_method(name) do |*args|
        zipped_array = opts.zip(args).flatten
        snippet = File.read(File.join(SNIPPET_PATH, "#{name}.erb"))
        hash = Hash[*zipped_array].delete_if { |_,v| v.nil? }
        data = defaults.merge(hash)
        ERB.new(snippet).result(binding)
      end
    end

    generate_snippet_for :normalize_for_dockly, []
    generate_snippet_for :get_and_install_deb, [:s3_url, :deb_path]

    generate_snippet_for :file_docker_import, [:path, :repo, :tag]
    generate_snippet_for :file_diff_docker_import, [:base_image, :diff_image, :repo, :tag]
    generate_snippet_for :s3_docker_import, [:s3_url, :repo, :tag]
    generate_snippet_for :s3_diff_docker_import, [:base_image, :diff_image, :repo, :tag]
    generate_snippet_for :registry_import, [:repo, :tag], { :tag => "latest" }

    generate_snippet_for :docker_tag_latest, [:repo, :tag]
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
dockly-3.0.4 lib/dockly/bash_builder.rb
dockly-3.0.3 lib/dockly/bash_builder.rb
dockly-3.0.2 lib/dockly/bash_builder.rb
dockly-3.0.1 lib/dockly/bash_builder.rb
dockly-3.0.0 lib/dockly/bash_builder.rb
dockly-2.7.2 lib/dockly/bash_builder.rb
dockly-2.7.1 lib/dockly/bash_builder.rb
dockly-2.7.0 lib/dockly/bash_builder.rb
dockly-1.13.0 lib/dockly/bash_builder.rb
dockly-2.6.0 lib/dockly/bash_builder.rb
dockly-1.12.3 lib/dockly/bash_builder.rb
dockly-2.5.3 lib/dockly/bash_builder.rb
dockly-1.12.2 lib/dockly/bash_builder.rb
dockly-2.5.2 lib/dockly/bash_builder.rb
dockly-1.12.1 lib/dockly/bash_builder.rb
dockly-2.5.1 lib/dockly/bash_builder.rb
dockly-1.12.0 lib/dockly/bash_builder.rb
dockly-2.5.0 lib/dockly/bash_builder.rb
dockly-1.11.0 lib/dockly/bash_builder.rb
dockly-2.4.0 lib/dockly/bash_builder.rb