Sha256: 61b2e87d42636eb7ec6206eaed36c486ec0f7817a9e4963414cddd98c9857af6

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

require 'tempfile'
require 'fileutils'
require 'logger'

module Evrone
  module CI
    module ContainerConnector

      class Local

        autoload :Spawner, File.expand_path("../local/spawner", __FILE__)

        attr_reader :work_dir, :logger

        def initialize(options = {})
          @work_dir = options[:work_dir] || default_work_dir
          @work_dir = File.expand_path(@work_dir)
          @logger   = options[:logger] || Logger.new(STDOUT)
        end

        def start(&block)
          FileUtils.rm_rf(work_dir)
          FileUtils.mkdir_p(work_dir)

          spawner = Spawner.new(work_dir)
          logger.info "inside #{work_dir}"
          yield spawner
        end

        private

          def default_work_dir
            "#{Dir.tmpdir}/.local_connector"
          end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrone-ci-container_connector-0.2.0.pre28 lib/evrone/ci/container_connector/local.rb