composable_operations 0.6.0 → 0.7.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: 658fbfd45d7aed7d7589d0603270cbac1b3fea39
4
- data.tar.gz: bb95ff34e25b6df75249604c9e606ffe2046c136
3
+ metadata.gz: 5ac9f54ccfaf7e9e03e47174f435b00f536764c9
4
+ data.tar.gz: ee9f3b4c7a5185403b4b418a3860bb05af007891
5
5
  SHA512:
6
- metadata.gz: 091483e197ccab3c020d27ecfe4e040a9fed7c0b8a0f90a08dbff8d97e75ed80545a642c64b86fab4ea995dea4f1e2d3dee4e9335bfd08b6df85a10a8542332a
7
- data.tar.gz: 66b9beda48a6df81f21eddee06f83d0bb0c6f3bdb9c60b6954000fcb0ed59402c277eb5f2a7c0e1ac6a8679285d781cf0457e33a523579e9f1deada49426ffcc
6
+ metadata.gz: 10dbdfddb4ad3957b07e95316518902b6880f2ef3e739ce298b143824cc568402eba18aadfcd47c0907684351175abb5612f860ee2736daf0afc58ef79f3d3b5
7
+ data.tar.gz: 12f3736f3056b60b79a18e9645a267f5f7f4718f89a384b231d4cc3f60b88c63f9144757b6f90a0f2bb809b9766d1fedfb88aa08822778988257867c9d43418a
@@ -8,8 +8,8 @@ module ComposableOperations
8
8
  @_options = options
9
9
  end
10
10
 
11
- def create(context, input = nil)
12
- new *Array(input), Hash[Array(@_options).map do |key, value|
11
+ def create(context, *input)
12
+ new *input, Hash[Array(@_options).map do |key, value|
13
13
  [key, value.kind_of?(Proc) ? context.instance_exec(&value) : value]
14
14
  end]
15
15
  end
@@ -46,7 +46,11 @@ module ComposableOperations
46
46
 
47
47
  def execute
48
48
  self.class.operations.inject(input) do |data, operation|
49
- operation = operation.create(self, data)
49
+ operation = if data.respond_to?(:to_ary)
50
+ operation.create(self, *data)
51
+ else
52
+ operation.create(self, data)
53
+ end
50
54
  operation.perform
51
55
 
52
56
  if operation.failed?
@@ -1,3 +1,3 @@
1
1
  module ComposableOperations
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe ComposableOperations::ComposedOperation, "input forwarding:" do
4
+
5
+ describe "An operation pipeline that first constructs an enumerator, then passes it from operation to operation and finally returns it as the result" do
6
+
7
+ let(:enum_generator) do
8
+ Class.new(ComposableOperations::Operation) do
9
+ def execute
10
+ %w[just some text].enum_for(:each)
11
+ end
12
+ end
13
+ end
14
+
15
+ let(:null_operation) do
16
+ Class.new(ComposableOperations::Operation) do
17
+ processes :enumerator
18
+ def execute
19
+ enumerator
20
+ end
21
+ end
22
+ end
23
+
24
+ subject(:pipeline) do
25
+ ComposableOperations::ComposedOperation.compose(enum_generator, null_operation)
26
+ end
27
+
28
+ it "should actually return an enumerator" do
29
+ result = pipeline.perform
30
+ result.should be_kind_of(Enumerator)
31
+ end
32
+ end
33
+
34
+ describe "An operation pipeline that first constructs an object that responds #to_a, then passes it from operation to operation and finally returns it as the result" do
35
+
36
+ let(:dummy) do
37
+ Object.new.tap do |o|
38
+ def o.to_a
39
+ %w[just some text]
40
+ end
41
+ end
42
+ end
43
+
44
+ let(:object_representable_as_array_generator) do
45
+ spec_context = self
46
+ Class.new(ComposableOperations::Operation) do
47
+ define_method(:execute) do
48
+ spec_context.dummy
49
+ end
50
+ end
51
+ end
52
+
53
+ let(:null_operation) do
54
+ Class.new(ComposableOperations::Operation) do
55
+ processes :object_representable_as_array
56
+ def execute
57
+ object_representable_as_array
58
+ end
59
+ end
60
+ end
61
+
62
+ subject(:pipeline) do
63
+ ComposableOperations::ComposedOperation.compose(object_representable_as_array_generator, null_operation)
64
+ end
65
+
66
+ it "should actually return this object" do
67
+ result = pipeline.perform
68
+ result.should == dummy
69
+ end
70
+ end
71
+
72
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_operations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Tennhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-03 00:00:00.000000000 Z
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: smart_properties
@@ -105,6 +105,7 @@ files:
105
105
  - lib/composable_operations/version.rb
106
106
  - spec/composable_operations/composed_operation_spec.rb
107
107
  - spec/composable_operations/control_flow_spec.rb
108
+ - spec/composable_operations/operation_input_forwarding_spec.rb
108
109
  - spec/composable_operations/operation_input_processing_spec.rb
109
110
  - spec/composable_operations/operation_spec.rb
110
111
  - spec/spec_helper.rb
@@ -128,13 +129,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  version: '0'
129
130
  requirements: []
130
131
  rubyforge_project:
131
- rubygems_version: 2.0.6
132
+ rubygems_version: 2.0.3
132
133
  signing_key:
133
134
  specification_version: 4
134
135
  summary: Tool set for operation pipelines.
135
136
  test_files:
136
137
  - spec/composable_operations/composed_operation_spec.rb
137
138
  - spec/composable_operations/control_flow_spec.rb
139
+ - spec/composable_operations/operation_input_forwarding_spec.rb
138
140
  - spec/composable_operations/operation_input_processing_spec.rb
139
141
  - spec/composable_operations/operation_spec.rb
140
142
  - spec/spec_helper.rb