ntl-orchestra 0.9.0 → 0.9.1

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: e510c2671333a04041a77dc8c6a745fd4e6f2e58
4
- data.tar.gz: 0c874a17df26a2f97e942feb60713b68c5648cd2
3
+ metadata.gz: c39c9dc0144c1c80a6a7a2bf82769fbfb1e17603
4
+ data.tar.gz: b58e51cb70edf817f0ff32efd3fa09e9753e1193
5
5
  SHA512:
6
- metadata.gz: e4beddf07b80930847e43228307e3065170a0fbb041e3215c28f89ef3ec9e50ce7d2a1d190f238e7c524caaec760a3dfdb6e085fb51d4bb118a97ba95bb55f8e
7
- data.tar.gz: 2c60866f23f0722cb01b96d6aa71ac717267ada8d4fb5dd17ab897749ddc9dc59b23a306dd2599f9015682e9721a59076c5e60ff161d0475df76d06de24e3ddc
6
+ metadata.gz: b10b097ed0729846e3ff79f43798efd3ca2ce25c6dd4f3b08f6571d43ee6add23152ff87f469dd2e55bd114ae0bcffd242f3baf6ea2435356a44ad51cbf938f6
7
+ data.tar.gz: 94b4a02725e1a1b12dc11d864bf462882927637b98e283cef9303dab5c1f5a6e077223f158c4b4ccabb82faaa5c92d50f2a6d611ee4c8ec78e2a101000f51ed4
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  Here's a simple example without a lot of context:
24
24
 
25
25
  ```ruby
26
- operation = Orchestra.define do
26
+ operation = Orchestra::Operation.new do
27
27
  node :make_array do
28
28
  depends_on :up_to
29
29
  provides :array
@@ -151,7 +151,7 @@ Objects like `InvitationService` are not fun to work with.
151
151
  Here is a simple translation of the above `InvitationService` into an orchestration:
152
152
 
153
153
  ```ruby
154
- InvitationService = Orchestra.define do
154
+ InvitationService = Orchestra::Operation.new do
155
155
  DEFAULT_MESSAGE = "I would really love for you to try out MyApp."
156
156
  ROBOT_FOLLOWER_THRESHHOLD = 500
157
157
 
@@ -273,7 +273,7 @@ Configuring the operation is rather simple. You define the various nodes, and th
273
273
  The first is very straightforward:
274
274
 
275
275
  ```ruby
276
- Orchestra.define do
276
+ Orchestra::Operation.new do
277
277
  node :foo do
278
278
  depends_on :bar
279
279
  provides :foo # optional, since the node is called :foo
@@ -287,7 +287,7 @@ end
287
287
  The second is just a shortened form of the first:
288
288
 
289
289
  ```ruby
290
- Orchestra.define do
290
+ Orchestra::Operation.new do
291
291
  # Define a node called :foo and make it the result
292
292
  result :foo do
293
293
  depends_on :bar
@@ -299,7 +299,7 @@ end
299
299
  The third is a minor variation of the second. The only difference is that the operation will always return `true`. `finally` makes sense for operations that perform side effects (e.g. Command objects), wherease `result` will make sense for queries.
300
300
 
301
301
  ```ruby
302
- Orchestra.define do
302
+ Orchestra::Operation.new do
303
303
  finally :foo do
304
304
  depends_on :bar
305
305
  perform do … end
@@ -419,7 +419,7 @@ What did this buy us? Two big things. We can now attach *observers* to the perfo
419
419
  Additionally, you can pass the `conductor` into nodes. In this way you can embed one orchestration into another:
420
420
 
421
421
  ```ruby
422
- inner_operation = Orchestra.define do
422
+ inner_operation = Orchestra::Operation.new do
423
423
  result :foo do
424
424
  provides :bar
425
425
  perform do
@@ -428,7 +428,7 @@ inner_operation = Orchestra.define do
428
428
  end
429
429
  end
430
430
 
431
- outer_operation = Orchestra.define do
431
+ outer_operation = Orchestra::Operation.new do
432
432
  result :baz do
433
433
  depends_on :conductor
434
434
  provides :qux
