tataru 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -0
  3. data/bin/console +15 -0
  4. data/bin/setup +8 -0
  5. data/lib/tataru.rb +70 -12
  6. data/lib/tataru/base_resource.rb +49 -0
  7. data/lib/tataru/base_resource_desc.rb +35 -0
  8. data/lib/tataru/compiler.rb +100 -0
  9. data/lib/tataru/create_subroutines.rb +31 -0
  10. data/lib/tataru/delete_subroutines.rb +42 -0
  11. data/lib/tataru/flattener.rb +81 -0
  12. data/lib/tataru/init_hash_compiler.rb +41 -0
  13. data/lib/tataru/instruction.rb +52 -7
  14. data/lib/tataru/instruction_hash.rb +54 -0
  15. data/lib/tataru/instructions/call_instruction.rb +19 -0
  16. data/lib/tataru/instructions/check_create_instruction.rb +27 -0
  17. data/lib/tataru/instructions/check_delete_instruction.rb +20 -0
  18. data/lib/tataru/instructions/check_instruction.rb +26 -0
  19. data/lib/tataru/instructions/check_update_instruction.rb +27 -0
  20. data/lib/tataru/instructions/clear_instruction.rb +12 -0
  21. data/lib/tataru/instructions/compare_instruction.rb +16 -0
  22. data/lib/tataru/instructions/create_instruction.rb +20 -0
  23. data/lib/tataru/instructions/delete_instruction.rb +14 -0
  24. data/lib/tataru/instructions/end_instruction.rb +12 -0
  25. data/lib/tataru/instructions/goto_if_instruction.rb +26 -0
  26. data/lib/tataru/instructions/immediate_mode_instruction.rb +12 -0
  27. data/lib/tataru/instructions/init_instruction.rb +27 -0
  28. data/lib/tataru/instructions/key_instruction.rb +12 -0
  29. data/lib/tataru/instructions/mark_deletable_instruction.rb +13 -0
  30. data/lib/tataru/instructions/read_instruction.rb +28 -0
  31. data/lib/tataru/instructions/rescmp_instruction.rb +34 -0
  32. data/lib/tataru/instructions/resource_instruction.rb +15 -0
  33. data/lib/tataru/instructions/return_instruction.rb +16 -0
  34. data/lib/tataru/instructions/update_instruction.rb +16 -0
  35. data/lib/tataru/instructions/value_instruction.rb +15 -0
  36. data/lib/tataru/instructions/value_rom_instruction.rb +23 -0
  37. data/lib/tataru/instructions/value_update_instruction.rb +18 -0
  38. data/lib/tataru/memory.rb +16 -0
  39. data/lib/tataru/quest.rb +43 -0
  40. data/lib/tataru/representation.rb +22 -0
  41. data/lib/tataru/representations/array_representation.rb +18 -0
  42. data/lib/tataru/representations/hash_representation.rb +20 -0
  43. data/lib/tataru/representations/literal_representation.rb +9 -0
  44. data/lib/tataru/representations/output_representation.rb +19 -0
  45. data/lib/tataru/representations/resource_representation.rb +49 -0
  46. data/lib/tataru/resolver.rb +39 -0
  47. data/lib/tataru/resource_dsl.rb +21 -71
  48. data/lib/tataru/resource_type_pool.rb +22 -0
  49. data/lib/tataru/rom_reader.rb +47 -0
  50. data/lib/tataru/runner.rb +48 -0
  51. data/lib/tataru/sub_planner.rb +41 -0
  52. data/lib/tataru/subroutine_compiler.rb +52 -0
  53. data/lib/tataru/top_dsl.rb +35 -0
  54. data/lib/tataru/update_subroutines.rb +111 -0
  55. data/lib/tataru/version.rb +1 -1
  56. data/spec/compiler_spec.rb +181 -0
  57. data/spec/flattener_spec.rb +88 -0
  58. data/spec/init_hash_compiler_spec.rb +85 -0
  59. data/spec/instruction_hash_spec.rb +63 -0
  60. data/spec/instruction_spec.rb +36 -0
  61. data/spec/instructions/call_instruction_spec.rb +28 -0
  62. data/spec/instructions/check_create_instruction_spec.rb +67 -0
  63. data/spec/instructions/check_delete_instruction_spec.rb +47 -0
  64. data/spec/instructions/check_update_instruction_spec.rb +67 -0
  65. data/spec/instructions/clear_instruction_spec.rb +16 -0
  66. data/spec/instructions/compare_instruction_spec.rb +29 -0
  67. data/spec/instructions/create_instruction_spec.rb +62 -0
  68. data/spec/instructions/delete_instruction_spec.rb +20 -0
  69. data/spec/instructions/end_instruction_spec.rb +15 -0
  70. data/spec/instructions/goto_if_instruction_spec.rb +42 -0
  71. data/spec/instructions/init_instruction_spec.rb +16 -0
  72. data/spec/instructions/key_instruction_spec.rb +15 -0
  73. data/spec/instructions/mark_deletable_instruction_spec.rb +20 -0
  74. data/spec/instructions/read_instruction_spec.rb +34 -0
  75. data/spec/instructions/rescmp_instruction_spec.rb +113 -0
  76. data/spec/instructions/return_instruction_spec.rb +28 -0
  77. data/spec/instructions/update_instruction_spec.rb +39 -0
  78. data/spec/instructions/value_instruction_spec.rb +27 -0
  79. data/spec/instructions/value_rom_instruction_spec.rb +170 -0
  80. data/spec/instructions/value_update_instruction_spec.rb +35 -0
  81. data/spec/quest_spec.rb +9 -0
  82. data/spec/representations/array_representation_spec.rb +29 -0
  83. data/spec/representations/hash_representation_spec.rb +29 -0
  84. data/spec/representations/literal_representation_spec.rb +10 -0
  85. data/spec/representations/output_representation_spec.rb +11 -0
  86. data/spec/representations/resource_representation_spec.rb +50 -0
  87. data/spec/resource_dsl_spec.rb +71 -0
  88. data/spec/runner_spec.rb +99 -0
  89. data/spec/spec_helper.rb +401 -0
  90. data/spec/subroutine_compiler_spec.rb +39 -0
  91. data/spec/taru_spec.rb +616 -0
  92. data/spec/top_dsl_spec.rb +68 -0
  93. data/tataru.gemspec +45 -0
  94. metadata +145 -27
  95. data/Rakefile +0 -8
  96. data/lib/tataru/default_resource_finder.rb +0 -10
  97. data/lib/tataru/execution_step.rb +0 -79
  98. data/lib/tataru/planner.rb +0 -93
  99. data/lib/tataru/requirements.rb +0 -67
  100. data/lib/tataru/requirements_dsl.rb +0 -33
  101. data/lib/tataru/resource.rb +0 -52
  102. data/lib/tataru/state.rb +0 -64
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tataru'
4
+
5
+ describe Tataru::TopDsl do
6
+ it 'creates a resource' do
7
+ pool = Tataru::ResourceTypePool.new
8
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
9
+
10
+ dsl = Tataru::TopDsl.new(pool)
11
+ dsl.instance_eval do
12
+ resource :file, 'somefile'
13
+ end
14
+ expect(dsl.resources['somefile']).to be_a(Tataru::Representations::ResourceRepresentation)
15
+ end
16
+
17
+ it 'raises error if resource already made' do
18
+ pool = Tataru::ResourceTypePool.new
19
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
20
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
21
+
22
+ dsl = Tataru::TopDsl.new(pool)
23
+ dsl.resource :file, 'somefile'
24
+ expect { dsl.resource :file, 'somefile' }.to raise_error 'already defined: somefile'
25
+ end
26
+
27
+ it 'can handle more than one resource' do
28
+ pool = Tataru::ResourceTypePool.new
29
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
30
+
31
+ dsl = Tataru::TopDsl.new(pool)
32
+ dsl.instance_eval do
33
+ resource :file, 'somefile'
34
+ resource :file, 'somefile2'
35
+ end
36
+ expect(dsl.resources.count).to eq 2
37
+ end
38
+
39
+ it 'has a dependency graph' do
40
+ pool = Tataru::ResourceTypePool.new
41
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
42
+
43
+ dsl = Tataru::TopDsl.new(pool)
44
+ dsl.instance_eval do
45
+ resource :file, 'somefile'
46
+ resource :file, 'somefile2'
47
+ end
48
+ expect(dsl.dep_graph).to eq( 'somefile' => [], 'somefile2' => [] )
49
+ end
50
+
51
+ it 'has a dependency graph that shows dependency' do
52
+ pool = Tataru::ResourceTypePool.new
53
+ pool.add_resource_desc(:file, Tataru::BaseResourceDesc)
54
+
55
+ allow_any_instance_of(Tataru::BaseResourceDesc).to receive(:mutable_fields) { [:content] }
56
+ allow_any_instance_of(Tataru::BaseResourceDesc).to receive(:output_fields) { [:created_at] }
57
+
58
+ dsl = Tataru::TopDsl.new(pool)
59
+ dsl.instance_eval do
60
+ f = resource :file, 'somefile'
61
+
62
+ resource :file, 'somefile2' do
63
+ content f.created_at
64
+ end
65
+ end
66
+ expect(dsl.dep_graph).to eq( 'somefile' => [], 'somefile2' => ['somefile'] )
67
+ end
68
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'tataru/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ unless spec.respond_to?(:metadata)
9
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host',
10
+ # or delete this section to allow pushing this gem to any host.
11
+ raise <<-ERR
12
+ RubyGems 2.0 or newer is required to protect against public gem pushes.
13
+ ERR
14
+ end
15
+
16
+ spec.name = 'tataru'
17
+ spec.version = Tataru::VERSION
18
+ spec.authors = ['David Siaw']
19
+ spec.email = ['davidsiaw@gmail.com']
20
+
21
+ spec.summary = 'The greatest organizer'
22
+ spec.description = 'Tataru is a DSL for orchestrating the creation of resources'
23
+ spec.homepage = 'https://github.com/davidsiaw/tataru'
24
+ spec.license = 'MIT'
25
+
26
+ spec.metadata['homepage_uri'] = spec.homepage
27
+ spec.metadata['source_code_uri'] = 'https://github.com/davidsiaw/tataru'
28
+ spec.metadata['changelog_uri'] = 'https://github.com/davidsiaw/tataru'
29
+
30
+ spec.files = Dir['{exe,lib,bin}/**/*'] +
31
+ %w[Gemfile tataru.gemspec]
32
+ spec.test_files = Dir['{spec,features}/**/*']
33
+ spec.bindir = 'exe'
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ['lib']
36
+
37
+ spec.add_dependency 'activesupport'
38
+ spec.add_dependency 'bunny-tsort'
39
+
40
+ spec.add_development_dependency 'bundler', '~> 1.9'
41
+ spec.add_development_dependency 'pry-byebug'
42
+ spec.add_development_dependency 'rspec'
43
+
44
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tataru
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
  - David Siaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,69 +44,149 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.17'
