Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package rubygem-dry-core for 
openSUSE:Factory checked in at 2022-12-13 18:56:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-dry-core (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-dry-core.new.1835 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-dry-core"

Tue Dec 13 18:56:33 2022 rev:7 rq:1042630 version:1.0.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-dry-core/rubygem-dry-core.changes        
2022-10-30 18:28:55.054410839 +0100
+++ 
/work/SRC/openSUSE:Factory/.rubygem-dry-core.new.1835/rubygem-dry-core.changes  
    2022-12-13 18:56:50.435643008 +0100
@@ -1,0 +2,17 @@
+Wed Dec  7 11:18:08 UTC 2022 - Stephan Kulow <[email protected]>
+
+updated to version 1.0.0
+ see installed CHANGELOG.md
+
+  ## 1.0.0 2022-11-04
+  
+  
+  ### Added
+  
+  - Import dry-container as `Dry::Core::Container` (via #77) (@solnic)
+  
+  
+  [Compare 
v0.9.1...v1.0.0](https://github.com/dry-rb/dry-core/compare/v0.9.1...v1.0.0)
+  
+
+-------------------------------------------------------------------

Old:
----
  dry-core-0.9.1.gem

New:
----
  dry-core-1.0.0.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-dry-core.spec ++++++
--- /var/tmp/diff_new_pack.B5qwQ3/_old  2022-12-13 18:56:50.979645911 +0100
+++ /var/tmp/diff_new_pack.B5qwQ3/_new  2022-12-13 18:56:50.983645933 +0100
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-dry-core
-Version:        0.9.1
+Version:        1.0.0
 Release:        0
 %define mod_name dry-core
 %define mod_full_name %{mod_name}-%{version}

++++++ dry-core-0.9.1.gem -> dry-core-1.0.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2022-10-18 06:20:32.000000000 +0200
+++ new/CHANGELOG.md    2022-11-04 13:52:43.000000000 +0100
@@ -1,5 +1,15 @@
 <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
 
+## 1.0.0 2022-11-04
+
+
+### Added
+
+- Import dry-container as `Dry::Core::Container` (via #77) (@solnic)
+
+
+[Compare 
v0.9.1...v1.0.0](https://github.com/dry-rb/dry-core/compare/v0.9.1...v1.0.0)
+
 ## 0.9.1 2022-10-18
 
 
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/config.rb 
new/lib/dry/core/container/config.rb
--- old/lib/dry/core/container/config.rb        1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/config.rb        2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # @api public
+      class Config
+        DEFAULT_NAMESPACE_SEPARATOR = "."
+        DEFAULT_RESOLVER = Resolver.new
+        DEFAULT_REGISTRY = Registry.new
+
+        # @api public
+        attr_accessor :namespace_separator
+
+        # @api public
+        attr_accessor :resolver
+
+        # @api public
+        attr_accessor :registry
+
+        # @api private
+        def initialize(
+          namespace_separator: DEFAULT_NAMESPACE_SEPARATOR,
+          resolver: DEFAULT_RESOLVER,
+          registry: DEFAULT_REGISTRY
+        )
+          @namespace_separator = namespace_separator
+          @resolver = resolver
+          @registry = registry
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/configuration.rb 
new/lib/dry/core/container/configuration.rb
--- old/lib/dry/core/container/configuration.rb 1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/configuration.rb 2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # @api public
+      module Configuration
+        # Use dry/configurable if it's available
+        begin
+          require "dry/configurable"
+
+          # @api private
+          def self.extended(klass)
+            super
+            klass.class_eval do
+              extend Dry::Configurable
+
+              setting :namespace_separator, default: 
Config::DEFAULT_NAMESPACE_SEPARATOR
+              setting :resolver, default: Config::DEFAULT_RESOLVER
+              setting :registry, default: Config::DEFAULT_REGISTRY
+            end
+          end
+        rescue LoadError
+          # @api private
+          def config
+            @config ||= Container::Config.new
+          end
+        end
+
+        # @api private
+        def configure
+          yield config
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/item/callable.rb 
new/lib/dry/core/container/item/callable.rb
--- old/lib/dry/core/container/item/callable.rb 1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/item/callable.rb 2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      class Item
+        # Callable class to returns a item call
+        #
+        # @api public
+        #
+        class Callable < Item
+          # Returns the result of item call or item
+          #
+          # @return [Mixed]
+          def call
+            callable? ? item.call : item
+          end
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/item/factory.rb 
new/lib/dry/core/container/item/factory.rb
--- old/lib/dry/core/container/item/factory.rb  1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/item/factory.rb  2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      class Item
+        # Factory for create an Item to register inside of container
+        #
+        # @api public
+        class Factory
+          # Creates an Item Memoizable or Callable
+          # @param [Mixed] item
+          # @param [Hash] options
+          #
+          # @raise [Dry::Core::Container::Error]
+          #
+          # @return [Dry::Core::Container::Item::Base]
+          def call(item, options = {})
+            if options[:memoize]
+              Item::Memoizable.new(item, options)
+            else
+              Item::Callable.new(item, options)
+            end
+          end
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/item/memoizable.rb 
new/lib/dry/core/container/item/memoizable.rb
--- old/lib/dry/core/container/item/memoizable.rb       1970-01-01 
01:00:00.000000000 +0100
+++ new/lib/dry/core/container/item/memoizable.rb       2022-11-04 
13:52:43.000000000 +0100
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      class Item
+        # Memoizable class to store and execute item calls
+        #
+        # @api public
+        #
+        class Memoizable < Item
+          # @return [Mutex] the stored mutex
+          attr_reader :memoize_mutex
+
+          # Returns a new Memoizable instance
+          #
+          # @param [Mixed] item
+          # @param [Hash] options
+          #
+          # @raise [Dry::Core::Container::Error]
+          #
+          # @return [Dry::Core::Container::Item::Base]
+          def initialize(item, options = {})
+            super
+            raise_not_supported_error unless callable?
+
+            @memoize_mutex = ::Mutex.new
+          end
+
+          # Returns the result of item call using a syncronized mutex
+          #
+          # @return [Dry::Core::Container::Item::Base]
+          def call
+            memoize_mutex.synchronize do
+              @memoized_item ||= item.call
+            end
+          end
+
+          private
+
+          # @private
+          def raise_not_supported_error
+            raise ::Dry::Core::Container::Error, "Memoize only supported for a 
block or a proc"
+          end
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/item.rb 
new/lib/dry/core/container/item.rb
--- old/lib/dry/core/container/item.rb  1970-01-01 01:00:00.000000000 +0100
+++ new/lib/dry/core/container/item.rb  2022-11-04 13:52:43.000000000 +0100
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # Base class to abstract Memoizable and Callable implementations
+      #
+      # @api abstract
+      #
+      class Item
+        # @return [Mixed] the item to be solved later
+        attr_reader :item
+
+        # @return [Hash] the options to memoize, call or no.
+        attr_reader :options
+
+        # @api abstract
+        def initialize(item, options = {})
+          @item = item
+          @options = {
+            call: item.is_a?(::Proc) && item.parameters.empty?
+          }.merge(options)
+        end
+
+        # @api abstract
+        def call
+          raise NotImplementedError
+        end
+
+        # @private
+        def value?
+          !callable?
+        end
+
+        # @private
+        def callable?
+          options[:call]
+        end
+
+        # Build a new item with transformation applied
+        #
+        # @private
+        def map(func)
+          if callable?
+            self.class.new(-> { func.(item.call) }, options)
+          else
+            self.class.new(func.(item), options)
+          end
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/mixin.rb 
new/lib/dry/core/container/mixin.rb
--- old/lib/dry/core/container/mixin.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/lib/dry/core/container/mixin.rb 2022-11-04 13:52:43.000000000 +0100
@@ -0,0 +1,311 @@
+# frozen_string_literal: true
+
+require "concurrent/hash"
+require "dry/core/constants"
+
+module Dry
+  module Core
+    class Container
+      include Dry::Core::Constants
+
+      # @api public
+      Error = Class.new(StandardError)
+
+      # Error raised when key is not defined in the registry
+      #
+      # @api public
+      KeyError = Class.new(::KeyError)
+
+      if defined?(DidYouMean::KeyErrorChecker)
+        DidYouMean.correct_error(KeyError, DidYouMean::KeyErrorChecker)
+      end
+
+      # Mixin to expose Inversion of Control (IoC) container behaviour
+      #
+      # @example
+      #
+      #   class MyClass
+      #     extend Dry::Core::Container::Mixin
+      #   end
+      #
+      #   MyClass.register(:item, 'item')
+      #   MyClass.resolve(:item)
+      #   => 'item'
+      #
+      #   class MyObject
+      #     include Dry::Core::Container::Mixin
+      #   end
+      #
+      #   container = MyObject.new
+      #   container.register(:item, 'item')
+      #   container.resolve(:item)
+      #   => 'item'
+      #
+      # @api public
+      #
+      # rubocop:disable Metrics/ModuleLength
+      module Mixin
+        PREFIX_NAMESPACE = lambda do |namespace, key, config|
+          [namespace, key].join(config.namespace_separator)
+        end
+
+        # @private
+        def self.extended(base)
+          hooks_mod = ::Module.new do
+            def inherited(subclass)
+              subclass.instance_variable_set(:@_container, @_container.dup)
+              super
+            end
+          end
+
+          base.class_eval do
+            extend Configuration
+            extend hooks_mod
+
+            @_container = ::Concurrent::Hash.new
+          end
+        end
+
+        # @private
+        module Initializer
+          def initialize(*args, &block)
+            @_container = ::Concurrent::Hash.new
+            super
+          end
+        end
+
+        # @private
+        def self.included(base)
+          base.class_eval do
+            extend Configuration
+            prepend Initializer
+
+            def config
+              self.class.config
+            end
+          end
+        end
+
+        # Register an item with the container to be resolved later
+        #
+        # @param [Mixed] key
+        #   The key to register the container item with (used to resolve)
+        # @param [Mixed] contents
+        #   The item to register with the container (if no block given)
+        # @param [Hash] options
+        #   Options to pass to the registry when registering the item
+        # @yield
+        #   If a block is given, contents will be ignored and the block
+        #   will be registered instead
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def register(key, contents = nil, options = EMPTY_HASH, &block)
+          if block_given?
+            item = block
+            options = contents if contents.is_a?(::Hash)
+          else
+            item = contents
+          end
+
+          config.registry.call(_container, key, item, options)
+
+          self
+        rescue FrozenError
+          raise FrozenError,
+                "can't modify frozen #{self.class} (when attempting to 
register '#{key}')"
+        end
+
+        # Resolve an item from the container
+        #
+        # @param [Mixed] key
+        #   The key for the item you wish to resolve
+        # @yield
+        #   Fallback block to call when a key is missing. Its result will be 
returned
+        # @yieldparam [Mixed] key Missing key
+        #
+        # @return [Mixed]
+        #
+        # @api public
+        def resolve(key, &block)
+          config.resolver.call(_container, key, &block)
+        end
+
+        # Resolve an item from the container
+        #
+        # @param [Mixed] key
+        #   The key for the item you wish to resolve
+        #
+        # @return [Mixed]
+        #
+        # @api public
+        # @see Dry::Core::Container::Mixin#resolve
+        def [](key)
+          resolve(key)
+        end
+
+        # Merge in the items of the other container
+        #
+        # @param [Dry::Core::Container] other
+        #   The other container to merge in
+        # @param [Symbol, nil] namespace
+        #   Namespace to prefix other container items with, defaults to nil
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def merge(other, namespace: nil, &block)
+          if namespace
+            _container.merge!(
+              other._container.each_with_object(::Concurrent::Hash.new) { 
|(key, item), hsh|
+                hsh[PREFIX_NAMESPACE.call(namespace, key, config)] = item
+              },
+              &block
+            )
+          else
+            _container.merge!(other._container, &block)
+          end
+
+          self
+        end
+
+        # Check whether an item is registered under the given key
+        #
+        # @param [Mixed] key
+        #   The key you wish to check for registration with
+        #
+        # @return [Bool]
+        #
+        # @api public
+        def key?(key)
+          config.resolver.key?(_container, key)
+        end
+
+        # An array of registered names for the container
+        #
+        # @return [Array<String>]
+        #
+        # @api public
+        def keys
+          config.resolver.keys(_container)
+        end
+
+        # Calls block once for each key in container, passing the key as a 
parameter.
+        #
+        # If no block is given, an enumerator is returned instead.
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def each_key(&block)
+          config.resolver.each_key(_container, &block)
+          self
+        end
+
+        # Calls block once for each key/value pair in the container, passing 
the key and
+        # the registered item parameters.
+        #
+        # If no block is given, an enumerator is returned instead.
+        #
+        # @return [Enumerator]
+        #
+        # @api public
+        #
+        # @note In discussions with other developers, it was felt that being 
able to iterate
+        #       over not just the registered keys, but to see what was 
registered would be
+        #       very helpful. This is a step toward doing that.
+        def each(&block)
+          config.resolver.each(_container, &block)
+        end
+
+        # Decorates an item from the container with specified decorator
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def decorate(key, with: nil, &block)
+          key = key.to_s
+          original = _container.delete(key) do
+            raise KeyError, "Nothing registered with the key #{key.inspect}"
+          end
+
+          if with.is_a?(Class)
+            decorator = with.method(:new)
+          elsif block.nil? && !with.respond_to?(:call)
+            raise Error, "Decorator needs to be a Class, block, or respond to 
the `call` method"
+          else
+            decorator = with || block
+          end
+
+          _container[key] = original.map(decorator)
+          self
+        end
+
+        # Evaluate block and register items in namespace
+        #
+        # @param [Mixed] namespace
+        #   The namespace to register items in
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def namespace(namespace, &block)
+          ::Dry::Core::Container::NamespaceDSL.new(
+            self,
+            namespace,
+            config.namespace_separator,
+            &block
+          )
+
+          self
+        end
+
+        # Import a namespace
+        #
+        # @param [Dry::Core::Container::Namespace] namespace
+        #   The namespace to import
+        #
+        # @return [Dry::Core::Container::Mixin] self
+        #
+        # @api public
+        def import(namespace)
+          namespace(namespace.name, &namespace.block)
+
+          self
+        end
+
+        # Freeze the container. Nothing can be registered after freezing
+        #
+        # @api public
+        def freeze
+          super
+          _container.freeze
+          self
+        end
+
+        # @private no, really
+        def _container
+          @_container
+        end
+
+        # @api public
+        def dup
+          copy = super
+          copy.instance_variable_set(:@_container, _container.dup)
+          copy
+        end
+
+        # @api public
+        def clone
+          copy = super
+          unless copy.frozen?
+            copy.instance_variable_set(:@_container, _container.dup)
+          end
+          copy
+        end
+      end
+      # rubocop:enable Metrics/ModuleLength
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/namespace.rb 
new/lib/dry/core/container/namespace.rb
--- old/lib/dry/core/container/namespace.rb     1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/namespace.rb     2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # Create a namespace to be imported
+      #
+      # @example
+      #
+      #   ns = Dry::Core::Container::Namespace.new('name') do
+      #     register('item', 'item')
+      #   end
+      #
+      #   container = Dry::Core::Container.new
+      #
+      #   container.import(ns)
+      #
+      #   container.resolve('name.item')
+      #   => 'item'
+      #
+      #
+      # @api public
+      class Namespace
+        # @return [Mixed] The namespace (name)
+        attr_reader :name
+
+        # @return [Proc] The block to be executed when the namespace is 
imported
+        attr_reader :block
+
+        # Create a new namespace
+        #
+        # @param [Mixed] name
+        #   The name of the namespace
+        # @yield
+        #   The block to evaluate when the namespace is imported
+        #
+        # @return [Dry::Core::Container::Namespace]
+        #
+        # @api public
+        def initialize(name, &block)
+          @name = name
+          @block = block
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/namespace_dsl.rb 
new/lib/dry/core/container/namespace_dsl.rb
--- old/lib/dry/core/container/namespace_dsl.rb 1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/namespace_dsl.rb 2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,63 @@
+# frozen_string_literal: true
+
+require "delegate"
+
+module Dry
+  module Core
+    class Container
+      # @api private
+      class NamespaceDSL < ::SimpleDelegator
+        # DSL for defining namespaces
+        #
+        # @param [Dry::Core::Container::Mixin] container
+        #   The container
+        # @param [String] namespace
+        #   The namespace (name)
+        # @param [String] namespace_separator
+        #   The namespace separator
+        # @yield
+        #   The block to evaluate to define the namespace
+        #
+        # @return [Mixed]
+        #
+        # @api private
+        def initialize(container, namespace, namespace_separator, &block)
+          @namespace = namespace
+          @namespace_separator = namespace_separator
+
+          super(container)
+
+          if block.arity.zero?
+            instance_eval(&block)
+          else
+            yield self
+          end
+        end
+
+        def register(key, *args, &block)
+          super(namespaced(key), *args, &block)
+        end
+
+        def namespace(namespace, &block)
+          super(namespaced(namespace), &block)
+        end
+
+        def import(namespace)
+          namespace(namespace.name, &namespace.block)
+
+          self
+        end
+
+        def resolve(key)
+          super(namespaced(key))
+        end
+
+        private
+
+        def namespaced(key)
+          [@namespace, key].join(@namespace_separator)
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/registry.rb 
new/lib/dry/core/container/registry.rb
--- old/lib/dry/core/container/registry.rb      1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/registry.rb      2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # Default registry for registering items with the container
+      #
+      # @api public
+      class Registry
+        # @private
+        def initialize
+          @_mutex = ::Mutex.new
+        end
+
+        # Register an item with the container to be resolved later
+        #
+        # @param [Concurrent::Hash] container
+        #   The container
+        # @param [Mixed] key
+        #   The key to register the container item with (used to resolve)
+        # @param [Mixed] item
+        #   The item to register with the container
+        # @param [Hash] options
+        # @option options [Symbol] :call
+        #   Whether the item should be called when resolved
+        #
+        # @raise [Dry::Core::Container::KeyError]
+        #   If an item is already registered with the given key
+        #
+        # @return [Mixed]
+        #
+        # @api public
+        def call(container, key, item, options)
+          key = key.to_s.dup.freeze
+
+          @_mutex.synchronize do
+            if container.key?(key)
+              raise KeyError, "There is already an item registered with the 
key #{key.inspect}"
+            end
+
+            container[key] = factory.call(item, options)
+          end
+        end
+
+        # @api private
+        def factory
+          @factory ||= Container::Item::Factory.new
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/resolver.rb 
new/lib/dry/core/container/resolver.rb
--- old/lib/dry/core/container/resolver.rb      1970-01-01 01:00:00.000000000 
+0100
+++ new/lib/dry/core/container/resolver.rb      2022-11-04 13:52:43.000000000 
+0100
@@ -0,0 +1,90 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      # Default resolver for resolving items from container
+      #
+      # @api public
+      class Resolver
+        # Resolve an item from the container
+        #
+        # @param [Concurrent::Hash] container
+        #   The container
+        # @param [Mixed] key
+        #   The key for the item you wish to resolve
+        # @yield
+        #   Fallback block to call when a key is missing. Its result will be 
returned
+        # @yieldparam [Mixed] key Missing key
+        #
+        # @raise [KeyError]
+        #   If the given key is not registered with the container (and no 
block provided)
+        #
+        #
+        # @return [Mixed]
+        #
+        # @api public
+        def call(container, key)
+          item = container.fetch(key.to_s) do
+            if block_given?
+              return yield(key)
+            else
+              raise KeyError.new(%(key not found: "#{key}"), key: key.to_s, 
receiver: container)
+            end
+          end
+
+          item.call
+        end
+
+        # Check whether an items is registered under the given key
+        #
+        # @param [Concurrent::Hash] container
+        #   The container
+        # @param [Mixed] key
+        #   The key you wish to check for registration with
+        #
+        # @return [Bool]
+        #
+        # @api public
+        def key?(container, key)
+          container.key?(key.to_s)
+        end
+
+        # An array of registered names for the container
+        #
+        # @return [Array]
+        #
+        # @api public
+        def keys(container)
+          container.keys
+        end
+
+        # Calls block once for each key in container, passing the key as a 
parameter.
+        #
+        # If no block is given, an enumerator is returned instead.
+        #
+        # @return Hash
+        #
+        # @api public
+        def each_key(container, &block)
+          container.each_key(&block)
+        end
+
+        # Calls block once for each key in container, passing the key and
+        # the registered item parameters.
+        #
+        # If no block is given, an enumerator is returned instead.
+        #
+        # @return Key, Value
+        #
+        # @api public
+        # @note In discussions with other developers, it was felt that being 
able
+        #       to iterate over not just the registered keys, but to see what 
was
+        #       registered would be very helpful. This is a step toward doing 
that.
+        def each(container, &block)
+          container.map { |key, value| [key, value.call] }.each(&block)
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container/stub.rb 
new/lib/dry/core/container/stub.rb
--- old/lib/dry/core/container/stub.rb  1970-01-01 01:00:00.000000000 +0100
+++ new/lib/dry/core/container/stub.rb  2022-11-04 13:52:43.000000000 +0100
@@ -0,0 +1,57 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    class Container
+      module Stub
+        # Overrides resolve to look into stubbed keys first
+        #
+        # @api public
+        def resolve(key)
+          _stubs.fetch(key.to_s) { super }
+        end
+
+        # Add a stub to the container
+        def stub(key, value, &block)
+          unless key?(key)
+            raise ArgumentError, "cannot stub #{key.to_s.inspect} - no such 
key in container"
+          end
+
+          _stubs[key.to_s] = value
+
+          if block
+            yield
+            unstub(key)
+          end
+
+          self
+        end
+
+        # Remove stubbed keys from the container
+        def unstub(*keys)
+          keys = _stubs.keys if keys.empty?
+          keys.each { |key| _stubs.delete(key.to_s) }
+        end
+
+        # Stubs have already been enabled turning this into a noop
+        def enable_stubs!
+          # DO NOTHING
+        end
+
+        private
+
+        # Stubs container
+        def _stubs
+          @_stubs ||= {}
+        end
+      end
+
+      module Mixin
+        # Enable stubbing functionality into the current container
+        def enable_stubs!
+          extend ::Dry::Core::Container::Stub
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/container.rb 
new/lib/dry/core/container.rb
--- old/lib/dry/core/container.rb       1970-01-01 01:00:00.000000000 +0100
+++ new/lib/dry/core/container.rb       2022-11-04 13:52:43.000000000 +0100
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Dry
+  module Core
+    # Thread-safe object registry
+    #
+    # @example
+    #
+    #   container = Dry::Core::Container.new
+    #   container.register(:item, 'item')
+    #   container.resolve(:item)
+    #   => 'item'
+    #
+    #   container.register(:item1, -> { 'item' })
+    #   container.resolve(:item1)
+    #   => 'item'
+    #
+    #   container.register(:item2, -> { 'item' }, call: false)
+    #   container.resolve(:item2)
+    #   => #<Proc:0x007f33b169e998@(irb):10 (lambda)>
+    #
+    # @api public
+    class Container
+      include Container::Mixin
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/memoizable.rb 
new/lib/dry/core/memoizable.rb
--- old/lib/dry/core/memoizable.rb      2022-10-18 06:20:32.000000000 +0200
+++ new/lib/dry/core/memoizable.rb      2022-11-04 13:52:43.000000000 +0100
@@ -16,7 +16,7 @@
             super
 
             memoizer = base.ancestors.find { _1.is_a?(Memoizer) }
-            base.prepend(memoizer.dup)
+            base.prepend(memoizer.dup) if memoizer
           end
         end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core/version.rb new/lib/dry/core/version.rb
--- old/lib/dry/core/version.rb 2022-10-18 06:20:32.000000000 +0200
+++ new/lib/dry/core/version.rb 2022-11-04 13:52:43.000000000 +0100
@@ -2,6 +2,6 @@
 
 module Dry
   module Core
-    VERSION = "0.9.1"
+    VERSION = "1.0.0"
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/dry/core.rb new/lib/dry/core.rb
--- old/lib/dry/core.rb 2022-10-18 06:20:32.000000000 +0200
+++ new/lib/dry/core.rb 2022-11-04 13:52:43.000000000 +0100
@@ -22,6 +22,7 @@
           "#{root}/dry-core.rb",
           "#{root}/dry/core/{constants,errors,version}.rb"
         )
+        loader.inflector.inflect("namespace_dsl" => "NamespaceDSL")
       end
     end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2022-10-18 06:20:32.000000000 +0200
+++ new/metadata        2022-11-04 13:52:43.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: dry-core
 version: !ruby/object:Gem::Version
-  version: 0.9.1
+  version: 1.0.0
 platform: ruby
 authors:
 - Nikita Shilnikov
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2022-10-18 00:00:00.000000000 Z
+date: 2022-11-04 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: concurrent-ruby
@@ -98,6 +98,19 @@
 - lib/dry/core/class_attributes.rb
 - lib/dry/core/class_builder.rb
 - lib/dry/core/constants.rb
+- lib/dry/core/container.rb
+- lib/dry/core/container/config.rb
+- lib/dry/core/container/configuration.rb
+- lib/dry/core/container/item.rb
+- lib/dry/core/container/item/callable.rb
+- lib/dry/core/container/item/factory.rb
+- lib/dry/core/container/item/memoizable.rb
+- lib/dry/core/container/mixin.rb
+- lib/dry/core/container/namespace.rb
+- lib/dry/core/container/namespace_dsl.rb
+- lib/dry/core/container/registry.rb
+- lib/dry/core/container/resolver.rb
+- lib/dry/core/container/stub.rb
 - lib/dry/core/deprecations.rb
 - lib/dry/core/descendants_tracker.rb
 - lib/dry/core/equalizer.rb

Reply via email to