@@ -445,7 +445,7 @@ conductor.perform outer_operation
445
445
  To shorten this, the inner operation can be "mounted" inside the outer operation:
446
446
 
447
447
  ```ruby
448
- inner_operation = Orchestra.define do
448
+ inner_operation = Orchestra::Operation.new do
449
449
  result :foo do
450
450
  provides :bar
451
451
  perform do
@@ -454,7 +454,7 @@ inner_operation = Orchestra.define do
454
454
  end
455
455
  end
456
456
 
457
- outer_operation = Orchestra.define do
457
+ outer_operation = Orchestra::Operation.new do
458
458
  result inner_operation
459
459
  end
460
460
  ```
@@ -0,0 +1 @@
1
+ require_relative '../orchestra'
data/lib/orchestra.rb CHANGED
@@ -10,12 +10,6 @@ module Orchestra
10
10
  Configuration.module_eval &block
11
11
  end
12
12
 
13
- def define &block
14
- builder = DSL::Operations::Builder.new
15
- DSL::Operations::Context.evaluate builder, &block
16
- builder.build_operation
17
- end
18
-
19
13
  def perform operation, inputs = {}
20
14
  Conductor.new.perform operation, inputs
21
15
  end
@@ -1,5 +1,15 @@
1
1
  module Orchestra
2
2
  class Operation < Module
3
+ def self.new *args, &block
4
+ return super unless block_given?
5
+ unless args.empty?
6
+ raise ArgumentError, "wrong number of arguments (#{args.size} for 0)"
7
+ end
8
+ builder = DSL::Operations::Builder.new
9
+ DSL::Operations::Context.evaluate builder, &block
10
+ builder.build_operation
11
+ end
12
+
3
13
  extend Forwardable
4
14
 
5
15
  def_delegators :@default_run_list, :node_names, :provisions, :dependencies,
@@ -1,3 +1,3 @@
1
1
  module Orchestra
2
- VERSION = "0.9.0" unless defined? VERSION
2
+ VERSION = "0.9.1" unless defined? VERSION
3
3
  end
@@ -1,5 +1,5 @@
1
1
  module Examples
2
- FizzBuzz = Orchestra.define do
2
+ FizzBuzz = Orchestra::Operation.new do
3
3
  node :make_array do
4
4
  depends_on :up_to
5
5
  provides :array
@@ -1,5 +1,5 @@
1
1
  module Examples
2
- InvitationService = Orchestra.define do
2
+ InvitationService = Orchestra::Operation.new do
3
3
  DEFAULT_MESSAGE = "I would really love for you to try out MyApp."
4
4
  ROBOT_FOLLOWER_THRESHHOLD = 500
5
5
 
@@ -2,7 +2,7 @@ class MultithreadingTest < Minitest::Test
2
2
  CustomError = Class.new StandardError
3
3
 
4
4
  def setup
5
- @operation = Orchestra.define do
5
+ @operation = Orchestra::Operation.new do
6
6
  node :map_thread_ids do
7
7
  iterates_over :list
8
8
  provides :thread_ids
@@ -12,7 +12,7 @@ class DSLTest < Minitest::Test
12
12
 
13
13
  def test_two_nodes_one_name
14
14
  error = assert_raises ArgumentError do
15
- Orchestra.define do
15
+ Orchestra::Operation.new do
16
16
  node :foo do
17
17
  depends_on :bar
18
18
  perform do bar + bar end
@@ -28,19 +28,19 @@ class DSLTest < Minitest::Test
28
28
  end
29
29
 
30
30
  def test_result_node
31
- operation = Orchestra.define do
31
+ operation = Orchestra::Operation.new do
32
32
  result :foo do perform do 'foo' end end
33
33
  end
34
34
  assert_equal :foo, operation.result
35
35
 
36
36
  error = assert_raises ArgumentError do
37
- operation = Orchestra.define do
37
+ operation = Orchestra::Operation.new do
38
38
  result do perform do 'foo' end end
39
39
  end
40
40
  end
41
41
  assert_equal "Could not infer name for node from a provision", error.message
42
42
 
43
- operation = Orchestra.define do
43
+ operation = Orchestra::Operation.new do
44
44
  result do
45
45
  provides :foo
