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? ⇒ Boolean
- #test_run_id? ⇒ Boolean
- #test_run_name? ⇒ Boolean
- #uids_not_set_yet? ⇒ Boolean
Constructor Details
#initialize(hash = nil) ⇒ CliOptions
Returns a new instance of CliOptions.
93 94 95 96 97 98 99 |
# File 'lib/hiptest-publisher/options_parser.rb', line 93 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
101 102 103 |
# File 'lib/hiptest-publisher/options_parser.rb', line 101 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
133 134 135 136 137 138 139 140 |
# File 'lib/hiptest-publisher/options_parser.rb', line 133 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 "hiptest-publisher #{args.join(' ')}".strip end |
#groups_to_keep ⇒ Object
129 130 131 |
# File 'lib/hiptest-publisher/options_parser.rb', line 129 def groups_to_keep only.split(",") if only end |
#language_framework ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/hiptest-publisher/options_parser.rb', line 121 def language_framework if framework.empty? language else "#{language}-#{framework}" end end |
#normalize!(reporter = nil) ⇒ Object
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 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/hiptest-publisher/options_parser.rb', line 146 def normalize!(reporter = nil) self.uids = true if test_run? && uids_not_set_yet? 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, I18n.t("help.options.nomalized_options")) end return delta end end |
#push? ⇒ Boolean
105 106 107 |
# File 'lib/hiptest-publisher/options_parser.rb', line 105 def push? option_present?(push) end |
#test_run? ⇒ Boolean
117 118 119 |
# File 'lib/hiptest-publisher/options_parser.rb', line 117 def test_run? test_run_id? || test_run_name? end |
#test_run_id? ⇒ Boolean
109 110 111 |
# File 'lib/hiptest-publisher/options_parser.rb', line 109 def test_run_id? option_present?(test_run_id) end |
#test_run_name? ⇒ Boolean
113 114 115 |
# File 'lib/hiptest-publisher/options_parser.rb', line 113 def test_run_name? option_present?(test_run_name) end |
#uids_not_set_yet? ⇒ Boolean
142 143 144 |
# File 'lib/hiptest-publisher/options_parser.rb', line 142 def uids_not_set_yet? !__cli_args.include?(:uids) && !__config_args.include?(:uids) end |