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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 738c5a4d28001bffdd43fcbdba89ce68a44528d7
4
- data.tar.gz: a76a4a54f9b98695afced640b51046e5c0b6e081
3
+ metadata.gz: 534bd888be61a7665ca241765836aaf7d2d7acf2
4
+ data.tar.gz: 76ab2e3e41b43fd8d9ae8b7e0be584777b31124b
5
5
  SHA512:
6
- metadata.gz: f3467f86ec952c25d98f6e367dfd3d0df4410bfaf07036674690f82eafee07b5a20f266ab81a0d5cbcf8b724475780108054f0ddb3a17388197ba8950add9dbb
7
- data.tar.gz: 45d73c21e3345718d21e9b7fb0a42a9b281213aaca07bb090484f36a606481c25ebcbc1f8fe368b805329266548be28106c6fd55cca9e43d809b982f2743e247
6
+ metadata.gz: 3f0bc41ffabaedd6dcdc1bd7dece3b413756fc0c182d8ac6544398a3bde64daacabf1b15c7bc14bd30d50192a8ff08b85c6e8f28c942b8cd3c073f449a81ceaa
7
+ data.tar.gz: 645e85427de5fff7f65ff95310e1fe0164d0e1309a921c867faefcc8e59aaab60dd0bd629a98252e5b5b3c6e8466edd4d5428eaa5b6d446212ffbcc93de10f6e
@@ -6,6 +6,7 @@ module Stuka
6
6
  class SetupCommand < Command
7
7
 
8
8
  def execute
9
+ Stuka::SetupConfig.new.setup
9
10
  Stuka::SetupDirectories.new.setup
10
11
  Stuka::SetupGemfile.new.setup
11
12
  Stuka::SetupRakefile.new.setup
@@ -20,6 +20,7 @@ module Stuka
20
20
 
21
21
  def setup(name)
22
22
  Dir.chdir(name) do
23
+ SetupConfig.new.setup
23
24
  SetupDirectories.new.setup
24
25
  SetupGemfile.new.setup
25
26
  SetupRakefile.new.setup
@@ -0,0 +1,21 @@
1
+ require_relative "../../command"
2
+
3
+ module Stuka
4
+
5
+ class SetupConfig < Command
6
+
7
+ def setup
8
+ config_exists = File.file?("#{Dir.pwd}/stuka_config.rb")
9
+
10
+ if config_exists
11
+ say("\tConfig already setup")
12
+ return
13
+ end
14
+
15
+ template('templates/configs/stuka_config.tt', "stuka_config.rb")
16
+ say("\tconfig file (stuka_config.rb) setup")
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative "../../command"
2
+ require 'stuka/config/stuka_paths'
2
3
  require 'fileutils'
3
4
 
4
5
  module Stuka
@@ -6,16 +7,16 @@ module Stuka
6
7
  class SetupDirectories < Command
7
8
 
8
9
  def setup
9
- processes_dir_exists = File.directory?("#{Dir.pwd}/process_definition/processes")
10
+ processes_dir_exists = File.directory?("#{Dir.pwd}/#{StukaPaths.relative_processes_source_path}")
10
11
 
11
12
  if processes_dir_exists
12
- say("Stuka dsl source directories are already setup")
13
+ say("\tStuka dsl source directories are already setup")
13
14
  return
14
15
  end
15
16
 
16
- FileUtils.mkdir_p "process_definition"
17
-
18
- say("Source directories setup")
17
+ FileUtils.mkdir_p "processes_definition"
18
+ template('templates/samples/process_file.tt', "processes_definition/process_file.rb")
19
+ say("\tSource directories setup")
19
20
 
20
21
  end
21
22
 
@@ -8,12 +8,12 @@ module Stuka
8
8
  gemfile_exists = File.file?("#{Dir.pwd}/Gemfile")
9
9
 
10
10
  if gemfile_exists
11
- say("Gemfile already setup")
11
+ say("\tGemfile already setup")
12
12
  return
13
13
  end
14
14
 
15
15
  template('templates/configs/gemfile.tt', "Gemfile")
16
- say("Gemfile setup, run bundle or bundle install --path vendor/bundle")
16
+ say("\tGemfile setup, run bundle or bundle install --path vendor/bundle")
17
17
  end
18
18
 
19
19
  end
@@ -12,7 +12,7 @@ module Stuka
12
12
  return
