Sha256: d2ab8222922e996dae706b0b6600d2356c4db597ffaf15f29383b54a2e476368

Contents?: true

Size: 659 Bytes

Versions: 4

Compression:

Stored size: 659 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

4 entries across 4 versions & 1 rubygems

Version Path
cap-util-1.4.0 lib/cap-util/fake_cap.rb
cap-util-1.3.0 lib/cap-util/fake_cap.rb
cap-util-1.2.0 lib/cap-util/fake_cap.rb
cap-util-1.1.0 lib/cap-util/fake_cap.rb