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.



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

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



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/hiptest-publisher/options_parser.rb', line 526

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



548
549
550
551
552
553
554
# File 'lib/hiptest-publisher/options_parser.rb', line 548

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



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

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

#include_group?(group_name) ⇒ Boolean

Returns:

  • (Boolean)


556
557
558
# File 'lib/hiptest-publisher/options_parser.rb', line 556

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

#language_group_configsObject



560
561
562
# File 'lib/hiptest-publisher/options_parser.rb', line 560

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

#name_action_word(name) ⇒ Object



564
565
566
# File 'lib/hiptest-publisher/options_parser.rb', line 564

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