yawl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,3 +9,6 @@ require File.dirname(File.expand_path(__FILE__)) + "/steps/scrambled_eggs"
9
9
 
10
10
  p = Yawl::Process.create(:desired_state => "scrambled_eggs")
11
11
  p.start
12
+
13
+ p = Yawl::Process.create(:desired_state => "breakfast")
14
+ p.start
@@ -32,7 +32,38 @@ Yawl::Steps.set :scrambled_eggs do
32
32
  end
33
33
  end
34
34
 
35
+
36
+ Yawl::Steps.set :toast do
37
+ step :slice_toast do
38
+ def run
39
+ puts "slice toast like a boss"
40
+ end
41
+ end
42
+
43
+ step :put_slice_in_toaster do
44
+ def run
45
+ puts "toast!"
46
+ end
47
+ end
48
+
49
+ step :butter do
50
+ def run
51
+ puts "butter!"
52
+ end
53
+ end
54
+ end
55
+
35
56
  # Define a process definition and which set of steps should belong to the process
36
57
  Yawl::ProcessDefinitions.add(:scrambled_eggs) do |process|
37
58
  Yawl::Steps.realize_set_on(:scrambled_eggs, process)
38
59
  end
60
+
61
+ Yawl::ProcessDefinitions.add(:toast) do |process|
62
+ Yawl::Steps.realize_set_on(:toast, process)
63
+ end
64
+
65
+ # Define a process based on two different set of steps
66
+ Yawl::ProcessDefinitions.add(:breakfast) do |process|
67
+ Yawl::Steps.realize_set_on(:toast, process)
68
+ Yawl::Steps.realize_set_on(:scrambled_eggs, process)
69
+ end
@@ -5,6 +5,9 @@ require "yawl/log"
5
5
 
6
6
  module Yawl
7
7
  class Process < Sequel::Model
8
+ plugin :serialization, :json, :config
9
+ plugin :serialization_modification_detection
10
+
8
11
  plugin :validation_helpers
9
12
  one_to_many :steps, :order => [:seq]
10
13
 
@@ -0,0 +1,57 @@
1
+ require 'sequel'
2
+
3
+ Sequel.extension :migration
4
+
5
+ module Yawl
6
+ module Setup
7
+ extend self
8
+
9
+ MIGRATION = Sequel.migration do
10
+ change do
11
+ create_table(:processes) do
12
+ primary_key :id
13
+ String :desired_state, :text=>true, :null=>false
14
+ String :state, :default=>"pending", :text=>true, :null=>false
15
+ DateTime :created_at
16
+ String :name, :text=>true
17
+ String :config
18
+ String :request_id, :text=>true
19
+ String :specified_attributes
20
+ end
21
+
22
+ create_table(:steps) do
23
+ primary_key :id
24
+ Integer :process_id, :null=>false
25
+ Integer :seq, :null=>false
26
+ String :name, :text=>true, :null=>false
27
+ String :state, :default=>"pending", :text=>true, :null=>false
28
+
29
+ index [:process_id]
30
+ end
31
+
32
+ create_table(:step_attempts) do
33
+ primary_key :id
34
+ Integer :step_id, :null=>false
35
+ File :output
36
+ DateTime :started_at
37
+ DateTime :completed_at
38
+
39
+ index [:step_id]
40
+ end
41
+ end
42
+ end
43
+
44
+
45
+ def create!
46
+ MIGRATION.apply(db, :up)
47
+ end
48
+
49
+ def destroy!
50
+ MIGRATION.apply(db, :down)
51
+ end
52
+
53
+ def db
54
+ Sequel.connect(ENV["DATABASE_URL"])
55
+ end
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module Yawl
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yawl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -127,6 +127,7 @@ files:
127
127
  - lib/yawl/log.rb
128
128
  - lib/yawl/process.rb
129
129
  - lib/yawl/process_definitions.rb
130
+ - lib/yawl/setup.rb
130
131
  - lib/yawl/step.rb
131
132
  - lib/yawl/step_attempt.rb
132
133
  - lib/yawl/steps/base.rb
@@ -150,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
151
  version: '0'
151
152
  segments:
152
153
  - 0
153
- hash: -1330465653979215358
154
+ hash: -1266345301425141028
154
155
  required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  none: false
156
157
  requirements:
@@ -159,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  version: '0'
160
161
  segments:
161
162
  - 0
162
- hash: -1330465653979215358
163
+ hash: -1266345301425141028
163
164
  requirements: []
164
165
  rubyforge_project:
165
166
  rubygems_version: 1.8.23