Class: Gitty::Runner

Inherits:
Object show all
Defined in:
lib/gitty/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
# File 'lib/gitty/runner.rb', line 5

def initialize(args, stdout = STDOUT, stderr = STDERR)
  @args, @stdout, @stderr = args, stdout, stderr
  parse_args!
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/gitty/runner.rb', line 3

def args
  @args
end

#stderrObject (readonly)

Returns the value of attribute stderr.



3
4
5
# File 'lib/gitty/runner.rb', line 3

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



3
4
5
# File 'lib/gitty/runner.rb', line 3

def stdout
  @stdout
end

Class Method Details

.run(args, stdout = STDOUT, stderr = STDERR) ⇒ Object



35
36
37
# File 'lib/gitty/runner.rb', line 35

def self.run(args, stdout = STDOUT, stderr = STDERR)
  new(args, stdout, stderr).run
end

Instance Method Details

#handle_show_helpObject



28
29
30
31
32
33
# File 'lib/gitty/runner.rb', line 28

def handle_show_help
  if @show_help
    puts @show_help
    exit(1)
  end
end

#option_parserObject



18
19
20
21
22
23
24
25
26
# File 'lib/gitty/runner.rb', line 18

def option_parser
  @option_parser ||= OptionParser.new do |opts|
    opts.banner = "Usage: #{$0}"
    opts.separator "Options:"
    opts.on('--help', "Show help") do |h|
      @show_help = opts
    end
  end
end

#optionsObject



10
11
12
# File 'lib/gitty/runner.rb', line 10

def options
  @options ||= {}
end

#runObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/gitty/runner.rb', line 14

def run
  raise NotImplementedError
end