muina 0.3.0 → 0.5.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: b2b5222927ea1bfd1e6abec8b52f4be5496b472cbb661473ff790a0e3e608b74
4
- data.tar.gz: fc283c096aaea590df228972a7d1c74dfa882274a12ba791de319d294f21e624
3
+ metadata.gz: f7322acdc8c2503f893db20260a561551cd9cc3350d07ccaa7c0a9b929ce7007
4
+ data.tar.gz: 29679c640cc94c29860a9237cf82bcd9fcb3c363481dbe214ccbe5b3ac8e5feb
5
5
  SHA512:
6
- metadata.gz: b6df6e69e9d809a4e4f99685653a01a73c6d2ef851fa034c221bad0970682b55d1f7d500150eb45241453c3fba4b4ec72787c7d30feb9929931461fc5fac6ba7
7
- data.tar.gz: 609cca9f912c9a79d39be44f455ebc0c7e6fe4fc8e267bd4291f7e77d8a1234f1fa85b8680a62fffc1005ddd15620db937996809ef72cf7628d10d3fc8334660
6
+ metadata.gz: 3f2fec87c12b2e968d621663781b9e9e079f10fd6bda0e7d9aabadbeadbd01851de54eb1e393def47e63b066a3c0c62dcc1cf5f101e8b33bb68b9c10430c2f02
7
+ data.tar.gz: 1431602da952ac911732a3284c9a6f73383ddecb20c4b1fe2bb477a970c8724404c6097518a0ee5d8005d10cd631c03a519aebc032173f060af3fc5d4ae4ada8
@@ -4,6 +4,10 @@ module Muina
4
4
  class Maybe
5
5
  class None < self
6
6
  private_class_method(:new)
7
+ def initialize
8
+ freeze
9
+ end
10
+
7
11
  def some?
8
12
  false
9
13
  end
@@ -40,7 +44,7 @@ module Muina
40
44
  def map
41
45
  self
42
46
  end
43
-
47
+
44
48
  def map_none
45
49
  Maybe.return yield
46
50
  end
@@ -52,6 +56,10 @@ module Muina
52
56
  def bind_none
53
57
  yield
54
58
  end
59
+
60
+ def ==(other)
61
+ self.class == other.class
62
+ end
55
63
  end
56
64
  end
57
65
  end
@@ -5,6 +5,7 @@ module Muina
5
5
  class Some < self
6
6
  def initialize(value)
7
7
  @value = value
8
+ freeze
8
9
  end
9
10
  private_class_method(:new)
10
11
 
@@ -44,7 +45,7 @@ module Muina
44
45
  def map
45
46
  Maybe.return yield(@value)
46
47
  end
47
-
48
+
48
49
  def map_none
49
50
  self
50
51
  end
@@ -56,6 +57,11 @@ module Muina
56
57
  def bind_none
57
58
  self
58
59
  end
60
+
61
+ def ==(other)
62
+ self.class == other.class &&
63
+ self.value! == other.value!
64
+ end
59
65
  end
60
66
  end
61
67
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Muina
4
+ class Result
5
+ class Failure < self
6
+ def initialize(error)
7
+ @error = error
8
+ freeze
9
+ end
10
+
11
+ def value!
12
+ raise
13
+ end
14
+
15
+ def error!
16
+ @error
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Muina
4
+ class Result
5
+ class Success < self
6
+ def initialize(value)
7
+ @value = value
8
+ freeze
9
+ end
10
+
11
+ def value!
12
+ @value
13
+ end
14
+
15
+ def error!
16
+ raise
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Muina
4
+ class Result
5
+ private_class_method :new
6
+
7
+ def self.success(value)
8
+ Success.__send__(:new, value)
9
+ end
10
+
11
+ def self.failure(error)
12
+ Failure.__send__(:new, error)
13
+ end
14
+ end
15
+ 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.3.0'
4
+ VERSION = '0.5.0'
5
5
  public_constant :VERSION
6
6
  end
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.3.0
4
+ version: 0.5.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-02 00:00:00.000000000 Z
11
+ date: 2024-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -37,6 +37,9 @@ files:
37
37
  - lib/muina/maybe.rb
38
38
  - lib/muina/maybe/none.rb
39
39
  - lib/muina/maybe/some.rb
40
+ - lib/muina/result.rb
41
+ - lib/muina/result/failure.rb
42
+ - lib/muina/result/success.rb
40
43
  - lib/muina/version.rb
41
44
  homepage: https://github.com/vaporyhumo/muina
42
45
  licenses: