transflow 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: e56210712ab5748639ce2feb57913c5754102588
4
- data.tar.gz: 7823b8b50bf6f6d258ca2ee787585341b9a72ca9
3
+ metadata.gz: 191a70cd5a82b31910a2f10b64e5058ae376f729
4
+ data.tar.gz: d7ad841f948925604c5b0c176c86c66c9d4a05cf
5
5
  SHA512:
6
- metadata.gz: 1dba14fc104d96601b42e7a73abbfcba85a2b3e7f67eb33b2863f129a6ade75bfc025e5750b2749e342f5078ea5a950aba5ee76182ca7696f7a4f4028701a1c5
7
- data.tar.gz: 0da536341a6345f6205a5db977d57be6c1a0e8f1ae94e4d51c2494487751a67fa85ad3421f0832c32ad7fe1653a184e05392cb8f10cbcb43948260ca8fd63dd8
6
+ metadata.gz: c2c407713885bd8d348fbdbd6ea3c79547d82047dd20d989da5a83f3b7f1aba0134dacb1bffd57ba73385de1c13ab75735652659c99ca203118dafd888da110a
7
+ data.tar.gz: dc06637017c57a11ed654b1361490a98269aeeb1cb616751cc048b42ec67ea14195665b3582360889986605b69af8859224d4d073ce8b122de262c359fe71105
@@ -1,3 +1,11 @@
1
+ # 0.2.0 2015-08-18
2
+
3
+ ## Added
4
+
5
+ - Support for currying a publisher step (solnic)
6
+
7
+ [Compare v0.1.0...v0.2.0](https://github.com/solnic/transflow/compare/v0.1.0...v0.2.0)
8
+
1
9
  # 0.1.0 2015-08-17
2
10
 
3
11
  ## Added
@@ -8,11 +8,48 @@ module Transflow
8
8
 
9
9
  attr_reader :op
10
10
 
11
+ class Curried < Publisher
12
+ attr_reader :publisher
13
+
14
+ attr_reader :arity
15
+
16
+ attr_reader :curry_args
17
+
18
+ def initialize(publisher, curry_args = [])
19
+ @publisher = publisher
20
+ @arity = publisher.arity
21
+ @curry_args = curry_args
22
+ end
23
+
24
+ def call(*args)
25
+ all_args = curry_args + args
26
+
27
+ if all_args.size == arity
28
+ publisher.call(*all_args)
29
+ else
30
+ self.class.new(publisher, all_args)
31
+ end
32
+ end
33
+
34
+ def subscribe(*args)
35
+ publisher.subscribe(*args)
36
+ end
37
+ end
38
+
11
39
  def initialize(name, op)
12
40
  @name = name
13
41
  @op = op
14
42
  end
15
43
 
44
+ def curry
45
+ raise "can't curry publisher where operation arity is < 0" if arity < 0
46
+ Curried.new(self)
47
+ end
48
+
49
+ def arity
50
+ op.is_a?(Proc) ? op.arity : op.method(:call).arity
51
+ end
52
+
16
53
  def call(*args)
17
54
  result = op.call(*args)
18
55
  broadcast(:"#{name}_success", result)
@@ -1,3 +1,3 @@
1
1
  module Transflow
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-17 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transproc