Class: AnnotationSecurity::Exec::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/annotation_security/exec.rb

Overview

An abstract class that encapsulates the executable code for all executables.

Direct Known Subclasses

RailsInstaller

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Generic

Returns a new instance of Generic.

Parameters:

  • args (Array<String>)

    The command-line arguments



21
22
23
# File 'lib/annotation_security/exec.rb', line 21

def initialize(args)
  @args = args
end

Instance Method Details

#optionsObject

Parsed options



16
17
18
# File 'lib/annotation_security/exec.rb', line 16

def options
  @options ||= {}
end

#parse!Object

Parses the command-line arguments and runs the executable. Calls ‘Kernel#exit` at the end, so it never returns.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/annotation_security/exec.rb', line 27

def parse!
  begin
    @opts = OptionParser.new(&method(:set_opts))
    @opts.parse!(@args)

    process_result

    options
  rescue Exception => e
    raise e if e.is_a?(SystemExit) || options[:trace]

    $stderr.puts e.message
    exit 1
  end
  exit 0
end

#to_sString

Returns A description of the executable.

Returns:

  • (String)

    A description of the executable



45
46
47
# File 'lib/annotation_security/exec.rb', line 45

def to_s
  @opts.to_s
end