stuka 0.0.10 → 0.0.11
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/stuka/commands/command.rb +0 -8
- data/lib/stuka/commands/public_commands/new_command.rb +0 -1
- data/lib/stuka/commands/public_commands/process_command.rb +2 -2
- data/lib/stuka/commands/public_commands/setup_command.rb +3 -4
- data/lib/stuka/{stuka_cli.rb → commands/stuka_cli.rb} +4 -4
- data/lib/stuka/commands/subcommands/create/{create_process.rb → create_process_file.rb} +3 -3
- data/lib/stuka/commands/subcommands/setup/setup_directories.rb +6 -6
- data/lib/stuka/external/action_finder.rb +25 -0
- data/lib/stuka/external/business_action.rb +18 -0
- data/lib/stuka/external/business_process.rb +85 -0
- data/lib/stuka/external/dispatcher.rb +27 -0
- data/lib/stuka/external/process_states/finished_state.rb +13 -0
- data/lib/stuka/external/process_states/inactive_state.rb +16 -0
- data/lib/stuka/external/process_states/started_state.rb +21 -0
- data/lib/stuka/external/process_states/starting_state.rb +16 -0
- data/lib/stuka/external/unknown_action.rb +9 -0
- data/lib/stuka/internal/domain/action.rb +32 -0
- data/lib/stuka/internal/domain/domain.rb +29 -0
- data/lib/stuka/internal/domain/process.rb +32 -0
- data/lib/stuka/internal/domain_builders/action_domain_builder.rb +19 -0
- data/lib/stuka/internal/domain_builders/domain_builder.rb +32 -0
- data/lib/stuka/internal/domain_builders/process_domain_builder.rb +17 -0
- data/lib/stuka/internal/process_cleaner.rb +0 -2
- data/lib/stuka/internal/source_builders/action_builder.rb +32 -0
- data/lib/stuka/internal/source_builders/process_builder.rb +38 -0
- data/lib/stuka/internal/source_builders/source_builder.rb +14 -0
- data/lib/stuka/internal/validator.rb +22 -7
- data/lib/stuka/paths/stuka_paths.rb +18 -0
- data/lib/stuka/templates/source/process.tt +18 -3
- data/lib/stuka/version.rb +2 -2
- data/lib/stuka.rb +0 -1
- data/spec/{commands → aceptance/commands}/new_command_spec.rb +1 -1
- data/spec/aceptance/commands/process_command_spec.rb +22 -0
- data/spec/{commands → aceptance/commands}/setup_command_spec.rb +1 -1
- data/spec/aceptance/external/action_aceptance_spec.rb +24 -0
- data/spec/aceptance/external/feed_cat_process_aceptance_spec.rb +46 -0
- data/spec/aceptance/external/processes/cat/check_food.rb +14 -0
- data/spec/aceptance/external/processes/cat/fill_up_plate.rb +14 -0
- data/spec/aceptance/external/processes/cat/go_to_store.rb +14 -0
- data/spec/aceptance/external/processes/feed_cat_process.rb +28 -0
- data/spec/spec_helper.rb +10 -2
- data/spec/unit/external/example_source/create_world.rb +28 -0
- data/spec/unit/external/example_source/kill_monster.rb +38 -0
- data/spec/unit/external/example_source/world/gather_materials.rb +13 -0
- data/spec/unit/external/example_source/world/scrap_world.rb +13 -0
- data/spec/unit/external/example_source/world/seperate_light_from_darkness.rb +13 -0
- data/spec/unit/external/finder_spec.rb +37 -0
- data/spec/unit/external/process_interface.rb +9 -0
- data/spec/unit/external/process_to_action.rb +61 -0
- data/spec/unit/external/process_to_dispatcher_spec.rb +35 -0
- data/spec/unit/external/process_to_finder_spec.rb +138 -0
- data/spec/{build/process_builder_spec.rb → unit/internal/action_builder_spec.rb} +6 -7
- data/spec/unit/internal/action_domain_builder_spec.rb +44 -0
- data/spec/unit/internal/action_spec.rb +14 -0
- data/spec/unit/internal/process_builder_spec.rb +44 -0
- data/spec/{build → unit/internal}/process_cleaner_spec.rb +2 -3
- data/spec/unit/internal/process_domain_builder_spec.rb +51 -0
- data/spec/unit/internal/process_spec.rb +14 -0
- data/spec/unit/internal/process_validator_spec.rb +42 -0
- data/spec/{build → unit/internal}/processes_dsl_test/correct_test_process.rb +12 -5
- data/stuka.gemspec +1 -1
- metadata +82 -41
- data/lib/stuka/commands/public_commands/step_command.rb +0 -25
- data/lib/stuka/commands/subcommands/create/create_action.rb +0 -16
- data/lib/stuka/internal/action.rb +0 -33
- data/lib/stuka/internal/action_builder.rb +0 -31
- data/lib/stuka/internal/action_incubator.rb +0 -37
- data/lib/stuka/internal/process.rb +0 -38
- data/lib/stuka/internal/process_builder.rb +0 -30
- data/lib/stuka/internal/process_incubator.rb +0 -37
- data/lib/stuka/stuka_paths.rb +0 -21
- data/lib/stuka/templates/definitions/step.tt +0 -8
- data/spec/build/action_builder_spec.rb +0 -23
- data/spec/build/action_incubator_spec.rb +0 -24
- data/spec/build/dsl_spec.rb +0 -44
- data/spec/build/process_incubator_spec.rb +0 -27
- data/spec/build/process_validator_spec.rb +0 -40
- data/spec/commands/process_command_spec.rb +0 -19
- data/spec/commands/step_command_spec.rb +0 -19
- /data/spec/{build/processes_dsl_test/incorrect → unit/internal/processes_dsl_test_incorrect}/incorrect_test_process.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca27a15c874129787e12f36fc8c2056ac0211f70
|
4
|
+
data.tar.gz: 943bea8f273e1df5e2225e93f645a1afb3e1e0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dc8f84801d5430d25f17bd6b4b3bac841322983000d30474da7d398709724eb421c9522facd668122432125aa35ef35ce4a05bff2dc8ebc7d56b648909f9a87
|
7
|
+
data.tar.gz: d4856b738eff0ca6d6977eddf3adc9ec99466f2ee9d151e4ffda848d86bed05f7d868a8e9200b05a1e48d85385f0a132817e113a1bfb114beff564cf9f68456d
|
data/.gitignore
CHANGED
@@ -5,10 +5,6 @@ module Stuka
|
|
5
5
|
class Command < Thor::Group
|
6
6
|
include Thor::Actions
|
7
7
|
|
8
|
-
class << self
|
9
|
-
attr_accessor :pwd
|
10
|
-
end
|
11
|
-
|
12
8
|
# root of project, from where we reference the templates
|
13
9
|
def self.source_root
|
14
10
|
File.dirname(__FILE__) + "/.."
|
@@ -31,10 +27,6 @@ module Stuka
|
|
31
27
|
"#{command_name} description"
|
32
28
|
end
|
33
29
|
|
34
|
-
def self.current_dir(cd)
|
35
|
-
pwd || Dir.pwd
|
36
|
-
end
|
37
|
-
|
38
30
|
end
|
39
31
|
|
40
32
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative "../command"
|
2
|
-
require_relative "../subcommands/create/
|
2
|
+
require_relative "../subcommands/create/create_process_file"
|
3
3
|
|
4
4
|
module Stuka
|
5
5
|
|
@@ -8,7 +8,7 @@ module Stuka
|
|
8
8
|
argument :name, :desc => "Name of the process"
|
9
9
|
|
10
10
|
def execute
|
11
|
-
Stuka::
|
11
|
+
Stuka::CreateProcessFile.new.create(name)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.description
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require_relative "../command"
|
2
|
-
Dir["#{File.dirname(__FILE__)}/../subcommands/setup/*.rb"].each { |file| require_relative file }
|
3
|
-
|
4
|
-
|
5
1
|
module Stuka
|
6
2
|
|
3
|
+
require_relative "../command"
|
4
|
+
Dir["#{File.dirname(__FILE__)}/../subcommands/setup/*.rb"].each { |file| require_relative file }
|
5
|
+
|
7
6
|
class SetupCommand < Command
|
8
7
|
|
9
8
|
def execute
|
@@ -1,12 +1,12 @@
|
|
1
|
-
|
1
|
+
require 'thor'
|
2
|
+
Dir["#{File.dirname(__FILE__)}/public_commands/*.rb"].each { |file| require_relative file }
|
2
3
|
|
3
|
-
|
4
|
-
Dir["#{File.dirname(__FILE__)}/commands/public_commands/*.rb"].each { |file| require_relative file }
|
4
|
+
module Stuka
|
5
5
|
|
6
6
|
class StukaCli < Thor
|
7
7
|
|
8
8
|
# Retrieve all classes from the Stuka module that end with Command except Stuka::Command abstract class
|
9
|
-
# Register all those classes so they are available in the terminal as commands
|
9
|
+
# Register all those classes so they are available in the terminal as commands using
|
10
10
|
# register(class_name, subcommand_alias, usage_list_string, description_string)
|
11
11
|
commands = Stuka.constants.select { |c| c.match(/\w+Command/) && Stuka.const_get(c).is_a?(Class) }
|
12
12
|
commands.each do |command|
|
@@ -2,12 +2,12 @@ require_relative "../../command"
|
|
2
2
|
|
3
3
|
module Stuka
|
4
4
|
|
5
|
-
class
|
5
|
+
class CreateProcessFile < Command
|
6
6
|
|
7
7
|
def create(name)
|
8
8
|
@name = name
|
9
|
-
template('templates/definitions/process.tt', "process_definition/
|
10
|
-
say("Process #{name} created")
|
9
|
+
template('templates/definitions/process.tt', "process_definition/business/#{name}.rb")
|
10
|
+
say("Process file '#{name}.rb' created")
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "../../command"
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Stuka
|
4
5
|
|
@@ -6,17 +7,16 @@ module Stuka
|
|
6
7
|
|
7
8
|
def setup
|
8
9
|
processes_dir_exists = File.directory?("#{Dir.pwd}/process_definition/processes")
|
9
|
-
steps_dir_exists = File.directory?("#{Dir.pwd}/process_definition/steps")
|
10
10
|
|
11
|
-
if processes_dir_exists
|
12
|
-
say("Stuka
|
11
|
+
if processes_dir_exists
|
12
|
+
say("Stuka dsl source directories are already setup")
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
template('templates/samples/my_process.tt', "process_definition/processes/my_process.rb")
|
16
|
+
FileUtils.mkdir_p "process_definition"
|
17
|
+
|
19
18
|
say("Source directories setup")
|
19
|
+
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'stuka/external/unknown_action'
|
2
|
+
|
3
|
+
module Stuka
|
4
|
+
|
5
|
+
class ActionFinder
|
6
|
+
|
7
|
+
def find_action action, process
|
8
|
+
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
|
+
begin
|
12
|
+
clazz = Object.const_get("#{class_namespace}::#{class_name}")
|
13
|
+
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
|
+
require_relative file_path
|
17
|
+
clazz = Object.const_get("#{class_namespace}::#{class_name}")
|
18
|
+
end
|
19
|
+
clazz.new(process)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class BusinessAction
|
4
|
+
|
5
|
+
attr_reader :process
|
6
|
+
|
7
|
+
def initialize(process)
|
8
|
+
@process = process
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(name, args, &block)
|
12
|
+
super unless @process.can_transition_to? name
|
13
|
+
@process.transition args, name
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'observer'
|
2
|
+
require 'stuka/external/dispatcher'
|
3
|
+
require 'stuka/external/action_finder'
|
4
|
+
|
5
|
+
Dir["#{File.dirname(__FILE__)}/process_states/*.rb"].each { |file| require_relative file }
|
6
|
+
|
7
|
+
module Stuka
|
8
|
+
|
9
|
+
class BusinessProcess
|
10
|
+
|
11
|
+
PROCESS_STATES = {
|
12
|
+
inactive: InactiveState.new,
|
13
|
+
starting: StartingState.new,
|
14
|
+
started: StartedState.new,
|
15
|
+
finished: FinishedState.new
|
16
|
+
}
|
17
|
+
|
18
|
+
include Observable
|
19
|
+
|
20
|
+
attr_reader :options, :process_id, :start_action, :current_action, :current_state, :process_params, :action_params, :transition_helper, :dispatcher, :action_finder
|
21
|
+
|
22
|
+
def initialize(process_id: nil, options: {}, dispatcher: Dispatcher.new, action_finder: ActionFinder.new)
|
23
|
+
@options = options
|
24
|
+
@process_id = process_id
|
25
|
+
@dispatcher = dispatcher
|
26
|
+
@action_finder = action_finder
|
27
|
+
change_state :inactive
|
28
|
+
yield(@dispatcher) if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def run(params = {})
|
32
|
+
set_process_params params
|
33
|
+
transition(params, nil)
|
34
|
+
end
|
35
|
+
|
36
|
+
def transition(params, transition)
|
37
|
+
set_action_params params
|
38
|
+
notify
|
39
|
+
current_state.handle_transition(self, transition)
|
40
|
+
end
|
41
|
+
|
42
|
+
def can_transition_to?(transition)
|
43
|
+
transition_map.has_key?(current_action) && transition_map[current_action].has_key?(transition)
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def next_action(transition)
|
49
|
+
raise "transition not defined" unless can_transition_to?(transition)
|
50
|
+
return transition_map[current_action][transition]
|
51
|
+
end
|
52
|
+
|
53
|
+
def method_missing(name, args)
|
54
|
+
change_state :finished
|
55
|
+
if dispatcher.can_end_with? name
|
56
|
+
dispatcher.call(name.to_sym, args)
|
57
|
+
else
|
58
|
+
super
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_current_action(new_action)
|
63
|
+
@current_action = new_action
|
64
|
+
end
|
65
|
+
|
66
|
+
def change_state(new_state)
|
67
|
+
@current_state = PROCESS_STATES[new_state]
|
68
|
+
end
|
69
|
+
|
70
|
+
def set_process_params(params)
|
71
|
+
@process_params = params
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_action_params(params)
|
75
|
+
@action_params = params
|
76
|
+
end
|
77
|
+
|
78
|
+
def notify
|
79
|
+
changed true
|
80
|
+
notify_observers(self)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class Dispatcher
|
4
|
+
|
5
|
+
attr_reader :callbacks
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@callbacks = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def can_end_with?(name)
|
12
|
+
@callbacks.has_key?(name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def method_missing(name, *args, &block)
|
16
|
+
callbacks[name] = block
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(name, args)
|
20
|
+
name = name.to_sym
|
21
|
+
cb = callbacks[name]
|
22
|
+
cb ? cb.call(args) : false
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class InactiveState
|
4
|
+
|
5
|
+
def handle_transition(context, transition = nil)
|
6
|
+
context.instance_eval do
|
7
|
+
change_state(:started)
|
8
|
+
set_current_action(start_action)
|
9
|
+
start_action_instance = action_finder.find_action(start_action, self)
|
10
|
+
start_action_instance.run(action_params)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class StartedState
|
4
|
+
|
5
|
+
def handle_transition(context, transition)
|
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]
|
10
|
+
send(process_message.to_sym, action_params)
|
11
|
+
else
|
12
|
+
set_current_action(action_desc)
|
13
|
+
action_instance = action_finder.find_action(action_desc, context)
|
14
|
+
action_instance.run(action_params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class StartingState
|
4
|
+
|
5
|
+
def handle_transition(context, transition)
|
6
|
+
context.instance_eval do
|
7
|
+
set_current_action(start_action)
|
8
|
+
start_action_class = transition_helper.find_action(start_action)
|
9
|
+
change_state(:started)
|
10
|
+
start_action_class.new(context).run(action_params)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "domain"
|
2
|
+
|
3
|
+
module Stuka
|
4
|
+
|
5
|
+
class Action < Domain
|
6
|
+
|
7
|
+
# must not be nil
|
8
|
+
ATTRS = ["name", "description", "namespace"]
|
9
|
+
|
10
|
+
# must not be empty
|
11
|
+
REQUIRED_ATTRS = ["name", "namespace"]
|
12
|
+
|
13
|
+
def initialize(name, description = nil, namespace = nil)
|
14
|
+
super()
|
15
|
+
@name = name
|
16
|
+
@description = description
|
17
|
+
@namespace = namespace
|
18
|
+
end
|
19
|
+
|
20
|
+
# redefined
|
21
|
+
def namespace(namespace = nil)
|
22
|
+
raise "'process' namespace is reserved" if namespace == "process"
|
23
|
+
if namespace
|
24
|
+
@namespace = namespace
|
25
|
+
else
|
26
|
+
@namespace
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class Domain
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
self.class.define_basic_methods()
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_binding
|
10
|
+
binding()
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.define_basic_methods()
|
14
|
+
subclass = self
|
15
|
+
subclass::ATTRS.each do |arg_name|
|
16
|
+
next if subclass.method_defined? arg_name.to_sym
|
17
|
+
subclass.send(:define_method, arg_name.to_sym) do |arg = nil|
|
18
|
+
if arg
|
19
|
+
instance_variable_set("@#{arg_name}".to_sym, arg)
|
20
|
+
else
|
21
|
+
instance_variable_get("@#{arg_name}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "domain"
|
2
|
+
|
3
|
+
module Stuka
|
4
|
+
|
5
|
+
class Process < Domain
|
6
|
+
|
7
|
+
attr_reader :transitions
|
8
|
+
|
9
|
+
# must not be nil
|
10
|
+
ATTRS = ["name", "description", "start_action"]
|
11
|
+
|
12
|
+
# must not be empty
|
13
|
+
REQUIRED_ATTRS = ["name", "start_action"]
|
14
|
+
|
15
|
+
def initialize(name, description = nil, arguments = nil, start_action = nil)
|
16
|
+
super()
|
17
|
+
@arguments = []
|
18
|
+
@name = name
|
19
|
+
@description = description
|
20
|
+
@arguments = arguments
|
21
|
+
@start_action = start_action
|
22
|
+
@transitions = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def action_transition(action_name, transition_hash)
|
26
|
+
new_transition = { action_name => transition_hash }
|
27
|
+
transitions.merge!(new_transition)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'stuka/internal/domain/action'
|
2
|
+
require_relative 'domain_builder'
|
3
|
+
|
4
|
+
module Stuka
|
5
|
+
|
6
|
+
class ActionDomainBuilder < DomainBuilder
|
7
|
+
|
8
|
+
def action(name, &block)
|
9
|
+
act = Action.new(name)
|
10
|
+
act.instance_eval(&block)
|
11
|
+
@instances << act
|
12
|
+
act
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class DomainBuilder
|
4
|
+
|
5
|
+
DOMAIN_OBJECTS = ["process", "action"]
|
6
|
+
|
7
|
+
attr_accessor :instances
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@instances = []
|
11
|
+
end
|
12
|
+
|
13
|
+
DOMAIN_OBJECTS.each do |object_name|
|
14
|
+
define_method object_name.to_sym do |*arg|
|
15
|
+
#empty process and action method so it does not raise method not found
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def domain_files
|
20
|
+
Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/**/*.rb"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_domain
|
24
|
+
domain_files.each do |path|
|
25
|
+
instance_eval(File.read(path), path, __LINE__)
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'stuka/internal/domain/process'
|
2
|
+
require_relative 'domain_builder'
|
3
|
+
|
4
|
+
module Stuka
|
5
|
+
|
6
|
+
class ProcessDomainBuilder < DomainBuilder
|
7
|
+
|
8
|
+
def process(name, &block)
|
9
|
+
proc = Process.new(name)
|
10
|
+
proc.instance_eval(&block)
|
11
|
+
@instances << proc
|
12
|
+
proc
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'stuka/internal/domain_builders/action_domain_builder'
|
2
|
+
require_relative 'source_builder'
|
3
|
+
|
4
|
+
module Stuka
|
5
|
+
|
6
|
+
class ActionBuilder < SourceBuilder
|
7
|
+
|
8
|
+
def self.build
|
9
|
+
|
10
|
+
adb = ActionDomainBuilder.new
|
11
|
+
adb.build_domain
|
12
|
+
|
13
|
+
template_file = "#{templates_path}/source/action.tt"
|
14
|
+
renderer = ERB.new(File.read(template_file))
|
15
|
+
|
16
|
+
FileUtils.mkdir_p Stuka::StukaPaths::PROCESSES_SOURCE_PATH
|
17
|
+
|
18
|
+
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))
|
21
|
+
out_file.close
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.source_path
|
27
|
+
Stuka::StukaPaths::PROCESSES_SOURCE_PATH
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'stuka/internal/domain_builders/process_domain_builder'
|
2
|
+
require 'stuka/internal/validator'
|
3
|
+
require_relative 'source_builder'
|
4
|
+
|
5
|
+
module Stuka
|
6
|
+
|
7
|
+
class ProcessBuilder < SourceBuilder
|
8
|
+
|
9
|
+
def self.build
|
10
|
+
pdb = ProcessDomainBuilder.new
|
11
|
+
pdb.build_domain
|
12
|
+
|
13
|
+
validator = Stuka::Validator.new
|
14
|
+
raise validator.message unless validator.process_set_valid? pdb.instances
|
15
|
+
|
16
|
+
template_file = "#{templates_path}/source/process.tt"
|
17
|
+
renderer = ERB.new(File.read(template_file))
|
18
|
+
|
19
|
+
FileUtils.mkdir_p source_path
|
20
|
+
|
21
|
+
#raise pdb.instances.to_s
|
22
|
+
|
23
|
+
pdb.instances.each do |proc|
|
24
|
+
raise validator.message unless validator.process_valid? proc
|
25
|
+
out_file = File.new("#{source_path}/#{proc.name}.rb", "w")
|
26
|
+
out_file.puts(renderer.result(proc.get_binding))
|
27
|
+
out_file.close
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.source_path
|
33
|
+
Stuka::StukaPaths::PROCESSES_SOURCE_PATH
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|