47
+ version: '1.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.17'
54
+ version: '1.9'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
83
- description: Sworn upon the name of the receptionist
82
+ version: '0'
83
+ description: Tataru is a DSL for orchestrating the creation of resources
84
84
  email:
85
- - dsiaw@degica.com
85
+ - davidsiaw@gmail.com
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - Rakefile
90
+ - Gemfile
91
+ - bin/console
92
+ - bin/setup
91
93
  - lib/tataru.rb
92
- - lib/tataru/default_resource_finder.rb
93
- - lib/tataru/execution_step.rb
94
+ - lib/tataru/base_resource.rb
95
+ - lib/tataru/base_resource_desc.rb
96
+ - lib/tataru/compiler.rb
97
+ - lib/tataru/create_subroutines.rb
98
+ - lib/tataru/delete_subroutines.rb
99
+ - lib/tataru/flattener.rb
100
+ - lib/tataru/init_hash_compiler.rb
94
101
  - lib/tataru/instruction.rb
95
- - lib/tataru/planner.rb
96
- - lib/tataru/requirements.rb
97
- - lib/tataru/requirements_dsl.rb
98
- - lib/tataru/resource.rb
102
+ - lib/tataru/instruction_hash.rb
103
+ - lib/tataru/instructions/call_instruction.rb
104
+ - lib/tataru/instructions/check_create_instruction.rb
105
+ - lib/tataru/instructions/check_delete_instruction.rb
106
+ - lib/tataru/instructions/check_instruction.rb
107
+ - lib/tataru/instructions/check_update_instruction.rb
108
+ - lib/tataru/instructions/clear_instruction.rb
109
+ - lib/tataru/instructions/compare_instruction.rb
110
+ - lib/tataru/instructions/create_instruction.rb
111
+ - lib/tataru/instructions/delete_instruction.rb
112
+ - lib/tataru/instructions/end_instruction.rb
113
+ - lib/tataru/instructions/goto_if_instruction.rb
114
+ - lib/tataru/instructions/immediate_mode_instruction.rb
115
+ - lib/tataru/instructions/init_instruction.rb
116
+ - lib/tataru/instructions/key_instruction.rb
117
+ - lib/tataru/instructions/mark_deletable_instruction.rb
118
+ - lib/tataru/instructions/read_instruction.rb
119
+ - lib/tataru/instructions/rescmp_instruction.rb
120
+ - lib/tataru/instructions/resource_instruction.rb
121
+ - lib/tataru/instructions/return_instruction.rb
122
+ - lib/tataru/instructions/update_instruction.rb
123
+ - lib/tataru/instructions/value_instruction.rb
124
+ - lib/tataru/instructions/value_rom_instruction.rb
125
+ - lib/tataru/instructions/value_update_instruction.rb
126
+ - lib/tataru/memory.rb
127
+ - lib/tataru/quest.rb
128
+ - lib/tataru/representation.rb
129
+ - lib/tataru/representations/array_representation.rb
130
+ - lib/tataru/representations/hash_representation.rb
131
+ - lib/tataru/representations/literal_representation.rb
132
+ - lib/tataru/representations/output_representation.rb
133
+ - lib/tataru/representations/resource_representation.rb
134
+ - lib/tataru/resolver.rb
99
135
  - lib/tataru/resource_dsl.rb
