Sha256: 21d26eff69cfbf63e70af7eebc0404378970e455c9bdec293b107c8dbd571151

Contents?: true

Size: 726 Bytes

Versions: 21

Compression:

Stored size: 726 Bytes

Contents

module CapistranoSentinel
  # class used to hook into the input stream
  class InputStream
    def self.hook(actor, stringio)
      $stdin = new($stdin, actor, stringio)
    end

    def self.unhook
      $stdin.finish if $stdin.is_a? CapistranoSentinel::InputStream
      $stdin = STDIN
    end

    attr_accessor :real, :actor, :stringio

    def initialize(real_stdin, actor, stringio)
      self.real = real_stdin
      self.actor = actor
      self.stringio = stringio
    end

    def gets(*_args)
      @stringio.rewind
      data = @stringio.read
      @actor.user_prompt_needed?(data)
    end

    def finish
    end

    def method_missing(name, *args, &block)
      @real.send name, *args, &block
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
capistrano_sentinel-0.2.3 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.2.2 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.2.1 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.2.0 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.1.1 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.1.0 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.18 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.17 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.16 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.15 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.14 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.12 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.10 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.9 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.8 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.7 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.6 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.5 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.3 lib/capistrano_sentinel/classes/input_stream.rb
capistrano_sentinel-0.0.2 lib/capistrano_sentinel/classes/input_stream.rb