Sha256: ac9ec01bb75397be1bf2f974f78debeaae6c2f33e379d46e83c92db53b0bbb1d

Contents?: true

Size: 661 Bytes

Versions: 3

Compression:

Stored size: 661 Bytes

Contents

require 'ostruct'

module CapUtil

  class FakeCap

    attr_reader :roles, :cmds_run

    def initialize(*args)
      @struct = OpenStruct.new
      @roles = []
      @cmds_run = []
    end

    def method_missing(method, *args, &block)
      @struct.send(method, *args, &block)
    end

    def respond_to?(method)
      @struct.respond_to?(method) ? true : super
    end

    def run(cmd, *args)
      @cmds_run << cmd
    end

    def sudo(cmd, *args)
      run("sudo #{cmd}", *args)
    end

    def fetch(var_name)
      self.send("fetch_#{var_name}")
    end

    def role(name, hostname, opts)
      @roles << [name, hostname, opts]
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cap-util-1.5.2 lib/cap-util/fake_cap.rb
cap-util-1.5.1 lib/cap-util/fake_cap.rb
cap-util-1.5.0 lib/cap-util/fake_cap.rb