Class: LanguageConfigParser
- Inherits:
-
Object
- Object
- LanguageConfigParser
- Defined in:
- lib/hiptest-publisher/options_parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #filtered_group_names ⇒ Object
- #group_names ⇒ Object
- #include_group?(group_name) ⇒ Boolean
-
#initialize(cli_options, language_config_path = nil) ⇒ LanguageConfigParser
constructor
A new instance of LanguageConfigParser.
- #language_group_configs ⇒ Object
- #meta ⇒ Object
- #name_action_word(name) ⇒ Object
Constructor Details
#initialize(cli_options, language_config_path = nil) ⇒ LanguageConfigParser
Returns a new instance of LanguageConfigParser.
690 691 692 693 694 |
# File 'lib/hiptest-publisher/options_parser.rb', line 690 def initialize(, language_config_path = nil) @cli_options = language_config_path ||= LanguageConfigParser.config_path_for() @config = ParseConfig.new(language_config_path) end |
Class Method Details
.config_path_for(cli_options) ⇒ Object
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
# File 'lib/hiptest-publisher/options_parser.rb', line 696 def self.config_path_for() config_name = if .framework.empty? "#{.language}.conf" else "#{.language}-#{.framework}.conf" end config_path = "/lib/config/#{config_name.downcase}" config_prefix = if !.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. = File.("#{.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?() config_path = '' end end config_path = File.("#{config_prefix || hiptest_publisher_path}#{config_path}") if !File.file?(config_path) if .framework.to_s.empty? = I18n.t('errors.invalid_config_file_no_framework', hiptest_publisher_path: hiptest_publisher_path, language: .language.inspect) else = I18n.t('errors.invalid_config_file', hiptest_publisher_path: hiptest_publisher_path, language: .language.inspect, framework: .framework.inspect) end raise ArgumentError.new() end File.(config_path) end |
Instance Method Details
#filtered_group_names ⇒ Object
735 736 737 738 739 740 741 |
# File 'lib/hiptest-publisher/options_parser.rb', line 735 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 ⇒ Object
729 730 731 732 733 |
# File 'lib/hiptest-publisher/options_parser.rb', line 729 def group_names @config.groups.reject {|group_name| group_name.start_with?('_') } end |
#include_group?(group_name) ⇒ Boolean
743 744 745 |
# File 'lib/hiptest-publisher/options_parser.rb', line 743 def include_group?(group_name) filtered_group_names.include?(group_name) end |
#language_group_configs ⇒ Object
747 748 749 |
# File 'lib/hiptest-publisher/options_parser.rb', line 747 def language_group_configs filtered_group_names.map {|group_name| make_language_group_config(group_name)} end |
#meta ⇒ Object
755 756 757 758 759 760 761 762 763 764 765 766 767 768 |
# File 'lib/hiptest-publisher/options_parser.rb', line 755 def treated = {} = @cli_options. || "" .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) ⇒ Object
751 752 753 |
# File 'lib/hiptest-publisher/options_parser.rb', line 751 def name_action_word(name) name.send(get_key_from_group('actionwords', 'naming_convention')) end |