13
13
  end
14
14
 
15
- template('templates/tasks/stuka.tt', "lib/stuka.rake")
15
+ template('templates/tasks/stuka.tt', "lib/tasks/stuka.rake")
16
16
  end
17
17
 
18
18
  end
@@ -0,0 +1,109 @@
1
+ module Stuka
2
+
3
+ module StukaPaths
4
+
5
+ RescuableExceptions = [LoadError, NameError]
6
+
7
+ def self.processes_definition_path
8
+
9
+ config_definition_path = get_config_item("PROCESS_DEFINITION_PATH")
10
+
11
+ if config_definition_path
12
+ return "#{Dir.pwd}/#{config_definition_path}"
13
+ else
14
+ PROCESSES_DEFINITION_PATH
15
+ end
16
+
17
+ end
18
+
19
+ def self.processes_source_path
20
+
21
+ config_source_path = get_config_item("PROCESS_SOURCE_PATH")
22
+
23
+ if config_source_path
24
+ return "#{Dir.pwd}/#{config_source_path}"
25
+ else
26
+ PROCESSES_SOURCE_PATH
27
+ end
28
+
29
+ end
30
+
31
+ def self.actions_source_path
32
+
33
+ config_source_path = get_config_item("ACTIONS_SOURCE_PATH")
34
+
35
+ if config_source_path
36
+ return "#{Dir.pwd}/#{config_source_path}"
37
+ else
38
+ ACTIONS_SOURCE_PATH
39
+ end
40
+
41
+ end
42
+
43
+ def self.relative_processes_definition_path
44
+
45
+ config_item = get_config_item("ProcessDefinitionPath")
46
+
47
+ if config_item
48
+ return config_item
49
+ else
50
+ RELATIVE_PROCESSES_DEFINITION_PATH
51
+ end
52
+
53
+ end
54
+
55
+ def self.relative_processes_source_path
56
+
57
+ config_item = get_config_item("ProcessSourcePath")
58
+
59
+ if config_item
60
+ return config_item
61
+ else
62
+ RELATIVE_PROCESSES_SOURCE_PATH
63
+ end
64
+
65
+ end
66
+
67
+ def self.relative_actions_source_path
68
+
69
+ config_item = get_config_item("ActionSourcePath")
70
+
71
+ if config_item
72
+ return config_item
73
+ else
74
+ RELATIVE_ACTIONS_SOURCE_PATH
75
+ end
76
+
77
+ end
78
+
79
+ def self.get_config_item(name)
80
+ begin
81
+ require_relative "#{Dir.pwd}/stuka_config"
82
+ return StukaConfig.const_get(name)
83
+ rescue *RescuableExceptions
84
+ return false
85
+ end
86
+ end
87
+
88
+ #defaults
89
+
90
+ PROCESSES_DEFINITION_PATH = "#{Dir.pwd}/processes_definition"
91
+
92
+ PROCESSES_SOURCE_PATH = "#{Dir.pwd}/lib/processes"
93
+ ACTIONS_SOURCE_PATH = "#{Dir.pwd}/lib/actions"
94
+
95
+ RELATIVE_PROCESSES_DEFINITION_PATH = "processes_definition"
96
+
97
+ RELATIVE_PROCESSES_SOURCE_PATH = "lib/processes"
98
+ RELATIVE_ACTIONS_SOURCE_PATH = "lib/actions"
99
+
100
+ TEST_PROCESSES_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_dsl_test"
101
+ TEST_PROCESSES_INCORRECT_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_dsl_test_incorrect"
102
+
103
+ TEST_PROCESSES_SOURCE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/processes_source_test"
104
+ TEST_ACTIONS_SOURCE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../../spec/unit/internal/actions_source_test"
105
+ TEMPLATES_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../templates"
106
+
107
+ end
108
+
109
+ end
@@ -0,0 +1,59 @@
1
+ module Stuka
2
+
3
+ module TemplateConfig
4
+
5
+ RescuableExceptions = [LoadError, NameError]
6
+
7
+ def self.action_module_namespaces
8
+
9
+ config_item = get_config_item("ActionModuleNamespaces")
10
+
11
+ if config_item
12
+ return config_item
13
+ else
14
+ ACTION_MODULE_NAMESPACES
15
+ end
16
+
17
+ end
18
+
19
+ def self.add_require_statements
20
+
21
+ add_requires = get_config_item("AddRequires")
22
+
23
+ unless add_requires.nil?
24
+ return add_requires
25
+ else
26
+ ADD_REQUIRE_STATEMENTS
27
+ end
28
+
29
+ end
30
+
31
+ def self.process_module_namespaces
32
+
33
+ config_item = get_config_item("ProcessModuleNamespaces")
34
+
35
+ if config_item
36
+ return config_item
37
+ else
38
+ PROCESS_MODULE_NAMESPACES
39
+ end
40
+
41
+ end
42
+
43
+ def self.get_config_item(name)
44
+ begin
45
+ require_relative "#{Dir.pwd}/stuka_config"
46
+ return StukaConfig.const_get(name)
47
+ rescue *RescuableExceptions
48
+ return false
49
+ end
50
+ end
51
+
52
+ # defaults
53
+ ACTION_MODULE_NAMESPACES = ["Actions"]
54
+ PROCESS_MODULE_NAMESPACES = ["Processes"]
55
+ ADD_REQUIRE_STATEMENTS = true
56
+
57
+ end
58
+
59
+ end
@@ -1,20 +1,22 @@
1
1
  require 'stuka/external/unknown_action'
