dry-effects 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/dry-effects.gemspec +3 -3
  4. data/lib/dry/effects/all.rb +1 -5
  5. data/lib/dry/effects/constructors.rb +29 -3
  6. data/lib/dry/effects/container.rb +1 -3
  7. data/lib/dry/effects/effect.rb +0 -2
  8. data/lib/dry/effects/effects/async.rb +0 -2
  9. data/lib/dry/effects/effects/cache.rb +0 -2
  10. data/lib/dry/effects/effects/cmp.rb +0 -2
  11. data/lib/dry/effects/effects/current_time.rb +0 -11
  12. data/lib/dry/effects/effects/defer.rb +0 -2
  13. data/lib/dry/effects/effects/env.rb +0 -2
  14. data/lib/dry/effects/effects/fork.rb +0 -2
  15. data/lib/dry/effects/effects/implicit.rb +0 -2
  16. data/lib/dry/effects/effects/interrupt.rb +0 -2
  17. data/lib/dry/effects/effects/lock.rb +0 -2
  18. data/lib/dry/effects/effects/parallel.rb +0 -2
  19. data/lib/dry/effects/effects/random.rb +0 -2
  20. data/lib/dry/effects/effects/reader.rb +0 -2
  21. data/lib/dry/effects/effects/resolve.rb +1 -6
  22. data/lib/dry/effects/effects/retry.rb +0 -7
  23. data/lib/dry/effects/effects/state.rb +0 -11
  24. data/lib/dry/effects/effects/timeout.rb +0 -2
  25. data/lib/dry/effects/effects/timestamp.rb +0 -2
  26. data/lib/dry/effects/errors.rb +4 -4
  27. data/lib/dry/effects/extensions/auto_inject.rb +7 -3
  28. data/lib/dry/effects/frame.rb +0 -5
  29. data/lib/dry/effects/halt.rb +0 -1
  30. data/lib/dry/effects/inflector.rb +0 -2
  31. data/lib/dry/effects/initializer.rb +0 -2
  32. data/lib/dry/effects/instructions/execute.rb +0 -6
  33. data/lib/dry/effects/instructions/raise.rb +0 -6
  34. data/lib/dry/effects/instructions.rb +15 -0
  35. data/lib/dry/effects/provider/class_interface.rb +1 -3
  36. data/lib/dry/effects/provider.rb +0 -3
  37. data/lib/dry/effects/providers/async.rb +0 -3
  38. data/lib/dry/effects/providers/cache.rb +0 -3
  39. data/lib/dry/effects/providers/cmp.rb +0 -2
  40. data/lib/dry/effects/providers/current_time/time_generators.rb +1 -3
  41. data/lib/dry/effects/providers/current_time.rb +1 -3
  42. data/lib/dry/effects/providers/defer.rb +0 -2
  43. data/lib/dry/effects/providers/env.rb +0 -3
  44. data/lib/dry/effects/providers/fork.rb +0 -3
  45. data/lib/dry/effects/providers/implicit.rb +0 -2
  46. data/lib/dry/effects/providers/interrupt.rb +0 -4
  47. data/lib/dry/effects/providers/lock.rb +0 -3
  48. data/lib/dry/effects/providers/parallel.rb +0 -2
  49. data/lib/dry/effects/providers/random.rb +0 -2
  50. data/lib/dry/effects/providers/reader.rb +0 -2
  51. data/lib/dry/effects/providers/resolve.rb +0 -3
  52. data/lib/dry/effects/providers/retry.rb +0 -3
  53. data/lib/dry/effects/providers/state.rb +0 -3
  54. data/lib/dry/effects/providers/timeout.rb +0 -2
  55. data/lib/dry/effects/providers/timestamp.rb +2 -5
  56. data/lib/dry/effects/stack.rb +2 -6
  57. data/lib/dry/effects/version.rb +1 -1
  58. data/lib/dry/effects.rb +28 -4
  59. data/lib/dry-effects.rb +3 -0
  60. metadata +16 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0239ad7c00317ef55c59d15f20b9445a23e4209ee381e6eb0e46300cca5615a4'
4
- data.tar.gz: 25c49fe75fe6ada449943aa1642763acab11e20d91d66cd3ed0e5353ecf747b6
3
+ metadata.gz: 4689f958a2a85578e4e0a3bd536ab47c85537df6782a4e48c9c306c425c7b968
4
+ data.tar.gz: bbcbd08b72281a805c47ea40c75250aedbc755b667e33d9839f51bbb6b7a4658
5
5
  SHA512:
