class Schmersion::Config

Constants

DEFAULT_LINTING_OPTIONS
DEFAULT_TYPES
DEFAULT_VERSION_OPTIONS

Public Class Methods

new(hash) click to toggle source
# File lib/schmersion/config.rb, line 16
def initialize(hash)
  @hash = hash
end

Public Instance Methods

exports() click to toggle source
# File lib/schmersion/config.rb, line 40
def exports
  return [] if @hash['exports'].nil?

  @hash['exports'].map { |e| create_export(e) }
end
linting() click to toggle source
# File lib/schmersion/config.rb, line 46
def linting
  DEFAULT_LINTING_OPTIONS.merge(@hash['linting']&.transform_keys(&:to_sym) || {})
end
scopes() click to toggle source
# File lib/schmersion/config.rb, line 30
def scopes
  @hash['scopes'] || []
end
types() click to toggle source
# File lib/schmersion/config.rb, line 20
def types
  @hash['types'] || DEFAULT_TYPES
end
valid_scope?(scope) click to toggle source
# File lib/schmersion/config.rb, line 34
def valid_scope?(scope)
  return true if scopes.empty?

  scopes.include?(scope.to_s)
end
valid_type?(type) click to toggle source
# File lib/schmersion/config.rb, line 24
def valid_type?(type)
  return true if types.empty?

  types.include?(type.to_s)
end
version_options() click to toggle source
# File lib/schmersion/config.rb, line 50
def version_options
  DEFAULT_VERSION_OPTIONS.merge(@hash['version_options']&.transform_keys(&:to_sym) || {})
end

Private Instance Methods

create_export(export) click to toggle source
# File lib/schmersion/config.rb, line 56
def create_export(export)
  name = export['name']
  formatter = Formatters::FORMATTERS[export['formatter'].to_sym]
  if formatter.nil?
    raise Error, "Invalid formatter '#{export['formatter']}' for #{name}"
  end

  formatter.new(name, export['options'] || {})
end