2
+ require 'stuka/config/stuka_paths'
3
+ require 'stuka/monkeypatch/string_patch'
2
4
 
3
- module Stuka
5
+ module Stuka::External
4
6
 
5
7
  class ActionFinder
6
8
 
7
9
  def find_action action, process
8
10
  namespace, name = action.split "::"
9
- class_namespace = namespace.split('_').collect!{ |w| w.capitalize }.join
10
- class_name = name.split('_').collect!{ |w| w.capitalize }.join
11
+ class_namespace = namespace.camelcase_notation
12
+ class_name = name.camelcase_notation
11
13
  begin
12
- clazz = Object.const_get("#{class_namespace}::#{class_name}")
14
+ clazz = Object.const_get("Actions#{class_namespace}::#{class_name}")
13
15
  rescue NameError
14
- file_path = "#{Stuka::StukaPaths::PROCESSES_SOURCE_PATH}/#{namespace}/#{name}"
15
- raise Stuka::UnknownAction.new(action) unless File.file?("#{file_path}.rb")
16
+ file_path = "#{Stuka::StukaPaths.actions_source_path}/#{namespace}/#{name}"
17
+ raise Stuka::External::UnknownAction.new(action) unless File.file?("#{file_path}.rb")
16
18
  require_relative file_path
17
- clazz = Object.const_get("#{class_namespace}::#{class_name}")
19
+ clazz = Object.const_get("Actions::#{class_namespace}::#{class_name}")
18
20
  end
19
21
  clazz.new(process)
20
22
  end
@@ -1,4 +1,4 @@
1
- module Stuka
1
+ module Stuka::External
2
2
 
3
3
  class BusinessAction
4
4
 
@@ -8,9 +8,12 @@ module Stuka
8
8
  @process = process
9
9
  end
10
10
 
11
- def method_missing(name, args, &block)
12
- super unless @process.can_transition_to? name
13
- @process.transition args, name
11
+ def method_missing(name, args = {}, &block)
12
+ if @process.can_transition_to?(name)
13
+ @process.transition args, name
14
+ else
15
+ super
16
+ end
14
17
  end
15
18
 
16
19
  end
@@ -4,31 +4,30 @@ require 'stuka/external/action_finder'
4
4
 
5
5
  Dir["#{File.dirname(__FILE__)}/process_states/*.rb"].each { |file| require_relative file }
6
6
 
7
- module Stuka
7
+ module Stuka::External
8
8
 
9
9
  class BusinessProcess
10
10
 
11
11
  PROCESS_STATES = {
12
- inactive: InactiveState.new,
13
- starting: StartingState.new,
14
- started: StartedState.new,
15
- finished: FinishedState.new
12
+ inactive: ProcessStates::InactiveState.new,
13
+ started: ProcessStates::StartedState.new,
14
+ finished: ProcessStates::FinishedState.new
16
15
  }
17
16
 
18
17
  include Observable
19
18
 
20
- attr_reader :options, :process_id, :start_action, :current_action, :current_state, :process_params, :action_params, :transition_helper, :dispatcher, :action_finder
19
+ attr_reader :options, :process_id, :start_block, :current_block, :current_action, :current_state, :process_params, :action_params, :dispatcher, :action_finder
21
20
 