6
- metadata.gz: 311d562013b53ed8e3744b2dd433ab5200313e17021ec8b9e3219d48d1ff31ddd824c537b8282be3647e90dd4045369229814f58782c13bd47be7374f9b48036
7
- data.tar.gz: 7eac1b68843190d616057fdd61212ae46e70b3f88b21318daad6e1a5b9d6ea7d15ddbf32e0171095e16a8929d7d45d3661a4eb264629043cb3ae1a794ffc5da4
6
+ metadata.gz: 1d9a9ec37dff625b770b21a24a10c4ae663bea543b5c9924dc9b4280cfb234b69639dcf82947e53842577aba8a7e93911db938054efa73800480c3ae27185ae5
7
+ data.tar.gz: 844c22f024a56801cf5e351f2e1540d353e570ee7e5b26b94e94e53467605d122408444c32a196fd6c9b773c4d7cdfaaff8c0051d8ca39f4a7c4729d7fa58916
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.4.0
4
+
5
+
6
+ ### Changed
7
+
8
+ - This version is compatible with recently released dry-rb dependencies (@flash-gordon)
9
+
10
+ [Compare v0.3.1...main](https://github.com/dry-rb/dry-effects/compare/v0.3.1...main)
11
+
12
+ ## 0.3.1 2022-10-17
13
+
14
+
15
+ ### Changed
16
+
17
+ - Add missing zeitwerk loader (@flash-gordon)
18
+
19
+ [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-effects/compare/v0.3.0...v0.3.1)
20
+
3
21
  ## 0.3.0 2022-10-15
4
22
 
5
23
 
data/dry-effects.gemspec CHANGED
@@ -30,10 +30,10 @@ 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 "dry-container", "~> 0.7", ">= 0.7.2"
34
- spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9"
35
- spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
33
+ spec.add_runtime_dependency "dry-core", "~> 1.0"
34
+ spec.add_runtime_dependency "dry-inflector", "~> 1.0"
36
35
  spec.add_runtime_dependency "dry-initializer", "~> 3.0"
36
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
37
37
 
38
38
  spec.add_development_dependency "bundler"
39
39
  spec.add_development_dependency "rake"
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "concurrent/map"
4
- require "dry/effects/inflector"
5
- require "dry/effects/handler"
6
-
7
3
  module Dry
8
4
  module Effects
9
5
  default = %i[
@@ -40,7 +36,7 @@ module Dry
40
36
  Providers.const_get(Inflector.camelize(key))
41
37
  end
42
38
 
43
- Handler.singleton_class.send(:define_method, class_name) do |*args, **kwargs|
39
+ Handler.singleton_class.define_method(class_name) do |*args, **kwargs|
44
40
  ::Dry::Effects.providers[key].mixin(*args, **kwargs)
45
41
  end
46
42
  end
@@ -3,10 +3,36 @@
3
3
  module Dry
4
4
  module Effects
5
5
  module Constructors
6
- def self.register(name, &block)
7
- define_method(name, &block)
8
- module_function name
6
+ # @api public
7
+ def CurrentTime(**kwargs)
8
+ if kwargs.empty?
9
+ Effects::CurrentTime::CurrentTime
10
+ else
11
+ Effects::CurrentTime::CurrentTime.(**kwargs)
12
+ end
9
13
  end
14
+
15
+ # @api public
16
+ def Resolve(identifier)
17
+ Effects::Resolve::Resolve.(identifier)
18
+ end
19
+
20
+ # @api public
21
+ def Retry(scope)
22
+ Effects::Retry::Retry.new(type: :retry, scope: scope)
23
+ end
24
+
25
+ # @api public
26
+ def Read(scope)
27
+ Effects::State::State.new(type: :state, name: :read, scope: scope)
28
+ end
29
+
30
+ # @api public
31
+ def Write(scope, value)
32
+ Effects::State::State.new(type: :state, name: :write, scope: scope, payload: [value])
33
+ end
34
+
35
+ instance_methods(false).each { module_function(_1) }
10
36
  end
11
37
  end
12
38
  end
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/container"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  class Container
8
- include Dry::Container::Mixin
6
+ include Core::Container::Mixin
9
7
  end
10
8
  end
11
9
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/initializer"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  class Effect
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,22 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
- require "dry/effects/constructors"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Effects
9
6
  class CurrentTime < ::Module
10
7
  CurrentTime = Effect.new(type: :current_time)
11
8
 
12
- Constructors.register(:CurrentTime) do |**kwargs|
13
- if kwargs.empty?
14
- CurrentTime
15
- else
16
- CurrentTime.(**kwargs)
17
- end
18
- end
19
-
20
9
  def initialize(**options)
21
10
  super()
22
11
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effects/state"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,20 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
- require "dry/effects/constructors"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Effects
9
6
  class Resolve < ::Module
10
- DependencyNameInvalid = Class.new(StandardError)
7
+ DependencyNameInvalid = ::Class.new(StandardError)
11
8
 
12
9
  VALID_NAME = /([a-z_][a-zA-Z_0-9]*)$/.freeze
13
10
 
14
11
  Resolve = Effect.new(type: :resolve)
15
12
 
16
- Constructors.register(:Resolve) { Resolve.(_1) }
17
-
18
13
  def initialize(*keys, **aliases)
19
14
  super()
20
15
 
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
- require "dry/effects/constructors"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Effects
@@ -13,10 +10,6 @@ module Dry
13
10
  option :scope
14
11
  end
15
12
 
16
- Constructors.register(:Retry) do |scope|
17
- Retry.new(type: :retry, scope: scope)
18
- end
19
-
20
13
  def initialize
21
14
  super
22
15
 
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
- require "dry/effects/constructors"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Effects
@@ -13,14 +10,6 @@ module Dry
13
10
  option :scope
14
11
  end
15
12
 
16
- Constructors.register(:Read) do |scope|
17
- State.new(type: :state, name: :read, scope: scope)
18
- end
19
-
20
- Constructors.register(:Write) do |scope, value|
21
- State.new(type: :state, name: :write, scope: scope, payload: [value])
22
- end
23
-
24
13
  def initialize(scope, default: Undefined, writer: true, as: scope)
25
14
  super()
26
15
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/effect"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Effects
@@ -19,7 +19,7 @@ module Dry
19
19
 
20
20
  super(
21
21
  Undefined.default(message) {
22
- "Effect #{effect.inspect} not handled. "\
22
+ "Effect #{effect.inspect} not handled. " \
23
23
  "Effects must be wrapped with corresponding handlers"
24
24
  }
25
25
  )
@@ -31,7 +31,7 @@ module Dry
31
31
  # @api private
32
32
  class MissingStateError < UnhandledEffectError
33
33
  def initialize(effect)
34
- message = "Value of +#{effect.scope}+ is not set, "\
34
+ message = "Value of +#{effect.scope}+ is not set, " \
35
35
  "you need to provide value with an effect handler"
36
36
 
37
37
  super(effect, message)
@@ -45,8 +45,8 @@ module Dry
45
45
  include Error
46
46
 
47
47
  def initialize(effect)
48
- message = "+#{effect.scope}+ is not defined, you need to assign it first "\
49
- "by using a writer, passing initial value to the handler, or "\
48
+ message = "+#{effect.scope}+ is not defined, you need to assign it first " \
49
+ "by using a writer, passing initial value to the handler, or " \
50
50
  "providing a fallback value"
51
51
 
52
52
  super(message)
@@ -1,13 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "concurrent/map"
4
- require "dry/auto_inject/strategies/constructor"
5
- require "dry/effects/effects/resolve"
4
+ require "dry/auto_inject"
5
+ require "dry/auto_inject/version"
6
+
7
+ if Gem::Version.new(Dry::AutoInject::VERSION) < Gem::Version.new("0.10.0")
8
+ raise RuntimeError, "dry-effects requires dry-auto_inject >= 0.10.0"
9
+ end
6
10
 
7
11
  module Dry
8
12
  module Effects
9
13
  class DryAutoEffectsStrategies
10
- extend Dry::Container::Mixin
14
+ extend Core::Container::Mixin
11
15
 
12
16
  class Base < AutoInject::Strategies::Constructor
13
17
  private
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fiber"
4
- require "dry/effects/initializer"
5
- require "dry/effects/effect"
6
- require "dry/effects/errors"
7
- require "dry/effects/stack"
8
- require "dry/effects/instructions/raise"
9
4
 
10
5
  module Dry
11
6
  module Effects
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "concurrent/map"
4
- require "dry/effects/inflector"
5
4
 
6
5
  module Dry
7
6
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/inflector"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  Inflector = ::Dry::Inflector.new
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/initializer"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Initializer
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/instruction"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Instructions
@@ -17,10 +15,6 @@ module Dry
17
15
  block.call
18
16
  end
19
17
  end
20
-
21
- def self.Execute(&block)
22
- Execute.new(block)
23
- end
24
18
  end
25
19
  end
26
20
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/instruction"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Instructions
@@ -17,10 +15,6 @@ module Dry
17
15
  raise error
18
16
  end
19
17
  end
20
-
21
- def self.Raise(error)
22
- Raise.new(error)
23
- end
24
18
  end
25
19
  end
26
20
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dry
4
+ module Effects
5
+ module Instructions
6
+ def self.Raise(error)
7
+ Raise.new(error)
8
+ end
9
+
10
+ def self.Execute(&block)
11
+ Execute.new(block)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/frame"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  class Provider
@@ -14,7 +12,7 @@ module Dry
14
12
  @effects = ::Hash.new do |es, type|
15
13
  @mutex.synchronize do
16
14
  es.fetch(type) do
17
- es[type] = Class.new(Provider).tap do |provider|
15
+ es[type] = ::Class.new(Provider).tap do |provider|
18
16
  provider.type type
19
17
  end
20
18
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/initializer"
4
- require "dry/effects/provider/class_interface"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  # Base class for effect providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/frame"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/instructions/execute"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
8
6
  class CurrentTime < Provider[:current_time]
9
- module TimeGenetators
7
+ module TimeGenerators
10
8
  FixedTimeGenerator = lambda do
11
9
  time = ::Time.now
12
10
  lambda do |refresh: false, **|
@@ -1,15 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "time"
4
- require "dry/effects/provider"
5
- require "dry/effects/providers/current_time/time_generators"
6
4
 
7
5
  module Dry
8
6
  module Effects
9
7
  module Providers
10
8
  class CurrentTime < Provider[:current_time]
11
9
  include ::Dry::Equalizer(:fixed, :round, inspect: false)
12
- include TimeGenetators
10
+ include TimeGenerators
13
11
 
14
12
  Locate = Effect.new(type: :current_time, name: :locate)
15
13
 
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "concurrent/promise"
4
- require "dry/effects/provider"
5
- require "dry/effects/frame"
6
4
 
7
5
  module Dry
8
6
  module Effects
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/instructions/raise"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/frame"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/instructions/raise"
5
- require "dry/effects/halt"
6
-
7
3
  module Dry
8
4
  module Effects
9
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/initializer"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "concurrent/promise"
4
- require "dry/effects/provider"
5
- require "dry/effects/frame"
6
4
 
7
5
  module Dry
8
6
  module Effects
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/instructions/raise"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/halt"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/providers/reader"
4
- require "dry/effects/instructions/raise"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
-
5
3
  module Dry
6
4
  module Effects
7
5
  module Providers
@@ -1,14 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/provider"
4
- require "dry/effects/providers/current_time"
5
-
6
3
  module Dry
7
4
  module Effects
8
5
  module Providers
9
6
  class Timestamp < Provider[:timestamp]
10
- include Dry::Equalizer(:round)
11
- include CurrentTime::TimeGenetators
7
+ include ::Dry::Equalizer(:round)
8
+ include CurrentTime::TimeGenerators
12
9
 
13
10
  Locate = Effect.new(type: :timestamp, name: :locate)
14
11
 
@@ -1,15 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dry/effects/initializer"
4
- require "dry/effects/effect"
5
- require "dry/effects/instructions/raise"
6
-
7
3
  module Dry
8
4
  module Effects
9
5
  class Stack
10
6
  extend Initializer
11
- include Enumerable
12
- include Dry::Equalizer(:providers)
7
+ include ::Enumerable
8
+ include ::Dry::Equalizer(:providers)
13
9
 
14
10
  param :providers, default: -> { [] }
15
11
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Effects
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
data/lib/dry/effects.rb CHANGED
@@ -1,21 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "zeitwerk"
4
+ require "concurrent/map"
5
+
3
6
  require "dry/core"
4
- require "dry/effects/version"
7
+ require "dry/inflector"
8
+ require "dry/initializer"
9
+
5
10
  require "dry/effects/container"
11
+ require "dry/effects/inflector"
12
+ require "dry/effects/initializer"
13
+ require "dry/effects/extensions"
6
14
  require "dry/effects/errors"
7
- require "dry/effects/instructions/raise"
15
+ require "dry/effects/version"
8
16
 
9
17
  module Dry
10
18
  module Effects
11
19
  include Core::Constants
12
20
 
13
- class Error < StandardError; end
21
+ class Error < ::StandardError; end
14
22
 
15
23
  @effects = Container.new
16
24
  @providers = Container.new
17
25
 
18
26
  class << self
27
+ # @api private
28
+ def loader
29
+ @loader ||= ::Zeitwerk::Loader.new.tap do |loader|
30
+ root = ::File.expand_path("..", __dir__)
31
+ loader.tag = "dry-effects"
32
+ loader.inflector = ::Zeitwerk::GemInflector.new("#{root}/dry-effects.rb")
33
+ loader.push_dir(root)
34
+ loader.ignore(
35
+ "#{root}/dry-effects.rb",
36
+ "#{root}/dry/effects/{all,error,extensions,inflector,initializer,version}.rb",
37
+ "#{root}/dry/effects/extensions/**/*.rb"
38
+ )
39
+ end
40
+ end
41
+
19
42
  attr_reader :effects, :providers
20
43
 
21
44
  # Handle an effect.
@@ -66,8 +89,9 @@ module Dry
66
89
  Handler.new(...)
67
90
  end
68
91
  end
92
+
93
+ loader.setup
69
94
  end
70
95
  end
71
96
 
72
97
  require "dry/effects/all"
73
- require "dry/effects/extensions"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/effects"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-effects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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-10-15 00:00:00.000000000 Z
11
+ date: 2022-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -25,79 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dry-container
28
+ name: dry-core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.7'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.7.2
33
+ version: '1.0'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.7'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.7.2
40
+ version: '1.0'
47
41
  - !ruby/object:Gem::Dependency
48
- name: dry-core
42
+ name: dry-inflector
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.9'
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0.9'
47
+ version: '1.0'
57
48
  type: :runtime
58
49
  prerelease: false
59
50
  version_requirements: !ruby/object:Gem::Requirement
60
51
  requirements:
61
52
  - - "~>"
62
53
  - !ruby/object:Gem::Version
63
- version: '0.9'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '0.9'
54
+ version: '1.0'
67
55
  - !ruby/object:Gem::Dependency
68
- name: dry-inflector
56
+ name: dry-initializer
69
57
  requirement: !ruby/object:Gem::Requirement
70
58
  requirements:
71
59
  - - "~>"
72
60
  - !ruby/object:Gem::Version
73
- version: '0.1'
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 0.1.2
61
+ version: '3.0'
77
62
  type: :runtime
78
63
  prerelease: false
79
64
  version_requirements: !ruby/object:Gem::Requirement
80
65
  requirements:
81
66
  - - "~>"
82
67
  - !ruby/object:Gem::Version
83
- version: '0.1'
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 0.1.2
68
+ version: '3.0'
87
69
  - !ruby/object:Gem::Dependency
88
- name: dry-initializer
70
+ name: zeitwerk
89
71
  requirement: !ruby/object:Gem::Requirement
90
72
  requirements:
91
73
  - - "~>"
92
74
  - !ruby/object:Gem::Version
93
- version: '3.0'
75
+ version: '2.6'
94
76
  type: :runtime
95
77
  prerelease: false
96
78
  version_requirements: !ruby/object:Gem::Requirement
97
79
  requirements:
98
80
  - - "~>"
99
81
  - !ruby/object:Gem::Version
100
- version: '3.0'
82
+ version: '2.6'
101
83
  - !ruby/object:Gem::Dependency
102
84
  name: bundler
103
85
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +133,7 @@ files:
151
133
  - LICENSE
152
134
  - README.md
153
135
  - dry-effects.gemspec
136
+ - lib/dry-effects.rb
154
137
  - lib/dry/effects.rb
155
138
  - lib/dry/effects/all.rb
156
139
  - lib/dry/effects/constructors.rb
@@ -186,6 +169,7 @@ files:
186
169
  - lib/dry/effects/inflector.rb
187
170
  - lib/dry/effects/initializer.rb
188
171
  - lib/dry/effects/instruction.rb
172
+ - lib/dry/effects/instructions.rb
189
173
  - lib/dry/effects/instructions/execute.rb
190
174
  - lib/dry/effects/instructions/raise.rb
191
175
  - lib/dry/effects/provider.rb