dry-core 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d3ee16c97a04071316e718d8277a4a0ac5aea083b37ac7944d65fd3fd78dfc2
4
- data.tar.gz: 44e0e7cb408530f47add47481dd393ba8544e2bcb41256fa0d88af915e7ce547
3
+ metadata.gz: fa73bd9fdfe719f10520d29c6261e8ad9f8a2c33b9efc0b11c70cb3c24b79a57
4
+ data.tar.gz: 32546a46687b7d6e5a10d82fa4c8ef604b02be4cb6ec6e5386e9ef1953bd63b8
5
5
  SHA512:
6
- metadata.gz: 0a9787d9d8514c54564448b7e38a5c52810dfd95f098c399c0067928c221357ee772273ca8d8d258e9305679ad3d2ff552b3ea38318a8872136e36d7c434d0b3
7
- data.tar.gz: 8f073e6e1c574404f6df1b699470432e4406129a20d2a8d27b0de10db52a8363beb5aaa086fb4c8c629402e3d1d5735715c5126e38384e20519dbee4f30a233f
6
+ metadata.gz: 5b9be43a19034cf9f61a4724f70e106d4a70e50d76d23b98dffcc2b8ae4c6a175aa5058c1eec38d69e13c638a4a96a71027a783ab34ec9555030d9e6657cd7a2
7
+ data.tar.gz: 00d0f0a5c647a68b7b0d49a30805caa08faa10787c61435751538cb28d0b36e2a561bfa5b0222a40b2505248002558c4dfdb945ac484a2bde3eedb65a257c8a7
data/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- ## 0.8.0
3
+ ## 0.9.0 2022-10-14
4
+
5
+
6
+ ### Changed
7
+
8
+ - dry-core now uses zeitwerk for autoloading (@solnic)
9
+
10
+ [Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-core/compare/v0.8.1...v0.9.0)
11
+
12
+ ## 0.8.1 2022-07-27
13
+
14
+
15
+ ### Fixed
16
+
17
+ - [memoizable] plays better with inheritance.
18
+ There were cases when cached values from base claesses were used, see #70 (@flash-gordon)
19
+
20
+
21
+
22
+ [Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-core/compare/v0.8.0...v0.8.1)
23
+
24
+ ## 0.8.0 2022-07-15
25
+
4
26
 
5
27
  ### Added
6
28
 
@@ -12,7 +34,7 @@
12
34
  This changes the order of returned subclasses (immediate subclasses now go first) (@flash-gordon)
13
35
 
14
36
 
15
- [Compare v0.7.1...v0.8.0](https://github.com/dry-rb/dry-core/compare/v0.7.1...master)
37
+ [Compare v0.7.1...v0.8.0](https://github.com/dry-rb/dry-core/compare/v0.7.1...v0.8.0)
16
38
 
17
39
  ## 0.7.1 2021-07-10
18
40
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 dry-rb team
3
+ Copyright (c) 2015-2022 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/dry-core.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  # to update dependencies edit project.yml
32
32
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
33
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
33
34
 
34
35
  spec.add_development_dependency "bundler"
35
36
  spec.add_development_dependency "rake"
@@ -1,16 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/constants"
4
- require "dry/core/errors"
5
-
6
3
  module Dry
7
4
  module Core
8
5
  # Internal support module for class-level settings
9
6
  #
10
7
  # @api public
11
8
  module ClassAttributes
12
- include Constants
13
-
14
9
  # Specify what attributes a class will use
15
10
  #
16
11
  # @example
@@ -86,7 +81,7 @@ module Dry
86
81
  elsif type === value # rubocop:disable Style/CaseEquality
87
82
  instance_variable_set(ivar, coerce.call(value))
88
83
  else
89
- raise InvalidClassAttributeValue.new(name, value)
84
+ raise InvalidClassAttributeValueError.new(name, value)
90
85
  end
91
86
  end
92
87
  end
@@ -1,17 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dry
4
- # Build an equalizer module for the inclusion in other class
5
- #
6
- # ## Credits
7
- #
8
- # Equalizer has been originally imported from the equalizer gem created by Dan Kubb
9
- #
10
- # @api public
11
- def self.Equalizer(*keys, **options)
12
- Dry::Core::Equalizer.new(*keys, **options)
13
- end
14
-
15
4
  module Core
16
5
  # Define equality, equivalence and inspection methods
17
6
  class Equalizer < ::Module
@@ -149,4 +138,19 @@ module Dry
149
138
  end
150
139
  end
151
140
  end
141
+
142
+ # Old modules that depend on dry/core/equalizer may miss
143
+ # this method if dry/core is not required explicitly
144
+ unless singleton_class.method_defined?(:Equalizer)
145
+ # Build an equalizer module for the inclusion in other class
146
+ #
147
+ # ## Credits
148
+ #
149
+ # Equalizer has been originally imported from the equalizer gem created by Dan Kubb
150
+ #
151
+ # @api public
152
+ def self.Equalizer(*keys, **options)
153
+ Dry::Core::Equalizer.new(*keys, **options)
154
+ end
155
+ end
152
156
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Dry
4
4
  module Core
5
- class InvalidClassAttributeValue < StandardError
5
+ class InvalidClassAttributeValueError < StandardError
6
6
  def initialize(name, value)
7
7
  super(
8
8
  "Value #{value.inspect} is invalid for class attribute #{name.inspect}"
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/core/deprecations"
4
-
5
3
  module Dry
6
4
  module Core
7
5
  module Memoizable
@@ -91,7 +89,7 @@ module Dry
91
89
  define_method(method.name) do
92
90
  value = super()
93
91
 
94
- if kernel[:frozen].bind(self).call
92
+ if kernel[:frozen].bind_call(self)
95
93
  # It's not possible to modify singleton classes
96
94
  # of frozen objects
97
95
  mod.remove_method(method.name)
@@ -113,8 +111,8 @@ module Dry
113
111
  # expect :)
114
112
  attr_name = :"__memozed_#{key}__"
115
113
  ivar_name = :"@#{attr_name}"
116
- kernel[:ivar_set].bind(self).(ivar_name, value)
117
- eigenclass = kernel[:singleton].bind(self).call
114
+ kernel[:ivar_set].bind_call(self, ivar_name, value)
115
+ eigenclass = kernel[:singleton].bind_call(self)
118
116
  eigenclass.attr_reader(attr_name)
119
117
  eigenclass.alias_method(method.name, attr_name)
120
118
  eigenclass.remove_method(attr_name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Core
5
- VERSION = "0.8.1"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
data/lib/dry/core.rb CHANGED
@@ -1,10 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "zeitwerk"
4
+
5
+ require "dry/core/constants"
6
+ require "dry/core/errors"
3
7
  require "dry/core/version"
4
8
 
5
9
  # :nodoc:
6
10
  module Dry
7
11
  # :nodoc:
8
12
  module Core
13
+ include Constants
14
+
15
+ def self.loader
16
+ @loader ||= Zeitwerk::Loader.new.tap do |loader|
17
+ root = File.expand_path("..", __dir__)
18
+ loader.tag = "dry-core"
19
+ loader.inflector = Zeitwerk::GemInflector.new("#{root}/dry-core.rb")
20
+ loader.push_dir(root)
21
+ loader.ignore(
22
+ "#{root}/dry-core.rb",
23
+ "#{root}/dry/core/{constants,errors,version}.rb"
24
+ )
25
+ end
26
+ end
27
+
28
+ loader.setup
29
+ end
30
+
31
+ # See dry/core/equalizer.rb
32
+ unless singleton_class.method_defined?(:Equalizer)
33
+ # Build an equalizer module for the inclusion in other class
34
+ #
35
+ # ## Credits
36
+ #
37
+ # Equalizer has been originally imported from the equalizer gem created by Dan Kubb
38
+ #
39
+ # @api public
40
+ def self.Equalizer(*keys, **options)
41
+ Dry::Core::Equalizer.new(*keys, **options)
42
+ end
9
43
  end
10
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Shilnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-27 00:00:00.000000000 Z
11
+ date: 2022-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zeitwerk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement