diff --git a/.rspec b/.rspec deleted file mode 100644 index dd90eb63e..000000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---require ./hearth/spec/spec_helper --I ./hearth/lib \ No newline at end of file diff --git a/hearth/.rspec b/hearth/.rspec deleted file mode 100644 index c99d2e739..000000000 --- a/hearth/.rspec +++ /dev/null @@ -1 +0,0 @@ ---require spec_helper diff --git a/hearth/lib/hearth.rb b/hearth/lib/hearth.rb index a0057f0a0..c05fa862b 100755 --- a/hearth/lib/hearth.rb +++ b/hearth/lib/hearth.rb @@ -58,6 +58,7 @@ module Hearth VERSION = File.read(File.expand_path('../VERSION', __dir__)).strip + # @api private @config = {} class << self diff --git a/hearth/lib/hearth/config/resolver.rb b/hearth/lib/hearth/config/resolver.rb index 19a5467ce..9fa528c43 100644 --- a/hearth/lib/hearth/config/resolver.rb +++ b/hearth/lib/hearth/config/resolver.rb @@ -1,58 +1,5 @@ # frozen_string_literal: true -# module Hearth -# # @api private -# module Config -# # Resolves configuration defaults. -# class Resolver -# private_class_method :new -# -# # @param config [Struct] -# # @param defaults [Hash] -# # @return [Struct] -# def self.resolve(config, defaults = {}) -# new(config).send(:resolve, defaults) -# end -# -# def [](key) -# unless @resolved[key] -# @config[key] = resolve_default(key) -# @resolved[key] = true -# end -# @config[key] -# end -# -# private -# -# # @param config [Struct] -# def initialize(config) -# @config = config -# @resolved = {} -# end -# -# def resolve(defaults) -# @defaults = defaults -# @config.members.each do |key| -# @config[key] = self[key] -# end -# end -# -# def resolve_default(key) -# @defaults[key]&.each do |default| -# value = -# if default.respond_to?(:call) -# default.call(self) -# else -# default -# end -# return value unless value.nil? -# end -# nil -# end -# end -# end -# end - module Hearth # @api private module Config diff --git a/hearth/lib/hearth/configuration.rb b/hearth/lib/hearth/configuration.rb index 90f735550..3df757abc 100644 --- a/hearth/lib/hearth/configuration.rb +++ b/hearth/lib/hearth/configuration.rb @@ -10,7 +10,7 @@ def initialize(**options) end # @return [Hash] The original configuration options. - attr_accessor :options + attr_reader :options def merge(configuration) self.class.new(**to_h.merge(configuration.to_h)) diff --git a/hearth/sig/lib/hearth.rbs b/hearth/sig/lib/hearth.rbs new file mode 100644 index 000000000..e3bfffc81 --- /dev/null +++ b/hearth/sig/lib/hearth.rbs @@ -0,0 +1,7 @@ +module Hearth + VERSION: String + + attr_reader self.config: Hash[Symbol, untyped] + + def self.config=: (Hash[Symbol, untyped] config) -> Hash[Symbol, untyped] +end diff --git a/hearth/sig/lib/hearth/configuration.rbs b/hearth/sig/lib/hearth/configuration.rbs index 5170a818f..6e537a36d 100644 --- a/hearth/sig/lib/hearth/configuration.rbs +++ b/hearth/sig/lib/hearth/configuration.rbs @@ -2,6 +2,8 @@ module Hearth module Configuration[ServiceConfig] def initialize: (**Hash[Symbol, untyped] options) -> void + attr_reader options: Hash[Symbol, untyped] + def merge: (Hash[Symbol, untyped] configuration) -> ServiceConfig end end diff --git a/hearth/spec/spec_helper.rb b/hearth/spec/spec_helper.rb index 5052ed742..0294a2bf1 100644 --- a/hearth/spec/spec_helper.rb +++ b/hearth/spec/spec_helper.rb @@ -1,5 +1,13 @@ # frozen_string_literal: true +require 'simplecov' +SimpleCov.minimum_coverage 100 +SimpleCov.start do + add_filter %r{/spec/} +end + +require 'hearth' + # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause @@ -16,14 +24,6 @@ # # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -require 'simplecov' -SimpleCov.minimum_coverage 100 -SimpleCov.start do - add_filter %r{/spec/} -end - -require 'hearth' - RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest