Sha256: 88471c0901054ba8bf497f3552fffd293a043c6240f66791ce87a72c1eae803a

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require 'tomograph'

module Fitting
  class Configuration
    class Yaml
      attr_reader   :title
      attr_accessor :apib_path,
                    :drafter_yaml_path,
                    :strict,
                    :prefix,
                    :white_list,
                    :resource_white_list,
                    :ignore_list,
                    :include_resources,
                    :include_actions

      def initialize(yaml, title = 'fitting')
        @apib_path = yaml['apib_path']
        @drafter_yaml_path = yaml['drafter_yaml_path']
        @strict = yaml['strict']
        @prefix = yaml['prefix']
        @white_list = yaml['white_list']
        @resource_white_list = yaml['resource_white_list']
        @ignore_list = yaml['ignore_list']
        @include_resources = yaml['include_resources']
        @include_actions = yaml['include_actions']
        @title = title
        default
      end

      def tomogram
        @tomogram ||= Tomograph::Tomogram.new(
          prefix: @prefix,
          apib_path: @apib_path,
          drafter_yaml_path: @drafter_yaml_path
        )
      end

      def stats_path
        if @title == 'fitting'
          'fitting/stats'
        else
          "fitting/#{@title}/stats"
        end
      end

      def not_covered_path
        if @title == 'fitting'
          'fitting/not_covered'
        else
          "fitting/#{@title}/not_covered"
        end
      end

      private

      def default
        @strict ||= false if @strict.nil?
        @prefix ||= ''
        @ignore_list ||= []
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fitting-2.4.1 lib/fitting/configuration/yaml.rb
fitting-2.4.0 lib/fitting/configuration/yaml.rb