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
#branch_opt, #changed_since, #check_opt, #desc_opt, #file_opt, #force_test_opt, #git_opt, #https_opt, #no_shallow, #optional_options, #pr_number, #url_opt
Methods included from MandatoryOptions
#context_opt, #mandatory_options, #repo_opt, #test_opt
Constructor Details
#initialize ⇒ OptParserInternal
Returns a new instance of OptParserInternal.
131 132 133 134 |
# File 'lib/gitarro/opt_parser.rb', line 131 def initialize @options = {} @options = .clone if .any? end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
130 131 132 |
# File 'lib/gitarro/opt_parser.rb', line 130 def @options end |
Instance Method Details
#ck_mandatory_option(option) ⇒ Object
143 144 145 146 147 |
# File 'lib/gitarro/opt_parser.rb', line 143 def ck_mandatory_option(option) return unless @options[option.to_sym].nil? raise_incorrect_syntax("option --#{option} not found") end |
#option_help(opt) ⇒ Object
option help
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/gitarro/opt_parser.rb', line 158 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
149 150 151 152 153 154 155 |
# File 'lib/gitarro/opt_parser.rb', line 149 def parse(opt_parser) (opt_parser) = %w[repo context test_file] .each { |opt| ck_mandatory_option(opt) } defaults_false defaults_to_text end |
#raise_incorrect_syntax(msg) ⇒ Object
all this methods are private
137 138 139 140 141 |
# File 'lib/gitarro/opt_parser.rb', line 137 def raise_incorrect_syntax(msg) puts "Incorrect syntax: #{msg}\n\n" puts 'Use option -h for help' exit 1 end |