function-composite 0.1.0 → 0.1.1
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 +4 -4
- data/lib/function/composite.rb +11 -1
- data/test/test-function-composite.rb +12 -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: 7d8d598e71699c70c2b263faab6f1a75ad05e51c0a26dda76f24b46963e0082a
|
4
|
+
data.tar.gz: 3bd2fdaf11799cbb0132652e33d19053bebdcbf75a85a6441fb9f1d2f1c8e258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e8e702684c5dd71efba2b1b0a8814e5d5c2627c159c82bc455a6fabac84ce6d7bde2ece7498645ee0bedd5312bcebbc816711134c3dd3a9c80a292fe0a09655
|
7
|
+
data.tar.gz: 0ecbe1e884f4cb33053cca8403502a059cb1f6d75b99a43110a1061e1845215b4f0d7b5fc2e05b4043ac60ec6ab1f0c000ee178d6bbad688d6dd2bca01e7c838
|
data/lib/function/composite.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Function
|
2
2
|
module Composite
|
3
|
-
VERSION = "0.1.
|
3
|
+
VERSION = "0.1.1"
|
4
4
|
|
5
5
|
refine(Symbol) do
|
6
6
|
def call(*args, &block)
|
@@ -25,5 +25,15 @@ module Function
|
|
25
25
|
super(other.to_proc)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
refine(Method) do
|
30
|
+
def <<(other)
|
31
|
+
super(other.to_proc)
|
32
|
+
end
|
33
|
+
|
34
|
+
def >>(other)
|
35
|
+
super(other.to_proc)
|
36
|
+
end
|
37
|
+
end
|
28
38
|
end
|
29
39
|
end
|
@@ -27,9 +27,21 @@ class Function::CompositeTest < Test::Unit::TestCase
|
|
27
27
|
assert_equal(["H", "e", "l", "l", "o"], result)
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_method_to_symbol
|
31
|
+
result = %w{72 101 108 108 111}.map(&method(:int) >> :chr)
|
32
|
+
assert_equal(["H", "e", "l", "l", "o"], result)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_symbol_from_method
|
36
|
+
result = %w{72 101 108 108 111}.map(&:chr << method(:int))
|
37
|
+
assert_equal(["H", "e", "l", "l", "o"], result)
|
38
|
+
end
|
39
|
+
|
30
40
|
def test_symbol_to_callable
|
31
41
|
h = {Alice: 30, Bob: 60, Cris: 90}
|
32
42
|
result = %w{Alice Bob Cris}.map(&(:to_sym >> h))
|
33
43
|
assert_equal([30, 60, 90], result)
|
34
44
|
end
|
45
|
+
|
46
|
+
def int(s) s.to_i end
|
35
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: function-composite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobuyoshi Nakada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|