stuka 0.0.12 → 0.1.0

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stuka/commands/public_commands/setup_command.rb +1 -0
  3. data/lib/stuka/commands/subcommands/create/create_project.rb +1 -0
  4. data/lib/stuka/commands/subcommands/setup/setup_config.rb +21 -0
  5. data/lib/stuka/commands/subcommands/setup/setup_directories.rb +6 -5
  6. data/lib/stuka/commands/subcommands/setup/setup_gemfile.rb +2 -2
  7. data/lib/stuka/commands/subcommands/setup/setup_rakefile.rb +1 -1
  8. data/lib/stuka/config/stuka_paths.rb +109 -0
  9. data/lib/stuka/config/template_config.rb +59 -0
  10. data/lib/stuka/external/action_finder.rb +9 -7
  11. data/lib/stuka/external/business_action.rb +7 -4
  12. data/lib/stuka/external/business_process.rb +17 -13
  13. data/lib/stuka/external/dispatcher.rb +1 -1
  14. data/lib/stuka/external/process_states/finished_state.rb +1 -1
  15. data/lib/stuka/external/process_states/inactive_state.rb +3 -3
  16. data/lib/stuka/external/process_states/started_state.rb +7 -6
  17. data/lib/stuka/external/unknown_action.rb +1 -1
  18. data/lib/stuka/internal/domain/action.rb +16 -3
  19. data/lib/stuka/internal/domain/process.rb +32 -9
  20. data/lib/stuka/internal/domain_builders/action_domain_builder.rb +5 -1
  21. data/lib/stuka/internal/domain_builders/domain_builder.rb +1 -1
  22. data/lib/stuka/internal/process_cleaner.rb +3 -7
  23. data/lib/stuka/internal/source_builders/action_builder.rb +77 -7
  24. data/lib/stuka/internal/source_builders/process_builder.rb +29 -5
  25. data/lib/stuka/monkeypatch/string_patch.rb +12 -0
  26. data/lib/stuka/templates/configs/stuka_config.tt +11 -0
  27. data/lib/stuka/templates/samples/process_file.tt +39 -0
  28. data/lib/stuka/templates/source/action.tt +5 -5
  29. data/lib/stuka/templates/source/action_header.tt +8 -0
  30. data/lib/stuka/templates/source/process.tt +10 -17
  31. data/lib/stuka/templates/source/process_header.tt +8 -0
  32. data/lib/stuka/templates/tasks/stuka.tt +28 -20
  33. data/lib/stuka/version.rb +1 -1
  34. data/lib/stuka.rb +6 -0
  35. data/spec/aceptance/commands/process_command_spec.rb +3 -3
  36. data/spec/aceptance/external/action_aceptance_spec.rb +2 -2
  37. data/spec/aceptance/external/actions/cat/check_food.rb +16 -0
  38. data/spec/aceptance/external/actions/cat/fill_up_plate.rb +16 -0
  39. data/spec/aceptance/external/actions/cat/go_to_store.rb +16 -0
  40. data/spec/aceptance/external/feed_cat_process_aceptance_spec.rb +15 -14
  41. data/spec/aceptance/external/processes/feed_cat_process.rb +13 -14
  42. data/spec/spec_helper.rb +2 -1
  43. data/spec/unit/external/example_source/{world → actions/world}/gather_materials.rb +1 -1
  44. data/spec/unit/external/example_source/{world → actions/world}/scrap_world.rb +1 -1
  45. data/spec/unit/external/example_source/{world → actions/world}/seperate_light_from_darkness.rb +1 -1
  46. data/spec/unit/external/example_source/processes/create_world.rb +29 -0
  47. data/spec/unit/external/example_source/processes/kill_monster.rb +39 -0
  48. data/spec/unit/external/finder_spec.rb +8 -8
  49. data/spec/unit/external/process_to_dispatcher_spec.rb +3 -2
  50. data/spec/unit/external/process_to_finder_spec.rb +35 -17
  51. data/spec/unit/internal/action_builder_spec.rb +76 -6
  52. data/spec/unit/internal/action_domain_builder_spec.rb +8 -2
  53. data/spec/unit/internal/process_builder_spec.rb +18 -14
  54. data/spec/unit/internal/process_domain_builder_spec.rb +1 -1
  55. data/spec/unit/internal/processes_dsl_test/correct_test_process.rb +39 -19
  56. data/stuka.gemspec +1 -1
  57. metadata +27 -22
  58. data/lib/stuka/external/process_states/starting_state.rb +0 -16
  59. data/lib/stuka/paths/stuka_paths.rb +0 -18
  60. data/lib/stuka/templates/samples/my_process.tt +0 -19
  61. data/spec/aceptance/external/processes/cat/check_food.rb +0 -14
  62. data/spec/aceptance/external/processes/cat/fill_up_plate.rb +0 -14
  63. data/spec/aceptance/external/processes/cat/go_to_store.rb +0 -14
  64. data/spec/unit/external/example_source/create_world.rb +0 -28
  65. data/spec/unit/external/example_source/kill_monster.rb +0 -38
