Class: CliOptions
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- CliOptions
- Defined in:
- lib/hiptest-publisher/options_parser.rb
Instance Method Summary collapse
- #actionwords_diff? ⇒ Boolean
- #command_line_used(exclude: []) ⇒ Object
- #groups_to_keep ⇒ Object
-
#initialize(hash = nil) ⇒ CliOptions
constructor
A new instance of CliOptions.
- #language_framework ⇒ Object
- #normalize!(reporter = nil) ⇒ Object
- #push? ⇒ Boolean
- #test_run_id? ⇒ Boolean
- #test_run_name? ⇒ Boolean
Constructor Details
#initialize(hash = nil) ⇒ CliOptions
Returns a new instance of CliOptions.
91 92 93 94 95 96 97 |
# File 'lib/hiptest-publisher/options_parser.rb', line 91 def initialize(hash = nil) hash ||= {} hash[:language] ||= "" hash[:framework] ||= "" super(__cli_args: Set.new, __config_args: Set.new, **hash) end |
Instance Method Details
#actionwords_diff? ⇒ Boolean
99 100 101 |
# File 'lib/hiptest-publisher/options_parser.rb', line 99 def actionwords_diff? actionwords_diff || actionwords_diff_json || aw_deleted || aw_created || aw_renamed || aw_signature_changed || aw_definition_changed end |
#command_line_used(exclude: []) ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/hiptest-publisher/options_parser.rb', line 127 def command_line_used(exclude: []) args = self.__cli_args.map do |key| next if exclude.include?(key) "--#{key.to_s.gsub('_', '-')}=#{self[key]}" end.compact return "hiptest-publisher #{args.join(' ')}".strip end |
#groups_to_keep ⇒ Object
123 124 125 |
# File 'lib/hiptest-publisher/options_parser.rb', line 123 def groups_to_keep only.split(",") if only end |
#language_framework ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/hiptest-publisher/options_parser.rb', line 115 def language_framework if framework.empty? language else "#{language}-#{framework}" end end |
#normalize!(reporter = nil) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/hiptest-publisher/options_parser.rb', line 136 def normalize!(reporter = nil) self.no_uids = !uids # silent normalization = self.clone if actionwords_only .only = 'actionwords' elsif tests_only .only = 'tests' end if language.include?('-') .language, .framework = language.split("-", 2) elsif framework.empty? # pick first framework for the language _, frameworks = OptionsParser.languages.find do |language, frameworks| language.downcase.gsub(' ', '') == self.language.downcase.gsub(' ', '') end if frameworks .framework = frameworks.first.downcase end end if without begin available_groups = LanguageConfigParser.new().filtered_group_names .only = (available_groups - without.split(',')).join(',') rescue ArgumentError # Ok, that will be handled by cli_options_checkers later on end end if self != delta = .table.select do |key, value| [key] != self[key] end marshal_load(.marshal_dump) if reporter reporter.(delta, 'Options have been normalized. Values updated:') end return delta end end |
#push? ⇒ Boolean
103 104 105 |
# File 'lib/hiptest-publisher/options_parser.rb', line 103 def push? option_present?(push) end |
#test_run_id? ⇒ Boolean
107 108 109 |
# File 'lib/hiptest-publisher/options_parser.rb', line 107 def test_run_id? option_present?(test_run_id) end |
#test_run_name? ⇒ Boolean
111 112 113 |
# File 'lib/hiptest-publisher/options_parser.rb', line 111 def test_run_name? option_present?(test_run_name) end |