Sha256: f19fc4c94ab7435e142daf7c90afb9483ea84655bbc1dc7b95822ae18b1c0b93

Contents?: true

Size: 988 Bytes

Versions: 8

Compression:

Stored size: 988 Bytes

Contents

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, :actions

      def initialize(schema_paths: nil, type: nil, name: '', skip: false, only: [])
        @name = name
        @cover = false

        @actions = Fitting::Report::Actions.new([])
        return if skip

        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 cover!
        @cover = true
      end

      def cover?
        @cover
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fitting-4.2.1 lib/fitting/report/prefix.rb
fitting-4.2.0 lib/fitting/report/prefix.rb
fitting-4.1.0 lib/fitting/report/prefix.rb
fitting-4.0.4 lib/fitting/report/prefix.rb
fitting-4.0.3 lib/fitting/report/prefix.rb
fitting-4.0.2 lib/fitting/report/prefix.rb
fitting-4.0.1 lib/fitting/report/prefix.rb
fitting-4.0.0 lib/fitting/report/prefix.rb