100
- - lib/tataru/state.rb
136
+ - lib/tataru/resource_type_pool.rb
137
+ - lib/tataru/rom_reader.rb
138
+ - lib/tataru/runner.rb
139
+ - lib/tataru/sub_planner.rb
140
+ - lib/tataru/subroutine_compiler.rb
141
+ - lib/tataru/top_dsl.rb
142
+ - lib/tataru/update_subroutines.rb
101
143
  - lib/tataru/version.rb
144
+ - spec/compiler_spec.rb
145
+ - spec/flattener_spec.rb
146
+ - spec/init_hash_compiler_spec.rb
147
+ - spec/instruction_hash_spec.rb
148
+ - spec/instruction_spec.rb
149
+ - spec/instructions/call_instruction_spec.rb
150
+ - spec/instructions/check_create_instruction_spec.rb
151
+ - spec/instructions/check_delete_instruction_spec.rb
152
+ - spec/instructions/check_update_instruction_spec.rb
153
+ - spec/instructions/clear_instruction_spec.rb
154
+ - spec/instructions/compare_instruction_spec.rb
155
+ - spec/instructions/create_instruction_spec.rb
156
+ - spec/instructions/delete_instruction_spec.rb
157
+ - spec/instructions/end_instruction_spec.rb
158
+ - spec/instructions/goto_if_instruction_spec.rb
159
+ - spec/instructions/init_instruction_spec.rb
160
+ - spec/instructions/key_instruction_spec.rb
161
+ - spec/instructions/mark_deletable_instruction_spec.rb
162
+ - spec/instructions/read_instruction_spec.rb
163
+ - spec/instructions/rescmp_instruction_spec.rb
164
+ - spec/instructions/return_instruction_spec.rb
165
+ - spec/instructions/update_instruction_spec.rb
166
+ - spec/instructions/value_instruction_spec.rb
167
+ - spec/instructions/value_rom_instruction_spec.rb
168
+ - spec/instructions/value_update_instruction_spec.rb
169
+ - spec/quest_spec.rb
170
+ - spec/representations/array_representation_spec.rb
171
+ - spec/representations/hash_representation_spec.rb
172
+ - spec/representations/literal_representation_spec.rb
173
+ - spec/representations/output_representation_spec.rb
174
+ - spec/representations/resource_representation_spec.rb
175
+ - spec/resource_dsl_spec.rb
176
+ - spec/runner_spec.rb
177
+ - spec/spec_helper.rb
178
+ - spec/subroutine_compiler_spec.rb
179
+ - spec/taru_spec.rb
180
+ - spec/top_dsl_spec.rb
181
+ - tataru.gemspec
102
182
  homepage: https://github.com/davidsiaw/tataru