@@ -1,32 +1,102 @@
1
1
  require 'stuka/internal/domain_builders/action_domain_builder'
2
2
  require 'stuka/internal/source_builders/source_builder'
3
+ require 'stuka/monkeypatch/string_patch'
4
+ require 'tempfile'
5
+ require 'stuka/config/template_config'
3
6
 
4
7
  module Stuka
5
8
 
6
9
  class ActionBuilder < SourceBuilder
7
10
 
8
- def self.build
11
+ def self.build(stream)
9
12
 
10
13
  adb = ActionDomainBuilder.new
11
14
  adb.build_domain
12
15
 
16
+ template_file_header = "#{templates_path}/source/action_header.tt"
13
17
  template_file = "#{templates_path}/source/action.tt"
14
- renderer = ERB.new(File.read(template_file))
15
18
 
16
- FileUtils.mkdir_p Stuka::StukaPaths::PROCESSES_SOURCE_PATH
19
+ FileUtils.mkdir_p Stuka::StukaPaths.actions_source_path
17
20
 
18
21
  adb.instances.each do |acc|
19
- out_file = File.new("#{source_path}/#{acc.name}_action.rb", "w")
20
- out_file.puts(renderer.result(acc.get_binding))
22
+ action_file_path = "#{source_path}/#{acc.namespace}"
23
+ FileUtils.mkdir_p action_file_path
24
+
25
+ if File.file?("#{action_file_path}/#{acc.name}.rb")
26
+ stream.puts "action file #{acc.namespace}::#{acc.name} already exists."
27
+ next
28
+ end
29
+
30
+ # generate action header
31
+ action_string = ERB.new(File.read(template_file_header)).result(acc.get_binding)
32
+
33
+ # generate namespace modules
34
+ modules = Stuka::TemplateConfig.action_module_namespaces
35
+ modules.each_with_index do |mod, index|
36
+ action_string += ("\t" * index)
37
+ action_string += "module #{mod}\n"
38
+ end
39
+
40
+ action_class = ERB.new(File.read(template_file)).result(acc.get_binding)
41
+
42
+ # generate action class with tabs
43
+ action_class.lines.each do |line|
44
+ action_string += ("\t" * modules.count)
45
+ action_string += line
46
+ end
47
+
48
+ # generate module ends
49
+ modules.each_with_index do |mod, index|
50
+ action_string += ("\t" * (modules.count - index - 1))
51
+ action_string += "end\n"
52
+ end
53
+
54
+ # generate end file
55
+ out_file = File.new("#{source_path}/#{acc.namespace}/#{acc.name}.rb", "w")
56
+ out_file.puts(action_string)
21
57
  out_file.close
58
+
22
59
  end
23
60
 
24
61
  end
25
62
 
26
63
  def self.source_path
