Sha256: c0c9a481a31aa53a682aba5467dbda06406dd4a0acf3f5b5cf6f8b882360182e

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
module RopenPi
  module Specs
    class Configuration
      def initialize(rspec_config)
        @rspec_config = rspec_config
      end

      def root_dir
        @root_dir ||= begin
          raise ConfigurationError, 'No root_dir provided. See open_api_helper.rb' if @rspec_config.root_dir.nil?

          @rspec_config.root_dir
        end
      end

      def open_api_output_format
        @open_api_output_format ||= begin
          @rspec_config.open_api_output_format || :json
        end
      end

      def open_api_docs
        @open_api_docs ||= begin
          if @rspec_config.open_api_docs.nil? || @rspec_config.open_api_docs.empty?
            raise ConfigurationError, 'No open_api_docs defined. See open_api_helper.rb'
          end

          @rspec_config.open_api_docs
        end
      end

      def get_doc(name)
        return open_api_docs.values.first if name.nil?

        raise ConfigurationError, "Unknown doc '#{name}'" unless open_api_docs[name]

        open_api_docs[name]
      end
    end
    
    class ConfigurationError < StandardError; end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ropen_pi-0.5.0 lib/ropen_pi/specs/configuration.rb
ropen_pi-0.4.0 lib/ropen_pi/specs/configuration.rb
ropen_pi-0.3.0 lib/ropen_pi/specs/configuration.rb
ropen_pi-0.2.0 lib/ropen_pi/specs/configuration.rb