Sha256: e30e1277e1acda3620fffef63f70a8e493ca8a397c0301c874c67bc64cea7e70

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'dk/config_runner'
require 'dk/has_the_stubs'

module Dk

  class DryRunner < ConfigRunner
    include HasTheStubs

    # run with disabled cmds, just log actions, but run all sub-tasks

    def initialize(config, *args)
      super(config, *args)
      config.dry_tree_cmd_stubs.each do |s|
        self.stub_cmd(s.cmd_str_proc, {
          :input => s.input_proc,
          :opts  => s.given_opts_proc
        }, &s.block)
      end
      config.dry_tree_ssh_stubs.each do |s|
        self.stub_ssh(s.cmd_str_proc, {
          :input => s.input_proc,
          :opts  => s.given_opts_proc
        }, &s.block)
      end
    end

    private

    def has_the_stubs_build_local_cmd(cmd_str, given_opts)
      given_opts ||= {}
      cmd_klass = given_opts[:dry_tree_run] ? Local::Cmd : Local::CmdSpy
      cmd_klass.new(cmd_str, given_opts)
    end

    def has_the_stubs_build_remote_cmd(cmd_str, ssh_opts)
      ssh_opts ||= {}
      cmd_klass = ssh_opts[:dry_tree_run] ? Remote::Cmd : Remote::CmdSpy
      cmd_klass.new(cmd_str, ssh_opts)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dk-0.1.1 lib/dk/dry_runner.rb
dk-0.1.0 lib/dk/dry_runner.rb