Class: RubyFly::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_fly/commands/base.rb

Direct Known Subclasses

GetPipeline, Login, SetPipeline, UnpausePipeline, Version

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binary: nil) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/ruby_fly/commands/base.rb', line 8

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

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary.



6
7
8
# File 'lib/ruby_fly/commands/base.rb', line 6

def binary
  @binary
end

Instance Method Details

#configure_command(builder, opts) ⇒ Object



46
47
48
# File 'lib/ruby_fly/commands/base.rb', line 46

def configure_command(builder, opts)
  builder
end

#do_after(opts) ⇒ Object



50
51
# File 'lib/ruby_fly/commands/base.rb', line 50

def do_after(opts)
end

#do_before(opts) ⇒ Object



43
44
# File 'lib/ruby_fly/commands/base.rb', line 43

def do_before(opts)
end

#execute(opts = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_fly/commands/base.rb', line 24

def execute(opts = {})
  builder = instantiate_builder

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

#instantiate_builderObject



37
38
39
40
41
# File 'lib/ruby_fly/commands/base.rb', line 37

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

#stderrObject



20
21
22
# File 'lib/ruby_fly/commands/base.rb', line 20

def stderr
  STDERR
end

#stdinObject



12
13
14
# File 'lib/ruby_fly/commands/base.rb', line 12

def stdin
  ''
end

#stdoutObject



16
17
18
# File 'lib/ruby_fly/commands/base.rb', line 16

def stdout
  STDOUT
end