class LanguageGroupConfig
Public Class Methods
new(user_params, language_group_params = nil)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 481 def initialize(user_params, language_group_params = nil) @output_directory = user_params.output_directory || "" @filename_pattern = user_params.filename_pattern @split_scenarios = user_params.split_scenarios @with_folders = user_params.with_folders @leafless_export = user_params.leafless_export @language_group_params = language_group_params || {} @user_params = user_params end
Public Instance Methods
[](key)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 492 def [](key) @language_group_params[key] end
build_node_rendering_context(node)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 586 def build_node_rendering_context(node) relative_path = File.join(output_dirname(node), output_filename(node)) relative_path = relative_path[1..-1] if relative_path[0] == '/' path = File.join(language_group_output_directory, relative_path) if splitted_files? description = "#{singularize(node_name)} \"#{node.children[:name]}\"" else description = node_name.to_s end NodeRenderingContext.new( path: path, relative_path: relative_path, indentation: indentation, template_finder: template_finder, description: description, node: node, call_prefix: @language_group_params[:call_prefix], package: @language_group_params[:package], meta: @language_group_params[:meta], parameter_delimiter: @user_params[:parameter_delimiter], namespace: @language_group_params[:namespace], uids: @user_params[:uids], parent_folder_tags: @user_params[:parent_folder_tags], with_dataset_names: @user_params[:with_dataset_names], renderer_addons: @language_group_params[:renderer_addons] ) end
can_name_files?()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 517 def can_name_files? if filename_pattern.nil? false else splitted_files? || with_folders? end end
each_node_rendering_context(project) { |build_node_rendering_context(node)| ... }
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 574 def each_node_rendering_context(project) return to_enum(:each_node_rendering_context, project) unless block_given? nodes(project).each do |node| yield build_node_rendering_context(node) end end
filename_pattern()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 496 def filename_pattern @filename_pattern || self[:named_filename] end
forced_templates()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 542 def forced_templates forced = {} if splitted_files? forced.merge!( "scenario" => "single_scenario", "test" => "single_test", ) end if @language_group_params[:forced_templates] forced.merge!(@language_group_params[:forced_templates]) end forced end
indentation()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 581 def indentation return @user_params[:indent] unless @user_params[:indent].nil? @language_group_params[:indentation] || ' ' end
language_group_output_directory()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 616 def language_group_output_directory @user_params["#{@language_group_params[:group_name]}_output_directory"] || @output_directory end
nodes(project)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 525 def nodes(project) case node_name when :tests, :scenarios, :actionwords, :libraries if splitted_files? project.children[node_name].children[node_name] elsif with_folders? get_folder_nodes(project) else [project.children[node_name]] end when :library [project.children[:libraries]] when :folders get_folder_nodes(project) end end
output_dirname(node)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 620 def output_dirname(node) return "" unless with_folders? folder = node.folder hierarchy = [] while folder && !folder.root? hierarchy << normalized_dirname(folder.children[:name]) folder = folder.parent end File.join(*hierarchy.reverse) end
output_filename(node)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 631 def output_filename(node) if can_name_files? name = shorten_filename(normalized_filename(node.children[:name] || '')) filename = filename_pattern.gsub('%s', name) else self[:filename] end end
shorten_filename(name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 640 def shorten_filename(name) mandatory_characters = filename_pattern.gsub('%s', '').length if name.length + mandatory_characters > @@MAX_FILE_SIZE "#{name[0, (@@MAX_FILE_SIZE - 32 - mandatory_characters)]}#{Digest::MD5.hexdigest(name)}" else name end end
splitted_files?()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 504 def splitted_files? if filename_pattern.nil? # if we can't give a different name for each file, we can't split them false elsif self[:filename].nil? # if we can't give a name to a single file, we must split them true else # both options are possible, do as user specified @split_scenarios end end
template_dirs()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 556 def template_dirs if @language_group_params[:template_dirs] @language_group_params[:template_dirs].split(',').map(&:strip) else [] end end
template_finder()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 564 def template_finder @template_finder ||= TemplateFinder.new( template_dirs: template_dirs, overriden_templates: @language_group_params[:overriden_templates], indentation: indentation, forced_templates: forced_templates, fallback_template: @language_group_params[:fallback_template], ) end
with_folders?()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 500 def with_folders? @with_folders && (node_name == :scenarios || node_name == :folders) end
Private Instance Methods
get_folder_nodes(project)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 667 def get_folder_nodes(project) folders = project.children[:test_plan].children[:folders] unless @user_params.empty_folders folders.select {|folder| folder.children[:scenarios].length > 0} else folders end end
node_name()
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 651 def node_name if self[:node_name] == "tests" || self[:node_name] == "scenarios" || self[:group_name] == "tests" @leafless_export ? :tests : :scenarios elsif self[:node_name] == "actionwords" || self[:group_name] == "actionwords" :actionwords elsif self[:node_name] == "libraries" || self[:group_name] == "libraries" :libraries elsif self[:node_name] == "library" || self[:group_name] == "library" :library elsif self[:node_name] == "folders" :folders else raise I18n.t('errors.invalid_node', name: self[:node_name], group_name: self[:group_name]) end end
normalized_dirname(name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 676 def normalized_dirname(name) return name if @user_params.keep_foldernames dirname_convention = @language_group_params[:dirname_convention] || @language_group_params[:filename_convention] || :normalize name.send(dirname_convention) end
normalized_filename(name)
click to toggle source
# File lib/hiptest-publisher/options_parser.rb, line 683 def normalized_filename(name) return name if @user_params.keep_filenames filename_convention = @language_group_params[:filename_convention] || :normalize name.send(filename_convention) end