Sha256: a8ecefa4d04ac380536b4e92a49c991dd1129c109aa81c7898ccf99ccf3903a6

Contents?: true

Size: 975 Bytes

Versions: 3

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

class RopenPi::Specs::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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ropen_pi-0.1.2 lib/ropen_pi/specs/configuration.rb
ropen_pi-0.1.1 lib/ropen_pi/specs/configuration.rb
ropen_pi-0.1.0 lib/ropen_pi/specs/configuration.rb