Class: LanguageConfigParser

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli_options, language_config_path = nil) ⇒ LanguageConfigParser

Returns a new instance of LanguageConfigParser.



499
500
501
502
503
# File 'lib/hiptest-publisher/options_parser.rb', line 499

def initialize(cli_options, language_config_path = nil)
  @cli_options = cli_options
  language_config_path ||= LanguageConfigParser.config_path_for(cli_options)
  @config = ParseConfig.new(language_config_path)
end

Class Method Details

.config_path_for(cli_options) ⇒ Object



505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/hiptest-publisher/options_parser.rb', line 505

def self.config_path_for(cli_options)
  config_name = if cli_options.framework.empty?
    "#{cli_options.language}.conf"
  else
    "#{cli_options.language}-#{cli_options.framework}.conf"
  end
  config_path = File.expand_path("#{hiptest_publisher_path}/lib/config/#{config_name.downcase}")
  if !File.file?(config_path)
    message = "cannot find configuration file in \"#{hiptest_publisher_path}/lib/config\""
    message << " for language #{cli_options.language.inspect}"
    message << " and framework #{cli_options.framework.inspect}" unless cli_options.framework.to_s.empty?
    raise ArgumentError.new(message)
  end
  File.expand_path(config_path)
end

Instance Method Details

#filtered_group_namesObject



527
528
529
530
531
532
533
# File 'lib/hiptest-publisher/options_parser.rb', line 527

def filtered_group_names
  if @cli_options.groups_to_keep
    group_names.select {|group_name| @cli_options.groups_to_keep.include?(group_name)}
  else
    group_names
  end
end

#group_namesObject



521
522
523
524
525
# File 'lib/hiptest-publisher/options_parser.rb', line 521

def group_names
  @config.groups.reject {|group_name|
    group_name.start_with?('_')
  }
end

#include_group?(group_name) ⇒ Boolean

Returns:

  • (Boolean)


535
536
537
# File 'lib/hiptest-publisher/options_parser.rb', line 535

def include_group?(group_name)
  filtered_group_names.include?(group_name)
end

#language_group_configsObject



539
540
541
# File 'lib/hiptest-publisher/options_parser.rb', line 539

def language_group_configs
  filtered_group_names.map { |group_name| make_language_group_config(group_name) }
end

#name_action_word(name) ⇒ Object



543
544
545
# File 'lib/hiptest-publisher/options_parser.rb', line 543

def name_action_word(name)
  name.send(@config['actionwords']['naming_convention'])
end