funkify 0.0.1 → 0.0.2

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: df42a1e54ad9d803baf96647480e58dacff3e5eb
4
- data.tar.gz: 08175309961eea835db32aa26d019a0b68c169bf
3
+ metadata.gz: d5d368db1d50577c1cf79227015a65bfa6c89d02
4
+ data.tar.gz: 819c4d262056e8c8c2fbd4e37eeb3d822681e4f1
5
5
  SHA512:
6
- metadata.gz: 5098c8b190f2bafc7cac212fd0ff14d3ced074be958d68025f3e1f7945e725051eb150e0547f5c9a1c69417fa9b5f07c0d59abe7c11a8eed942aeb2dce3c2502
7
- data.tar.gz: a1b28ec738455b1109aee4f1f9cf1f9b22c4150dab18c718df56304ba0ce408994b0d9cbbd0d4e7362fbdef348090a1fafd2e85c1e9ccb36344fa9cbc212d48f
6
+ metadata.gz: e1c249b9939eabca11d0221377aff41e2c59951c4980ab6e54e30f5ca1561bc0117c949429c43ade6a5de0a32a64651759eda7915c7857f9ab26466f5003a5f8
7
+ data.tar.gz: 5948d58b24e0c4deaf5a397f4daf672531263b952aef994400f12ac775a5f41a2284996c39b8795321203f3e9a1bb5d02a9bf35656f22d77785d8c44d148c6dc
data/README.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Funkify
2
2
 
3
- **(c) Copyright 2013, Epitron**
4
-
5
3
  _Haskell-style partial application and composition for Ruby methods_
6
4
 
5
+
6
+ "In computer science, partial application refers to the process of
7
+ fixing a number of arguments to a function, producing another function of smaller arity."
8
+ --[Wikipedia](http://en.wikipedia.org/wiki/Partial_application)
9
+
10
+ [Partial application in haskell](http://www.haskell.org/haskellwiki/Partial_application)<br>
11
+ [Function composition in haskell](http://www.haskell.org/haskellwiki/Function_composition)
12
+
13
+
7
14
  ## Usage
8
15
 
9
16
  ```ruby
@@ -42,15 +49,15 @@ add_1 = funky.add(1) #=> The `1` is partially applied and a `Proc` is returned
42
49
  add_1.(2) #=> We invoke that `Proc` with the remaining argument and the final result (`3`) is returned.
43
50
  ```
44
51
 
45
- We can also compose methods using `+`:
52
+ We can also compose methods using `*`:
46
53
 
47
54
  ```ruby
48
- add_1_and_multiply_by_5 = funky.mult(5) + funky.add(1)
55
+ add_1_and_multiply_by_5 = funky.mult(5) * funky.add(1)
49
56
  add_1_and_multiply_by_5.(10) #=> 55
50
57
 
51
58
  # We can even further compose the above with another method:
52
59
 
53
- (funky.negate + add_1_and_multiply_by_5).(10) #=> -55
60
+ (funky.negate * add_1_and_multiply_by_5).(10) #=> -55
54
61
  ```
55
62
 
56
63
  Other examples:
@@ -58,13 +65,13 @@ Other examples:
58
65
  Add 10 to every item in an Enumerable:
59
66
 
60
67
  ```ruby
61
- (1..5).map(&funky.add(10)) #=> [10, 12, 13, 14, 15]
68
+ (1..5).map &funky.add(10) #=> [11, 12, 13, 14, 15]
62
69
  ```
63
70
 
64
71
  Multiply by 10 and negate every item in an Enumerable:
65
72
 
66
73
  ```ruby
67
- (1..5).map &(funky.negate + funky.mult(10)) => [-10, -20, -30, -40, -50]
74
+ (1..5).map &(funky.negate * funky.mult(10)) => [-10, -20, -30, -40, -50]
68
75
  ```
69
76
 
70
77
  ## Installation
@@ -6,7 +6,7 @@ module Funkify
6
6
  end
7
7
 
8
8
  class ::Proc
9
- def +(other)
9
+ def *(other)
10
10
  Funkify.compose(self, other)
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Funkify
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -106,19 +106,19 @@ describe Funkify do
106
106
  end
107
107
 
108
108
  it 'returns a new Proc when composing methods' do
109
- (@c.negate + @c.plus_1).is_a?(Proc).should == true
109
+ (@c.negate * @c.plus_1).is_a?(Proc).should == true
110
110
  end
111
111
 
112
112
  it 'invokes composed methods in the correct order (right-to-left)' do
113
- (@c.negate + @c.plus_1).(5).should == -6
113
+ (@c.negate * @c.plus_1).(5).should == -6
114
114
  end
115
115
 
116
116
  it 'can compose partially applied methods' do
117
- (@c.add(5) + @c.mult(2)).(5).should == 15
117
+ (@c.add(5) * @c.mult(2)).(5).should == 15
118
118
  end
119
119
 
120
120
  it 'can compose multiple methods' do
121
- (@c.negate + @c.add(5) + @c.mult(5)).(5).should == -30
121
+ (@c.negate * @c.add(5) * @c.mult(5)).(5).should == -30
122
122
  end
123
123
  end
124
124
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funkify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-10 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler