module Hiptest::RenderContextMaker
Public Instance Methods
walk_actionword(aw)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 25 def walk_actionword(aw) walk_item(aw).merge( chunks: aw.chunks || [], extra_inlined_parameters: aw.extra_inlined_parameters || [], has_free_text_parameter?: aw.children[:parameters].select(&:free_text?).count > 0, has_datatable_parameter?: aw.children[:parameters].select(&:datatable?).count > 0, uniq_name: aw.uniq_name ) end
walk_actionwords(aws)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 35 def walk_actionwords(aws) project = aws.parent { uses_library?: project.nil? ? false : project.has_libraries? } end
walk_call(c)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 100 def walk_call(c) { has_arguments?: !c.children[:arguments].empty?, has_annotation?: !c.children[:annotation].nil?, is_shared?: !c.children[:library_name].nil?, in_actionword?: c.parent.is_a?(Hiptest::Nodes::Actionword), in_datatabled_scenario?: c.parent.is_a?(Hiptest::Nodes::Scenario) && has_datasets?(c.parent), chunks: c.chunks || [], extra_inlined_arguments: c.extra_inlined_arguments || [] } end
walk_dataset(dataset)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 61 def walk_dataset(dataset) datatable = dataset.parent { scenario_name: datatable.parent.children[:name], has_tags?: !datatable.parent.children[:tags].empty?, tags: datatable.parent.children[:tags].map {|tag| @rendered[tag]} } end
walk_folder(folder)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 42 def walk_folder(folder) walk_relative_item(folder).merge( self_name: folder.children[:name], has_tags?: !folder.children[:tags].empty?, has_step?: has_step?(folder), is_empty?: folder.children[:body].empty?, datatables_present?: datatable_present?(folder) ) end
walk_ifthen(it)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 112 def walk_ifthen(it) { has_else?: !it.children[:else].empty? } end
walk_item(item)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 3 def walk_item(item) { has_description?: !item.children[:description].nil? && !item.children[:description].empty?, has_parameters?: !item.children[:parameters].empty?, has_tags?: !item.children[:tags].empty?, has_step?: has_step?(item), is_empty?: item.children[:body].empty?, declared_variables: item.declared_variables_names, raw_parameter_names: item.children[:parameters].map {|p| p.children[:name] }, self_name: item.children[:name] } end
walk_libraries(libraries)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 154 def walk_libraries(libraries) { library_names: libraries.children[:libraries].map {|lib| lib.children[:name]} } end
walk_libraryactionword(aw)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 148 def walk_libraryactionword(aw) walk_actionword(aw).merge( library_name: aw.parent.children[:name] ) end
walk_parameter(p)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 118 def walk_parameter(p) { is_free_text?: p.free_text?, is_datatable?: p.datatable?, is_bool?: p.children[:type] == :bool, has_default_value?: !p.children[:default].nil? } end
walk_relative_item(item)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 16 def walk_relative_item(item) relative_package = @context.relative_path.split('/')[0...-1].join('.') relative_package = ".#{relative_package}" unless relative_package.empty? { needs_to_import_actionwords?: @context.relative_path.count('/') > 0, relative_package: relative_package, } end
walk_scenario(scenario)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 52 def walk_scenario(scenario) walk_item(scenario).merge(walk_relative_item(scenario)).merge( project_name: scenario.parent.parent.children[:name], has_datasets?: has_datasets?(scenario), has_annotations?: has_annotations?(scenario), uniq_name: scenario.children[:name] ) end
walk_scenarios(scenarios)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 70 def walk_scenarios(scenarios) project = scenarios.parent { project_name: project.children[:name], self_name: project.children[:name], datatables_present?: datatable_present?(scenarios) } end
walk_tag(t)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 127 def walk_tag(t) { has_value?: !t.children[:value].nil? } end
walk_template(t)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 133 def walk_template(t) treated = t.children[:chunks].map do |chunk| { is_variable?: chunk.is_a?(Hiptest::Nodes::Variable), raw: chunk } end variable_names = treated.map {|item| item[:raw].children[:name] if item[:is_variable?]}.compact { treated_chunks: treated, variable_names: variable_names } end
walk_test(test)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 79 def walk_test(test) { has_description?: !test.children[:description].nil? && !test.children[:description].empty?, has_parameters?: false, has_tags?: !test.children[:tags].empty?, has_step?: has_step?(test), is_empty?: test.children[:body].empty?, has_datasets?: false, project_name: test.parent.parent.children[:name], self_name: test.children[:name] } end
walk_tests(tests)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 92 def walk_tests(tests) project = tests.parent { project_name: project.children[:name], self_name: project.children[:name] } end
Private Instance Methods
datatable_present?(container)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 181 def datatable_present?(container) datatables_present = false container.children[:scenarios].each do |scenario| if has_datasets?(scenario) datatables_present = true break end end return datatables_present end
has_annotations?(scenario)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 169 def has_annotations?(scenario) scenario.each_sub_nodes(deep: true) do |node| return true if node.is_a?(Hiptest::Nodes::Call) && !node.children[:annotation].nil? end false end
has_datasets?(scenario)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 176 def has_datasets?(scenario) datatable = scenario.children[:datatable] datatable ? !datatable.children[:datasets].empty? : false end
has_step?(item)
click to toggle source
# File lib/hiptest-publisher/render_context_maker.rb, line 162 def has_step?(item) item.each_sub_nodes(deep: true) do |node| return true if node.is_a?(Hiptest::Nodes::Step) end false end