27
- Stuka::StukaPaths::PROCESSES_SOURCE_PATH
64
+ Stuka::StukaPaths.actions_source_path
65
+ end
66
+
67
+ private
68
+
69
+ def self.refresh_action_file(path, action, renderer)
70
+ temp_file = Tempfile.new('foo')
71
+ begin
72
+ File.open(path, 'r') do |file|
73
+ implementation = ""
74
+ is_in_implement_section = false
75
+ file.each_line do |line|
76
+ if is_in_implement_section
77
+ if line.strip.start_with? "## END_IMPLEMENTATION"
78
+ is_in_implement_section = false
79
+ next
80
+ end
81
+ implementation += line
82
+ else
83
+ is_in_implement_section = true if line.strip.start_with? "## IMPLEMENTATION"
84
+ end
85
+ end
86
+
87
+ action.implementation = implementation
88
+ temp_file.puts(renderer.result(action.get_binding))
89
+
90
+ end
91
+
92
+ FileUtils.mv(temp_file.path, path)
93
+
94
+ ensure
95
+ temp_file.close
96
+ temp_file.unlink
97
+ end
28
98
  end
29
99
 
30
100
  end
31
101
 
32
- end
102
+ end
@@ -1,6 +1,7 @@
1
1
  require 'stuka/internal/domain_builders/process_domain_builder'
2
2
  require 'stuka/internal/validator'
3
3
  require 'stuka/internal/source_builders/source_builder'
4
+ require 'stuka/monkeypatch/string_patch'
4
5
 
5
6
  module Stuka
6
7
 
@@ -13,24 +14,47 @@ module Stuka
13
14
  validator = Stuka::Validator.new
14
15
  raise validator.message unless validator.process_set_valid? pdb.instances
15
16
 
17
+ template_file_header = "#{templates_path}/source/process_header.tt"
16
18
  template_file = "#{templates_path}/source/process.tt"
17
- renderer = ERB.new(File.read(template_file))
18
19
 
19
20
  FileUtils.mkdir_p source_path
20
21
 
21
- #raise pdb.instances.to_s
22
-
23
22
  pdb.instances.each do |proc|
24
23
  raise validator.message unless validator.process_valid? proc
24
+
25
+ # generate action header
26
+ process_string = ERB.new(File.read(template_file_header)).result(proc.get_binding)
27
+
28
+ # generate namespace modules
29
+ modules = Stuka::TemplateConfig.process_module_namespaces
30
+ modules.each_with_index do |mod, index|
31
+ process_string += ("\t" * index)
32
+ process_string += "module #{mod}\n"
33
+ end
34
+
35
+ process_class = ERB.new(File.read(template_file)).result(proc.get_binding)
36
+
37
+ # generate action class with tabs
38
+ process_class.lines.each do |line|
39
+ process_string += ("\t" * modules.count)
40
+ process_string += line
41
+ end
42
+
43
+ # generate module ends
44
+ modules.each_with_index do |mod, index|
45
+ process_string += ("\t" * (modules.count - index - 1))
46
+ process_string += "end\n"
47
+ end
48
+
25
49
  out_file = File.new("#{source_path}/#{proc.name}.rb", "w")
26
- out_file.puts(renderer.result(proc.get_binding))
50
+ out_file.puts(process_string)
27
51
  out_file.close
28
52
  end
29
53
 
30
54
  end
31
55
 
32
56
  def self.source_path
33
- Stuka::StukaPaths::PROCESSES_SOURCE_PATH
57
+ Stuka::StukaPaths.processes_source_path
34
58
  end
35
59
 
36
60
  end