46
46
  perform do 'foo' end
@@ -50,7 +50,7 @@ class DSLTest < Minitest::Test
50
50
  end
51
51
 
52
52
  def test_command_operations_using_finally
53
- operation = Orchestra.define do
53
+ operation = Orchestra::Operation.new do
54
54
  node :unnecessary do
55
55
  provides :baz
56
56
  perform do raise "Can't get here" end
@@ -85,7 +85,7 @@ class DSLTest < Minitest::Test
85
85
  end
86
86
 
87
87
  def test_modifies
88
- operation = Orchestra.define do
88
+ operation = Orchestra::Operation.new do
89
89
  result do
90
90
  modifies :list
91
91
  perform do list << :foo end
@@ -100,7 +100,7 @@ class DSLTest < Minitest::Test
100
100
 
101
101
  def test_must_supply_result
102
102
  error = assert_raises ArgumentError do
103
- Orchestra.define do
103
+ Orchestra::Operation.new do
104
104
  node :foo do
105
105
  perform do 'foo' end
106
106
  end
@@ -112,7 +112,7 @@ class DSLTest < Minitest::Test
112
112
 
113
113
  def test_must_contain_at_least_one_node
114
114
  error = assert_raises ArgumentError do
115
- Orchestra.define do
115
+ Orchestra::Operation.new do
116
116
  self.result = :foo
117
117
  end
118
118
  end
@@ -27,7 +27,7 @@ class ObjectAdapterTest < Minitest::Test
27
27
  end
28
28
 
29
29
  def test_performing_an_operation_with_integrated_objects
30
- operation = Orchestra.define do
30
+ operation = Orchestra::Operation.new do
31
31
  node Splitter, :provides => :words
32
32
  node Upcaser, :iterates_over => :words, :provides => :upcased_words, :method => :call
33
33
  node Bolder, :iterates_over => :upcased_words, :provides => :bolded_words, :method => :call
@@ -49,7 +49,7 @@ class ObjectAdapterTest < Minitest::Test
49
49
 
50
50
  def test_provent_singleton_objects_from_handling_collections
51
51
  error = assert_raises ArgumentError do
52
- Orchestra.define do
52
+ Orchestra::Operation.new do
53
53
  node Splitter, :iterates_over => :sentence
54
54
  end
55
55
  end
@@ -53,7 +53,7 @@ module OperationTest
53
53
  end
54
54
 
55
55
  def test_missing_input_errors
56
- operation = Orchestra.define do
56
+ operation = Orchestra::Operation.new do
57
57
  node :foo do
58
58
  depends_on :bar
59
59
  perform do bar + bar end
@@ -79,7 +79,7 @@ module OperationTest
79
79
  private
80
80
 
81
81
  def build_simple_operation
82
- Orchestra.define do
82
+ Orchestra::Operation.new do
83
83
  node :split do
84
84
  depends_on :sentence
85
85
  provides :word_list
@@ -102,7 +102,7 @@ module OperationTest
102
102
  end
103
103
 
104
104
  def build_mutator
105
- Orchestra.define do
105
+ Orchestra::Operation.new do
106
106
  node :carrots do
107
107
  depends_on :shopping_list
108
108
  provides :shopping_list
@@ -162,7 +162,7 @@ module OperationTest
162
162
 
163
163
  class EmbeddingOperationsTest < Minitest::Test
164
164
  def test_embedding_operations
165
- inner = Orchestra.define do
165
+ inner = Orchestra::Operation.new do
166
166
  node :double do
167
167
  depends_on :number
168
168
  provides :doubled
@@ -175,7 +175,7 @@ module OperationTest
175
175
  end
176
176
  end
177
177
 
178
- outer = Orchestra.define do
178
+ outer = Orchestra::Operation.new do
179
179
  node inner
180
180
 
181
181
  result :squared do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntl-orchestra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ntl
@@ -80,6 +80,7 @@ files:
80
80
  - README.md
81
81
  - Rakefile
82
82
  - bin/rake
83
+ - lib/ntl/orchestra.rb
83
84
  - lib/orchestra.rb
84
85
  - lib/orchestra/conductor.rb
85
86
  - lib/orchestra/configuration.rb