class RubyFly::Commands::Base

Attributes

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

Public Class Methods

new(binary: nil) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 8
def initialize(binary: nil)
  @binary = binary || RubyFly.configuration.binary
  @stdin = stdin || RubyFly.configuration.stdin
  @stdout = stdout || RubyFly.configuration.stdout
  @stderr = stderr || RubyFly.configuration.stderr
end

Public Instance Methods

configure_command(builder, opts) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 43
def configure_command(builder, opts)
  builder
end
do_after(opts) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 47
def do_after(opts)
end
do_around(opts, &block) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 39
def do_around(opts, &block)
  block.call(opts)
end
do_before(opts) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 36
def do_before(opts)
end
execute(opts = {}) click to toggle source
# File lib/ruby_fly/commands/base.rb, line 15
def execute(opts = {})
  builder = instantiate_builder

  do_before(opts)
  do_around(opts) do |new_opts|
    configure_command(builder, new_opts)
        .build
        .execute(
            stdin: stdin,
            stdout: stdout,
            stderr: stderr)
  end
  do_after(opts)
end
instantiate_builder() click to toggle source
# File lib/ruby_fly/commands/base.rb, line 30
def instantiate_builder
  Lino::CommandLineBuilder
      .for_command(binary)
      .with_option_separator('=')
end