@@ -0,0 +1,12 @@
1
+ unless "foo_bar".respond_to? :camelcase_notation
2
+
3
+ class String
4
+
5
+ def camelcase_notation
6
+ return self if self !~ /_/ && self =~ /[A-Z]+.*/
7
+ split('_').map{|e| e.capitalize}.join
8
+ end
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ module StukaConfig
2
+
3
+ ProcessDefinitionPath = "process_definition"
4
+ ProcessSourcePath = "lib/processes"
5
+ ActionSourcePath = "lib/actions"
6
+
7
+ ActionModuleNamespaces = ["Actions"]
8
+ ProcessModuleNamespaces = ["Processes"]
9
+ AddRequires = false
10
+
11
+ end
@@ -0,0 +1,39 @@
1
+ ##
2
+ #
3
+ # process "some_process" do
4
+ #
5
+ # description "description of a process
6
+ # should be concise and long enaugh for
7
+ # new people to understand what the process does."
8
+ #
9
+ # start_action "sample::action1"
10
+ #
11
+ # action_ending "sample::action1",
12
+ # success: "sample::action2",
13
+ # failure: "process::failure"
14
+ #
15
+ # action_ending "sample::action2",
16
+ # success: "process::success",
17
+ # failure: "process::failure"
18
+ #
19
+ # end
20
+ #
21
+ # action "action1" do
22
+ #
23
+ # description "the namespace is the name of the folder
24
+ # under which this action will be placed in the filesystem.
25
+ # 'process' is a reserved namespace used for sending messages to process"
26
+ #
27
+ # namespace "sample"
28
+ # end
29
+ #
30
+ # action "action2" do
31
+ #
32
+ # description <<-DESC
33
+ # all actions used in the process
34
+ # must be defined, if an action is missing the stuka:build task will not pass"
35
+ # DESC
36
+ #
37
+ # namespace "sample"
38
+ # end
39
+ #
@@ -1,9 +1,9 @@
1
- module <%= @namespace.capitalize %>
2
- class <%= @name.capitalize %>Action
1
+ module <%= @namespace.camelcase_notation %>
2
+ class <%= @name.camelcase_notation %> < Stuka::External::BusinessAction
3
3
 
4
- def initialize params, options = {}
5
- @params = params
4
+ def run(params)
5
+ # knock yourself out
6
6
  end
7
7
 
8
8
  end
9
- end
9
+ end
@@ -0,0 +1,8 @@
1
+ ##<% @description.split("\n").each do |description_line| %><% require "stuka/config/template_config" %>
2
+ # <%= description_line.strip %> <% end %>
3
+ #
4
+ #
5
+ <% if TemplateConfig.add_require_statements %>
6
+ require "stuka/external/business_action"
7
+ <% end %>
8
+
@@ -1,23 +1,16 @@
1
- require 'stuka/external/business_process'
1
+ class <%= @name.camelcase_notation %> < Stuka::External::BusinessProcess
2
2
 
