stuka 0.1.2 → 0.1.3
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/lib/stuka/commands/public_commands/new_command.rb +2 -2
- data/lib/stuka/commands/public_commands/process_command.rb +5 -4
- data/lib/stuka/commands/public_commands/setup_command.rb +1 -1
- data/lib/stuka/commands/subcommands/create/create_process_file.rb +5 -3
- data/lib/stuka/commands/subcommands/create/create_project.rb +1 -1
- data/lib/stuka/commands/subcommands/setup/setup_config.rb +1 -1
- data/lib/stuka/commands/subcommands/setup/setup_directories.rb +3 -3
- data/lib/stuka/commands/subcommands/setup/setup_gemfile.rb +1 -1
- data/lib/stuka/commands/subcommands/setup/setup_rakefile.rb +1 -1
- data/lib/stuka/commands/subcommands/setup/setup_tasks.rb +1 -1
- data/lib/stuka/internal/domain/action.rb +8 -2
- data/lib/stuka/internal/domain/block.rb +55 -0
- data/lib/stuka/internal/domain/process.rb +16 -25
- data/lib/stuka/internal/domain_builders/action_domain_builder.rb +7 -2
- data/lib/stuka/internal/domain_builders/domain_builder.rb +4 -3
- data/lib/stuka/internal/domain_builders/process_domain_builder.rb +14 -1
- data/lib/stuka/internal/source_builders/action_builder.rb +7 -1
- data/lib/stuka/internal/source_builders/process_builder.rb +6 -3
- data/lib/stuka/templates/samples/process_file.tt +18 -31
- data/lib/stuka/templates/source/action.tt +1 -0
- data/lib/stuka/templates/source/action_header.tt +3 -0
- data/lib/stuka/templates/source/process.tt +3 -3
- data/lib/stuka/version.rb +1 -1
- data/spec/aceptance/commands/process_command_spec.rb +2 -1
- data/spec/unit/internal/action_builder_spec.rb +10 -9
- data/spec/unit/internal/process_builder_spec.rb +18 -6
- data/spec/unit/internal/process_cleaner_spec.rb +8 -0
- data/spec/unit/internal/process_domain_builder_spec.rb +16 -6
- data/spec/unit/internal/process_validator_spec.rb +4 -4
- data/spec/unit/internal/processes_dsl_test/correct_test_process.rb +5 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e705b79ca5b428abbcf975536eb34e701a6c0bea
|
4
|
+
data.tar.gz: 3c39e964888ccd74b15f4b8309d2deb0a1c0312c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8a9746f732794dbe531b2585b01062411767e9b14bf9009692c1c6437bcfc1ccf647852a53d76d3d4af95e9be35718124e193d315c0c94f57d0f49b7c61c8e
|
7
|
+
data.tar.gz: 2dd2c68dfce2d8a965c7521c60785b171bcbdcdd2a182587ce7877e9ac3f97a01b77ecce9c2ce40fbb4d182891253e63cf822b4f07e5219760fc8d2f4359c7a9
|
@@ -1,14 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "stuka/commands/command"
|
2
|
+
require "stuka/commands/subcommands/create/create_process_file"
|
3
3
|
|
4
4
|
module Stuka
|
5
5
|
|
6
6
|
class ProcessCommand < Command
|
7
7
|
|
8
8
|
argument :name, :desc => "Name of the process"
|
9
|
+
argument :blocks, type: :array, default: [], :desc => "Name of blocks"
|
9
10
|
|
10
11
|
def execute
|
11
|
-
Stuka::CreateProcessFile.new.create(name)
|
12
|
+
Stuka::CreateProcessFile.new.create(name, blocks)
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.description
|
@@ -16,7 +17,7 @@ module Stuka
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.usage
|
19
|
-
"process NAME"
|
20
|
+
"process NAME *BLOCK_NAMES"
|
20
21
|
end
|
21
22
|
|
22
23
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
require "stuka/commands/command"
|
2
|
+
require 'stuka/config/stuka_paths'
|
2
3
|
|
3
4
|
module Stuka
|
4
5
|
|
5
6
|
class CreateProcessFile < Command
|
6
7
|
|
7
|
-
def create(name)
|
8
|
+
def create(name, block_names)
|
8
9
|
@name = name
|
9
|
-
|
10
|
+
@block_names = block_names
|
11
|
+
template('templates/definitions/process.tt', "#{StukaPaths.processes_definition_path}/#{name}.rb")
|
10
12
|
end
|
11
13
|
|
12
14
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require "stuka/commands/command"
|
2
2
|
require 'stuka/config/stuka_paths'
|
3
3
|
require 'fileutils'
|
4
4
|
|
@@ -14,8 +14,8 @@ module Stuka
|
|
14
14
|
return
|
15
15
|
end
|
16
16
|
|
17
|
-
FileUtils.mkdir_p "
|
18
|
-
template('templates/samples/process_file.tt', "
|
17
|
+
FileUtils.mkdir_p "process_definition"
|
18
|
+
template('templates/samples/process_file.tt', "process_definition/process_file.rb")
|
19
19
|
say("\tSource directories setup")
|
20
20
|
|
21
21
|
end
|
@@ -5,7 +5,7 @@ module Stuka
|
|
5
5
|
class Action < Domain
|
6
6
|
|
7
7
|
# needed durring generation
|
8
|
-
attr_accessor :implementation
|
8
|
+
attr_accessor :implementation, :definition_file
|
9
9
|
|
10
10
|
# must not be nil
|
11
11
|
ATTRS = ["name", "description", "namespace", "endings"]
|
@@ -17,10 +17,11 @@ module Stuka
|
|
17
17
|
super()
|
18
18
|
raise "'process' namespace is reserved" if namespace == "process"
|
19
19
|
@name = name
|
20
|
-
@description = description
|
21
20
|
@namespace = namespace
|
21
|
+
@description = description
|
22
22
|
@endings = endings.map(&:to_sym)
|
23
23
|
@implementation = ""
|
24
|
+
@definition_file = ""
|
24
25
|
end
|
25
26
|
|
26
27
|
# redefined
|
@@ -40,6 +41,11 @@ module Stuka
|
|
40
41
|
@endings
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
45
|
+
def full_name
|
46
|
+
"#{namespace}::#{name}"
|
47
|
+
end
|
48
|
+
|
43
49
|
end
|
44
50
|
|
45
51
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative "domain"
|
2
|
+
|
3
|
+
module Stuka
|
4
|
+
|
5
|
+
class Block < Domain
|
6
|
+
|
7
|
+
attr_accessor :defining_action, :referenced_action_name, :definition_file
|
8
|
+
|
9
|
+
# must not be nil
|
10
|
+
ATTRS = ["name", "endings"]
|
11
|
+
|
12
|
+
# must not be empty
|
13
|
+
REQUIRED_ATTRS = ["name", "endings"]
|
14
|
+
|
15
|
+
def initialize(name, endings = {})
|
16
|
+
super()
|
17
|
+
@name = name
|
18
|
+
@endings = endings
|
19
|
+
end
|
20
|
+
|
21
|
+
def reference_action(namespaced_name)
|
22
|
+
raise "already defining an action for block" if @defining_action
|
23
|
+
@referenced_action_name = namespaced_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def action(action_namespaced_name, action_description = nil)
|
27
|
+
raise "action already referenced for block" if referenced_action_name
|
28
|
+
action_namespace, action_name = action_namespaced_name.split("::")
|
29
|
+
action_description = action_name unless action_description
|
30
|
+
@defining_action = Action.new(action_name, action_namespace, action_description)
|
31
|
+
@defining_action.definition_file = definition_file
|
32
|
+
@defining_action.endings(@endings.keys) if @endings
|
33
|
+
end
|
34
|
+
|
35
|
+
def endings(endings_hash = nil)
|
36
|
+
if endings_hash
|
37
|
+
@endings = endings_hash
|
38
|
+
defining_action.endings(endings_hash.keys) if defining_action
|
39
|
+
else
|
40
|
+
@endings
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def action_namespaced_name
|
45
|
+
raise "no action in block" unless (defining_action || referenced_action_name)
|
46
|
+
if @defining_action
|
47
|
+
defining_action.full_name
|
48
|
+
else
|
49
|
+
referenced_action_name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require_relative "domain"
|
2
|
+
require_relative "block"
|
2
3
|
|
3
4
|
module Stuka
|
4
5
|
|
5
6
|
class Process < Domain
|
6
7
|
|
7
8
|
attr_reader :blocks
|
9
|
+
attr_accessor :definition_file
|
8
10
|
|
9
11
|
# must not be nil
|
10
12
|
ATTRS = ["name", "description", "start_block"]
|
@@ -12,44 +14,33 @@ module Stuka
|
|
12
14
|
# must not be empty
|
13
15
|
REQUIRED_ATTRS = ["name", "start_block"]
|
14
16
|
|
15
|
-
def initialize(name, description = nil,
|
17
|
+
def initialize(name, description = nil, start_block = nil)
|
16
18
|
super()
|
17
|
-
@arguments = []
|
18
19
|
@name = name
|
19
20
|
@description = description
|
20
|
-
@arguments = arguments
|
21
21
|
@start_block = start_block
|
22
22
|
@blocks = []
|
23
|
-
|
24
|
-
|
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
|
-
|
23
|
+
@definition_file = ""
|
43
24
|
end
|
44
25
|
|
45
26
|
def block(block_name, &block)
|
46
27
|
raise "block method requires a block" unless block_given?
|
47
|
-
process_block =
|
48
|
-
process_block.
|
28
|
+
process_block = Block.new(block_name)
|
29
|
+
process_block.definition_file = definition_file
|
49
30
|
process_block.instance_eval(&block)
|
50
31
|
@blocks << process_block
|
51
32
|
end
|
52
33
|
|
34
|
+
def actions
|
35
|
+
all_actions = blocks.select { |block| block.defining_action }.map(&:defining_action)
|
36
|
+
filtered_actions = []
|
37
|
+
all_actions.each do |acc|
|
38
|
+
next if filtered_actions.map(&:name).include? acc.name
|
39
|
+
filtered_actions << acc
|
40
|
+
end
|
41
|
+
filtered_actions
|
42
|
+
end
|
43
|
+
|
53
44
|
end
|
54
45
|
|
55
46
|
end
|
@@ -5,6 +5,13 @@ module Stuka
|
|
5
5
|
|
6
6
|
class ActionDomainBuilder < DomainBuilder
|
7
7
|
|
8
|
+
attr_accessor :instances
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@instances = []
|
13
|
+
end
|
14
|
+
|
8
15
|
def action(name, &block)
|
9
16
|
namespace, action_name = [nil, name]
|
10
17
|
if name.include?("::")
|
@@ -16,8 +23,6 @@ module Stuka
|
|
16
23
|
act
|
17
24
|
end
|
18
25
|
|
19
|
-
|
20
|
-
|
21
26
|
end
|
22
27
|
|
23
28
|
end
|
@@ -2,12 +2,12 @@ module Stuka
|
|
2
2
|
|
3
3
|
class DomainBuilder
|
4
4
|
|
5
|
-
|
5
|
+
attr_reader :current_file_path
|
6
6
|
|
7
|
-
|
7
|
+
DOMAIN_OBJECTS = ["process", "action"]
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
@
|
10
|
+
@current_file_path = ""
|
11
11
|
end
|
12
12
|
|
13
13
|
DOMAIN_OBJECTS.each do |object_name|
|
@@ -22,6 +22,7 @@ module Stuka
|
|
22
22
|
|
23
23
|
def build_domain
|
24
24
|
domain_files.each do |path|
|
25
|
+
@current_file_path = path
|
25
26
|
instance_eval(File.read(path), path, __LINE__)
|
26
27
|
end
|
27
28
|
self
|
@@ -5,10 +5,23 @@ module Stuka
|
|
5
5
|
|
6
6
|
class ProcessDomainBuilder < DomainBuilder
|
7
7
|
|
8
|
+
attr_accessor :process_instances, :action_instances
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super()
|
12
|
+
@process_instances = []
|
13
|
+
@action_instances = []
|
14
|
+
end
|
15
|
+
|
8
16
|
def process(name, &block)
|
9
17
|
proc = Process.new(name)
|
18
|
+
proc.definition_file = current_file_path
|
10
19
|
proc.instance_eval(&block)
|
11
|
-
@
|
20
|
+
@process_instances << proc
|
21
|
+
proc.actions.each do |acc|
|
22
|
+
next if @action_instances.map(&:name).include? acc.name
|
23
|
+
@action_instances << acc
|
24
|
+
end
|
12
25
|
proc
|
13
26
|
end
|
14
27
|
|
@@ -13,12 +13,18 @@ module Stuka
|
|
13
13
|
adb = ActionDomainBuilder.new
|
14
14
|
adb.build_domain
|
15
15
|
|
16
|
+
build_files(adb.instances, stream)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.build_files(instances, stream)
|
21
|
+
|
16
22
|
template_file_header = "#{templates_path}/source/action_header.tt"
|
17
23
|
template_file = "#{templates_path}/source/action.tt"
|
18
24
|
|
19
25
|
FileUtils.mkdir_p Stuka::StukaPaths.actions_source_path
|
20
26
|
|
21
|
-
|
27
|
+
instances.each do |acc|
|
22
28
|
action_file_path = "#{source_path}/#{acc.namespace}"
|
23
29
|
FileUtils.mkdir_p action_file_path
|
24
30
|
|
@@ -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/internal/source_builders/action_builder'
|
4
5
|
require 'stuka/monkeypatch/string_patch'
|
5
6
|
|
6
7
|
module Stuka
|
@@ -12,14 +13,16 @@ module Stuka
|
|
12
13
|
pdb.build_domain
|
13
14
|
|
14
15
|
validator = Stuka::Validator.new
|
15
|
-
raise validator.message unless validator.process_set_valid? pdb.
|
16
|
+
raise validator.message unless validator.process_set_valid? pdb.process_instances
|
16
17
|
|
17
18
|
template_file_header = "#{templates_path}/source/process_header.tt"
|
18
19
|
template_file = "#{templates_path}/source/process.tt"
|
19
20
|
|
20
21
|
FileUtils.mkdir_p source_path
|
21
22
|
|
22
|
-
pdb.
|
23
|
+
ActionBuilder.build_files(pdb.action_instances, $stdout)
|
24
|
+
|
25
|
+
pdb.process_instances.each do |proc|
|
23
26
|
raise validator.message unless validator.process_valid? proc
|
24
27
|
|
25
28
|
# generate action header
|
@@ -50,7 +53,7 @@ module Stuka
|
|
50
53
|
out_file.puts(process_string)
|
51
54
|
out_file.close
|
52
55
|
end
|
53
|
-
|
56
|
+
|
54
57
|
end
|
55
58
|
|
56
59
|
def self.source_path
|
@@ -1,39 +1,26 @@
|
|
1
1
|
##
|
2
2
|
#
|
3
|
-
# process "
|
3
|
+
# process "sample_process" do
|
4
4
|
#
|
5
|
-
# description "description of a process
|
6
|
-
# should be concise and long enaugh for
|
7
|
-
# new people to understand what the process does."
|
5
|
+
# description "description of a process."
|
8
6
|
#
|
9
|
-
#
|
7
|
+
# start_block "first_block"
|
10
8
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
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
|
9
|
+
# block "first_block" do
|
10
|
+
# action "sample::action_1", "this is the description of action 1"
|
11
|
+
# endings(
|
12
|
+
# success: "seccond_block",
|
13
|
+
# failure: "process::failure"
|
14
|
+
# )
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# block "second_block" do
|
18
|
+
# action "sample::action_2", "this is the description of action 2"
|
19
|
+
# endings(
|
20
|
+
# success: "process::success",
|
21
|
+
# failure: "process::failure"
|
22
|
+
# )
|
23
|
+
# end
|
36
24
|
#
|
37
|
-
# namespace "sample"
|
38
25
|
# end
|
39
26
|
#
|
@@ -1,6 +1,9 @@
|
|
1
1
|
##<% @description.split("\n").each do |description_line| %><% require "stuka/config/template_config" %>
|
2
2
|
# <%= description_line.strip %> <% end %>
|
3
3
|
#
|
4
|
+
# defined_at: <%= @definition_file %>
|
5
|
+
#
|
6
|
+
# endings: <%= @endings.join(', ') %>
|
4
7
|
#
|
5
8
|
<% if TemplateConfig.add_require_statements %>
|
6
9
|
require "stuka/external/business_action"
|
@@ -2,9 +2,9 @@ class <%= @name.camelcase_notation %> < Stuka::External::BusinessProcess
|
|
2
2
|
|
3
3
|
Blocks = {
|
4
4
|
<% @blocks.each do |block| %>
|
5
|
-
"<%= block.
|
6
|
-
action: "<%= block.
|
7
|
-
<% block.
|
5
|
+
"<%= block.name %>" => {
|
6
|
+
action: "<%= block.action_namespaced_name %>",
|
7
|
+
<% block.endings.each do |block_ending, next_block| %><%= block_ending %>: "<%= next_block %>",
|
8
8
|
<% end %>
|
9
9
|
},<% end %>
|
10
10
|
}
|
data/lib/stuka/version.rb
CHANGED
@@ -8,11 +8,12 @@ describe "process file command" do
|
|
8
8
|
Stuka::StukaCli.start ["new", "test_pro"]
|
9
9
|
example.run
|
10
10
|
FileUtils.rm_rf 'test_pro'
|
11
|
+
FileUtils.rm_rf Dir["#{Stuka::StukaPaths.processes_definition_path}/test_process.rb"]
|
11
12
|
end
|
12
13
|
|
13
14
|
it "sets up the project" do
|
14
15
|
Dir.chdir "test_pro" do
|
15
|
-
expect { Stuka::StukaCli.start ["process", "test_process"] }.to output(%r|create
|
16
|
+
expect { Stuka::StukaCli.start ["process", "test_process"] }.to output(%r|create .*/processes_dsl_test/test_process.rb|).to_stdout
|
16
17
|
|
17
18
|
definition_files = Dir["#{Stuka::StukaPaths.processes_definition_path}/**/*.rb"]
|
18
19
|
expect { definition_files.to include("#{Stuka::StukaPaths.processes_definition_path}/test_process.rb}") }
|
@@ -17,25 +17,26 @@ describe "ActionBuilder" do
|
|
17
17
|
Stuka::ActionBuilder.build(stream)
|
18
18
|
|
19
19
|
source_files = Dir["#{Stuka::StukaPaths.actions_source_path}/*/*.rb"]
|
20
|
+
puts Dir["#{Stuka::StukaPaths.processes_definition_path}/**/*.rb"]
|
20
21
|
source_files = source_files.map{ |path| File.basename(path) }
|
21
22
|
expect(source_files.count).to eq(2)
|
22
|
-
expect(source_files.include? "
|
23
|
-
expect(source_files.include? "
|
23
|
+
expect(source_files.include? "acc3.rb").to be(true)
|
24
|
+
expect(source_files.include? "acc4.rb").to be(true)
|
24
25
|
end
|
25
26
|
|
26
27
|
it "notifies if the action file already exists using stdout passed as an argument" do
|
27
28
|
|
28
29
|
Stuka::ActionBuilder.build(stream)
|
29
30
|
|
30
|
-
expect(stream).to receive(:puts).with("action file bla::
|
31
|
+
expect(stream).to receive(:puts).with("action file bla::acc3 already exists.")
|
31
32
|
|
32
33
|
Stuka::ActionBuilder.build(stream)
|
33
34
|
|
34
35
|
source_files = Dir["#{Stuka::StukaPaths.actions_source_path}/*/*.rb"]
|
35
36
|
source_files = source_files.map{ |path| File.basename(path) }
|
36
37
|
expect(source_files.count).to eq(2)
|
37
|
-
expect(source_files.include? "
|
38
|
-
expect(source_files.include? "
|
38
|
+
expect(source_files.include? "acc3.rb").to be(true)
|
39
|
+
expect(source_files.include? "acc4.rb").to be(true)
|
39
40
|
|
40
41
|
end
|
41
42
|
|
@@ -45,8 +46,8 @@ describe "ActionBuilder" do
|
|
45
46
|
|
46
47
|
Stuka::ActionBuilder.build(stream)
|
47
48
|
|
48
|
-
require_relative "#{File.dirname(__FILE__)}/actions_source_test/bla/
|
49
|
-
expect(Bla::
|
49
|
+
require_relative "#{File.dirname(__FILE__)}/actions_source_test/bla/acc3.rb"
|
50
|
+
expect(Bla::Acc3.instance_methods.include? :additional_method).to be true
|
50
51
|
end
|
51
52
|
|
52
53
|
private
|
@@ -68,7 +69,7 @@ describe "ActionBuilder" do
|
|
68
69
|
require 'stuka/external/business_action'
|
69
70
|
|
70
71
|
module Bla
|
71
|
-
class
|
72
|
+
class Acc3 < Stuka::External::BusinessAction
|
72
73
|
|
73
74
|
def run(params)
|
74
75
|
params[stream].puts "test"
|
@@ -84,7 +85,7 @@ end
|
|
84
85
|
TEST
|
85
86
|
|
86
87
|
FileUtils.mkdir_p "#{File.dirname(__FILE__)}/actions_source_test/bla"
|
87
|
-
out_file = File.new("#{File.dirname(__FILE__)}/actions_source_test/bla/
|
88
|
+
out_file = File.new("#{File.dirname(__FILE__)}/actions_source_test/bla/acc3.rb", "w")
|
88
89
|
out_file.puts(file_content)
|
89
90
|
out_file.close
|
90
91
|
end
|
@@ -7,18 +7,20 @@ describe "ProcessBuilder" do
|
|
7
7
|
|
8
8
|
around(:each) do |example|
|
9
9
|
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
10
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
10
11
|
example.run
|
11
|
-
|
12
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
13
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
12
14
|
end
|
13
15
|
|
14
16
|
it "builds ruby source with ProcessBuilder::build" do
|
15
17
|
Stuka::ProcessBuilder.build
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
expect(
|
20
|
-
expect(
|
21
|
-
expect(
|
19
|
+
process_source_files = Dir["#{Stuka::StukaPaths.processes_source_path}/*.rb"]
|
20
|
+
process_source_files = process_source_files.map{ |path| File.basename(path) }
|
21
|
+
expect(process_source_files.count).to eq(2)
|
22
|
+
expect(process_source_files.include? "check_smth.rb").to be(true)
|
23
|
+
expect(process_source_files.include? "test2.rb").to be(true)
|
22
24
|
|
23
25
|
require_relative "processes_source_test/check_smth"
|
24
26
|
|
@@ -45,4 +47,14 @@ describe "ProcessBuilder" do
|
|
45
47
|
|
46
48
|
end
|
47
49
|
|
50
|
+
it "builds action source files that are defined inside blocks" do
|
51
|
+
Stuka::ProcessBuilder.build
|
52
|
+
|
53
|
+
action_source_files = Dir["#{Stuka::StukaPaths.actions_source_path}/**/*.rb"]
|
54
|
+
action_source_files = action_source_files.map{ |path| File.basename(path) }
|
55
|
+
expect(action_source_files.count).to eq(2)
|
56
|
+
expect(action_source_files.include? "acc1.rb").to be(true)
|
57
|
+
expect(action_source_files.include? "acc2.rb").to be(true)
|
58
|
+
end
|
59
|
+
|
48
60
|
end
|
@@ -4,6 +4,14 @@ require "stuka/internal/source_builders/process_builder"
|
|
4
4
|
|
5
5
|
describe "ProcessCleaner" do
|
6
6
|
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
9
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
10
|
+
example.run
|
11
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
12
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
13
|
+
end
|
14
|
+
|
7
15
|
it "deletes ruby source with ProcessCleaner::clean" do
|
8
16
|
Stuka::ProcessBuilder.build
|
9
17
|
Stuka::ProcessCleaner.clean
|
@@ -14,13 +14,13 @@ describe Stuka::ProcessDomainBuilder do
|
|
14
14
|
description "desc2"
|
15
15
|
end
|
16
16
|
|
17
|
-
expect(pdb.
|
17
|
+
expect(pdb.process_instances.count).to eq(2)
|
18
18
|
|
19
|
-
proc1 = pdb.
|
19
|
+
proc1 = pdb.process_instances[0]
|
20
20
|
expect(proc1.name).to eq("new_process1")
|
21
21
|
expect(proc1.description).to eq("desc1")
|
22
22
|
|
23
|
-
proc2 = pdb.
|
23
|
+
proc2 = pdb.process_instances[1]
|
24
24
|
expect(proc2.name).to eq("new_process2")
|
25
25
|
expect(proc2.description).to eq("desc2")
|
26
26
|
end
|
@@ -29,9 +29,19 @@ describe Stuka::ProcessDomainBuilder do
|
|
29
29
|
it "evaluates correct test files with ProcessDomainBuilder#build_domain" do
|
30
30
|
pdb = Stuka::ProcessDomainBuilder.new
|
31
31
|
pdb.build_domain
|
32
|
-
expect(pdb.
|
33
|
-
expect(pdb.
|
34
|
-
expect(pdb.
|
32
|
+
expect(pdb.process_instances.count).to eq(2)
|
33
|
+
expect(pdb.process_instances.map(&:name).include? "check_smth").to be true
|
34
|
+
expect(pdb.process_instances.map(&:name).include? "test2").to be true
|
35
|
+
|
36
|
+
expect(pdb.action_instances.count).to eq(2)
|
37
|
+
|
38
|
+
expect(pdb.action_instances[0].name).to eq("acc1")
|
39
|
+
expect(pdb.action_instances[0].definition_file).to eq "#{(Stuka::StukaPaths.processes_definition_path)}/correct_test_process.rb"
|
40
|
+
expect(pdb.action_instances[0].endings).to eq [:success, :failure]
|
41
|
+
|
42
|
+
expect(pdb.action_instances[1].name).to eq("acc2")
|
43
|
+
expect(pdb.action_instances[1].definition_file).to eq "#{(Stuka::StukaPaths.processes_definition_path)}/correct_test_process.rb"
|
44
|
+
expect(pdb.action_instances[1].endings).to eq [:success, :failure]
|
35
45
|
end
|
36
46
|
end
|
37
47
|
|
@@ -6,11 +6,11 @@ describe "Validator" do
|
|
6
6
|
|
7
7
|
let(:validator) { Stuka::Validator.new }
|
8
8
|
|
9
|
-
let(:valid_process) { Stuka::Process.new("pr1", "pr2_desc",
|
10
|
-
let(:valid_process2) { Stuka::Process.new("pr2", "pr2_desc",
|
9
|
+
let(:valid_process) { Stuka::Process.new("pr1", "pr2_desc", "start_action") }
|
10
|
+
let(:valid_process2) { Stuka::Process.new("pr2", "pr2_desc", "start_action") }
|
11
11
|
|
12
|
-
let(:invalid_process) { Stuka::Process.new("pr3", nil,
|
13
|
-
let(:invalid_process2) { Stuka::Process.new("", "description",
|
12
|
+
let(:invalid_process) { Stuka::Process.new("pr3", nil, "start_action") }
|
13
|
+
let(:invalid_process2) { Stuka::Process.new("", "description", "start_action") }
|
14
14
|
|
15
15
|
context "when testing single process" do
|
16
16
|
|
@@ -4,7 +4,7 @@ process "check_smth" do
|
|
4
4
|
start_block "test_block_1"
|
5
5
|
|
6
6
|
block "test_block_1" do
|
7
|
-
action "bla::acc1"
|
7
|
+
action "bla::acc1", "acc1 description"
|
8
8
|
endings(
|
9
9
|
success: "test_block_2",
|
10
10
|
failure: "process::failure"
|
@@ -12,7 +12,7 @@ process "check_smth" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
block "test_block_2" do
|
15
|
-
action "bla::acc2"
|
15
|
+
action "bla::acc2", "acc2 description"
|
16
16
|
endings(
|
17
17
|
success: "process::success",
|
18
18
|
failure: "process::failure"
|
@@ -27,7 +27,7 @@ process "test2" do
|
|
27
27
|
start_block "block_1"
|
28
28
|
|
29
29
|
block "block_1" do
|
30
|
-
action "bla::acc1"
|
30
|
+
action "bla::acc1", "acc1 description"
|
31
31
|
endings(
|
32
32
|
success: "process::success",
|
33
33
|
failure: "process::failure"
|
@@ -35,8 +35,7 @@ process "test2" do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
action "bla::acc1" do
|
38
|
+
action "bla::acc3" do
|
40
39
|
description "acc description
|
41
40
|
some more
|
42
41
|
text"
|
@@ -45,7 +44,7 @@ action "bla::acc1" do
|
|
45
44
|
end
|
46
45
|
|
47
46
|
|
48
|
-
action "bla::
|
47
|
+
action "bla::acc4" do
|
49
48
|
description "acc description"
|
50
49
|
|
51
50
|
endings [:success, :failure]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stuka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Sljukic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/stuka/external/process_states/started_state.rb
|
106
106
|
- lib/stuka/external/unknown_action.rb
|
107
107
|
- lib/stuka/internal/domain/action.rb
|
108
|
+
- lib/stuka/internal/domain/block.rb
|
108
109
|
- lib/stuka/internal/domain/domain.rb
|
109
110
|
- lib/stuka/internal/domain/process.rb
|
110
111
|
- lib/stuka/internal/domain_builders/action_domain_builder.rb
|