Module: OptionalOptions
- Included in:
- OptParserInternal
- Defined in:
- lib/gitarro/opt_parser.rb
Overview
this are the optional options
Instance Method Summary collapse
- #branch_opt(opt) ⇒ Object
- #changed_since(opt) ⇒ Object
- #check_opt(opt) ⇒ Object
- #desc_opt(opt) ⇒ Object
- #file_opt(opt) ⇒ Object
- #git_opt(opt) ⇒ Object
- #https_opt(opt) ⇒ Object
- #no_shallow(opt) ⇒ Object
- #optional_options(opt) ⇒ Object
- #pr_number(opt) ⇒ Object
- #url_opt(opt) ⇒ Object
Instance Method Details
#branch_opt(opt) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/gitarro/opt_parser.rb', line 51 def branch_opt(opt) desc = 'run tests only if the pr target the upstream branch specified' opt.on('-b', "--branch 'GITHUB BRANCH'", desc) do |b| @options[:branch] = b end end |
#changed_since(opt) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/gitarro/opt_parser.rb', line 96 def changed_since(opt) changed_since_desc = 'If present, will only check PRs with a ' \ 'change in the last X seconds' opt.on("--changed_since 'SECONDS'", changed_since_desc) do |changed_since| @options[:changed_since] = Integer(changed_since) end end |
#check_opt(opt) ⇒ Object
35 36 37 38 |
# File 'lib/gitarro/opt_parser.rb', line 35 def check_opt(opt) desc = 'Check if there is any PR requiring a test, but do not run it.' opt.on('-C', '--check', desc) { |check| @options[:check] = check } end |
#desc_opt(opt) ⇒ Object
45 46 47 48 49 |
# File 'lib/gitarro/opt_parser.rb', line 45 def desc_opt(opt) opt.on('-d', "--description 'DESCRIPTION'", 'Test decription') do |d| @options[:description] = d end end |
#file_opt(opt) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/gitarro/opt_parser.rb', line 75 def file_opt(opt) file_description = 'pr_file type to run the test against: .py, .rb' opt.on('-f', "--file \'.py\'", file_description) do |file_type| @options[:file_type] = file_type end end |
#git_opt(opt) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/gitarro/opt_parser.rb', line 58 def git_opt(opt) desc = 'Specify a location where gitarro will clone the GitHub project. '\ 'If the dir does not exists, gitarro will create one. '\ 'by default is the /tmp' opt.on('-g', "--git_dir 'GIT_LOCAL_DIR'", desc) do |git_dir| @options[:git_dir] = git_dir end end |
#https_opt(opt) ⇒ Object
82 83 84 85 |
# File 'lib/gitarro/opt_parser.rb', line 82 def https_opt(opt) https_desc = 'If present, use https instead of ssh for git operations' opt.on('--https', https_desc) { |https| @options[:https] = https } end |
#no_shallow(opt) ⇒ Object
40 41 42 43 |
# File 'lib/gitarro/opt_parser.rb', line 40 def no_shallow(opt) desc = 'If enabled, gitarro will not use git shallow clone' opt.on('--noshallow', desc) { |noshallow| @options[:noshallow] = noshallow } end |
#optional_options(opt) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/gitarro/opt_parser.rb', line 105 def (opt) opt.separator "\n Optional options:" desc_opt(opt) check_opt(opt) branch_opt(opt) no_shallow(opt) file_opt(opt) url_opt(opt) pr_number(opt) https_opt(opt) changed_since(opt) git_opt(opt) end |
#pr_number(opt) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/gitarro/opt_parser.rb', line 87 def pr_number(opt) desc = 'Specify the PR number instead of checking all of them. ' \ 'Force to rerun against a specific PR number,' \ 'even if it is not needed.' opt.on('-P', "--PR 'NUMBER'", desc) do |pr_number| @options[:pr_number] = pr_number.to_i end end |
#url_opt(opt) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/gitarro/opt_parser.rb', line 67 def url_opt(opt) desc = 'Specify the URL to append to add to the GitHub review. ' \ 'Usually you will use an URL to the Jenkins build log.' opt.on('-u', "--url 'TARGET_URL'", desc) do |target_url| @options[:target_url] = target_url end end |