3
- class <%= @name.capitalize %> < Stuka::BusinessProcess
4
-
5
- TRANSITION_MAP = {
6
- <% @transitions.keys.each do |action| %>
7
- "<%= action %>" => {
8
- <% @transitions[action].keys.each do |action_transition| %>
9
- <%= action_transition %>: "<%= @transitions[action][action_transition] %>",
3
+ Blocks = {
4
+ <% @blocks.each do |block| %>
5
+ "<%= block.block_name %>" => {
6
+ action: "<%= block.action_name %>",
7
+ <% block.block_endings.each do |block_ending, next_block| %><%= block_ending %>: "<%= next_block %>",
10
8
  <% end %>
11
- },
12
- <% end %>
9
+ },<% end %>
13
10
  }
14
11
 
15
- def transition_map
16
- TRANSITION_MAP
17
- end
18
-
19
- def start_action
20
- "<%= @start_action %>"
12
+ def start_block
13
+ "<%= @start_block %>"
21
14
  end
22
15
 
23
- end
16
+ end
@@ -0,0 +1,8 @@
1
+ ##<% @description.split("\n").each do |description_line| %><% require "stuka/config/template_config" %>
2
+ # <%= description_line.strip %> <% end %>
3
+ #
4
+ #
5
+ <% if TemplateConfig.add_require_statements %>
6
+ require "stuka/external/business_process"
7
+ <% end %>
8
+
@@ -1,28 +1,36 @@
1
- task :clean do
2
-
3
- puts "running clean"
4
- require 'stuka/internal/process_cleaner'
5
- Stuka::ProcessCleaner.clean
6
- puts "clean finished"
1
+ namespace :stuka do
7
2
 
8
- end
3
+ desc "deletes all process files"
4
+ task :clean do
5
+
6
+ puts "running clean"
7
+ require 'stuka/internal/process_cleaner'
8
+ Stuka::ProcessCleaner.clean
9
+ puts "clean finished"
9
10
 
10
- task :build_processes do
11
+ end
11
12
 
12
- puts "running build processes"
13
- require 'stuka/internal/source_builders/process_builder'
14
- Stuka::ProcessBuilder.build
15
- puts "build processes finished"
13
+ desc "builds process files"
14
+ task :build_processes do
16
15
 
17
- end
16
+ puts "running build processes"
17
+ require 'stuka/internal/source_builders/process_builder'
18
+ Stuka::ProcessBuilder.build
19
+ puts "build processes finished"
18
20
 
19
- task :build_actions do
21
+ end
20
22
 
21
- puts "running build actions"
22
- require 'stuka/internal/source_builders/action_builder'
23
- Stuka::ActionBuilder.build
24
- puts "build actions finished"
23
+ desc "builds action files"
24
+ task :build_actions do
25
25
 
26
- end
26
+ puts "running build actions"
27
+ require 'stuka/internal/source_builders/action_builder'
28
+ Stuka::ActionBuilder.build($stdout)
29
+ puts "build actions finished"
27
30
 
28
- task :build => [:clean, :build_processes, :build_actions]
31
+ end
32
+
33
+ desc "cleans process files, builds/updates action files"
34
+ task :build => [:clean, :build_processes, :build_actions]
35
+
36
+ end
data/lib/stuka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stuka
2
- VERSION = "0.0.12"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/stuka.rb CHANGED
@@ -1 +1,7 @@
1
1
  require_relative "stuka/version"
2
+
3
+ require 'stuka/external/action_finder'
4
+ require 'stuka/external/business_action'
5
+ require 'stuka/external/business_process'
6
+ require 'stuka/external/dispatcher'
7
+ require 'stuka/external/unknown_action'
@@ -12,10 +12,10 @@ describe "process file command" do
12
12
 
13
13
  it "sets up the project" do
14
14
  Dir.chdir "test_pro" do
15
- expect { Stuka::StukaCli.start ["process", "test_process"] }.to output(%r|Process file 'test_process.rb' created|).to_stdout
15
+ expect { Stuka::StukaCli.start ["process", "test_process"] }.to output(%r|create process_definition/business/test_process.rb|).to_stdout
16
16
 
17
- definition_files = Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/**/*.rb"]
18
- expect { definition_files.to include("#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/test_process.rb}") }
17
+ definition_files = Dir["#{Stuka::StukaPaths.processes_definition_path}/**/*.rb"]
18
+ expect { definition_files.to include("#{Stuka::StukaPaths.processes_definition_path}/test_process.rb}") }
19
19
  end
20
20
  end
21
21
 
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
  require "stuka/external/business_action"
3
- require_relative 'processes/cat/check_food'
3
+ require_relative 'actions/cat/check_food'
4
4
 
5
5
  describe "CheckFood" do
6
6
 
7
7
  let(:process) { double(transition: nil, can_transition_to?: true) }
8
8
  let(:outstream) { StringIO.new }
9
- let(:action) { Cat::CheckFood.new(process) }
9
+ let(:action) { Actions::Cat::CheckFood.new(process) }
10
10
 
11
11
  after :each do
12
12
  outstream.close
@@ -0,0 +1,16 @@
1
+ require "stuka/external/business_action"
2
+
3
+ module Actions
4
+ module Cat
5
+
6
+ class CheckFood < Stuka::External::BusinessAction
7
+
8
+ def run(params)
9
+ params[:outstream].puts "There is enaugh food"
10
+ has_food(params)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "stuka/external/business_action"
2
+
3
+ module Actions
4
+ module Cat
5
+
6
+ class FillUpPlate < Stuka::External::BusinessAction
7
+
8
+ def run(params)
9
+ params[:outstream].puts "#{params[:name]}'s food plate filled up"
10
+ success(params)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "stuka/external/business_action"
2
+
3
+ module Actions
4
+ module Cat
5
+
6
+ class GoToStore < Stuka::External::BusinessAction
7
+
8
+ def run(params)
9
+ params[:outstream].puts "went to store"
10
+ success(params)
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -6,21 +6,12 @@ describe "Feed cat process" do
6
6
 
7
7
  before :each do
8
8
  Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace "#{File.dirname(__FILE__)}/processes"
9
+ Stuka::StukaPaths::ACTIONS_SOURCE_PATH.replace "#{File.dirname(__FILE__)}/actions"
9
10
  end
10
11
 
11
12
  let(:process) do
12
13
 
13
- FeedCatProcess.new({}) do |on|
14
-
15
- on.success { |params|
16
- params[:outstream].puts "yay success"
17
- }
18
-
19
- on.failure { |params|
20
- params[:outstream].puts "nay failure"
21
- }
22
-
23
- end
14
+ FeedCatProcess.new({})
24
15
 
25
16
  end
26
17
 
@@ -32,11 +23,21 @@ describe "Feed cat process" do
32
23
 
33
24
  it "process starts executing actions when it ran" do
34
25
 
35
- expect(process.current_state).to eq(Stuka::BusinessProcess::PROCESS_STATES[:inactive])
26
+ expect(process.current_state).to eq(Stuka::External::BusinessProcess::PROCESS_STATES[:inactive])
36
27
 
37
- process.run({name: "George", outstream: outstream})
28
+ process.run({name: "George", outstream: outstream}) do |on|
29
+
30
+ on.success { |params|
31
+ params[:outstream].puts "yay success"
32
+ }
33
+
34
+ on.failure { |params|
35
+ params[:outstream].puts "nay failure"
36
+ }
37
+
38
+ end
38
39
 
39
- expect(process.current_state).to eq(Stuka::BusinessProcess::PROCESS_STATES[:finished])
40
+ expect(process.current_state).to eq(Stuka::External::BusinessProcess::PROCESS_STATES[:finished])
40
41
 
41
42
  expect(outstream.string).to include "There is enaugh food\nGeorge's food plate filled up\nyay success\n"
42
43
 
@@ -1,28 +1,27 @@
1
1
  require "stuka/external/business_process"
2
2
 
3
- class FeedCatProcess < Stuka::BusinessProcess
3
+ class FeedCatProcess < Stuka::External::BusinessProcess
4
4
 
5
- TRANSITION_MAP = {
6
- "cat::check_food" => {
7
- has_food: "cat::fill_up_plate",
8
- no_food: "cat::go_to_store"
5
+ Blocks = {
6
+ "check_food" => {
7
+ action: "cat::check_food",
8
+ has_food: "fill_up_plate",
9
+ no_food: "go_to_store"
9
10
  },
10
- "cat::fill_up_plate" => {
11
+ "fill_up_plate" => {
12
+ action: "cat::fill_up_plate",
11
13
  success: "process::success",
12
14
  failure: "process::failure"
13
15
  },
14
- "cat::go_to_store" => {
15
- success: "cat::fill_up_plate",
16
+ "go_to_store" => {
17
+ action: "cat::go_to_store",
18
+ success: "fill_up_plate",
16
19
  failure: "process::failure"
17
20
  }
18
21
  }
19
22
 
20
- def transition_map
21
- TRANSITION_MAP
22
- end
23
-
24
- def start_action
25
- "cat::check_food"
23
+ def start_block
24
+ "check_food"
26
25
  end
27
26
 
28
27
  end
data/spec/spec_helper.rb CHANGED
@@ -19,9 +19,10 @@ RSpec.configure do |config|
19
19
  # with RSpec, but feel free to customize to your heart's content.
20
20
 
21
21
  config.before(:each) do
22
- require "stuka/paths/stuka_paths"
22
+ require "stuka/config/stuka_paths"
23
23
  Stuka::StukaPaths::PROCESSES_DEFINITION_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_DEFINITION_PATH
24
24
  Stuka::StukaPaths::PROCESSES_SOURCE_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH
25
+ Stuka::StukaPaths::ACTIONS_SOURCE_PATH.replace Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH
25
26
  end
26
27
 
27
28
  original_stdout = $stdout
@@ -2,7 +2,7 @@ require "stuka/external/business_action"
2
2
 
3
3
  module World
4
4
 
5
- class GatherMaterials < Stuka::BusinessAction
5
+ class GatherMaterials < Stuka::External::BusinessAction
6
6
 
7
7
  def run(params = {})
8
8
  success(params)
@@ -2,7 +2,7 @@ require "stuka/external/business_action"
2
2
 
3
3
  module World
4
4
 
5
- class ScrapWorld < Stuka::BusinessAction
5
+ class ScrapWorld < Stuka::External::BusinessAction
6
6
 
7
7
  def run(params = {})
8
8
  success(params)
@@ -2,7 +2,7 @@ require "stuka/external/business_action"
2
2
 
3
3
  module World
4
4
 
5
- class SeperateLightFromDarkness < Stuka::BusinessAction
5
+ class SeperateLightFromDarkness < Stuka::External::BusinessAction
6
6
 
7
7
  def run(params = {})
8
8
  failure(params)
@@ -0,0 +1,29 @@
1
+ require "stuka/external/business_process"
2
+
3
+ class CreateWorld < Stuka::External::BusinessProcess
4
+
5
+ Blocks = {
6
+ "gather_materials" => {
7
+ action: "world::gather_materials",
8
+ success: "seperate_light_from_dark",
9
+ failure: "scrap_world"
10
+ },
11
+
12
+ "seperate_light_from_dark" => {
13
+ action: "world::seperate_light_from_darkness",
14
+ success: "process::success",
15
+ failure: "scrap_world"
16
+ },
17
+
18
+ "scrap_world" => {
19
+ action: "world::scrap_world",
20
+ success: "process::failure",
21
+ failure: "process::failure"
22
+ }
23
+ }
24
+
25
+ def start_block
26
+ "gather_materials"
27
+ end
28
+
29
+ end
@@ -0,0 +1,39 @@
1
+ require "stuka/external/business_process"
2
+
3
+ class KillMonster < Stuka::External::BusinessProcess
4
+
5
+ Blocks = {
6
+ "train_hard" => {
7
+ action: "monster::train_hard",
8
+ good_with_sword: "get_a_sharp_sword",
9
+ sharp_shooter: "get_a_new_gun",
10
+ failure: "train_fast_running"
11
+ },
12
+ "get_a_sharp_sword" => {
13
+ action: "monster::get_a_sharp_sword",
14
+ success: "process::success",
15
+ failure: "process::failure"
16
+ },
17
+ "get_a_new_gun" => {
18
+ action: "monster::get_a_new_gun",
19
+ success: "get_bullets",
20
+ failure: "process::failure"
21
+ },
22
+ "get_bullets" => {
23
+ action: "gun::get_bullets",
24
+ success: "process::success",
25
+ failure: "process::failure"
26
+ },
27
+ "train_fast_running" => {
28
+ action: "monster::train_fast_running",
29
+ success: "process::success",
30
+ failure: "process::failure"
31
+ }
32
+
33
+ }
34
+
35
+ def start_block
36
+ "train_hard"
37
+ end
38
+
39
+ end