Sha256: e54cb055890c89c091c1f2aa49b82f43ef322e01b5f5e4d323daa8e4017ab9cc

Contents?: true

Size: 1.67 KB

Versions: 26

Compression:

Stored size: 1.67 KB

Contents

require 'dockly/util'
require 'dockly/util/tar'
require 'dockly/util/git'
require 'fog'
require 'foreman/cli_fix'
require 'foreman/export/base_fix'

module Dockly
  attr_reader :instance, :git_sha
  attr_writer :load_file

  autoload :AWS, 'dockly/aws'
  autoload :Foreman, 'dockly/foreman'
  autoload :BashBuilder, 'dockly/bash_builder'
  autoload :BuildCache, 'dockly/build_cache'
  autoload :Docker, 'dockly/docker'
  autoload :Deb, 'dockly/deb'
  autoload :Rpm, 'dockly/rpm'
  autoload :TarDiff, 'dockly/tar_diff'

  LOAD_FILE = 'dockly.rb'

  def load_file
    @load_file || LOAD_FILE
  end

  def inst
    @instance ||= load_inst
  end

  def load_inst
    setup.tap do |state|
      if File.exists?(load_file)
        instance_eval(IO.read(load_file), load_file)
      end
    end
  end

  def setup
    {
      :debs => Dockly::Deb.instances,
      :rpms => Dockly::Rpm.instances,
      :dockers => Dockly::Docker.instances,
      :foremans => Dockly::Foreman.instances
    }
  end

  {
    :deb => Dockly::Deb,
    :rpm => Dockly::Rpm,
    :docker => Dockly::Docker,
    :foreman => Dockly::Foreman
  }.each do |method, klass|
    define_method(method) do |sym, &block|
      if block.nil?
        inst[:"#{method}s"][sym]
      else
        klass.new!(:name => sym, &block)
      end
    end
  end

  [:debs, :rpms, :dockers, :foremans].each do |method|
    define_method(method) do
      inst[method]
    end
  end

  def git_sha
    @git_sha ||= Dockly::Util::Git.git_sha
  end

  module_function :inst, :load_inst, :setup, :load_file, :load_file=,
                  :deb,  :rpm,  :docker,  :foreman, :git_sha,
                  :debs, :rpms, :dockers, :foremans
end

require 'dockly/rake_task'

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dockly-1.7.0 lib/dockly.rb
dockly-1.6.0 lib/dockly.rb
dockly-1.5.16 lib/dockly.rb
dockly-1.5.15 lib/dockly.rb
dockly-1.5.14 lib/dockly.rb
dockly-1.5.12 lib/dockly.rb