dry-monads 1.8.3 → 1.10.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fde1d69a13c813c949f00f87b32998f78cd44a28a628f0485b008b99dac51a1
4
- data.tar.gz: ff2b3e91a18fce8a3688d47078111a825d2ad6fd88f5307f4dd9d4c6f4c69df8
3
+ metadata.gz: 527c622566bcbf2acd219b357314a4b6388f49ef9f4dcfd775298de921629c7b
4
+ data.tar.gz: 3dc196066bd360620f39a550575a52b4d112849e09484ad76eb565002611950c
5
5
  SHA512:
6
- metadata.gz: 0c973b98c0133522d770a876f8f3d9eb64668c0c2182d30ffcbaf4cf1253a6c861233d54d38fa2dbb0cb7c68485d8741e82d7b1dbae0f47d993b6e1868b05d9d
7
- data.tar.gz: a644b428c0bbff998a542ab984875fed0d0ce590effb89d03d600606ae2f86a28c311321e2232bfd513c29ab5b0c0f48cddfb5dd771aa58b562fec77bc8ab7c6
6
+ metadata.gz: 5dc4be9b41c1f2349b8078831d0d8980e89095da3b09cbf0084d392ce0966fcf4575d4ffa811deecf894eeb4c16cea1d09d97ebd2ef6458c6e18864f0adc42b6
7
+ data.tar.gz: 587c40965ce23128508b1978d2e5e2d55aff7d3780f777d6a45fbff58d19165809d8a143871269b6092ef475b4b769fcfa262414693bd9b716435ec45c4b0915
data/CHANGELOG.md CHANGED
@@ -1,37 +1,75 @@
1
- <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
1
+ # Changelog
2
2
 
3
- ## 1.8.3 2025-04-04
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ ### Changed
13
+
14
+ ### Deprecated
15
+
16
+ ### Removed
5
17
 
6
18
  ### Fixed
7
19
 
