Sha256: 8dbd42ac28ab7063bd12df2f880e3290e60359291913adfcb5b0e0035aa186a7

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

require 'lino'

module RubyGPG2
  module Commands
    class Base
      def initialize(binary: nil, stdin: nil, stdout: nil, stderr: nil)
        @binary = binary || RubyGPG2.configuration.binary
        @stdin = stdin || RubyGPG2.configuration.stdin
        @stdout = stdout || RubyGPG2.configuration.stdout
        @stderr = stderr || RubyGPG2.configuration.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

      protected

      attr_reader :binary, :stdin, :stdout, :stderr

      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

11 entries across 11 versions & 1 rubygems

Version Path
ruby_gpg2-0.1.0.pre.14 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.13 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.12 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.11 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.10 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.9 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.8 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.7 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.6 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.5 lib/ruby_gpg2/commands/base.rb
ruby_gpg2-0.1.0.pre.4 lib/ruby_gpg2/commands/base.rb