Class: RubyEasyRSA::Commands::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binary: nil) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/ruby_easy_rsa/commands/base.rb', line 10

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

Instance Attribute Details

#binaryObject (readonly)

Returns the value of attribute binary.



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

def binary
  @binary
end

Instance Method Details

#configure_command(builder, _opts) ⇒ Object



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

def configure_command(builder, _opts)
  builder
end

#do_after(_) ⇒ Object



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

def do_after(_); end

#do_before(_) ⇒ Object



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

def do_before(_); end

#execute(opts = {}) ⇒ Object



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

def execute(opts = {})
  do_before(opts)
  configure_command(instantiate_builder, opts)
    .build
    .execute(
      stdin: stdin,
      stdout: stdout,
      stderr: stderr
    )
  do_after(opts)
end

#instantiate_builderObject



38
39
40
41
42
# File 'lib/ruby_easy_rsa/commands/base.rb', line 38

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

#stderrObject



22
23
24
# File 'lib/ruby_easy_rsa/commands/base.rb', line 22

def stderr
  $stderr
end

#stdinObject



14
15
16
# File 'lib/ruby_easy_rsa/commands/base.rb', line 14

def stdin
  ''
end

#stdoutObject



18
19
20
# File 'lib/ruby_easy_rsa/commands/base.rb', line 18

def stdout
  $stdout
end