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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 868d82b70df649f4904a718c34d487f5c05da90a0e9d28620765c080cb970020
4
- data.tar.gz: 322edb475ebf673ae7d54b8bae3e6c44a0a0be9b7a2bb80df5d27f474b35d90c
3
+ metadata.gz: 6455e37c318b57b20d89adcb6c5a6f684bca41c109242c8cf794c8233580a4f9
4
+ data.tar.gz: 07f7a32d10145c3780dee62b6a97437274e8f595cb889e0cee01818038665219
5
5
  SHA512:
6
- metadata.gz: 996ea7ae5699568af2096e486edf7df2eaf72c4ca7b2dfd1d40d3c54483fa1c2d97227f1c53947ec674a698a8abd5368e5fb854fc5a998c2ec0cbe231094bec6
7
- data.tar.gz: a93c3d768491556b845fbeb7d00e7424e5b9966b1ed5b940abc627f4b9a873b7184615c4e5f55f55a073fe0e1ece527610e48055a0dac8a5e84156438c96bcae
6
+ metadata.gz: 85336bd3e9e13e0ede2d5f8a4eeacefdc49c1f9428ce084d6921b964ab17683129c9c60a59817c29137a0b25a55d1970fb3d59e49279f3f171a88f9d0d43edf7
7
+ data.tar.gz: 2fb0728d76c26fdc8e84f9947cc6df4fe2bd3b6e102ebc53050c0cbabdcbfc6c0a48c2a7638a8790c3ab54b85ebca1e484b9b7773078244e2e916dad478d1064
@@ -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
@@ -3,11 +3,11 @@
3
3
  module Muina
4
4
  class Maybe
5
5
  class Some < self
6
- def initialize(value)
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(default)
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
- def self.return(value)
6
- Some.__send__(:new, value)
7
- end
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
- def self.none
10
- None.__send__(:new)
13
+ def none
14
+ None.__send__(:new)
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -3,7 +3,7 @@
3
3
  module Muina
4
4
  class Result
5
5
  class Failure < self
6
- def initialize(error)
6
+ def initialize(error) # rubocop:disable Lint/MissingSuper
7
7
  @error = error
8
8
  freeze
9
9
  end
@@ -3,7 +3,7 @@
3
3
  module Muina
4
4
  class Result
5
5
  class Success < self
6
- def initialize(value)
6
+ def initialize(value) # rubocop:disable Lint/MissingSuper
7
7
  @value = value
8
8
  freeze
9
9
  end
data/lib/muina/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Muina
4
- VERSION = '0.4.0'
4
+ VERSION = '0.6.0'
5
5
  public_constant :VERSION
6
6
  end
data/lib/muina.rb CHANGED
@@ -5,6 +5,7 @@ loader = Zeitwerk::Loader.for_gem
5
5
  loader.setup
6
6
 
7
7
  module Muina
8
+ Error = Class.new(StandardError)
8
9
  end
9
10
 
10
11
  loader.eager_load
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.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-03 00:00:00.000000000 Z
11
+ date: 2024-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk