Sha256: 7ec5366307eb340a0d7495a029a98a272591d25d83b421365ca6deb07f9341ac

Contents?: true

Size: 655 Bytes

Versions: 8

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

require 'stringio'

module RubyGPG2
  module Commands
    module Mixins
      module WithCapturedOutput
        def initialize(*args)
          super(*args)
          @stdout = StringIO.new unless
              defined?(@stdout) && @stdout.respond_to?(:string)
        end

        def do_after(opts)
          super(opts.merge(output: resolve_output(stdout.string, opts)))
        end

        private

        def resolve_output(output, opts)
          parse_output = opts[:parse_output].nil? ? true : opts[:parse_output]
          parse_output ? ColonOutput.parse(output) : output
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_gpg2-0.11.0.pre.4 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.11.0.pre.3 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.11.0.pre.2 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.11.0.pre.1 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.10.0 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.9.0.pre.9 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.9.0.pre.8 lib/ruby_gpg2/commands/mixins/with_captured_output.rb
ruby_gpg2-0.9.0.pre.7 lib/ruby_gpg2/commands/mixins/with_captured_output.rb