22
21
  def initialize(process_id: nil, options: {}, dispatcher: Dispatcher.new, action_finder: ActionFinder.new)
23
- @options = options
24
22
  @process_id = process_id
23
+ @options = options
25
24
  @dispatcher = dispatcher
26
25
  @action_finder = action_finder
27
26
  change_state :inactive
28
- yield(@dispatcher) if block_given?
29
27
  end
30
28
 
31
29
  def run(params = {})
30
+ yield(@dispatcher) if block_given?
32
31
  set_process_params params
33
32
  transition(params, nil)
34
33
  end
@@ -40,14 +39,18 @@ module Stuka
40
39
  end
41
40
 
42
41
  def can_transition_to?(transition)
43
- transition_map.has_key?(current_action) && transition_map[current_action].has_key?(transition)
42
+ blocks.has_key?(current_block) && blocks[current_block].has_key?(transition)
43
+ end
44
+
45
+ def blocks
46
+ self.class::Blocks
44
47
  end
45
48
 
46
49
  private
47
50
 
48
- def next_action(transition)
51
+ def next_block(transition)
49
52
  raise "transition not defined" unless can_transition_to?(transition)
50
- return transition_map[current_action][transition]
53
+ return blocks[current_block][transition]
51
54
  end
52
55
 
53
56
  def method_missing(name, args)
@@ -59,8 +62,9 @@ module Stuka
59
62
  end
60
63
  end
61
64
 
62
- def set_current_action(new_action)
63
- @current_action = new_action
65
+ def set_current_block(new_block)
66
+ @current_block = new_block
67
+ @current_action = blocks[new_block][:action]
64
68
  end
65
69
 
66
70
  def change_state(new_state)
@@ -1,4 +1,4 @@
1
- module Stuka
1
+ module Stuka::External
2
2
 
3
3
  class Dispatcher
4
4
 
@@ -1,4 +1,4 @@
1
- module Stuka
1
+ module Stuka::External::ProcessStates
2
2
 
3
3
  class FinishedState
4
4
 
@@ -1,12 +1,12 @@
1
- module Stuka
1
+ module Stuka::External::ProcessStates
2
2
 
3
3
  class InactiveState
4
4
 
5
5
  def handle_transition(context, transition = nil)
6
6
  context.instance_eval do
7
7
  change_state(:started)
8
- set_current_action(start_action)
9
- start_action_instance = action_finder.find_action(start_action, self)
8
+ set_current_block(start_block)
9
+ start_action_instance = action_finder.find_action(current_action, self)
10
10
  start_action_instance.run(action_params)
11
11
  end
12
12
  end
@@ -1,16 +1,17 @@
1
- module Stuka
1
+ module Stuka::External::ProcessStates
2
2
 
3
3
  class StartedState
4
4
 
5
5
  def handle_transition(context, transition)
6
6
  context.instance_eval do
7
- action_desc = next_action(transition)
8
- if action_desc.start_with?("process::")
9
- process_message = action_desc.split("::")[1]
7
+ new_block = next_block(transition)
8
+ if new_block.start_with?("process::")
9
+ process_message = new_block.split("::")[1]
10
10
  send(process_message.to_sym, action_params)
11
11
  else
12
- set_current_action(action_desc)
13
- action_instance = action_finder.find_action(action_desc, context)
12
+ set_current_block(new_block)
13
+ action_name = blocks[new_block][:action]
14
+ action_instance = action_finder.find_action(action_name, context)
14
15
  action_instance.run(action_params)
15
16
  end
16
17
  end
@@ -1,4 +1,4 @@
1
- module Stuka
1
+ module Stuka::External
2
2
 
3
3
  class UnknownAction < StandardError
4
4
  def initialize(action_name)
@@ -4,17 +4,23 @@ module Stuka
4
4
 
5
5
  class Action < Domain
6
6
 
7
+ # needed durring generation
8
+ attr_accessor :implementation
9
+
7
10
  # must not be nil
8
- ATTRS = ["name", "description", "namespace"]
11
+ ATTRS = ["name", "description", "namespace", "endings"]
9
12
 
10
13
  # must not be empty
11
- REQUIRED_ATTRS = ["name", "namespace"]
14
+ REQUIRED_ATTRS = ["name", "namespace", "endings"]
12
15
 
