muina 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/muina/maybe/none.rb +8 -6
- data/lib/muina/maybe/some.rb +9 -4
- data/lib/muina/maybe.rb +10 -5
- data/lib/muina/result/failure.rb +1 -1
- data/lib/muina/result/success.rb +1 -1
- data/lib/muina/version.rb +1 -1
- data/lib/muina.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6455e37c318b57b20d89adcb6c5a6f684bca41c109242c8cf794c8233580a4f9
|
4
|
+
data.tar.gz: 07f7a32d10145c3780dee62b6a97437274e8f595cb889e0cee01818038665219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85336bd3e9e13e0ede2d5f8a4eeacefdc49c1f9428ce084d6921b964ab17683129c9c60a59817c29137a0b25a55d1970fb3d59e49279f3f171a88f9d0d43edf7
|
7
|
+
data.tar.gz: 2fb0728d76c26fdc8e84f9947cc6df4fe2bd3b6e102ebc53050c0cbabdcbfc6c0a48c2a7638a8790c3ab54b85ebca1e484b9b7773078244e2e916dad478d1064
|
data/lib/muina/maybe/none.rb
CHANGED
@@ -4,7 +4,7 @@ module Muina
|
|
4
4
|
class Maybe
|
5
5
|
class None < self
|
6
6
|
private_class_method(:new)
|
7
|
-
def initialize
|
7
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
8
8
|
freeze
|
9
9
|
end
|
10
10
|
|
@@ -17,7 +17,7 @@ module Muina
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def value!
|
20
|
-
raise
|
20
|
+
raise UnwrappingError
|
21
21
|
end
|
22
22
|
|
23
23
|
def value_or(default)
|
@@ -28,9 +28,7 @@ module Muina
|
|
28
28
|
yield
|
29
29
|
end
|
30
30
|
|
31
|
-
def value_or_nil
|
32
|
-
nil
|
33
|
-
end
|
31
|
+
def value_or_nil; end
|
34
32
|
|
35
33
|
def and_then
|
36
34
|
self
|
@@ -44,7 +42,7 @@ module Muina
|
|
44
42
|
def map
|
45
43
|
self
|
46
44
|
end
|
47
|
-
|
45
|
+
|
48
46
|
def map_none
|
49
47
|
Maybe.return yield
|
50
48
|
end
|
@@ -56,6 +54,10 @@ module Muina
|
|
56
54
|
def bind_none
|
57
55
|
yield
|
58
56
|
end
|
57
|
+
|
58
|
+
def ==(other)
|
59
|
+
self.class == other.class
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/lib/muina/maybe/some.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module Muina
|
4
4
|
class Maybe
|
5
5
|
class Some < self
|
6
|
-
|
6
|
+
private_class_method(:new)
|
7
|
+
def initialize(value) # rubocop:disable Lint/MissingSuper
|
7
8
|
@value = value
|
8
9
|
freeze
|
9
10
|
end
|
10
|
-
private_class_method(:new)
|
11
11
|
|
12
12
|
def some?
|
13
13
|
true
|
@@ -21,7 +21,7 @@ module Muina
|
|
21
21
|
@value
|
22
22
|
end
|
23
23
|
|
24
|
-
def value_or(
|
24
|
+
def value_or(_default)
|
25
25
|
@value
|
26
26
|
end
|
27
27
|
|
@@ -45,7 +45,7 @@ module Muina
|
|
45
45
|
def map
|
46
46
|
Maybe.return yield(@value)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def map_none
|
50
50
|
self
|
51
51
|
end
|
@@ -57,6 +57,11 @@ module Muina
|
|
57
57
|
def bind_none
|
58
58
|
self
|
59
59
|
end
|
60
|
+
|
61
|
+
def ==(other)
|
62
|
+
self.class == other.class &&
|
63
|
+
value! == other.value!
|
64
|
+
end
|
60
65
|
end
|
61
66
|
end
|
62
67
|
end
|
data/lib/muina/maybe.rb
CHANGED
@@ -2,12 +2,17 @@
|
|
2
2
|
|
3
3
|
module Muina
|
4
4
|
class Maybe
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
UnwrappingError = Class.new(Error)
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def return(value)
|
9
|
+
Some.__send__(:new, value)
|
10
|
+
end
|
11
|
+
alias some return
|
8
12
|
|
9
|
-
|
10
|
-
|
13
|
+
def none
|
14
|
+
None.__send__(:new)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/muina/result/failure.rb
CHANGED
data/lib/muina/result/success.rb
CHANGED
data/lib/muina/version.rb
CHANGED
data/lib/muina.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaporyhumo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|