Class: OptParserInternal
- Inherits:
-
Object
- Object
- OptParserInternal
- Includes:
- MandatoryOptions, OptionalOptions
- Defined in:
- lib/gitarro/opt_parser.rb
Overview
this class is only private and helper for main class OptParser
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #ck_mandatory_option(option) ⇒ Object
-
#initialize ⇒ OptParserInternal
constructor
A new instance of OptParserInternal.
-
#option_help(opt) ⇒ Object
option help.
- #parse(opt_parser) ⇒ Object
-
#raise_incorrect_syntax(msg) ⇒ Object
all this methods are private.
Methods included from OptionalOptions
#changed_since, #check_opt, #desc_opt, #file_opt, #https_opt, #optional_options, #pr_number, #url_opt
Methods included from MandatoryOptions
#context_opt, #git_opt, #mandatory_options, #repo_opt, #test_opt
Constructor Details
#initialize ⇒ OptParserInternal
111 112 113 114 |
# File 'lib/gitarro/opt_parser.rb', line 111 def initialize = {} = .clone if .any? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
110 111 112 |
# File 'lib/gitarro/opt_parser.rb', line 110 def end |
Instance Method Details
#ck_mandatory_option(option) ⇒ Object
123 124 125 126 |
# File 'lib/gitarro/opt_parser.rb', line 123 def ck_mandatory_option(option) return unless [option.to_sym].nil? raise_incorrect_syntax("option --#{option} not found") end |
#option_help(opt) ⇒ Object
option help
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/gitarro/opt_parser.rb', line 137 def option_help(opt) opt.separator "\n Help:" opt.on('-h', '--help', 'help') do opt.separator " \n Example: gitarro.rb -r " \ "openSUSE/gitarro -c 'python-test " \ "-d 'someCoolTest' -g /tmp/pr-ruby01/ -t /tmp/test.sh "\ "-f '.py'" puts @opt_parser exit 0 end end |
#parse(opt_parser) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/gitarro/opt_parser.rb', line 128 def parse(opt_parser) (opt_parser) = %w[repo context test_file git_dir] .each { |opt| ck_mandatory_option(opt) } defaults_false defaults_to_text end |
#raise_incorrect_syntax(msg) ⇒ Object
all this methods are private
117 118 119 120 121 |
# File 'lib/gitarro/opt_parser.rb', line 117 def raise_incorrect_syntax(msg) puts "Incorrect syntax: #{msg}\n\n" puts 'Use option -h for help' exit 1 end |