stuka 0.0.8 → 0.0.9
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/internal/action.rb +33 -0
- data/lib/stuka/internal/action_builder.rb +31 -0
- data/lib/stuka/internal/action_incubator.rb +37 -0
- data/lib/stuka/internal/process.rb +30 -0
- data/lib/stuka/internal/process_builder.rb +18 -9
- data/lib/stuka/internal/process_cleaner.rb +7 -9
- data/lib/stuka/internal/process_incubator.rb +37 -0
- data/lib/stuka/internal/validator.rb +39 -0
- data/lib/stuka/stuka_paths.rb +21 -0
- data/lib/stuka/templates/source/action.tt +9 -0
- data/lib/stuka/templates/source/process.tt +8 -0
- data/lib/stuka/templates/tasks/rakefile.tt +13 -6
- data/lib/stuka/version.rb +1 -1
- data/spec/build/action_builder_spec.rb +23 -0
- data/spec/build/action_incubator_spec.rb +24 -0
- data/spec/build/dsl_spec.rb +44 -0
- data/spec/build/process_builder_spec.rb +23 -0
- data/spec/build/process_cleaner_spec.rb +15 -0
- data/spec/build/process_incubator_spec.rb +27 -0
- data/spec/build/process_validator_spec.rb +40 -0
- data/spec/build/processes_dsl_test/correct_test_process.rb +25 -0
- data/spec/build/processes_dsl_test/incorrect/incorrect_test_process.rb +20 -0
- data/spec/{new_command_spec.rb → commands/new_command_spec.rb} +1 -1
- data/spec/{process_command_spec.rb → commands/process_command_spec.rb} +1 -1
- data/spec/{setup_command_spec.rb → commands/setup_command_spec.rb} +1 -1
- data/spec/{step_command_spec.rb → commands/step_command_spec.rb} +1 -1
- data/spec/spec_helper.rb +8 -0
- metadata +36 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4906f828f358b2c15207f6683744758dee8a4a7
|
4
|
+
data.tar.gz: f4030865b1d8133cd03e7e78f7600da124470228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fba522774519973b68bdfbb8fc5cd72e8a39bbe8ce1e3a79f7ed39f8e5ef64bc2368e997eb4f2c82e55132cab19947538ad9171f285e099a36c14ba2ce9b463
|
7
|
+
data.tar.gz: cd85cdf3b64e6cea7161237700199defef031ccca3c0b4f58ef367d5b1afcf6b7e0dfbfa5cd839ac16f752a83a5fcb99e79e666cf70503fbdc977e89033b071a
|
data/.gitignore
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
class Action
|
4
|
+
|
5
|
+
# must not be nil
|
6
|
+
ATTRS = ["name", "description", "namespace"]
|
7
|
+
|
8
|
+
# must not be empty
|
9
|
+
REQUIRED_ATTRS = ["name", "description", "namespace"]
|
10
|
+
|
11
|
+
def initialize(name, description = nil, namespace = nil)
|
12
|
+
@name = name
|
13
|
+
@description = description if description
|
14
|
+
@namespace = namespace if namespace
|
15
|
+
end
|
16
|
+
|
17
|
+
ATTRS.each do |arg_name|
|
18
|
+
define_method arg_name.to_sym do |arg = nil|
|
19
|
+
if arg
|
20
|
+
instance_variable_set("@#{arg_name}".to_sym, arg)
|
21
|
+
else
|
22
|
+
instance_variable_get("@#{arg_name}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_binding
|
28
|
+
binding()
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
require_relative 'action_incubator'
|
3
|
+
require_relative '../stuka_paths'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'erb'
|
6
|
+
|
7
|
+
module Stuka
|
8
|
+
|
9
|
+
class ActionBuilder
|
10
|
+
|
11
|
+
def self.build
|
12
|
+
|
13
|
+
action_incubator = ActionIncubator.new
|
14
|
+
action_incubator.incubate
|
15
|
+
|
16
|
+
template_file = "#{File.expand_path(File.dirname(__FILE__))}/../templates/source/action.tt"
|
17
|
+
renderer = ERB.new(File.read(template_file))
|
18
|
+
|
19
|
+
FileUtils.mkdir_p Stuka::StukaPaths::ACTIONS_SOURCE_PATH
|
20
|
+
|
21
|
+
action_incubator.actions.each do |acc|
|
22
|
+
out_file = File.new("#{Stuka::StukaPaths::ACTIONS_SOURCE_PATH}/#{acc.name}_action.rb", "w")
|
23
|
+
out_file.puts(renderer.result(acc.get_binding))
|
24
|
+
out_file.close
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
require_relative '../stuka_paths'
|
3
|
+
|
4
|
+
module Stuka
|
5
|
+
|
6
|
+
class ActionIncubator
|
7
|
+
|
8
|
+
attr_accessor :actions
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@actions = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def action(name, &block)
|
15
|
+
act = Action.new(name)
|
16
|
+
act.instance_eval(&block)
|
17
|
+
@actions << act
|
18
|
+
act
|
19
|
+
end
|
20
|
+
|
21
|
+
def incubate
|
22
|
+
action_files.each do |path|
|
23
|
+
instance_eval(File.read(path), path, __LINE__)
|
24
|
+
end
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def action_files
|
29
|
+
Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/*.rb"]
|
30
|
+
end
|
31
|
+
|
32
|
+
# just ignore process calls, so we can mix process and actions in same files
|
33
|
+
def process(*args); end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -2,6 +2,36 @@ module Stuka
|
|
2
2
|
|
3
3
|
class Process
|
4
4
|
|
5
|
+
# must not be nil
|
6
|
+
ATTRS = ["name", "description", "arguments"]
|
7
|
+
|
8
|
+
# must not be empty
|
9
|
+
REQUIRED_ATTRS = ["name", "description"]
|
10
|
+
|
11
|
+
def initialize(name, description = nil, arguments = nil)
|
12
|
+
@arguments = []
|
13
|
+
@name = name
|
14
|
+
@description = description if description
|
15
|
+
@arguments = arguments if arguments
|
16
|
+
end
|
17
|
+
|
18
|
+
ATTRS.each do |arg_name|
|
19
|
+
define_method arg_name.to_sym do |arg = nil|
|
20
|
+
if arg
|
21
|
+
instance_variable_set("@#{arg_name}".to_sym, arg)
|
22
|
+
else
|
23
|
+
instance_variable_get("@#{arg_name}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_binding
|
29
|
+
binding()
|
30
|
+
end
|
31
|
+
|
32
|
+
def action_transition(action_name, transition_hash)
|
33
|
+
"#{action_name} this will be important later"
|
34
|
+
end
|
5
35
|
|
6
36
|
end
|
7
37
|
|
@@ -1,19 +1,28 @@
|
|
1
|
+
require_relative 'process'
|
2
|
+
require_relative 'process_incubator'
|
3
|
+
require_relative '../stuka_paths'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'erb'
|
6
|
+
|
1
7
|
module Stuka
|
2
8
|
|
3
9
|
class ProcessBuilder
|
4
10
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
11
|
+
def self.build
|
12
|
+
process_incubator = ProcessIncubator.new
|
13
|
+
process_incubator.incubate
|
14
|
+
|
15
|
+
template_file = "#{File.expand_path(File.dirname(__FILE__))}/../templates/source/process.tt"
|
16
|
+
renderer = ERB.new(File.read(template_file))
|
17
|
+
|
18
|
+
FileUtils.mkdir_p Stuka::StukaPaths::PROCESSES_SOURCE_PATH
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
process_name = File.basename(file, ".rb")
|
13
|
-
out_file = File.new("processes/processes/#{process_name}.rb", "w")
|
14
|
-
out_file.puts("Class #{process_name}; end")
|
20
|
+
process_incubator.processes.each do |proc|
|
21
|
+
out_file = File.new("#{Stuka::StukaPaths::PROCESSES_SOURCE_PATH}/#{proc.name}_process.rb", "w")
|
22
|
+
out_file.puts(renderer.result(proc.get_binding))
|
15
23
|
out_file.close
|
16
24
|
end
|
25
|
+
|
17
26
|
end
|
18
27
|
|
19
28
|
end
|
@@ -1,23 +1,21 @@
|
|
1
|
+
require_relative '../stuka_paths'
|
2
|
+
|
1
3
|
module Stuka
|
2
4
|
|
3
5
|
class ProcessCleaner
|
4
6
|
|
5
|
-
def gather_process_files
|
6
|
-
Dir["#{
|
7
|
+
def self.gather_process_files
|
8
|
+
Dir["#{Stuka::StukaPaths::PROCESSES_SOURCE_PATH}/*.rb"]
|
7
9
|
end
|
8
10
|
|
9
|
-
def gather_action_files
|
11
|
+
def self.gather_action_files
|
10
12
|
Dir["#{Dir.pwd}/processes/actions/*_action.rb"]
|
11
13
|
end
|
12
14
|
|
13
|
-
def clean
|
15
|
+
def self.clean
|
14
16
|
files = gather_process_files + gather_action_files
|
15
17
|
files.each do |path|
|
16
|
-
|
17
|
-
File.delete(path)
|
18
|
-
rescue SystemCallError => e
|
19
|
-
$stderr.puts e.message
|
20
|
-
end
|
18
|
+
File.delete(path)
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'process'
|
2
|
+
require_relative '../stuka_paths'
|
3
|
+
|
4
|
+
module Stuka
|
5
|
+
|
6
|
+
class ProcessIncubator
|
7
|
+
|
8
|
+
attr_accessor :processes
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@processes = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def process(name, &block)
|
15
|
+
proc = Process.new(name)
|
16
|
+
proc.instance_eval(&block)
|
17
|
+
@processes << proc
|
18
|
+
proc
|
19
|
+
end
|
20
|
+
|
21
|
+
def incubate
|
22
|
+
process_files.each do |path|
|
23
|
+
instance_eval(File.read(path), path, __LINE__)
|
24
|
+
end
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def process_files
|
29
|
+
Dir["#{Stuka::StukaPaths::PROCESSES_DEFINITION_PATH}/*.rb"]
|
30
|
+
end
|
31
|
+
|
32
|
+
# ignore action calls so action and process calls can be mixed in same files
|
33
|
+
def action(*arg); end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'process'
|
2
|
+
|
3
|
+
module Stuka
|
4
|
+
|
5
|
+
class Validator
|
6
|
+
|
7
|
+
def self.process_valid?(process)
|
8
|
+
|
9
|
+
Stuka::Process::ATTRS.each do |arg|
|
10
|
+
result = process.public_send(arg.to_sym)
|
11
|
+
return false if result.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
Stuka::Process::REQUIRED_ATTRS.each do |arg|
|
15
|
+
result = process.public_send(arg.to_sym)
|
16
|
+
return false if result.nil? || result.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.process_set_valid?(processes)
|
23
|
+
|
24
|
+
return false if processes.include? nil
|
25
|
+
|
26
|
+
names = processes.map(&:name)
|
27
|
+
|
28
|
+
return false if names.include?(nil) || names.include?("")
|
29
|
+
|
30
|
+
if names.uniq.length == names.length
|
31
|
+
return true
|
32
|
+
else
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Stuka
|
2
|
+
|
3
|
+
module StukaPaths
|
4
|
+
|
5
|
+
PROCESSES_DEFINITION_PATH = "#{Dir.pwd}/process_definition/processes/*.rb"
|
6
|
+
PROCESSES_SOURCE_PATH = "#{Dir.pwd}/processes"
|
7
|
+
|
8
|
+
ACTIONS_DEFINITION_PATH = "#{Dir.pwd}/process_definition/actions/*.rb"
|
9
|
+
ACTIONS_SOURCE_PATH = "#{Dir.pwd}/actions"
|
10
|
+
|
11
|
+
TEST_PROCESSES_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/processes_dsl_test"
|
12
|
+
TEST_PROCESSES_INCORRECT_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/processes_dsl_test/incorrect"
|
13
|
+
TEST_PROCESSES_SOURCE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/processes_source_test"
|
14
|
+
|
15
|
+
TEST_ACTIONS_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/actions_dsl_test"
|
16
|
+
TEST_ACTIONS_INCORRECT_DEFINITION_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/action_dsl_test/incorrect"
|
17
|
+
TEST_ACTIONS_SOURCE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/../../spec/build/actions_source_test"
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -1,15 +1,22 @@
|
|
1
1
|
task :clean do
|
2
2
|
|
3
3
|
require 'stuka/internal/process_cleaner'
|
4
|
-
|
5
|
-
cl.clean
|
4
|
+
Stuka::ProcessCleaner.clean
|
6
5
|
|
7
6
|
end
|
8
7
|
|
9
|
-
task :
|
8
|
+
task :build_processes do
|
10
9
|
|
11
10
|
require 'stuka/internal/process_builder'
|
12
|
-
|
13
|
-
pb.build_processes
|
11
|
+
Stuka::ProcessBuilder.build
|
14
12
|
|
15
|
-
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task :build_actions do
|
16
|
+
|
17
|
+
require 'stuka/internal/action_builder'
|
18
|
+
Stuka::ActionBuilder.build
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
task :build => [:clean, :build_processes, :build_actions]
|
data/lib/stuka/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/action_builder"
|
3
|
+
require_relative "../../lib/stuka/stuka_paths"
|
4
|
+
|
5
|
+
describe "ActionBuilder" do
|
6
|
+
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
9
|
+
example.run
|
10
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_ACTIONS_SOURCE_PATH}/.", secure: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "builds ruby source with ProcessBuilder::build" do
|
14
|
+
Stuka::ActionBuilder.build
|
15
|
+
|
16
|
+
source_files = Dir["#{Stuka::StukaPaths::ACTIONS_SOURCE_PATH}/*.rb"]
|
17
|
+
source_files = source_files.map{ |path| File.basename(path) }
|
18
|
+
expect(source_files.count).to eq(2)
|
19
|
+
expect(source_files.include? "acc1_action.rb").to be(true)
|
20
|
+
expect(source_files.include? "acc2_action.rb").to be(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/action_incubator"
|
3
|
+
require_relative "../../lib/stuka/stuka_paths"
|
4
|
+
|
5
|
+
describe Stuka::ActionIncubator do
|
6
|
+
|
7
|
+
it "ActionIncubator#action, it creates an action and stores it in @actions attribute, this are the methods called in the dsl." do
|
8
|
+
act_incubator = Stuka::ActionIncubator.new
|
9
|
+
|
10
|
+
act_incubator.action("new_action1") do
|
11
|
+
description "desc1"
|
12
|
+
end
|
13
|
+
|
14
|
+
act_incubator.action("new_action2") do
|
15
|
+
description "desc2"
|
16
|
+
end
|
17
|
+
|
18
|
+
expect(act_incubator.actions.count).to eq(2)
|
19
|
+
act1 = act_incubator.actions.first
|
20
|
+
expect(act1.name).to eq("new_action1")
|
21
|
+
expect(act1.description).to eq("desc1")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/process_incubator"
|
3
|
+
require_relative "../../lib/stuka/internal/action_incubator"
|
4
|
+
require_relative "../../lib/stuka/stuka_paths"
|
5
|
+
|
6
|
+
describe "processes dsl test" do
|
7
|
+
|
8
|
+
context "when dsl syntax is correct" do
|
9
|
+
it "ProcessIncubator#incubate evaluates correct test files" do
|
10
|
+
proc_incubator = Stuka::ProcessIncubator.new
|
11
|
+
proc_incubator.incubate
|
12
|
+
expect(proc_incubator.processes.count).to eq(2)
|
13
|
+
expect(proc_incubator.processes.map(&:name).include? "test1").to be true
|
14
|
+
expect(proc_incubator.processes.map(&:name).include? "test2").to be true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "ActionIncubator#incubate evaluates correct test dsl files" do
|
18
|
+
act_incubator = Stuka::ActionIncubator.new
|
19
|
+
act_incubator.incubate
|
20
|
+
expect(act_incubator.actions.count).to eq(2)
|
21
|
+
expect(act_incubator.actions.map(&:name).include? "acc1").to be true
|
22
|
+
expect(act_incubator.actions.map(&:name).include? "acc2").to be true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when dsl syntax is incorrect" do
|
27
|
+
|
28
|
+
before(:each) do
|
29
|
+
Stuka::StukaPaths::PROCESSES_DEFINITION_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_INCORRECT_DEFINITION_PATH
|
30
|
+
end
|
31
|
+
|
32
|
+
it "ProcessIncubator#incubate evaluates bad test files" do
|
33
|
+
proc_incubator = Stuka::ProcessIncubator.new
|
34
|
+
expect{proc_incubator.incubate}.to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it "ActionIncubator#incubate evaluates bad test files" do
|
38
|
+
act_incubator = Stuka::ActionIncubator.new
|
39
|
+
expect{act_incubator.incubate}.to raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/process_builder"
|
3
|
+
require_relative "../../lib/stuka/stuka_paths"
|
4
|
+
|
5
|
+
describe "ProcessBuilder" do
|
6
|
+
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
9
|
+
example.run
|
10
|
+
FileUtils.rm_rf("#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/.", secure: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "builds ruby source with ProcessBuilder::build" do
|
14
|
+
Stuka::ProcessBuilder.build
|
15
|
+
|
16
|
+
source_files = Dir["#{Stuka::StukaPaths::PROCESSES_SOURCE_PATH}/*.rb"]
|
17
|
+
source_files = source_files.map{ |path| File.basename(path) }
|
18
|
+
expect(source_files.count).to eq(2)
|
19
|
+
expect(source_files.include? "test1_process.rb").to be(true)
|
20
|
+
expect(source_files.include? "test2_process.rb").to be(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/process_cleaner"
|
3
|
+
require_relative "../../lib/stuka/internal/process_builder"
|
4
|
+
require_relative "../../lib/stuka/stuka_paths"
|
5
|
+
|
6
|
+
describe "ProcessCleaner" do
|
7
|
+
|
8
|
+
it "deletes ruby source with ProcessCleaner::clean" do
|
9
|
+
Stuka::ProcessBuilder.build
|
10
|
+
Stuka::ProcessCleaner.clean
|
11
|
+
source_files = Dir["#{Stuka::StukaPaths::TEST_PROCESSES_SOURCE_PATH}/*.rb"]
|
12
|
+
expect(source_files.count).to eq(0)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/process_incubator"
|
3
|
+
require_relative "../../lib/stuka/stuka_paths"
|
4
|
+
|
5
|
+
describe Stuka::ProcessIncubator do
|
6
|
+
|
7
|
+
it "ProcessIncubator#process, it creates a process and stores it in @processes attribute, this are the methods called in the dsl." do
|
8
|
+
proc_incubator = Stuka::ProcessIncubator.new
|
9
|
+
|
10
|
+
proc_incubator.process("new_process1") do
|
11
|
+
description "desc1"
|
12
|
+
arguments ["arg1", "arg2"]
|
13
|
+
end
|
14
|
+
|
15
|
+
proc_incubator.process("new_process2") do
|
16
|
+
description "desc2"
|
17
|
+
arguments ["arg1", "arg2"]
|
18
|
+
end
|
19
|
+
|
20
|
+
expect(proc_incubator.processes.count).to eq(2)
|
21
|
+
proc1 = proc_incubator.processes.first
|
22
|
+
expect(proc1.name).to eq("new_process1")
|
23
|
+
expect(proc1.description).to eq("desc1")
|
24
|
+
expect(proc1.arguments).to eq(["arg1", "arg2"])
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../lib/stuka/internal/validator"
|
3
|
+
require_relative "../../lib/stuka/internal/process"
|
4
|
+
|
5
|
+
describe "Validator" do
|
6
|
+
|
7
|
+
let(:valid_process) { Stuka::Process.new("pr1", "pr2_desc", ["arg1", "arg2"]) }
|
8
|
+
let(:valid_process2) { Stuka::Process.new("pr2", "pr2_desc", []) }
|
9
|
+
|
10
|
+
let(:invalid_process) { Stuka::Process.new("pr3", nil, ["arg1", "arg2"]) }
|
11
|
+
let(:invalid_process2) { Stuka::Process.new("", "description", ["arg1", "arg2"]) }
|
12
|
+
|
13
|
+
context "when testing single process" do
|
14
|
+
|
15
|
+
it "Validator::process_valid?" do
|
16
|
+
expect(Stuka::Validator.process_valid? valid_process).to eq(true)
|
17
|
+
expect(Stuka::Validator.process_valid? valid_process2).to eq(true)
|
18
|
+
expect(Stuka::Validator.process_valid? invalid_process).to eq(false)
|
19
|
+
expect(Stuka::Validator.process_valid? invalid_process2).to eq(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when testing process sets" do
|
25
|
+
|
26
|
+
let(:valid_process_set) { [valid_process, valid_process2] }
|
27
|
+
let(:invalid_process_set) { [valid_process, valid_process, valid_process2] }
|
28
|
+
let(:invalid_process_set2) { [valid_process, valid_process, nil] }
|
29
|
+
let(:invalid_process_set3) { [valid_process, valid_process2, invalid_process2] }
|
30
|
+
|
31
|
+
it "Validator::process_set_valid? checks if all processes have different names" do
|
32
|
+
expect(Stuka::Validator.process_set_valid? valid_process_set).to eq(true)
|
33
|
+
expect(Stuka::Validator.process_set_valid? invalid_process_set).to eq(false)
|
34
|
+
expect(Stuka::Validator.process_set_valid? invalid_process_set2).to eq(false)
|
35
|
+
expect(Stuka::Validator.process_set_valid? invalid_process_set3).to eq(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
process "test1" do
|
2
|
+
description "pro description"
|
3
|
+
arguments ["muzika", "stuke"]
|
4
|
+
action_transition "akcija",
|
5
|
+
success: "druga",
|
6
|
+
failure: "treca"
|
7
|
+
end
|
8
|
+
|
9
|
+
process "test2" do
|
10
|
+
description "proc2 description"
|
11
|
+
arguments ["taylor", "swift"]
|
12
|
+
action_transition "akcija",
|
13
|
+
success: "bla",
|
14
|
+
failure: "foo"
|
15
|
+
end
|
16
|
+
|
17
|
+
action "acc1" do
|
18
|
+
description "acc description"
|
19
|
+
namespace "bla"
|
20
|
+
end
|
21
|
+
|
22
|
+
action "acc2" do
|
23
|
+
description "acc description"
|
24
|
+
namespace "bla"
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
process "test" do
|
2
|
+
deion "pro description"
|
3
|
+
arguments ["muzika", "stuke"]
|
4
|
+
action_transition "akcija",
|
5
|
+
success: "druga",
|
6
|
+
failure: "treca"
|
7
|
+
end
|
8
|
+
|
9
|
+
process "proc2" do
|
10
|
+
some_stuff "proc2 description"
|
11
|
+
arguments ["taylor", "swift"]
|
12
|
+
action_transition "akcija",
|
13
|
+
success: "bla",
|
14
|
+
failure: "foo"
|
15
|
+
end
|
16
|
+
|
17
|
+
action "acc1" do
|
18
|
+
descss "acc description"
|
19
|
+
namespace "acc_namespace"
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,6 +17,14 @@
|
|
17
17
|
RSpec.configure do |config|
|
18
18
|
# The settings below are suggested to provide a good initial experience
|
19
19
|
# with RSpec, but feel free to customize to your heart's content.
|
20
|
+
|
21
|
+
config.before(:each) do
|
22
|
+
require_relative "../lib/stuka/stuka_paths"
|
23
|
+
Stuka::StukaPaths::PROCESSES_DEFINITION_PATH.replace Stuka::StukaPaths::TEST_PROCESSES_DEFINITION_PATH
|
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
|
26
|
+
end
|
27
|
+
|
20
28
|
=begin
|
21
29
|
# These two settings work together to allow you to limit a spec run
|
22
30
|
# to individual examples or groups you care about by tagging them with
|
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.0.
|
4
|
+
version: 0.0.9
|
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-09-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,23 +94,40 @@ files:
|
|
94
94
|
- lib/stuka/commands/subcommands/setup/setup_gemfile.rb
|
95
95
|
- lib/stuka/commands/subcommands/setup/setup_rakefile.rb
|
96
96
|
- lib/stuka/commands/subcommands/setup/setup_tasks.rb
|
97
|
+
- lib/stuka/internal/action.rb
|
98
|
+
- lib/stuka/internal/action_builder.rb
|
99
|
+
- lib/stuka/internal/action_incubator.rb
|
97
100
|
- lib/stuka/internal/process.rb
|
98
101
|
- lib/stuka/internal/process_builder.rb
|
99
102
|
- lib/stuka/internal/process_cleaner.rb
|
103
|
+
- lib/stuka/internal/process_incubator.rb
|
104
|
+
- lib/stuka/internal/validator.rb
|
100
105
|
- lib/stuka/stuka_cli.rb
|
106
|
+
- lib/stuka/stuka_paths.rb
|
101
107
|
- lib/stuka/templates/configs/gemfile.tt
|
102
108
|
- lib/stuka/templates/definitions/process.tt
|
103
109
|
- lib/stuka/templates/definitions/step.tt
|
104
110
|
- lib/stuka/templates/samples/my_first_step.tt
|
105
111
|
- lib/stuka/templates/samples/my_process.tt
|
106
112
|
- lib/stuka/templates/samples/my_second_step.tt
|
113
|
+
- lib/stuka/templates/source/action.tt
|
114
|
+
- lib/stuka/templates/source/process.tt
|
107
115
|
- lib/stuka/templates/tasks/rakefile.tt
|
108
116
|
- lib/stuka/version.rb
|
109
|
-
- spec/
|
110
|
-
- spec/
|
111
|
-
- spec/
|
117
|
+
- spec/build/action_builder_spec.rb
|
118
|
+
- spec/build/action_incubator_spec.rb
|
119
|
+
- spec/build/dsl_spec.rb
|
120
|
+
- spec/build/process_builder_spec.rb
|
121
|
+
- spec/build/process_cleaner_spec.rb
|
122
|
+
- spec/build/process_incubator_spec.rb
|
123
|
+
- spec/build/process_validator_spec.rb
|
124
|
+
- spec/build/processes_dsl_test/correct_test_process.rb
|
125
|
+
- spec/build/processes_dsl_test/incorrect/incorrect_test_process.rb
|
126
|
+
- spec/commands/new_command_spec.rb
|
127
|
+
- spec/commands/process_command_spec.rb
|
128
|
+
- spec/commands/setup_command_spec.rb
|
129
|
+
- spec/commands/step_command_spec.rb
|
112
130
|
- spec/spec_helper.rb
|
113
|
-
- spec/step_command_spec.rb
|
114
131
|
- stuka.gemspec
|
115
132
|
homepage: ''
|
116
133
|
licenses:
|
@@ -137,8 +154,17 @@ signing_key:
|
|
137
154
|
specification_version: 4
|
138
155
|
summary: Stuka is a dsl for managing business processes
|
139
156
|
test_files:
|
140
|
-
- spec/
|
141
|
-
- spec/
|
142
|
-
- spec/
|
157
|
+
- spec/build/action_builder_spec.rb
|
158
|
+
- spec/build/action_incubator_spec.rb
|
159
|
+
- spec/build/dsl_spec.rb
|
160
|
+
- spec/build/process_builder_spec.rb
|
161
|
+
- spec/build/process_cleaner_spec.rb
|
162
|
+
- spec/build/process_incubator_spec.rb
|
163
|
+
- spec/build/process_validator_spec.rb
|
164
|
+
- spec/build/processes_dsl_test/correct_test_process.rb
|
165
|
+
- spec/build/processes_dsl_test/incorrect/incorrect_test_process.rb
|
166
|
+
- spec/commands/new_command_spec.rb
|
167
|
+
- spec/commands/process_command_spec.rb
|
168
|
+
- spec/commands/setup_command_spec.rb
|
169
|
+
- spec/commands/step_command_spec.rb
|
143
170
|
- spec/spec_helper.rb
|
144
|
-
- spec/step_command_spec.rb
|