rfunk 1.6.1 → 1.7.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
  SHA1:
3
- metadata.gz: eacce4df0c1a491a05befdc7a538628816fc95fa
4
- data.tar.gz: 2c390966683706cb50c1074f8dec0db9ef364b3f
3
+ metadata.gz: b903a5e57ad02cb3ce4aad68527844a54e41c296
4
+ data.tar.gz: 52a6223d519be58a35360407524a16391d8a0bae
5
5
  SHA512:
6
- metadata.gz: 7e14f42d01f38bce865971a3d171efb11bbafdf6d12deb92d417c2b7bf86f088e65bfbd6bdcbaf555a74cb196e953f787ee90c7d55fe7d136dfc607f6fe5157f
7
- data.tar.gz: 8e7f84f68f9d76b1539c0952fd09a28e37bcddcb4b410f6db5e60a30df8a5951cd534eaeb8610c067e0e4dc3cf1f459b245d8860b1c1051d25f2935e756aa6f3
6
+ metadata.gz: d3518017a522c77111be0461cb8b13b72e73cafed66628f0187f83d46699bfb41c03a5851a0240bf006c9eb2e21b1bd955df58982946189ff723f880ca571388
7
+ data.tar.gz: 7f0a210a7177c8748a99c9d770b6139589712b31c59d34f2592b947e5974d03298a6724b103577ae2c2af147b477c95e52d191edcdd25f5b38a714893dac7760
@@ -7,7 +7,9 @@ module RFunk
7
7
  define_method function_definition.value(0).value, &lambda
8
8
  end
9
9
 
10
- [:fn, :func, :defn].each { |m| alias_method m, :fun }
10
+ alias fn fun
11
+ alias func fun
12
+ alias defn fun
11
13
 
12
14
  private
13
15
 
@@ -22,7 +22,7 @@ module RFunk
22
22
  RFunk.some(RFunk.some(variables)[options])
23
23
  end
24
24
 
25
- [:let].each { |m| alias_method m, :val }
25
+ alias let val
26
26
 
27
27
  def assert(&_)
28
28
  return true if yield
@@ -57,10 +57,6 @@ module RFunk
57
57
  this.send(method, *arguments, &block)
58
58
  end
59
59
 
60
- def respond_to_missing?(method_name, include_private = false)
61
- this.respond_to_missing?(method_name, include_private)
62
- end
63
-
64
60
  private
65
61
 
66
62
  attr_reader :block, :pre_block, :post_block, :body_block, :function_definition
@@ -13,6 +13,8 @@ module RFunk
13
13
  end
14
14
  end
15
15
 
16
+ alias identity result
17
+
16
18
  def ==(other)
17
19
  other.result == result
18
20
  end
@@ -11,6 +11,10 @@ module RFunk
11
11
  def or(value)
12
12
  RFunk.failure(value)
13
13
  end
14
+
15
+ def key
16
+ :failure
17
+ end
14
18
  end
15
19
 
16
20
  class << self
@@ -11,6 +11,10 @@ module RFunk
11
11
  def or(_)
12
12
  self
13
13
  end
14
+
15
+ def key
16
+ :success
17
+ end
14
18
  end
15
19
 
16
20
  class << self
@@ -0,0 +1,16 @@
1
+ module RFunk
2
+ module Match
3
+ class Pattern
4
+ attr_reader :cases
5
+
6
+ def initialize
7
+ @cases = []
8
+ end
9
+
10
+ def with(type, func)
11
+ cases << [type, func]
12
+ RFunk.none
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module RFunk
2
+ module Match
3
+ def match(option)
4
+ pattern = RFunk::Match::Pattern.new
5
+ yield(pattern)
6
+
7
+ pattern.cases.each do |t|
8
+ return t.last.call(option.identity) if t.first == option.key
9
+ end
10
+
11
+ RFunk.none
12
+ end
13
+ end
14
+ end
@@ -34,6 +34,10 @@ module RFunk
34
34
  {}
35
35
  end
36
36
 
37
+ def key
38
+ :none
39
+ end
40
+
37
41
  protected
38
42
 
39
43
  def enum
@@ -10,6 +10,8 @@ module RFunk
10
10
  @value
11
11
  end
12
12
 
13
+ alias identity value
14
+
13
15
  def or(_)
14
16
  self
15
17
  end
@@ -38,6 +40,10 @@ module RFunk
38
40
 
39
41
  [:to_str, :to_ary, :to_hash].each { |k| define_method(k) { value } }
40
42
 
43
+ def key
44
+ :some
45
+ end
46
+
41
47
  def_delegators :@value, :to_s, :inspect, :respond_to?, :class
42
48
 
43
49
  protected
data/lib/rfunk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RFunk
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
data/lib/rfunk.rb CHANGED
@@ -26,3 +26,5 @@ require 'rfunk/either/either'
26
26
  require 'rfunk/either/failure'
27
27
  require 'rfunk/either/success'
28
28
  require 'rfunk/tuple'
29
+ require 'rfunk/match'
30
+ require 'rfunk/match/pattern'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski
@@ -148,6 +148,8 @@ files:
148
148
  - lib/rfunk/either/failure.rb
149
149
  - lib/rfunk/either/success.rb
150
150
  - lib/rfunk/lazy.rb
151
+ - lib/rfunk/match.rb
152
+ - lib/rfunk/match/pattern.rb
151
153
  - lib/rfunk/maybe/none.rb
152
154
  - lib/rfunk/maybe/option.rb
153
155
  - lib/rfunk/maybe/some.rb