bizflow 0.0.1

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 (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +27 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +105 -0
  7. data/Rakefile +2 -0
  8. data/bin/bizflow +28 -0
  9. data/bizflow.gemspec +29 -0
  10. data/lib/bizflow/business_model/handler.rb +13 -0
  11. data/lib/bizflow/business_model/head.rb +34 -0
  12. data/lib/bizflow/business_model/input_action.rb +47 -0
  13. data/lib/bizflow/business_model/process.rb +46 -0
  14. data/lib/bizflow/business_model/simple_wrapper.rb +22 -0
  15. data/lib/bizflow/business_model/task.rb +41 -0
  16. data/lib/bizflow/business_model/task_action.rb +36 -0
  17. data/lib/bizflow/command/build_command.rb +33 -0
  18. data/lib/bizflow/command/clean_command.rb +9 -0
  19. data/lib/bizflow/command/command_helper.rb +19 -0
  20. data/lib/bizflow/command/help_command.rb +11 -0
  21. data/lib/bizflow/command/install_command.rb +16 -0
  22. data/lib/bizflow/command/setup_command.rb +29 -0
  23. data/lib/bizflow/config_generator.rb +16 -0
  24. data/lib/bizflow/data_model/action.rb +22 -0
  25. data/lib/bizflow/data_model/action_blueprint.rb +22 -0
  26. data/lib/bizflow/data_model/handler.rb +16 -0
  27. data/lib/bizflow/data_model/handler_blueprint.rb +17 -0
  28. data/lib/bizflow/data_model/head.rb +16 -0
  29. data/lib/bizflow/data_model/next_action.rb +17 -0
  30. data/lib/bizflow/data_model/next_action_blueprint.rb +17 -0
  31. data/lib/bizflow/data_model/process.rb +31 -0
  32. data/lib/bizflow/data_model/process_blueprint.rb +17 -0
  33. data/lib/bizflow/data_model/task.rb +17 -0
  34. data/lib/bizflow/data_model/task_blueprint.rb +17 -0
  35. data/lib/bizflow/fakes/action.rb +23 -0
  36. data/lib/bizflow/fakes/action_blueprint.rb +24 -0
  37. data/lib/bizflow/fakes/handler.rb +15 -0
  38. data/lib/bizflow/fakes/handler_blueprint.rb +18 -0
  39. data/lib/bizflow/fakes/head.rb +14 -0
  40. data/lib/bizflow/fakes/process.rb +20 -0
  41. data/lib/bizflow/fakes/process_blueprint.rb +14 -0
  42. data/lib/bizflow/fakes/task.rb +16 -0
  43. data/lib/bizflow/fakes/task_blueprint.rb +19 -0
  44. data/lib/bizflow/interpreters/domain_interpreter.rb +19 -0
  45. data/lib/bizflow/interpreters/input_action_interpreter.rb +35 -0
  46. data/lib/bizflow/interpreters/process_interpreter.rb +37 -0
  47. data/lib/bizflow/interpreters/task_action_interpreter.rb +29 -0
  48. data/lib/bizflow/lib/blueprint_builder.rb +90 -0
  49. data/lib/bizflow/lib/callback_handler.rb +27 -0
  50. data/lib/bizflow/lib/callbackable.rb +25 -0
  51. data/lib/bizflow/lib/process_builder.rb +61 -0
  52. data/lib/bizflow/lib/semantic_builder.rb +36 -0
  53. data/lib/bizflow/migrations/001_create_processes.rb +21 -0
  54. data/lib/bizflow/migrations/002_create_actions.rb +17 -0
  55. data/lib/bizflow/migrations/003_create_process_heads.rb +15 -0
  56. data/lib/bizflow/migrations/004_create_tasks.rb +16 -0
  57. data/lib/bizflow/migrations/005_create_process_blueprints.rb +14 -0
  58. data/lib/bizflow/migrations/006_action_blueprints.rb +16 -0
  59. data/lib/bizflow/migrations/007_next_action_blueprints.rb +14 -0
  60. data/lib/bizflow/migrations/008_handler_blueprints.rb +15 -0
  61. data/lib/bizflow/migrations/009_task_blueprints.rb +16 -0
  62. data/lib/bizflow/migrations/010_create_handlers.rb +16 -0
  63. data/lib/bizflow/migrations/011_next_actions.rb +14 -0
  64. data/lib/bizflow/monkey_patch.rb +12 -0
  65. data/lib/bizflow/repos/repo.rb +21 -0
  66. data/lib/bizflow/semantic_model/action.rb +29 -0
  67. data/lib/bizflow/semantic_model/domain_repo.rb +19 -0
  68. data/lib/bizflow/semantic_model/handler.rb +21 -0
  69. data/lib/bizflow/semantic_model/input_action.rb +19 -0
  70. data/lib/bizflow/semantic_model/process.rb +29 -0
  71. data/lib/bizflow/semantic_model/task.rb +18 -0
  72. data/lib/bizflow/semantic_model/task_action.rb +26 -0
  73. data/lib/bizflow/source_generator.rb +62 -0
  74. data/lib/bizflow/source_presenters/process_template_presenter.rb +26 -0
  75. data/lib/bizflow/templates/js/descriptor.tt +9 -0
  76. data/lib/bizflow/templates/js/process.tt +41 -0
  77. data/lib/bizflow/templates/rb/config.tt +11 -0
  78. data/lib/bizflow/templates/rb/handler.tt +4 -0
  79. data/lib/bizflow/templates/rb/process.tt +53 -0
  80. data/lib/bizflow/version.rb +3 -0
  81. data/lib/bizflow.rb +15 -0
  82. data/spec/factories/factories.rb +38 -0
  83. data/spec/spec_config.rb +42 -0
  84. data/spec/spec_helper.rb +89 -0
  85. data/spec/unit/business/business_process_spec.rb +203 -0
  86. data/spec/unit/business/process_alternative_spec.rb +77 -0
  87. data/spec/unit/command/build_order_spec.rb +44 -0
  88. data/spec/unit/command/build_spec.rb +44 -0
  89. data/spec/unit/creating_processes_spec.rb +59 -0
  90. data/spec/unit/dsl_scripts/breakfast/process_file.rb +50 -0
  91. data/spec/unit/dsl_scripts/order/order.rb +41 -0
  92. data/spec/unit/interpreters/interpreters_spec.rb +105 -0
  93. data/text/Master.odt +0 -0
  94. data/text/prezentacija.odp +0 -0
  95. data/text/zbornik.doc +0 -0
  96. metadata +248 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16e6dec37607b0ed02eb68da35726f246f6330ef
4
+ data.tar.gz: b0e87ddc7260ceac3b11ff2195945d0b21184241
5
+ SHA512:
6
+ metadata.gz: 91b8a225ca5c15582d20d66ae6c0d3344ec4a3463eae5d81b4beb78757c062c9187390047e46231ac0cb77241d02b1c062c3e1ce9ced9cc175957ff7b11372d0
7
+ data.tar.gz: 1a368432550ed7edae2dbba31230e8b10d4f734ef78579a028bdefd915f6bcb1367486e9d5a34674ab11f986f2c512f5a30c18ba6585cfde5f337fb6b8e60133
data/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ *.db
23
+ mkmf.log
24
+ /vendor
25
+ text/.~lock.Master.odt#
26
+ text/.~lock.zbornik.doc#
27
+ text/.~lock.prezentacija.odp#
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bizflow.gemspec
4
+ gemspec
5
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 DSljukic
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Bizflow
2
+
3
+ Bizflow is software for managing business processes.
4
+ Its features are:
5
+ - DSL for process modeling
6
+ - Compiling DSL scripts into process models
7
+ - Creating and managing process instances
8
+ - Reviewing status of process instances
9
+
10
+ ## Installation
11
+
12
+ Install sqlite3:
13
+
14
+ $ sudo apt-get install sqlite3 libsqlite3-dev
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'bizflow'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install bizflow
27
+
28
+ ## Usage
29
+
30
+ Setup config file and place for DSL scripts:
31
+
32
+ $ bundle exec bizflow install
33
+
34
+ Setup internal database:
35
+
36
+ $ bundle exec bizflow setup
37
+
38
+ Compile:
39
+
40
+ $ bundle exec bizflow build
41
+
42
+ DSL sample:
43
+
44
+ ```ruby
45
+
46
+ process "make_breakfast" do
47
+
48
+ description "creates breakfast"
49
+
50
+ start "check_supplies"
51
+
52
+ input_action "check_supplies" do
53
+
54
+ description "checks if there are enaugh eggs, bacon and bread"
55
+ question "Are there enaugh supplies?"
56
+
57
+ next_actions(
58
+ not_enaugh_supplies: "get_supplies",
59
+ enaugh_supplies: "make_breakfast"
60
+ )
61
+
62
+ end
63
+
64
+ task_action "get_supplies" do
65
+
66
+ description "get enaugh eggs, bacon and bread"
67
+ task "get_bacon", roles: ["storage", "kitchen"], description: "optional description", auto_assign: true
68
+ task "get_eggs", roles: ["storage", "kitchen"]
69
+ task "get_bread", roles: ["storage"]
70
+
71
+ next_action "make_breakfast"
72
+
73
+ end
74
+
75
+ task_action "make_breakfast" do
76
+
77
+ description "sets stove, fry eggs, roast bacon"
78
+ task "make_breakfast", roles: ["kitchen"]
79
+
80
+ next_action "serve_breakfast"
81
+
82
+ end
83
+
84
+ task_action "serve_breakfast" do
85
+
86
+ task "prepare_table", roles: ["servers"]
87
+ task "slice_bread", roles: ["kitchen"]
88
+
89
+ next_action "process:finish"
90
+
91
+ end
92
+
93
+
94
+ end
95
+
96
+ ```
97
+
98
+
99
+ ## Contributing
100
+
101
+ 1. Fork it ( https://github.com/[my-github-username]/bizflow/fork )
102
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
103
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
104
+ 4. Push to the branch (`git push origin my-new-feature`)
105
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/bizflow ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ args = ARGV.dup
7
+ ARGV.clear
8
+ command = args.shift.strip rescue 'help'
9
+
10
+ require "bizflow/command/command_helper"
11
+
12
+ config = {}
13
+
14
+ if(!["help", "install"].include? command)
15
+ begin
16
+ require "#{Dir.pwd}/bizflow_config"
17
+ config = BizflowConfig::Config
18
+ rescue LoadError
19
+ puts "run bizflow install before continuing"
20
+ abort
21
+ end
22
+ end
23
+
24
+ if Bizflow::CommandHelper::CommandHash.keys.include?(command.to_sym)
25
+ Bizflow::CommandHelper::CommandHash[command.to_sym].run(config, args: args)
26
+ else
27
+ puts "command '#{command}' not recognized"
28
+ end
data/bizflow.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bizflow/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bizflow"
8
+ spec.version = Bizflow::VERSION
9
+ spec.authors = ["DSljukic"]
10
+ spec.email = ["uraniumsheep@gmail.com"]
11
+ spec.summary = %q{DSL for business processes.}
12
+ spec.description = %q{DSL for buisness processes.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'sqlite3', '~> 1.3.10'
22
+ spec.add_runtime_dependency 'sequel'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "factory_girl"
28
+ spec.add_development_dependency "database_cleaner"
29
+ end
@@ -0,0 +1,13 @@
1
+ module Bizflow
2
+ module BusinessModel
3
+
4
+ class Handler < SimpleWrapper
5
+
6
+ def handle
7
+ raise NotImplementedError
8
+ end
9
+
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ require_relative 'simple_wrapper'
2
+ require_relative 'handler'
3
+ require_relative 'task_action'
4
+ require_relative 'input_action'
5
+ require_relative 'process'
6
+
7
+ module Bizflow
8
+ module BusinessModel
9
+
10
+ class Head < SimpleWrapper
11
+
12
+ ActionHash = {
13
+ task: Bizflow::BusinessModel::TaskAction,
14
+ input: Bizflow::BusinessModel::InputAction
15
+ }
16
+
17
+ def jump(next_id = nil)
18
+
19
+ if next_id.nil?
20
+ Bizflow::BusinessModel::Process.wrap(process).finish
21
+ return
22
+ end
23
+
24
+ update(action_id: next_id)
25
+ raise "Head does not point to an action" unless action
26
+ bus_action = ActionHash[action.type.to_sym].new(action)
27
+ bus_action.resolve
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'simple_wrapper'
2
+ require 'bizflow/lib/callbackable'
3
+
4
+ module Bizflow
5
+ module BusinessModel
6
+
7
+ class InputAction < SimpleWrapper
8
+
9
+ include Bizflow::Lib::Callbackable
10
+
11
+ def resolve
12
+
13
+ end
14
+
15
+ def submit_input(input, &block)
16
+
17
+ raise "must have an input" if(input.nil? || input.empty?)
18
+ setup_callbacks(&block)
19
+
20
+ if(heads.nil? || heads.empty?)
21
+ callback(:not_active,
22
+ data: self,
23
+ message: "Action is not active, there are no process heads pointing to this action. No inputs can be submited to inactive actions.")
24
+ return
25
+ end
26
+
27
+ na = next_actions.select { |item| item.ending == input }
28
+
29
+ if(na.nil? || na.empty?)
30
+ callback(:bad_input,
31
+ data: self,
32
+ message: "Input is not valid. Valid inputs for #{name} are #{next_actions.map(&:ending).join(", ")}")
33
+ return
34
+ end
35
+
36
+ next_action = na.first
37
+ bhs = Bizflow::BusinessModel::Head.wraps(heads)
38
+ bhs.each { |h| h.jump(next_action.next_id) }
39
+
40
+ callback(:success, data: self, message: "Input submitted to the process successfully.")
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'simple_wrapper'
2
+ require_relative 'head'
3
+ require 'bizflow/lib/callbackable'
4
+ require 'bizflow/lib/process_builder'
5
+
6
+ module Bizflow
7
+ module BusinessModel
8
+
9
+ class Process < SimpleWrapper
10
+
11
+ include Bizflow::Lib::Callbackable
12
+
13
+ def start(runner_id, &block)
14
+
15
+ setup_callbacks(&block)
16
+
17
+ if runned_at != nil
18
+ callback(:already_started, data: self, message: "process has already been started") and return
19
+ end
20
+
21
+ ph = Bizflow::BusinessModel::Head.wrap(head)
22
+ ph.jump(start_action_id)
23
+ update(runner_id: runner_id, runned_at: Time.now)
24
+
25
+ callback(:success, data: self, message: "process started successfully")
26
+
27
+ end
28
+
29
+ def finish
30
+ update(finished_at: Time.now)
31
+ end
32
+
33
+ def self.create_process(blueprint_id, creator_id)
34
+ Bizflow::Lib::ProcessBuilder.new.build(blueprint_id, creator_id)
35
+ end
36
+
37
+ private
38
+
39
+ def start_action
40
+ Bizflow::DataModel::Action[start_action_id]
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,22 @@
1
+ require 'delegate'
2
+
3
+ module Bizflow
4
+ module BusinessModel
5
+
6
+ class SimpleWrapper < SimpleDelegator
7
+
8
+ def self.wrap(item)
9
+ new item
10
+ end
11
+
12
+ def self.wraps(items)
13
+ res = items.map do |item|
14
+ new item
15
+ end
16
+
17
+ res
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'simple_wrapper'
2
+ require 'bizflow/lib/callbackable'
3
+
4
+ module Bizflow
5
+ module BusinessModel
6
+
7
+ class Task < SimpleWrapper
8
+
9
+ include Bizflow::Lib::Callbackable
10
+
11
+ def assign(user_id, &block)
12
+ setup_callbacks(&block)
13
+
14
+ if(finished_at != nil)
15
+ callback(:already_finished, data: self, message: "Task has already been finished.")
16
+ return
17
+ end
18
+
19
+ update(assignee_id: user_id)
20
+
21
+ callback(:success, data: self, message: "Task assigned successfully.")
22
+ end
23
+
24
+ def finish(user_id, &block)
25
+ setup_callbacks(&block)
26
+
27
+ if(finished_at != nil)
28
+ callback(:already_finished, data: self, message: "Task has already been finished.")
29
+ return
30
+ end
31
+
32
+ update(finished_at: Time.now)
33
+ Bizflow::BusinessModel::TaskAction.wrap(action).task_finished
34
+
35
+ callback(:success, data: self, message: "Task has been finished successfully.")
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'simple_wrapper'
2
+
3
+ module Bizflow
4
+ module BusinessModel
5
+
6
+ class TaskAction < SimpleWrapper
7
+
8
+ def resolve
9
+ action_blueprint.task_blueprints.each do |tbp|
10
+ add_task(name: tbp.name, task_blueprint: tbp)
11
+ end
12
+ end
13
+
14
+ def finish
15
+ bhs = Bizflow::BusinessModel::Head.wraps(heads)
16
+ bp = Bizflow::BusinessModel::Process.wrap(process)
17
+ next_action_id = next_action ? next_action.id : nil
18
+ bhs.each { |h| h.jump(next_action_id) }
19
+ end
20
+
21
+ def next_action
22
+ nexts.first
23
+ end
24
+
25
+ def active
26
+ tasks_dataset.where(finished_at: nil).all
27
+ end
28
+
29
+ def task_finished
30
+ finish if active.empty?
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ require "sqlite3"
2
+ require 'sequel'
3
+
4
+ module Bizflow
5
+ class BuildCommand
6
+
7
+ def self.run(config, args = [])
8
+
9
+ puts "Building processes..."
10
+
11
+ require 'bizflow/lib/semantic_builder'
12
+
13
+ source_path = args[0] || config[:source_path]
14
+ raise "dsl source path not specified" if source_path.nil?
15
+ source_path = "#{Dir.pwd}/#{source_path}"
16
+ domain_repo = Bizflow::Lib::SemanticBuilder.new(source_path).build
17
+
18
+ raise "bizflow database path not specified" if config[:db_path].nil?
19
+ db_path = "#{Dir.pwd}/#{config[:db_path]}"
20
+ db = Sequel.sqlite(db_path)
21
+
22
+ Dir["#{File.dirname(__FILE__)}/../model/*.rb"].each { |path| require_relative path }
23
+
24
+ require 'bizflow/lib/blueprint_builder'
25
+
26
+ Bizflow::Lib::BlueprintBuilder.new.build(domain_repo)
27
+
28
+ puts "Processes built"
29
+
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ module Bizflow
2
+ class CleanCommand
3
+
4
+ def self.run(config, args)
5
+ puts "All cleaned... not realy"
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require "bizflow/command/build_command"
2
+ require "bizflow/command/help_command"
3
+ require "bizflow/command/clean_command"
4
+ require "bizflow/command/install_command"
5
+ require "bizflow/command/setup_command"
6
+
7
+ module Bizflow
8
+ class CommandHelper
9
+
10
+ CommandHash = {
11
+ :help => Bizflow::HelpCommand,
12
+ :build => Bizflow::BuildCommand,
13
+ :clean => Bizflow::CleanCommand,
14
+ :install => Bizflow::InstallComand,
15
+ :setup => Bizflow::SetupCommand
16
+ }
17
+
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Bizflow
2
+ class HelpCommand
3
+
4
+ def self.run(config, args)
5
+ puts "run one of these commands like this:"
6
+ puts "bizflow COMMAND_NAME [ARGS]"
7
+ puts "commands:\n#{Bizflow::CommandHelper::CommandHash.keys.join("\n")}"
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ require 'bizflow/config_generator'
2
+ require 'fileutils'
3
+
4
+ module Bizflow
5
+ class InstallComand
6
+
7
+ def self.run(config, args)
8
+ cg = Bizflow::ConfigGenerator.new()
9
+ cg.generate
10
+ puts "bizflow_config created in root path"
11
+
12
+ FileUtils::mkdir_p "#{Dir.pwd}/bizflow_processes"
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ require "sqlite3"
2
+ require 'sequel'
3
+ require 'fileutils'
4
+ require 'pathname'
5
+
6
+ module Bizflow
7
+ class SetupCommand
8
+
9
+ def self.run(config, args)
10
+
11
+ Sequel.extension :migration, :core_extensions
12
+
13
+ # Create a database
14
+ puts "Creating and migrating database for processes..."
15
+
16
+ db_path = config[:db_path] || "bizflow_db/bf.db"
17
+ db_path = "#{Dir.pwd}/#{db_path}"
18
+
19
+ pn = Pathname.new(db_path)
20
+ FileUtils::mkdir_p pn.dirname.to_s
21
+
22
+ db = Sequel.sqlite(db_path)
23
+
24
+ Sequel::Migrator.run(db, File.expand_path("#{File.expand_path(File.dirname(__FILE__))}/../migrations"), :use_transactions=>true)
25
+ puts "Database setup"
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require 'erb'
2
+
3
+ module Bizflow
4
+ class ConfigGenerator
5
+
6
+ RbTemplatesPath = "#{File.dirname(__FILE__)}/templates/rb"
7
+
8
+ def generate
9
+ process_source = ERB.new(File.read("#{RbTemplatesPath}/config.tt"), nil, '-').result()
10
+ out_file = File.new("#{Dir.pwd}/bizflow_config.rb", "w")
11
+ out_file.puts(process_source)
12
+ out_file.close
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ require 'sequel'
2
+
3
+ module Bizflow
4
+
5
+ module DataModel
6
+
7
+ class Action < Sequel::Model
8
+
9
+ one_to_many :tasks
10
+ one_to_many :heads
11
+ one_to_many :handlers
12
+ many_to_one :process
13
+ many_to_one :action_blueprint
14
+
15
+ one_to_many :next_actions
16
+ many_to_many :nexts, class: :'Bizflow::DataModel::Action', :join_table => :next_actions
17
+
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'sequel'
2
+
3
+ module Bizflow
4
+
5
+ module DataModel
6
+
7
+ class ActionBlueprint < Sequel::Model
8
+
9
+ many_to_one :process_blueprint
10
+ one_to_many :handler_blueprints
11
+ one_to_many :task_blueprints
12
+ one_to_many :actions
13
+
14
+ one_to_many :next_action_blueprints
15
+ many_to_many :next_blueprints, :join_table => :next_action_blueprints
16
+
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+
@@ -0,0 +1,16 @@
1
+ require 'sequel'
2
+
3
+ module Bizflow
4
+
5
+ module DataModel
6
+
7
+ class Handler < Sequel::Model
8
+
9
+ many_to_one :action
10
+
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+