Sha256: ffb9f1c4414e3b845fcd56747dbd9df3756e52face5c18f5f6d55d14c7b09e06

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 Bytes

Contents

require 'lino'

module RubyGPG2
  module Commands
    class Base
      attr_reader :binary

      def initialize(binary: nil)
        @binary = binary || RubyGPG2.configuration.binary
      end

      def stdin
        ''
      end

      def stdout
        STDOUT
      end

      def stderr
        STDERR
      end

      def execute(opts = {})
        builder = instantiate_builder

        do_before(opts)
        builder = configure_command(builder, opts)
        builder
            .build
            .execute(
                stdin: stdin,
                stdout: stdout,
                stderr: stderr)
        do_after(opts)
      end

      def instantiate_builder
        Lino::CommandLineBuilder
            .for_command(binary)
            .with_option_separator('=')
      end

      def do_before(opts)
      end

      def configure_command(builder, opts)
        builder
      end

      def do_after(opts)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_gpg2-0.1.0.pre.3 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.2 lib/ruby_gpg2/commands/base.rb