Class: Gitty::Runner
Direct Known Subclasses
HookCommand, HookCommand::Init, HookCommand::Install, HookCommand::List, HookCommand::Publish, HookCommand::Share, HookCommand::Shell, HookCommand::Show, HookCommand::Uninstall
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
Instance Method Summary collapse
- #handle_show_help ⇒ Object
-
#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Runner
constructor
A new instance of Runner.
- #option_parser ⇒ Object
- #options ⇒ Object
- #run ⇒ Object
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
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/gitty/runner.rb', line 3 def args @args end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
3 4 5 |
# File 'lib/gitty/runner.rb', line 3 def stderr @stderr end |
#stdout ⇒ Object (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_help ⇒ Object
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_parser ⇒ Object
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. = "Usage: #{$0}" opts.separator "Options:" opts.on('--help', "Show help") do |h| @show_help = opts end end end |
#options ⇒ Object
10 11 12 |
# File 'lib/gitty/runner.rb', line 10 def @options ||= {} end |