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.
692 693 694 695 696 |
# File 'lib/hiptest-publisher/options_parser.rb', line 692 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
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 728 729 |
# File 'lib/hiptest-publisher/options_parser.rb', line 698 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
737 738 739 740 741 742 743 |
# 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 ⇒ Object
731 732 733 734 735 |
# 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) ⇒ Boolean
745 746 747 |
# File 'lib/hiptest-publisher/options_parser.rb', line 745 def include_group?(group_name) filtered_group_names.include?(group_name) end |
#language_group_configs ⇒ Object
749 750 751 |
# 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 ⇒ Object
757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
# File 'lib/hiptest-publisher/options_parser.rb', line 757 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
753 754 755 |
# File 'lib/hiptest-publisher/options_parser.rb', line 753 def name_action_word(name) name.send(get_key_from_group('actionwords', 'naming_convention')) end |