Sha256: a41370c5f2663af6881fea959c8bd66f0c75fc189e25d720aa0795e30dbb041a

Contents?: true

Size: 1.5 KB

Versions: 57

Compression:

Stored size: 1.5 KB

Contents

require "mothership"
require "interact"
require "vmc"

# [EventLog]
$vmc_event = nil

class VMC::CLI
  def run(name)
    if input[:help]
      invoke :help, :command => cmd.name.to_s
    else
      precondition
      super
    end
  end

  class ProgressEventReporter
    def initialize(message, skipper)
      @message = message
      @skipper = skipper
      @skipped = false
    end

    def skip(&blk)
      @skipped = true
      $vmc_event.skipped(@message)
      @skipper.skip(&blk)
    end

    def fail(&blk)
      @skipped = true
      $vmc_event.failed_to(@message)
      @skipper.fail(&blk)
    end

    def give_up(&blk)
      @skipped = true
      $vmc_event.gave_up(@message)
      @skipper.give_up(&blk)
    end

    def skipped?
      @skipped
    end
  end

  def ask(*args)
    $vmc_event.asking(*args) if $vmc_event
    super
  end

  def line(*args)
    $vmc_event.printed(*args) if $vmc_event
    super
  end

  def force?
    false
  end

  def with_progress(msg, &blk)
    super(msg) do |s|
      reporter = ProgressEventReporter.new(msg, s)

      res = blk.call(reporter)

      $vmc_event.did(msg) unless reporter.skipped?

      res
    end
  rescue
    $vmc_event.failed_to(msg)
    raise
  end
end

class Mothership::Inputs
  alias_method :vmc_spec_get, :get

  def get(name, context, *args)
    val = vmc_spec_get(name, context, *args)
    $vmc_event.got_input(name, val) if $vmc_event
    val
  end
end

module Interactive
  def set_input_state(input)
  end

  def restore_input_state(input, before)
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
vmc-0.4.0.beta.93 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.92 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.91 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.90 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.89 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.88 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.87 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.86 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.85 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.84 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.83 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.82 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.81 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.80 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.79 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.78 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.77 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.76 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.75 vmc-ng/lib/vmc/spec_helpers/patches.rb
vmc-0.4.0.beta.74 vmc-ng/lib/vmc/spec_helpers/patches.rb