103
183
  licenses:
104
184
  - MIT
105
185
  metadata:
106
- allowed_push_host: https://rubygems.org
107
186
  homepage_uri: https://github.com/davidsiaw/tataru
108
187
  source_code_uri: https://github.com/davidsiaw/tataru
109
188
  changelog_uri: https://github.com/davidsiaw/tataru
189
+ allowed_push_host: https://rubygems.org
110
190
  post_install_message:
111
191
  rdoc_options: []
112
192
  require_paths:
@@ -122,8 +202,46 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
202
  - !ruby/object:Gem::Version
123
203
  version: '0'
124
204
  requirements: []
125
- rubygems_version: 3.0.3
205
+ rubyforge_project:
206
+ rubygems_version: 2.7.8
126
207
  signing_key:
127
208
  specification_version: 4
128
- summary: Task planner
129
- test_files: []
209
+ summary: The greatest organizer
210
+ test_files:
211
+ - spec/quest_spec.rb
212
+ - spec/init_hash_compiler_spec.rb
213
+ - spec/flattener_spec.rb
214
+ - spec/instruction_hash_spec.rb
215
+ - spec/resource_dsl_spec.rb
216
+ - spec/instruction_spec.rb
217
+ - spec/taru_spec.rb
218
+ - spec/subroutine_compiler_spec.rb
219
+ - spec/instructions/mark_deletable_instruction_spec.rb
220
+ - spec/instructions/rescmp_instruction_spec.rb
221
+ - spec/instructions/read_instruction_spec.rb
222
+ - spec/instructions/goto_if_instruction_spec.rb
223
+ - spec/instructions/check_update_instruction_spec.rb
224
+ - spec/instructions/init_instruction_spec.rb
225
+ - spec/instructions/check_create_instruction_spec.rb
226
+ - spec/instructions/create_instruction_spec.rb
227
+ - spec/instructions/check_delete_instruction_spec.rb
228
+ - spec/instructions/compare_instruction_spec.rb
229
+ - spec/instructions/update_instruction_spec.rb
230
+ - spec/instructions/end_instruction_spec.rb
231
+ - spec/instructions/delete_instruction_spec.rb
232
+ - spec/instructions/return_instruction_spec.rb
233
+ - spec/instructions/value_update_instruction_spec.rb
234
+ - spec/instructions/value_rom_instruction_spec.rb
235
+ - spec/instructions/clear_instruction_spec.rb
236
+ - spec/instructions/call_instruction_spec.rb
237
+ - spec/instructions/value_instruction_spec.rb
238
+ - spec/instructions/key_instruction_spec.rb
239
+ - spec/top_dsl_spec.rb
240
+ - spec/spec_helper.rb
241
+ - spec/runner_spec.rb
242
+ - spec/compiler_spec.rb
243
+ - spec/representations/array_representation_spec.rb
244
+ - spec/representations/output_representation_spec.rb
245
+ - spec/representations/literal_representation_spec.rb
246
+ - spec/representations/hash_representation_spec.rb
247
+ - spec/representations/resource_representation_spec.rb
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tataru
4
- # finds resource classes
5
- class DefaultResourceFinder
6
- def resource_named(name)
7
- Kernel.const_get("Tataru::Resources::#{name.to_s.camelize}Resource")
8
- end
9
- end
10
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tataru
4
- # An execution step
5
- class ExecutionStep
6
- def initialize(state, instruction)
7
- @state = state
8
- @instruction = instruction
9
- @instances = {}
10
- end
11
-
12
- def id
13
- @instruction.id
14
- end
15
-
16
- def rf
17
- @instruction.requirements.resource_finder
18
- end
19
-
20
- def type_of_id
21
- @instruction.requirements.type(id)
22
- end
23
-
24
- def class_of_id
25
- rf.resource_named(type_of_id)
26
- end
27
-
28
- def instance_of_id
29
- @instances[id] ||= class_of_id.new
30
- end
31
-
32
- def execute
33
- return execute_begin! if @instruction.action.to_s.start_with?('begin_')
34
-
35
- execute_wait!
36
- end
37
-
38
- def overall_action
39
- @instruction.action.to_s.split('_')[1].to_sym
40
- end
41
-
42
- def execute_begin!
43
- instance_of_id.send(@instruction.action, @state)
44
- [send(:"begin_#{overall_action}"), true]
45
- end
46
-
47
- def begin_create
48
- new_state = @state.clone
49
- replacer = true
50
- replacer = false if new_state[id].nil?
51
-
52
- @instruction.state.each do |name, value|
53
- new_state.putstate(id, name, value, replacer: replacer)
54
- end
55
- new_state.waiting_on(id, overall_action)
56
- new_state
57
- end
58
-
59
- def begin_delete
60
- begin_update
61
- end
62
-
63
- def begin_update
64
- new_state = @state.clone
65
- new_state.waiting_on(id, overall_action)
66
- new_state
67
- end
68
-
69
- def execute_wait!
70
- new_state = @state.clone
71
- success = instance_of_id.send(:"#{overall_action}_complete?", @state)
72
- if success
73
- new_state.no_longer_waiting(id)
74
- new_state.replace(id) if overall_action == :delete
75
- end
76
- [new_state, success]
77
- end
78
- end
79
- end