class LanguageConfigParser
Public Class Methods
config_path_for(cli_options)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 698 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 = "/lib/config/#{config_name.downcase}" config_prefix = if !cli_options.overriden_language_configs.to_s.empty? # If the user has specified a overiden language config path, check it first. If the config # exists there, return that, otherwise fall back to the default setup and look for a config there. expanded = File.expand_path("#{cli_options.overriden_language_configs}/#{config_name.downcase}") # If the file exists in the path the user specified, set the config path to blank so we will be # looking in the exact path that the user requested. if File.file?(expanded) config_path = '' expanded end end config_path = File.expand_path("#{config_prefix || hiptest_publisher_path}#{config_path}") if !File.file?(config_path) if cli_options.framework.to_s.empty? message = I18n.t('errors.invalid_config_file_no_framework', hiptest_publisher_path: hiptest_publisher_path, language: cli_options.language.inspect) else message = I18n.t('errors.invalid_config_file', hiptest_publisher_path: hiptest_publisher_path, language: cli_options.language.inspect, framework: cli_options.framework.inspect) end raise ArgumentError.new(message) end File.expand_path(config_path) end
new(cli_options, language_config_path = nil)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 692 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
Public Instance Methods
filtered_group_names()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 737 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_names()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 731 def group_names @config.groups.reject {|group_name| group_name.start_with?('_') } end
include_group?(group_name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 745 def include_group?(group_name) filtered_group_names.include?(group_name) end
language_group_configs()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 749 def language_group_configs filtered_group_names.map {|group_name| make_language_group_config(group_name)} end
meta()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 757 def meta treated = {} meta_opt = @cli_options.meta || "" meta_opt.split(',').each do |m| key, value = m.split(':') value = true if value == 'true' value = false if value == 'false' treated[key.strip] = value end treated end
name_action_word(name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 753 def name_action_word(name) name.send(get_key_from_group('actionwords', 'naming_convention')) end
Private Instance Methods
get_key_from_group(group, key)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 774 def get_key_from_group(group, key) @config[group][key] || @config['_common'][key] end
group_config(group_name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 778 def group_config(group_name) if @config[group_name] key_values = @config[group_name].map {|key, value| [key.to_sym, value]} Hash[key_values] else {} end end
make_language_group_config(group_name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 787 def make_language_group_config group_name # List of options that can be set in the config file but not in command line non_visible_options = { package: @cli_options.package, meta: meta, namespace: @cli_options.namespace, test_export_dir: @cli_options.test_export_dir, tests_ouput_dir: @cli_options.tests_ouput_dir, features_output_directory: @cli_options.features_output_directory, step_definitions_output_directory: @cli_options.step_definitions_output_directory, step_definitions_library_output_directory: @cli_options.step_definitions_output_directory, libraries_output_directory: @cli_options.actionwords_output_directory, library_output_directory: @cli_options.actionwords_output_directory, actionwords_output_directory: @cli_options.actionwords_output_directory } language_group_params = group_config('_common') language_group_params.merge!(group_config(group_name)) language_group_params[:group_name] = group_name non_visible_options.each do |key, value| language_group_params[key] = value if value end unless @cli_options.overriden_templates.nil? || @cli_options.overriden_templates.empty? language_group_params[:overriden_templates] = @cli_options.overriden_templates end if @cli_options.step_definitions_output_directory @cli_options.step_definitions_library_output_directory = @cli_options.step_definitions_output_directory end if @cli_options.actionwords_output_directory @cli_options.libraries_output_directory = @cli_options.actionwords_output_directory @cli_options.library_output_directory = @cli_options.actionwords_output_directory end LanguageGroupConfig.new(@cli_options, language_group_params) end