Sha256: 12427e33b58d872197978389b5a2a353d0ec6802c3d6d76977ace14ca42fa9e7

Contents?: true

Size: 915 Bytes

Versions: 8

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

require 'tempfile'

require_relative '../../status_output'

module RubyGPG2
  module Commands
    module Mixins
      module WithCapturedStatus
        def do_around(opts)
          if opts[:with_status]
            Tempfile.create('status-file', opts[:work_directory]) do |f|
              yield opts.merge(status_file: f.path)
              @status = File.read(f.path)
            end
          else
            yield opts
          end
        end

        def do_after(opts)
          if opts[:with_status]
            super(opts.merge(status: resolve_status(@status, opts)))
          else
            super(opts)
          end
        end

        private

        def resolve_status(status, opts)
          parse_status = opts[:parse_status].nil? ? true : opts[:parse_status]
          parse_status ? StatusOutput.parse(status) : status
        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_status.rb
ruby_gpg2-0.11.0.pre.3 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.11.0.pre.2 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.11.0.pre.1 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.10.0 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.9.0.pre.9 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.9.0.pre.8 lib/ruby_gpg2/commands/mixins/with_captured_status.rb
ruby_gpg2-0.9.0.pre.7 lib/ruby_gpg2/commands/mixins/with_captured_status.rb