8
- - Fix signature of warning filter (@flash-gordon, issue #187)
20
+ ### Security
9
21
 
22
+ [Unreleased]: https://github.com/dry-rb/dry-monads/compare/v1.10.0...main
10
23
 
11
- [Compare v1.8.2...v1.8.3](https://github.com/dry-rb/dry-monads/compare/v1.8.2...v1.8.3)
24
+ ## [1.10.0] - 2026-04-24
12
25
 
13
- ## 1.8.2 2025-03-15
26
+ ### Added
14
27
 
28
+ - Support for JRuby (via fixes to RSpec extension). (@katafrakt in #200 & #201, @flash-gordon in c6967b6)
15
29
 
16
30
  ### Fixed
17
31
 
18
- - Fix be_* matchers for non-monadic values (@flash-gordon, issue #186)
32
+ - Fix param names and Ruby syntax in API doc examples. (@mensfeld in #196)
19
33
 
34
+ [1.10.0]: https://github.com/dry-rb/dry-monads/compare/v1.9.0...v1.10.0
20
35
 
21
- [Compare v1.8.1...v1.8.2](https://github.com/dry-rb/dry-monads/compare/v1.8.1...v1.8.2)
36
+ ## [1.9.0] - 2025-06-24
22
37
 
23
- ## 1.8.1 2025-03-12
38
+ ### Added
24
39
 
40
+ - Add `pretty_print` extension for improved output (@paul + @flash-gordon in #189 and #190)
25
41
 
26
42
  ### Fixed
27
43
 
28
- - Exclude extensions from the Zeitwerk loader (@flash-gordon, issue #185)
44
+ - Fix nested modules not being extended in RSpec (@flash-gordon)
29
45
 
46
+ [1.9.0]: https://github.com/dry-rb/dry-monads/compare/v1.8.3...v1.9.0
30
47
 
31
- [Compare v1.8.0...v1.8.1](https://github.com/dry-rb/dry-monads/compare/v1.8.0...v1.8.1)
48
+ ## [1.8.3] - 2025-04-04
32
49
 
33
- ## 1.8.0 2025-03-12
50
+ ### Fixed
34
51
 
52
+ - Fix signature of warning filter (@flash-gordon, issue #187)
53
+
54
+ [1.8.3]: https://github.com/dry-rb/dry-monads/compare/v1.8.2...v1.8.3
55
+
56
+ ## [1.8.2] - 2025-03-15
57
+
58
+ ### Fixed
59
+
60
+ - Fix be_* matchers for non-monadic values (@flash-gordon, issue #186)
61
+
62
+ [1.8.2]: https://github.com/dry-rb/dry-monads/compare/v1.8.1...v1.8.2
63
+
64
+ ## [1.8.1] - 2025-03-12
65
+
66
+ ### Fixed
67
+
68
+ - Exclude extensions from the Zeitwerk loader (@flash-gordon, issue #185)
69
+
70
+ [1.8.1]: https://github.com/dry-rb/dry-monads/compare/v1.8.0...v1.8.1
71
+
72
+ ## [1.8.0] - 2025-03-12
35
73
 
36
74
  ### Added
37
75
 
@@ -127,21 +165,17 @@
127
165
  )
128
166
  ```
129
167
 
168
+ [1.8.0]: https://github.com/dry-rb/dry-monads/compare/v1.7.1...v1.8.0
130
169
 
131
- [Compare v1.7.1...v1.8.0](https://github.com/dry-rb/dry-monads/compare/v1.7.1...v1.8.0)
132
-
133
- ## 1.7.1 2025-01-21
134
-
170
+ ## [1.7.1] - 2025-01-21
135
171
 
136
172
  ### Fixed
137
173
 
138
174
  - Fix warnings about unused block arguments (@flash-gordon)
139
175
 
176
+ [1.7.1]: https://github.com/dry-rb/dry-monads/compare/v1.7.0...v1.7.1
140
177
 
141
- [Compare v1.7.0...v1.7.1](https://github.com/dry-rb/dry-monads/compare/v1.7.0...v1.7.1)
142
-
143
- ## 1.7.0 2025-01-07
144
-
178
+ ## [1.7.0] - 2025-01-07
145
179
 
146
180
  ### Fixed
147
181
 
@@ -151,19 +185,17 @@
151
185
 
152
186
  - Set 3.1 as minimum Ruby version (@flash-gordon)
153
187
 
154
- [Compare v1.6.0...v1.7.0](https://github.com/dry-rb/dry-monads/compare/v1.6.0...v1.7.0)
155
-
156
- ## 1.6.0 2022-11-04
188
+ [1.7.0]: https://github.com/dry-rb/dry-monads/compare/v1.6.0...v1.7.0
157
189
 
190
+ ## [1.6.0] - 2022-11-04
158
191
 
159
192
  ### Changed
160
193
 
161
194
  - This version uses dry-core 1.0 (@flash-gordon)
162
195
 
163
- [Compare v1.5.0...v1.6.0](https://github.com/dry-rb/dry-monads/compare/v1.5.0...v1.6.0)
164
-
165
- ## 1.5.0 2022-10-16
196
+ [1.6.0]: https://github.com/dry-rb/dry-monads/compare/v1.5.0...v1.6.0
166
197
 
198
+ ## [1.5.0] - 2022-10-16
167
199
 
168
200
  ### Changed
169
201
 
@@ -172,10 +204,9 @@
172
204
  - Minimal Ruby version is now 2.7 (@flash-gordon)
173
205
  - Either (old name of Result) was removed (@flash-gordon)
174
206
 
175
- [Compare v1.4.0...v1.5.0](https://github.com/dry-rb/dry-monads/compare/v1.4.0...v1.5.0)
176
-
177
- ## 1.4.0 2021-07-20
207
+ [1.5.0]: https://github.com/dry-rb/dry-monads/compare/v1.4.0...v1.5.0
178
208
 
209
+ ## [1.4.0] - 2021-07-20
179
210
 
180
211
  ### Added
181
212
 
@@ -224,40 +255,33 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
224
255
  ```
225
256
  - Minimal Ruby version is 2.6
226
257
 
227
- [Compare v1.3.5...v1.4.0](https://github.com/dry-rb/dry-monads/compare/v1.3.5...v1.4.0)
228
-
229
- ## 1.3.5 2020-01-06
258
+ [1.4.0]: https://github.com/dry-rb/dry-monads/compare/v1.3.5...v1.4.0
230
259
 
260
+ ## [1.3.5] - 2020-01-06
231
261
 
232
262
  ### Added
233
263
 
234
264
  - Smarter keys deconstruction in pattern matching (flash-gordon)
235
265
 
266
+ [1.3.5]: https://github.com/dry-rb/dry-monads/compare/v1.3.4...v1.3.5
236
267
 
237
- [Compare v1.3.4...v1.3.5](https://github.com/dry-rb/dry-monads/compare/v1.3.4...v1.3.5)
238
-
239
- ## 1.3.4 2019-12-28
240
-
268
+ ## [1.3.4] - 2019-12-28
241
269
 
242
270
  ### Fixed
243
271
 
244
272
  - One more delegation warning happenning in do notation (flash-gordon)
245
273
 
274
+ [1.3.4]: https://github.com/dry-rb/dry-monads/compare/v1.3.3...v1.3.4
246
275
 
247
- [Compare v1.3.3...v1.3.4](https://github.com/dry-rb/dry-monads/compare/v1.3.3...v1.3.4)
248
-
249
- ## 1.3.3 2019-12-11
250
-
276
+ ## [1.3.3] - 2019-12-11
251
277
 
252
278
  ### Fixed
253
279
 
254
280
  - Incompatibility with Rails. Internal (!) halt exceptions now use mutable backtraces because spring [mutates](https://github.com/rails/spring/blob/ee687859008e947bc905b95121e306e2948d31c9/lib/spring/application.rb#L295-L311) (!) them. For the record, this a bug in Rails (johnmaxwell)
255
281
 
282
+ [1.3.3]: https://github.com/dry-rb/dry-monads/compare/v1.3.2...v1.3.3
256
283
 
257
- [Compare v1.3.2...v1.3.3](https://github.com/dry-rb/dry-monads/compare/v1.3.2...v1.3.3)
258
-
259
- ## 1.3.2 2019-11-30
260
-
284
+ ## [1.3.2] - 2019-11-30
261
285
 
262
286
  ### Added
263
287
 
@@ -274,21 +298,17 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
274
298
 
275
299
  - Warnings about keywords from Ruby 2.7 (flash-gordon)
276
300
 
301
+ [1.3.2]: https://github.com/dry-rb/dry-monads/compare/v1.3.1...v1.3.2
277
302
 
278
- [Compare v1.3.1...v1.3.2](https://github.com/dry-rb/dry-monads/compare/v1.3.1...v1.3.2)
279
-
280
- ## 1.3.1 2019-09-07
281
-
303
+ ## [1.3.1] - 2019-09-07
282
304
 
283
305
  ### Fixed
284
306
 
285
307
  - Added missing `None#maybe` :sweat_smile: (flash-gordon)
286
308
 
309
+ [1.3.1]: https://github.com/dry-rb/dry-monads/compare/v1.3.0...v1.3.1
287
310
 
288
- [Compare v1.3.0...v1.3.1](https://github.com/dry-rb/dry-monads/compare/v1.3.0...v1.3.1)
289
-
290
- ## 1.3.0 2019-08-03
291
-
311
+ ## [1.3.0] - 2019-08-03
292
312
 
293
313
  ### Added
294
314
 
@@ -371,11 +391,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
371
391
 
372
392
  Keep in mind this feature is experimental and can be changed by 2.7 release. But it rocks already!
373
393
 
394
+ [1.3.0]: https://github.com/dry-rb/dry-monads/compare/v1.2.0...v1.3.0
374
395
 
375
- [Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-monads/compare/v1.2.0...v1.3.0)
376
-
377
- ## 1.2.0 2019-01-12
378
-
396
+ ## [1.2.0] - 2019-01-12
379
397
 
380
398
  ### Added
381
399
 
@@ -463,11 +481,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
463
481
  ```
464
482
  - `Task.failed` is a counterpart of `Task.pure`, accepts an exception and returns a failed task immediately (flash-gordon)
465
483
 
484
+ [1.2.0]: https://github.com/dry-rb/dry-monads/compare/v1.1.0...v1.2.0
466
485
 
467
- [Compare v1.1.0...v1.2.0](https://github.com/dry-rb/dry-monads/compare/v1.1.0...v1.2.0)
468
-
469
- ## 1.1.0 2018-10-16
470
-
486
+ ## [1.1.0] - 2018-10-16
471
487
 
472
488
  ### Added
473
489
 
@@ -489,11 +505,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
489
505
 
490
506
  - Do notation was made to work nicely with inheritance. This shouldn't break any existing code but if it does please report (flash-gordon)
491
507
 
508
+ [1.1.0]: https://github.com/dry-rb/dry-monads/compare/v1.0.1...v1.1.0
492
509
 
493
- [Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-monads/compare/v1.0.1...v1.1.0)
494
-
495
- ## 1.0.1 2018-08-11
496
-
510
+ ## [1.0.1] - 2018-08-11
497
511
 
498
512
  ### Added
499
513
 
@@ -506,11 +520,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
506
520
 
507
521
  - Fixed behavior of `List<Validated>#traverse` in presence of `Valid` values (flash-gordon + SunnyMagadan)
508
522
 
523
+ [1.0.1]: https://github.com/dry-rb/dry-monads/compare/v1.0.0...v1.0.1
509
524
 
510
- [Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-monads/compare/v1.0.0...v1.0.1)
511
-
512
- ## 1.0.0 2018-06-26
513
-
525
+ ## [1.0.0] - 2018-06-26
514
526
 
515
527
  ### Added
516
528
 
@@ -648,11 +660,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
648
660
  - `Either#value` and `Maybe#value` were both droped, use `value_or` or `value!` when you :100: sure it's safe
649
661
  - `require 'dry/monads'` doesn't load all monads anymore, use `require 'dry/monads/all'` instead or cherry pick them with `require 'dry/monads/maybe'` etc (timriley)
650
662
 
663
+ [1.0.0]: https://github.com/dry-rb/dry-monads/compare/v0.4.0...v1.0.0
651
664
 
652
- [Compare v0.4.0...v1.0.0](https://github.com/dry-rb/dry-monads/compare/v0.4.0...v1.0.0)
653
-
654
- ## 0.4.0 2017-11-11
655
-
665
+ ## [0.4.0] - 2017-11-11
656
666
 
657
667
  ### Added
658
668
 
@@ -677,20 +687,17 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
677
687
  - The `Either` monad was renamed to `Result` which sounds less nerdy but better reflects the purpose of the type. `Either::Right` became `Result::Success` and `Either::Left` became `Result::Failure`. This change is backward-compatible overall but you will see the new names when using old `Left` and `Right` methods (citizen428)
678
688
  - Consequently, `Try::Success` and `Try::Failure` were renamed to `Try::Value` and `Try::Error` (flash-gordon)
679
689
 
680
- [Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-monads/compare/v0.3.1...v0.4.0)
681
-
682
- ## 0.3.1 2017-03-18
690
+ [0.4.0]: https://github.com/dry-rb/dry-monads/compare/v0.3.1...v0.4.0
683
691
 
692
+ ## [0.3.1] - 2017-03-18
684
693
 
685
694
  ### Fixed
686
695
 
687
696
  - Fixed unexpected coercing to `Hash` on `.bind` call (flash-gordon)
688
697
 
698
+ [0.3.1]: https://github.com/dry-rb/dry-monads/compare/v0.3.0...v0.3.1
689
699
 
690
- [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-monads/compare/v0.3.0...v0.3.1)
691
-
692
- ## 0.3.0 2017-03-16
693
-
700
+ ## [0.3.0] - 2017-03-16
694
701
 
695
702
  ### Added
696
703
 
@@ -702,11 +709,9 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
702
709
  - Added `List#traverse` that "flips" the list with an embedded monad (flash-gordon + damncabbage)
703
710
  - Added `#tee` for all right-biased monads (flash-gordon)
704
711
 
712
+ [0.3.0]: https://github.com/dry-rb/dry-monads/compare/v0.2.1...v0.3.0
705
713
 
706
- [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-monads/compare/v0.2.1...v0.3.0)
707
-
708
- ## 0.2.1 2016-11-13
709
-
714
+ ## [0.2.1] - 2016-11-13
710
715
 
711
716
  ### Added
712
717
 
@@ -717,32 +722,26 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
717
722
  - `Right(nil).to_maybe` now returns `None` with a warning instead of failing (orisaka)
718
723
  - `Some#value_or` doesn't require an argument because `None#value_or` doesn't require it either if a block was passed (flash-gordon)
719
724
 
725
+ [0.2.1]: https://github.com/dry-rb/dry-monads/compare/v0.2.0...v0.2.1
720
726
 
721
- [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-monads/compare/v0.2.0...v0.2.1)
722
-
723
- ## 0.2.0 2016-09-18
724
-
727
+ ## [0.2.0] - 2016-09-18
725
728
 
726
729
  ### Added
727
730
 
728
731
  - Added `Maybe#to_json` as an opt-in extension for serialization to JSON (rocknruby)
729
732
  - Added `Maybe#value_or` which returns you the underlying value with a fallback in a single method call (dsounded)
730
733
 
734
+ [0.2.0]: https://github.com/dry-rb/dry-monads/compare/v0.1.1...v0.2.0
731
735
 
732
- [Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-monads/compare/v0.1.1...v0.2.0)
733
-
734
- ## 0.1.1 2016-08-25
735
-
736
+ ## [0.1.1] - 2016-08-25
736
737
 
737
738
  ### Fixed
738
739
 
739
740
  - Added explicit requires of `dry-equalizer`. This allows to safely load only specific monads (artofhuman)
740
741
 
742
+ [0.1.1]: https://github.com/dry-rb/dry-monads/compare/v0.1.0...v0.1.1
741
743
 
742
- [Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-monads/compare/v0.1.0...v0.1.1)
743
-
744
- ## 0.1.0 2016-08-23
745
-
744
+ ## [0.1.0] - 2016-08-23
746
745
 
747
746
  ### Added
748
747
 
@@ -752,19 +751,17 @@ This behavior will be dropped in 2.0 but you can opt out of warnings for the tim
752
751
 
753
752
  - Dropped MRI 2.0 support (flash-gordon)
754
753
 
755
- [Compare v0.0.2...v0.1.0](https://github.com/dry-rb/dry-monads/compare/v0.0.2...v0.1.0)
756
-
757
- ## 0.0.2 2016-06-29
754
+ [0.1.0]: https://github.com/dry-rb/dry-monads/compare/v0.0.2...v0.1.0
758
755
 
756
+ ## [0.0.2] - 2016-06-29
759
757
 
760
758
  ### Added
761
759
 
762
760
  - Added `Either#to_either` so that you can rely on duck-typing when you work with different types of monads (timriley)
763
761
  - Added `Maybe#to_maybe` for consistency with `#to_either` (flash-gordon)
764
762
 
763
+ [0.0.2]: https://github.com/dry-rb/dry-monads/compare/v0.0.1...v0.0.2
765
764
 
766
- [Compare v0.0.1...v0.0.2](https://github.com/dry-rb/dry-monads/compare/v0.0.1...v0.0.2)
767
-
768
- ## 0.0.1 2016-05-02
765
+ ## [0.0.1] - 2016-05-02
769
766
 
770
767
  Initial release containing `Either`, `Maybe`, and `Try` monads.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2023 dry-rb team
3
+ Copyright (c) 2015-2026 Hanakai 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/README.md CHANGED
@@ -1,22 +1,22 @@
1
- <!--- this file is synced from dry-rb/template-gem project -->
2
- [gem]: https://rubygems.org/gems/dry-monads
3
- [actions]: https://github.com/dry-rb/dry-monads/actions
4
-
5
- # dry-monads [![Gem Version](https://badge.fury.io/rb/dry-monads.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-monads/workflows/CI/badge.svg)][actions]
1
+ <!--- This file is synced from hanakai-rb/repo-sync -->
6
2
 
7
- ## Links
3
+ [actions]: https://github.com/dry-rb/dry-monads/actions
4
+ [chat]: https://discord.gg/naQApPAsZB
5
+ [forum]: https://discourse.hanamirb.org
6
+ [rubygem]: https://rubygems.org/gems/dry-monads
8
7
 
9
- * [User documentation](https://dry-rb.org/gems/dry-monads)
10
- * [API documentation](http://rubydoc.info/gems/dry-monads)
11
- * [Forum](https://discourse.dry-rb.org)
8
+ # dry-monads [![Gem Version](https://badge.fury.io/rb/dry-monads.svg)][rubygem] [![CI Status](https://github.com/dry-rb/dry-monads/workflows/CI/badge.svg)][actions]
12
9
 
13
- ## Supported Ruby versions
10
+ [![Forum](https://img.shields.io/badge/Forum-dc360f?logo=discourse&logoColor=white)][forum]
11
+ [![Chat](https://img.shields.io/badge/Chat-717cf8?logo=discord&logoColor=white)][chat]
14
12
 
15
- This library officially supports the following Ruby versions:
13
+ ## Links
16
14
 
17
- * MRI `>= 3.1`
18
- * jruby `>= 9.4` (not tested on CI)
15
+ - [User documentation](https://dry-rb.org/gems/dry-monads)
16
+ - [API documentation](http://rubydoc.info/gems/dry-monads)
17
+ - [Forum](https://discourse.dry-rb.org)
19
18
 
20
19
  ## License
21
20
 
22
21
  See `LICENSE` file.
22
+
data/dry-monads.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # this file is synced from dry-rb/template-gem project
3
+ # This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
4
4
 
5
5
  lib = File.expand_path("lib", __dir__)
6
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -8,8 +8,8 @@ require "dry/monads/version"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = "dry-monads"
11
- spec.authors = ["Nikita Shilnikov"]
12
- spec.email = ["fg@flashgordon.ru"]
11
+ spec.authors = ["Hanakai team"]
12
+ spec.email = ["info@hanakai.org"]
13
13
  spec.license = "MIT"
14
14
  spec.version = Dry::Monads::VERSION.dup
15
15
 
@@ -17,20 +17,25 @@ Gem::Specification.new do |spec|
17
17
  spec.description = spec.summary
18
18
  spec.homepage = "https://dry-rb.org/gems/dry-monads"
19
19
  spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-monads.gemspec", "lib/**/*"]
20
- spec.bindir = "bin"
21
- spec.executables = []
20
+ spec.bindir = "exe"
21
+ spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
- spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-monads/blob/main/CHANGELOG.md"
26
- spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-monads"
27
- spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-monads/issues"
28
- spec.metadata["rubygems_mfa_required"] = "true"
24
+ spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
25
+
26
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-monads/blob/main/CHANGELOG.md"
27
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-monads"
28
+ spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-monads/issues"
29
+ spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
29
30
 
30
31
  spec.required_ruby_version = ">= 3.1.0"
31
32
 
32
- # to update dependencies edit project.yml
33
- spec.add_dependency "concurrent-ruby", "~> 1.0"
34
- spec.add_dependency "dry-core", "~> 1.1"
35
- spec.add_dependency "zeitwerk", "~> 2.6"
33
+ spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
34
+ spec.add_runtime_dependency "dry-core", "~> 1.1"
35
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
36
+ spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "debug_inspector"
38
+ spec.add_development_dependency "rake"
39
+ spec.add_development_dependency "rspec"
36
40
  end
41
+
@@ -38,8 +38,8 @@ module Dry
38
38
  # @api public
39
39
  def call
40
40
  yield
41
- rescue Halt => e
42
- e.result
41
+ rescue Halt => exception
42
+ exception.result
43
43
  end
44
44
 
45
45
  # @api public
data/lib/dry/monads/do.rb CHANGED
@@ -59,7 +59,7 @@ module Dry
59
59
  #
60
60
  # attr_reader :user_repo
61
61
  #
62
- # def initialize(:user_repo)
62
+ # def initialize(user_repo)
63
63
  # @user_repo = user_repo
64
64
  # end
65
65
  #
@@ -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
@@ -44,13 +44,14 @@ module Dry
44
44
  }.freeze
45
45
 
46
46
  PREDICATES.each do |name, args|
47
- args => { expected_classes:, extract_value: }
47
+ args => {expected_classes:, extract_value:}
48
48
  expected_constructors = expected_classes.map(&:name).map do |c|
49
49
  c.split("::").last
50
50
  end
51
51
 
52
- matcher :"be_#{name}" do |expected = Undefined|
52
+ matcher :"be_#{name}" do |*expected_args|
53
53
  predicate = "#{name}?"
54
+ expected = expected_args.fetch(0, Undefined)
54
55
 
55
56
  match do |actual|
56
57
  if expected_classes.any? { |klass| actual.is_a?(klass) }
@@ -159,6 +160,37 @@ module Dry
159
160
  ::Dry::Monads::List
160
161
  end
161
162
  end
163
+
164
+ def rspec_example_context?(location)
165
+ example_group_instance = ::RSpec.current_example&.example_group_instance
166
+ return false unless example_group_instance
167
+
168
+ spec_example_block?(location) || example_group_method?(example_group_instance, location)
169
+ end
170
+
171
+ private
172
+
173
+ def spec_example_block?(location)
174
+ location.path.end_with?("_spec.rb") && location.label.include?("block")
175
+ end
176
+
177
+ def example_group_method?(example_group_instance, location)
178
+ method_name = caller_method_name(location)
179
+ return false unless method_name
180
+
181
+ owner = example_group_instance.method(method_name).owner
182
+
183
+ ![::BasicObject, ::Kernel, ::Object].include?(owner)
184
+ rescue NameError
185
+ false
186
+ end
187
+
188
+ def caller_method_name(location)
189
+ label = location.label.to_s
190
+ return nil if label.include?("block")
191
+
192
+ label.split(/[.#]/).last&.to_sym
193
+ end
162
194
  end
163
195
  end
164
196
  end
@@ -185,7 +217,7 @@ catch_missing_const = Module.new do
185
217
  def const_missing(name)
186
218
  const_name = Dry::Monads::RSpec.resolve_constant_name(name)
187
219
 
188
- if const_name && caller_locations(1, 1).first.path.end_with?("_spec.rb")
220
+ if const_name && Dry::Monads::RSpec.rspec_example_context?(caller_locations(1, 1).first)
189
221
  Dry::Monads::RSpec.name_to_const(const_name)
190
222
  else
191
223
  super
@@ -195,8 +227,8 @@ catch_missing_const = Module.new do
195
227
 
196
228
  define_method(:include) do |*modules|
197
229
  super(*modules).tap do
198
- modules.each do |m|
199
- m.extend(catch_missing_const) unless m.frozen?
230
+ modules.flat_map(&:ancestors).uniq.each do |c|
231
+ c.extend(catch_missing_const) unless c.frozen?
200
232
  end
201
233
  end
202
234
  end
@@ -9,3 +9,7 @@ end
9
9
  Dry::Monads.register_extension(:super_diff) do
10
10
  require "dry/monads/extensions/super_diff"
11
11
  end
12
+
13
+ Dry::Monads.register_extension(:pretty_print) do
14
+ require "dry/monads/extensions/pretty_print"
15
+ end
@@ -331,9 +331,12 @@ module Dry
331
331
  #
332
332
  # @example
333
333
  # case List[1, 2, 3]
334
- # in List[1, 2, x] then ...
335
- # in List[Integer, _, _] then ...
336
- # in List[0..2, _, _] then ...
334
+ # in List[1, 2, x]
335
+ # x
336
+ # in List[Integer, _, _]
337
+ # # ...
338
+ # in List[0..2, _, _]
339
+ # # ...
337
340
  # end
338
341
  #
339
342
  # @api private
@@ -250,9 +250,12 @@ module Dry
250
250
  #
251
251
  # @example
252
252
  # case Some(:foo)
253
- # in Some(Integer) then ...
254
- # in Some(:bar) then ...
255
- # in None() then ...
253
+ # in Some(Integer)
254
+ # # ...
255
+ # in Some(:bar)
256
+ # # ...
257
+ # in None()
258
+ # # ...
256
259
  # end
257
260
  #
258
261
  # @api private
@@ -368,7 +368,7 @@ module Dry
368
368
  class Some < Maybe
369
369
  # Converts to Sucess(value!)
370
370
  #
371
- # @param fail [#call] Fallback value
371
+ # @param _fail [#call] Fallback value
372
372
  # @param block [Proc] Fallback block
373
373
  # @return [Success<Any>]
374
374
  def to_result(_fail = Unit, &) = Result::Success.new(@value)
@@ -176,9 +176,12 @@ module Dry
176
176
  #
177
177
  # @example
178
178
  # case Success(x)
179
- # in Success(Integer) then ...
180
- # in Success(2..100) then ...
181
- # in Success(2..200 => code) then ...
179
+ # in Success(Integer)
180
+ # # ...
181
+ # in Success(2..100)
182
+ # # ...
183
+ # in Success(2..200 => code)
184
+ # # ...
182
185
  # end
183
186
  #
184
187
  # @api private
@@ -322,10 +325,14 @@ module Dry
322
325
  #
323
326
  # @example
324
327
  # case Success(x)
325
- # in Success(Integer) then ...
326
- # in Success(2..100) then ...
327
- # in Success(2..200 => code) then ...
328
- # in Failure(_) then ...
328
+ # in Success(Integer)
329
+ # # ...
330
+ # in Success(2..100)
331
+ # # ...
332
+ # in Success(2..200 => code)
333
+ # # ...
334
+ # in Failure(_)
335
+ # # ...
329
336
  # end
330
337
  #
331
338
  # @api private
@@ -140,7 +140,7 @@ module Dry
140
140
  end
141
141
  alias_method :inspect, :to_s
142
142
 
143
- # Tranforms the error if the computation wasn't successful.
143
+ # Transforms the error if the computation wasn't successful.
144
144
  #
145
145
  # @param block [Proc]
146
146
  # @return [Task]
@@ -161,8 +161,8 @@ module Dry
161
161
  inner.execute
162
162
  inner.on_success { child.on_fulfill(_1) }
163
163
  inner.on_error { child.on_reject(_1) }
164
- rescue StandardError => e
165
- child.on_reject(e)
164
+ rescue StandardError => exception
165
+ child.on_reject(exception)
166
166
  end
167
167
  promise.on_success { child.on_fulfill(_1) }
168
168
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Dry
4
4
  module Monads
5
- # Advanced tranformations.
5
+ # Advanced transformations.
6
6
  module Transformer
7
7
  # Lifts a block/proc over the 2-level nested structure.
8
8
  # This is essentially fmap . fmap (. is the function composition
@@ -27,8 +27,8 @@ module Dry
27
27
  # @return [Try::Value, Try::Error]
28
28
  def run(exceptions, f)
29
29
  Value.new(exceptions, f.call)
30
- rescue *exceptions => e
31
- Error.new(e)
30
+ rescue *exceptions => exception
31
+ Error.new(exception)
32
32
  end
33
33
  deprecate :lift, :run
34
34
 
@@ -125,8 +125,8 @@ module Dry
125
125
  # @return [Object, Try::Error]
126
126
  def bind(...)
127
127
  super
128
- rescue *catchable => e
129
- Error.new(e)
128
+ rescue *catchable => exception
129
+ Error.new(exception)
130
130
  end
131
131
 
132
132
  # Does the same thing as #bind except it also wraps the value
@@ -143,8 +143,8 @@ module Dry
143
143
  # @return [Try::Value, Try::Error]
144
144
  def fmap(...)
145
145
  Value.new(catchable, bind_call(...))
146
- rescue *catchable => e
147
- Error.new(e)
146
+ rescue *catchable => exception
147
+ Error.new(exception)
148
148
  end
149
149
 
150
150
  # @return [String]
@@ -159,7 +159,7 @@ module Dry
159
159
 
160
160
  # Ignores values and returns self, see {Try::Error#recover}
161
161
  #
162
- # @param errors [Class] List of Exception subclasses
162
+ # @param _errors [Class] List of Exception subclasses
163
163
  #
164
164
  # @return [Try::Value]
165
165
  def recover(*_errors, &) = self
@@ -16,7 +16,7 @@ module Dry
16
16
  #
17
17
  # @example with Maybe
18
18
  # Maybe(Unit)
19
- # => Some(Unit)
19
+ # Some(Unit)
20
20
  #
21
21
  Unit = ::Object.new.tap do |unit|
22
22
  def unit.to_s = "Unit"
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  module Monads
5
5
  # Gem version
6
- VERSION = "1.8.3"
6
+ VERSION = "1.10.0"
7
7
  end
8
8
  end
data/lib/dry/monads.rb CHANGED
@@ -80,3 +80,5 @@ module Dry
80
80
  loader.setup
81
81
  end
82
82
  end
83
+
84
+ Dry::Monads.load_extensions(:pretty_print)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-monads
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
- - Nikita Shilnikov
8
- autorequire:
9
- bindir: bin
7
+ - Hanakai team
8
+ bindir: exe
10
9
  cert_chain: []
11
- date: 2025-04-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: concurrent-ruby
@@ -52,12 +51,71 @@ dependencies:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '2.6'
54
+ - !ruby/object:Gem::Dependency
55
+ name: bundler
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: debug_inspector
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rspec
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
55
110
  description: Common monads for Ruby
56
111
  email:
57
- - fg@flashgordon.ru
112
+ - info@hanakai.org
58
113
  executables: []
59
114
  extensions: []
60
- extra_rdoc_files: []
115
+ extra_rdoc_files:
116
+ - CHANGELOG.md
117
+ - LICENSE
118
+ - README.md
61
119
  files:
62
120
  - CHANGELOG.md
63
121
  - LICENSE
@@ -74,6 +132,7 @@ files:
74
132
  - lib/dry/monads/do/mixin.rb
75
133
  - lib/dry/monads/errors.rb
76
134
  - lib/dry/monads/extensions.rb
135
+ - lib/dry/monads/extensions/pretty_print.rb
77
136
  - lib/dry/monads/extensions/rspec.rb
78
137
  - lib/dry/monads/extensions/super_diff.rb
79
138
  - lib/dry/monads/lazy.rb
@@ -95,12 +154,10 @@ homepage: https://dry-rb.org/gems/dry-monads
95
154
  licenses:
96
155
  - MIT
97
156
  metadata:
98
- allowed_push_host: https://rubygems.org
99
157
  changelog_uri: https://github.com/dry-rb/dry-monads/blob/main/CHANGELOG.md
100
158
  source_code_uri: https://github.com/dry-rb/dry-monads
101
159
  bug_tracker_uri: https://github.com/dry-rb/dry-monads/issues
102
- rubygems_mfa_required: 'true'
103
- post_install_message:
160
+ funding_uri: https://github.com/sponsors/hanami
104
161
  rdoc_options: []
105
162
  require_paths:
106
163
  - lib
@@ -115,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
172
  - !ruby/object:Gem::Version
116
173
  version: '0'
117
174
  requirements: []
118
- rubygems_version: 3.3.27
119
- signing_key:
175
+ rubygems_version: 3.6.9
120
176
  specification_version: 4
121
177
  summary: Common monads for Ruby
122
178
  test_files: []