dry-monads 1.8.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/lib/dry/monads/do/all.rb +1 -1
- data/lib/dry/monads/extensions/pretty_print.rb +101 -0
- data/lib/dry/monads/extensions/rspec.rb +2 -2
- data/lib/dry/monads/extensions.rb +4 -0
- data/lib/dry/monads/version.rb +1 -1
- data/lib/dry/monads.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d622cbb5031bf37a7fa463737b02249525b347f8bf775586607dd8bf7229c1c3
|
4
|
+
data.tar.gz: da9d5de9434d5eebc18f83d501f718b348889bfa92cc0b5a991ab68c0223684e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e90960ceb2c111c424578e61daa1f0cde79bd52869e7545915e9d4d6208407820b3609f258da5dcf8be473ed8534056245d37a7d349de0934cec724077c3f54
|
7
|
+
data.tar.gz: 6653a465bca76cd3606a8135f03f6208062f73df42ff51164847ea15f5ed2e9a5afb9cd00665650d9b928163800d997947cc3c5ee5556f11759a229e373e573f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 1.9.0 2025-06-24
|
4
|
+
|
5
|
+
|
6
|
+
### Added
|
7
|
+
|
8
|
+
- Add `pretty_print` extension for improved output (@paul + @flash-gordon in #189 and #190)
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Fix nested modules not being extended in RSpec (@flash-gordon)
|
13
|
+
|
14
|
+
|
15
|
+
[Compare v1.8.3...v1.9.0](https://github.com/dry-rb/dry-monads/compare/v1.8.3...v1.9.0)
|
16
|
+
|
17
|
+
## 1.8.3 2025-04-04
|
18
|
+
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Fix signature of warning filter (@flash-gordon, issue #187)
|
23
|
+
|
24
|
+
|
25
|
+
[Compare v1.8.2...v1.8.3](https://github.com/dry-rb/dry-monads/compare/v1.8.2...v1.8.3)
|
26
|
+
|
3
27
|
## 1.8.2 2025-03-15
|
4
28
|
|
5
29
|
|
data/lib/dry/monads/do/all.rb
CHANGED
@@ -156,7 +156,7 @@ module Dry
|
|
156
156
|
|
157
157
|
if ::Gem::Version.new(::RUBY_VERSION) >= ::Gem::Version.new("3.4.0")
|
158
158
|
::Warning.singleton_class.prepend(::Module.new {
|
159
|
-
def warn(message, category: nil)
|
159
|
+
def warn(message, category: nil, **)
|
160
160
|
if message.include?("lib/dry/monads/do.rb") &&
|
161
161
|
message.include?("warning: the block passed to")
|
162
162
|
nil
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dry
|
4
|
+
module Monads
|
5
|
+
module Extensions
|
6
|
+
module PrettyPrint
|
7
|
+
class PrintValue < ::Module
|
8
|
+
def initialize(constructor, accessor: :value!)
|
9
|
+
super()
|
10
|
+
|
11
|
+
define_method(:pretty_print) do |pp|
|
12
|
+
value = public_send(accessor)
|
13
|
+
|
14
|
+
pp.text "#{constructor}("
|
15
|
+
|
16
|
+
unless Unit.equal?(value)
|
17
|
+
pp.group(1) do
|
18
|
+
pp.breakable("")
|
19
|
+
pp.pp(value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
pp.text ")"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class LazyPrintValue < ::Module
|
28
|
+
def initialize(constructor, success_prefix: "value=", error_prefix: "error=")
|
29
|
+
super()
|
30
|
+
|
31
|
+
define_method(:pretty_print) do |pp|
|
32
|
+
if promise.fulfilled?
|
33
|
+
value = promise.value
|
34
|
+
if Unit.equal?(value)
|
35
|
+
if success_prefix.empty?
|
36
|
+
pp.text "#{constructor}()"
|
37
|
+
else
|
38
|
+
pp.text "#{constructor}(#{success_prefix}())"
|
39
|
+
end
|
40
|
+
else
|
41
|
+
pp.text "#{constructor}(#{success_prefix}"
|
42
|
+
pp.group(1) do
|
43
|
+
pp.breakable("")
|
44
|
+
pp.pp(value)
|
45
|
+
end
|
46
|
+
pp.text ")"
|
47
|
+
end
|
48
|
+
elsif promise.rejected?
|
49
|
+
pp.text "#{constructor}(#{error_prefix}#{promise.reason.inspect})"
|
50
|
+
else
|
51
|
+
pp.text "#{constructor}(?)"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Monads.loader.on_load("Dry::Monads::Maybe") do
|
59
|
+
Maybe::Some.include(PrettyPrint::PrintValue.new("Some"))
|
60
|
+
Maybe::None.include(::Module.new {
|
61
|
+
def pretty_print(pp)
|
62
|
+
pp.text "None"
|
63
|
+
end
|
64
|
+
})
|
65
|
+
end
|
66
|
+
|
67
|
+
Monads.loader.on_load("Dry::Monads::Result") do
|
68
|
+
Result::Success.include(PrettyPrint::PrintValue.new("Success"))
|
69
|
+
Result::Failure.include(PrettyPrint::PrintValue.new("Failure", accessor: :failure))
|
70
|
+
end
|
71
|
+
|
72
|
+
Monads.loader.on_load("Dry::Monads::Try") do
|
73
|
+
Try::Value.include(PrettyPrint::PrintValue.new("Value"))
|
74
|
+
Try::Error.include(PrettyPrint::PrintValue.new("Error", accessor: :exception))
|
75
|
+
end
|
76
|
+
|
77
|
+
Monads.loader.on_load("Dry::Monads::List") do
|
78
|
+
List.include(PrettyPrint::PrintValue.new("List", accessor: :value))
|
79
|
+
end
|
80
|
+
|
81
|
+
Monads.loader.on_load("Dry::Monads::Validated") do
|
82
|
+
Validated::Valid.include(PrettyPrint::PrintValue.new("Valid"))
|
83
|
+
Validated::Invalid.include(PrettyPrint::PrintValue.new("Invalid", accessor: :error))
|
84
|
+
end
|
85
|
+
|
86
|
+
Monads.loader.on_load("Dry::Monads::Task") do
|
87
|
+
Task.include(PrettyPrint::LazyPrintValue.new("Task"))
|
88
|
+
end
|
89
|
+
|
90
|
+
Monads.loader.on_load("Dry::Monads::Lazy") do
|
91
|
+
Lazy.include(
|
92
|
+
PrettyPrint::LazyPrintValue.new(
|
93
|
+
"Lazy",
|
94
|
+
success_prefix: "",
|
95
|
+
error_prefix: "error="
|
96
|
+
)
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -195,8 +195,8 @@ catch_missing_const = Module.new do
|
|
195
195
|
|
196
196
|
define_method(:include) do |*modules|
|
197
197
|
super(*modules).tap do
|
198
|
-
modules.each do |
|
199
|
-
|
198
|
+
modules.flat_map(&:ancestors).uniq.each do |c|
|
199
|
+
c.extend(catch_missing_const) unless c.frozen?
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
data/lib/dry/monads/version.rb
CHANGED
data/lib/dry/monads.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-monads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.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: 2025-
|
11
|
+
date: 2025-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/dry/monads/do/mixin.rb
|
75
75
|
- lib/dry/monads/errors.rb
|
76
76
|
- lib/dry/monads/extensions.rb
|
77
|
+
- lib/dry/monads/extensions/pretty_print.rb
|
77
78
|
- lib/dry/monads/extensions/rspec.rb
|
78
79
|
- lib/dry/monads/extensions/super_diff.rb
|
79
80
|
- lib/dry/monads/lazy.rb
|