class RubyGPG2::Commands::Base

Attributes

binary[R]
stderr[R]
stdin[R]
stdout[R]

Public Class Methods

new(binary: nil, stdin: nil, stdout: nil, stderr: nil) click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 8
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

Public Instance Methods

execute(opts = {}) click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 15
def execute(opts = {})
  builder = instantiate_builder

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

Protected Instance Methods

configure_command(builder, opts) click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 43
def configure_command(builder, opts)
  builder
end
do_after(opts) click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 51
def do_after(opts)
  Result.new
end
do_around(opts) { |opts| ... } click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 47
def do_around(opts)
  yield opts
end
do_before(opts) click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 40
def do_before(opts)
end
instantiate_builder() click to toggle source
# File lib/ruby_gpg2/commands/base.rb, line 35
def instantiate_builder
  Lino::CommandLineBuilder
      .for_command(binary)
end