require 'fitting/report/actions' module Fitting module Report class Prefix KEYS = { 'openapi2' => :openapi2_json_path, 'openapi3' => :openapi3_yaml_path, 'drafter' => :drafter_yaml_path, 'crafter' => :crafter_yaml_path, 'tomogram' => :tomogram_json_path }.freeze attr_reader :name, :tests, :actions def initialize(schema_paths: nil, type: nil, name: '', skip: false, only: []) @name = name @tests = Fitting::Report::Tests.new([]) @skip = skip return if skip @actions = Fitting::Report::Actions.new([]) schema_paths.each do |path| tomogram = Tomograph::Tomogram.new(prefix: name, KEYS[type] => path) tomogram.to_a.filter! { |action| only.include?("#{action.method} #{action.path}") } if only.present? @actions.push(Fitting::Report::Actions.new(tomogram)) end end def skip? @skip end def details if @skip { name: @name, tests_size: @tests.size, actions: { tests_without_actions: [], actions_details: [] } } else { name: @name, tests_size: @tests.size, actions: @actions.details(self) } end end def add_test(test) @tests.push(test) end end end end