Class: CliOptions

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/hiptest-publisher/options_parser.rb

Instance Method Summary collapse

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

Returns:

  • (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_keepObject



123
124
125
# File 'lib/hiptest-publisher/options_parser.rb', line 123

def groups_to_keep
  only.split(",") if only
end

#language_frameworkObject



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
  modified_options = self.clone
  if actionwords_only
    modified_options.only = 'actionwords'
  elsif tests_only
    modified_options.only = 'tests'
  end

  if language.include?('-')
    modified_options.language, modified_options.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
      modified_options.framework = frameworks.first.downcase
    end
  end

  if without
    begin
      available_groups = LanguageConfigParser.new(modified_options).filtered_group_names
      modified_options.only = (available_groups - without.split(',')).join(',')
    rescue ArgumentError
      # Ok, that will be handled by cli_options_checkers later on
    end
  end

  if self != modified_options
    delta = modified_options.table.select do |key, value|
      modified_options[key] != self[key]
    end
    marshal_load(modified_options.marshal_dump)
    if reporter
      reporter.show_options(delta, 'Options have been normalized. Values updated:')
    end
    return delta
  end
end

#push?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/hiptest-publisher/options_parser.rb', line 103

def push?
  option_present?(push)
end

#test_run_id?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


111
112
113
# File 'lib/hiptest-publisher/options_parser.rb', line 111

def test_run_name?
  option_present?(test_run_name)
end