class CliOptions

Public Class Methods

new(hash = nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

actionwords_diff?() click to toggle source
# 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: []) click to toggle source
# 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() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 129
def groups_to_keep
  only.split(",") if only
end
language_framework() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 121
def language_framework
  if framework.empty?
    language
  else
    "#{language}-#{framework}"
  end
end
normalize!(reporter = nil) click to toggle source
# 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
  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, I18n.t("help.options.nomalized_options"))
    end
    return delta
  end
end
push?() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 105
def push?
  option_present?(push)
end
test_run?() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 117
def test_run?
  test_run_id? || test_run_name?
end
test_run_id?() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 109
def test_run_id?
  option_present?(test_run_id)
end
test_run_name?() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 113
def test_run_name?
  option_present?(test_run_name)
end
uids_not_set_yet?() click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 142
def uids_not_set_yet?
  !__cli_args.include?(:uids) && !__config_args.include?(:uids)
end

Private Instance Methods

option_present?(value) click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 191
def option_present?(value)
  value && !value.empty?
end