stonepath 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/generators/stonepath/task/templates/task.rb +52 -4
- data/lib/stonepath/task.rb +1 -72
- data/lib/stonepath/work_item.rb +3 -1
- data/lib/stonepath.rb +1 -2
- data/stonepath.gemspec +140 -0
- metadata +4 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.2
|
@@ -1,11 +1,53 @@
|
|
1
1
|
class <%= class_name %> < ActiveRecord::Base
|
2
2
|
include StonePath
|
3
3
|
|
4
|
-
|
4
|
+
# prior to stonepath 0.6.2, this definition of task was defined as a 'default' deep
|
5
|
+
# inside of the code to the gem. This created two problems:
|
6
|
+
# 1- users of the framework didn't realize this was their behavior to change/redefine
|
7
|
+
# 2- the way the reused block was defined broke in ruby 1.9.2
|
8
|
+
#
|
9
|
+
# Putting this in the generated template both solvs the 1.9.2 problem *and* makes it clear
|
10
|
+
# to end users that this is your behavior to modify as you see fit.
|
11
|
+
#
|
12
|
+
# the default workflow for tasks (upon generation) is:
|
13
|
+
# [active] -{complete}-> [completed]
|
14
|
+
# -{expire}-> [expired]
|
15
|
+
# -{cancel}-> [cancelled]
|
16
|
+
#
|
17
|
+
# you are free to modify that to suit your domain.
|
18
|
+
stonepath_task do
|
19
|
+
aasm_initial_state :active
|
20
|
+
aasm_state :active, :after_enter => :notify_created
|
21
|
+
aasm_state :completed, :enter => :timestamp_complete, :after_enter => :notify_closed
|
22
|
+
|
23
|
+
aasm_state :expired, :after_enter => :notify_closed
|
24
|
+
aasm_state :cancelled, :after_enter => :notify_closed
|
25
|
+
|
26
|
+
aasm_event :complete do
|
27
|
+
transitions :to => :completed, :from => :active
|
28
|
+
end
|
29
|
+
|
30
|
+
aasm_event :cancel do
|
31
|
+
transitions :to => :cancelled, :from => [:active, :completed]
|
32
|
+
end
|
33
|
+
|
34
|
+
aasm_event :expire do
|
35
|
+
transitions :to => :expired, :from => :active
|
36
|
+
end
|
37
|
+
|
38
|
+
scope :unassigned, { :conditions => ['workbench_id IS NULL'] }
|
39
|
+
scope :assigned, { :conditions => ['workbench_id IS NOT NULL'] }
|
40
|
+
scope :active, { :conditions => ['aasm_state in (?)', ['active']] }
|
41
|
+
scope :completed, { :conditions => ['aasm_state in (?)', ['completed']] }
|
42
|
+
scope :expired, { :conditions => ['aasm_state in (?)', ['expired']] }
|
43
|
+
scope :cancelled, { :conditions => ['aasm_state in (?)', ['cancelled']] }
|
44
|
+
scope :overdue, lambda { { :conditions => ['aasm_state in (?) AND due_at < ?', ['active'], Time.now] } }
|
45
|
+
end
|
5
46
|
|
6
|
-
#
|
47
|
+
# You can log events on Tasks by running the event log generator and uncommenting this line.
|
48
|
+
#log_events
|
7
49
|
|
8
|
-
attr_accessible :workitem, :workbench
|
50
|
+
attr_accessible :workitem, :workbench <% unless attributes.emoty? %>, <% end %> <%= attributes.map { |a| ":#{a.name}" }.join(", ") %>
|
9
51
|
|
10
52
|
# you might think 'overdue' should be a state, but no, part of the stonepath
|
11
53
|
# methodology is that states should be as free of time definition as possible.
|
@@ -17,7 +59,13 @@ class <%= class_name %> < ActiveRecord::Base
|
|
17
59
|
#
|
18
60
|
# so the state would be 'in process', even though it is 'overdue'.
|
19
61
|
def overdue?
|
20
|
-
(Time.now > due_at) &&
|
62
|
+
(Time.now > due_at) && self.active?
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def timestamp_complete
|
68
|
+
self.completed_at = Time.now
|
21
69
|
end
|
22
70
|
|
23
71
|
end
|
data/lib/stonepath/task.rb
CHANGED
@@ -4,52 +4,7 @@
|
|
4
4
|
|
5
5
|
module StonePath
|
6
6
|
module SPTask
|
7
|
-
|
8
|
-
# This will move from here shortly, into another class/module for containing things like this.
|
9
|
-
# This is the workflow definition for a default task. This is defined this way so that users
|
10
|
-
# can provide their own task workflow definition as a block to the stonepath_task declaration.
|
11
|
-
# This lanbda is passed in if the user doesn't provide anything.
|
12
|
-
# It is possible that we will identify other useful options and want to provide them as config
|
13
|
-
# blocks in the StonePath gem.
|
14
|
-
def self.default_config_block
|
15
|
-
lambda {
|
16
|
-
aasm_initial_state :active
|
17
|
-
aasm_state :active, :after_enter => :notify_created
|
18
|
-
aasm_state :completed, :enter => :timestamp_complete, :after_enter => :notify_closed
|
19
|
-
# was:
|
20
|
-
#aasm_state :completed, :after_enter => [:timestamp_complete, :notify_closed]
|
21
|
-
# but, from investigations into AASM,
|
22
|
-
# persist is done after :enter but before :after_exit, etc
|
23
|
-
# so fields changed in :after_enter will result in a dirty object that
|
24
|
-
# never gets saved to the DB
|
25
|
-
# WD-rpw / Ashish Tonse 11-16-2010
|
26
|
-
|
27
|
-
aasm_state :expired, :after_enter => :notify_closed
|
28
|
-
aasm_state :cancelled, :after_enter => :notify_closed
|
29
|
-
|
30
|
-
aasm_event :complete do
|
31
|
-
transitions :to => :completed, :from => :active
|
32
|
-
end
|
33
|
-
|
34
|
-
aasm_event :cancel do
|
35
|
-
transitions :to => :cancelled, :from => [:active, :completed]
|
36
|
-
end
|
37
|
-
|
38
|
-
aasm_event :expire do
|
39
|
-
transitions :to => :expired, :from => :active
|
40
|
-
end
|
41
|
-
|
42
|
-
named_scope :unassigned, { :conditions => ['workbench_id IS NULL'] }
|
43
|
-
named_scope :assigned, { :conditions => ['workbench_id IS NOT NULL'] }
|
44
|
-
named_scope :active, { :conditions => ['aasm_state in (?)', ['active']] }
|
45
|
-
named_scope :completed, { :conditions => ['aasm_state in (?)', ['completed']] }
|
46
|
-
named_scope :expired, { :conditions => ['aasm_state in (?)', ['expired']] }
|
47
|
-
named_scope :cancelled, { :conditions => ['aasm_state in (?)', ['cancelled']] }
|
48
|
-
named_scope :overdue, lambda { { :conditions => ['aasm_state in (?) AND due_at < ?', ['active'], Time.now] } }
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
|
7
|
+
|
53
8
|
def self.included(base)
|
54
9
|
base.instance_eval do
|
55
10
|
include AASM
|
@@ -74,34 +29,8 @@ module StonePath
|
|
74
29
|
end
|
75
30
|
end
|
76
31
|
|
77
|
-
# I don't think this should really be part of Stonepath, but I'm adding it here as a comment
|
78
|
-
# to communicate some design intent to my fellow teammembers on a project using stonepath.
|
79
|
-
# For the 'timely|imminent|overdue' stuff, at the time the task is created, we would need to
|
80
|
-
# set and calculate the imminent_at and due_at times. These methods would then do what
|
81
|
-
# we need them to do.
|
82
|
-
# def imminent?
|
83
|
-
# return false if imminent_at.nil?
|
84
|
-
# imminent_at < Time.now
|
85
|
-
# end
|
86
|
-
#
|
87
|
-
# we might also want this method, which would be useful in css styling
|
88
|
-
# def timeliness
|
89
|
-
# return "overdue" if overdue?
|
90
|
-
# return "imminent" if imminent?
|
91
|
-
# return "timely"
|
92
|
-
# end
|
93
|
-
|
94
|
-
def overdue?
|
95
|
-
return false if due_at.nil?
|
96
|
-
due_at < Time.now
|
97
|
-
end
|
98
|
-
|
99
32
|
private
|
100
33
|
|
101
|
-
def timestamp_complete
|
102
|
-
self.completed_at = Time.now
|
103
|
-
end
|
104
|
-
|
105
34
|
def notify_created
|
106
35
|
if workitem.respond_to?(:task_created)
|
107
36
|
workitem.task_created(self)
|
data/lib/stonepath/work_item.rb
CHANGED
data/lib/stonepath.rb
CHANGED
@@ -18,8 +18,7 @@ module StonePath
|
|
18
18
|
def stonepath_task(&config_block)
|
19
19
|
require File.expand_path(File.dirname(__FILE__)) + "/stonepath/task.rb"
|
20
20
|
include StonePath::SPTask
|
21
|
-
config_block
|
22
|
-
instance_eval &config_block
|
21
|
+
instance_eval &config_block if config_block
|
23
22
|
end
|
24
23
|
|
25
24
|
def stonepath_workbench
|
data/stonepath.gemspec
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{stonepath}
|
8
|
+
s.version = "0.6.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David Bock"]
|
12
|
+
s.date = %q{2011-01-30}
|
13
|
+
s.description = %q{Stateful workflow modeling for Rails}
|
14
|
+
s.email = %q{dbock@codesherpas.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"History.txt",
|
20
|
+
"Manifest.txt",
|
21
|
+
"PostInstall.txt",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"lib/generators/stonepath.rb",
|
26
|
+
"lib/generators/stonepath/event_log/event_log_generator.rb",
|
27
|
+
"lib/generators/stonepath/event_log/templates/create_event_records.rb",
|
28
|
+
"lib/generators/stonepath/event_log/templates/event_record.rb",
|
29
|
+
"lib/generators/stonepath/events_scaffold/events_scaffold_generator.rb",
|
30
|
+
"lib/generators/stonepath/task/USAGE",
|
31
|
+
"lib/generators/stonepath/task/task_generator.rb",
|
32
|
+
"lib/generators/stonepath/task/templates/migration.rb",
|
33
|
+
"lib/generators/stonepath/task/templates/task.rb",
|
34
|
+
"lib/generators/stonepath/workitem_model/templates/migration.rb",
|
35
|
+
"lib/generators/stonepath/workitem_model/templates/model.rb",
|
36
|
+
"lib/generators/stonepath/workitem_model/workitem_model_generator.rb",
|
37
|
+
"lib/generators/stonepath/workitem_scaffold/templates/model.rb",
|
38
|
+
"lib/generators/stonepath/workitem_scaffold/workitem_scaffold_generator.rb",
|
39
|
+
"lib/stonepath.rb",
|
40
|
+
"lib/stonepath/config.rb",
|
41
|
+
"lib/stonepath/dot.rb",
|
42
|
+
"lib/stonepath/event_logging.rb",
|
43
|
+
"lib/stonepath/extensions/action_view.rb",
|
44
|
+
"lib/stonepath/extensions/rails_generator_commands.rb",
|
45
|
+
"lib/stonepath/railtie.rb",
|
46
|
+
"lib/stonepath/task.rb",
|
47
|
+
"lib/stonepath/work_bench.rb",
|
48
|
+
"lib/stonepath/work_item.rb",
|
49
|
+
"lib/stonepath/work_owner.rb",
|
50
|
+
"lib/tasks/stonepath.rake",
|
51
|
+
"rails/init.rb",
|
52
|
+
"script/console",
|
53
|
+
"script/destroy",
|
54
|
+
"script/generate",
|
55
|
+
"stonepath.gemspec",
|
56
|
+
"stonepath.pdf",
|
57
|
+
"test/app_root/app/controllers/application_controller.rb",
|
58
|
+
"test/app_root/app/models/assignment.rb",
|
59
|
+
"test/app_root/app/models/case.rb",
|
60
|
+
"test/app_root/app/models/custom_assignment.rb",
|
61
|
+
"test/app_root/app/models/event_record.rb",
|
62
|
+
"test/app_root/app/models/user.rb",
|
63
|
+
"test/app_root/config/boot.rb",
|
64
|
+
"test/app_root/config/database.yml",
|
65
|
+
"test/app_root/config/environment.rb",
|
66
|
+
"test/app_root/config/environments/in_memory.rb",
|
67
|
+
"test/app_root/config/environments/mysql.rb",
|
68
|
+
"test/app_root/config/environments/postgresql.rb",
|
69
|
+
"test/app_root/config/environments/sqlite.rb",
|
70
|
+
"test/app_root/config/environments/sqlite3.rb",
|
71
|
+
"test/app_root/config/routes.rb",
|
72
|
+
"test/app_root/db/migrate/01_create_users.rb",
|
73
|
+
"test/app_root/db/migrate/02_create_assignments.rb",
|
74
|
+
"test/app_root/db/migrate/03_create_cases.rb",
|
75
|
+
"test/app_root/db/migrate/04_create_event_records.rb",
|
76
|
+
"test/app_root/lib/console_with_fixtures.rb",
|
77
|
+
"test/app_root/log/.gitignore",
|
78
|
+
"test/app_root/script/console",
|
79
|
+
"test/custom_task_test.rb",
|
80
|
+
"test/fixtures/users.yml",
|
81
|
+
"test/logging_test.rb",
|
82
|
+
"test/stonepath_test.rb",
|
83
|
+
"test/task_test.rb",
|
84
|
+
"test/test_helper.rb",
|
85
|
+
"test/workitem_test.rb",
|
86
|
+
"test/workowner_test.rb"
|
87
|
+
]
|
88
|
+
s.homepage = %q{http://github.com/bokmann/stonepath}
|
89
|
+
s.require_paths = ["lib"]
|
90
|
+
s.rubygems_version = %q{1.3.7}
|
91
|
+
s.summary = %q{Stonepath: stateful workflow modeling for rails}
|
92
|
+
s.test_files = [
|
93
|
+
"test/app_root/app/controllers/application_controller.rb",
|
94
|
+
"test/app_root/app/models/assignment.rb",
|
95
|
+
"test/app_root/app/models/case.rb",
|
96
|
+
"test/app_root/app/models/custom_assignment.rb",
|
97
|
+
"test/app_root/app/models/event_record.rb",
|
98
|
+
"test/app_root/app/models/user.rb",
|
99
|
+
"test/app_root/config/boot.rb",
|
100
|
+
"test/app_root/config/environment.rb",
|
101
|
+
"test/app_root/config/environments/in_memory.rb",
|
102
|
+
"test/app_root/config/environments/mysql.rb",
|
103
|
+
"test/app_root/config/environments/postgresql.rb",
|
104
|
+
"test/app_root/config/environments/sqlite.rb",
|
105
|
+
"test/app_root/config/environments/sqlite3.rb",
|
106
|
+
"test/app_root/config/routes.rb",
|
107
|
+
"test/app_root/db/migrate/01_create_users.rb",
|
108
|
+
"test/app_root/db/migrate/02_create_assignments.rb",
|
109
|
+
"test/app_root/db/migrate/03_create_cases.rb",
|
110
|
+
"test/app_root/db/migrate/04_create_event_records.rb",
|
111
|
+
"test/app_root/lib/console_with_fixtures.rb",
|
112
|
+
"test/custom_task_test.rb",
|
113
|
+
"test/logging_test.rb",
|
114
|
+
"test/stonepath_test.rb",
|
115
|
+
"test/task_test.rb",
|
116
|
+
"test/test_helper.rb",
|
117
|
+
"test/workitem_test.rb",
|
118
|
+
"test/workowner_test.rb"
|
119
|
+
]
|
120
|
+
|
121
|
+
if s.respond_to? :specification_version then
|
122
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
123
|
+
s.specification_version = 3
|
124
|
+
|
125
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
126
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
127
|
+
s.add_runtime_dependency(%q<aasm>, [">= 2.2.0"])
|
128
|
+
s.add_runtime_dependency(%q<sentient_user>, [">= 0.3.2"])
|
129
|
+
else
|
130
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
131
|
+
s.add_dependency(%q<aasm>, [">= 2.2.0"])
|
132
|
+
s.add_dependency(%q<sentient_user>, [">= 0.3.2"])
|
133
|
+
end
|
134
|
+
else
|
135
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
136
|
+
s.add_dependency(%q<aasm>, [">= 2.2.0"])
|
137
|
+
s.add_dependency(%q<sentient_user>, [">= 0.3.2"])
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stonepath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 5
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
8
|
+
- 2
|
9
|
+
version: 0.6.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- David Bock
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-30 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
28
|
segments:
|
31
29
|
- 3
|
32
30
|
- 0
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
43
|
segments:
|
47
44
|
- 2
|
48
45
|
- 2
|
@@ -58,7 +55,6 @@ dependencies:
|
|
58
55
|
requirements:
|
59
56
|
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 23
|
62
58
|
segments:
|
63
59
|
- 0
|
64
60
|
- 3
|
@@ -111,6 +107,7 @@ files:
|
|
111
107
|
- script/console
|
112
108
|
- script/destroy
|
113
109
|
- script/generate
|
110
|
+
- stonepath.gemspec
|
114
111
|
- stonepath.pdf
|
115
112
|
- test/app_root/app/controllers/application_controller.rb
|
116
113
|
- test/app_root/app/models/assignment.rb
|
@@ -156,7 +153,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
153
|
requirements:
|
157
154
|
- - ">="
|
158
155
|
- !ruby/object:Gem::Version
|
159
|
-
hash: 3
|
160
156
|
segments:
|
161
157
|
- 0
|
162
158
|
version: "0"
|
@@ -165,7 +161,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
161
|
requirements:
|
166
162
|
- - ">="
|
167
163
|
- !ruby/object:Gem::Version
|
168
|
-
hash: 3
|
169
164
|
segments:
|
170
165
|
- 0
|
171
166
|
version: "0"
|