13
- def initialize(name, description = nil, namespace = nil)
16
+ def initialize(name, namespace = nil, description = nil, endings = [])
14
17
  super()
18
+ raise "'process' namespace is reserved" if namespace == "process"
15
19
  @name = name
16
20
  @description = description
17
21
  @namespace = namespace
22
+ @endings = endings.map(&:to_sym)
23
+ @implementation = ""
18
24
  end
19
25
 
20
26
  # redefined
@@ -27,6 +33,13 @@ module Stuka
27
33
  end
28
34
  end
29
35
 
36
+ def endings(endings_array = nil)
37
+ if endings_array
38
+ @endings = endings_array.map(&:to_sym)
39
+ else
40
+ @endings
41
+ end
42
+ end
30
43
  end
31
44
 
32
45
  end
@@ -4,27 +4,50 @@ module Stuka
4
4
 
5
5
  class Process < Domain
6
6
 
7
- attr_reader :transitions
7
+ attr_reader :blocks
8
8
 
9
9
  # must not be nil
10
- ATTRS = ["name", "description", "start_action"]
10
+ ATTRS = ["name", "description", "start_block"]
11
11
 
12
12
  # must not be empty
13
- REQUIRED_ATTRS = ["name", "start_action"]
13
+ REQUIRED_ATTRS = ["name", "start_block"]
14
14
 
15
- def initialize(name, description = nil, arguments = nil, start_action = nil)
15
+ def initialize(name, description = nil, arguments = nil, start_block = nil)
16
16
  super()
17
17
  @arguments = []
18
18
  @name = name
19
19
  @description = description
20
20
  @arguments = arguments
21
- @start_action = start_action
22
- @transitions = {}
21
+ @start_block = start_block
22
+ @blocks = []
23
23
  end
24
24
 
25
- def action_transition(action_name, transition_hash)
26
- new_transition = { action_name => transition_hash }
27
- transitions.merge!(new_transition)
25
+ ProcessBlock = Struct.new(:block_name, :action_name, :block_endings) do
26
+
27
+ def action(action_name = nil)
28
+ if action_name
29
+ self.action_name = action_name
30
+ else
31
+ self.action_name
32
+ end
33
+ end
34
+
35
+ def endings(endings_hash)
36
+ if endings_hash
37
+ self.block_endings = endings_hash
38
+ else
39
+ self.block_endings
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ def block(block_name, &block)
46
+ raise "block method requires a block" unless block_given?
47
+ process_block = ProcessBlock.new
48
+ process_block.block_name = block_name
49
+ process_block.instance_eval(&block)
50
+ @blocks << process_block
28
51
  end
29
52
 
30
53
  end
@@ -6,7 +6,11 @@ module Stuka
6
6
  class ActionDomainBuilder < DomainBuilder
7
7
 
8
8
  def action(name, &block)
9
- act = Action.new(name)
9
+ namespace, action_name = [nil, name]
10
+ if name.include?("::")
11
+ namespace, action_name = name.split("::")
12
+ end
13
+ act = Action.new(action_name, namespace)
10
14
  act.instance_eval(&block)
11
15
  @instances << act
12
16
  act
@@ -17,7 +17,7 @@ module Stuka
17
17
  end
18
18
 
19
19
  def domain_files
20
- Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/**/*.rb"]
20
+ Dir["#{Stuka::StukaPaths.processes_definition_path}/**/*.rb"]
21
21
  end
22
22
 
23
23
  def build_domain
@@ -1,19 +1,15 @@
1
- require 'stuka/paths/stuka_paths'
1
+ require 'stuka/config/stuka_paths'
2
2
 
3
3
  module Stuka
4
4
 
5
5
  class ProcessCleaner
6
6
 
7
7
  def self.gather_process_files
8
- Dir["#{Stuka::StukaPaths::PROCESSES_SOURCE_PATH}/*.rb"]
9
- end
10
-
11
- def self.gather_action_files
12
- Dir["#{Dir.pwd}/processes/actions/*_action.rb"]
8
+ Dir["#{Stuka::StukaPaths.processes_source_path}/*.rb"]
13
9
  end
14
10
 
15
11
  def self.clean
16
- files = gather_process_files + gather_action_files
12
+ files = gather_process_files
17
13
  files.each do |path|
18
14
  File.delete(path)
19
15
  end