stonepath 0.3.3 → 0.4.0
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.
- data/VERSION +1 -1
- data/lib/stonepath/dot.rb +34 -0
- data/lib/stonepath/task.rb +3 -0
- data/lib/stonepath/work_item.rb +3 -0
- data/lib/tasks/stonepath.rake +45 -0
- data/rails_generators/stonepath_event_log/templates/event_record.rb +1 -2
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module StonePath
|
2
|
+
module Dot
|
3
|
+
|
4
|
+
def to_dot
|
5
|
+
dot = ""
|
6
|
+
|
7
|
+
dot << "digraph x {\n"
|
8
|
+
dot << "\trankdir=LR\n"
|
9
|
+
dot << "\tnode [fontname=Helvetica,fontcolor=blue]\n"
|
10
|
+
aasm_states.each do |state|
|
11
|
+
dot << "\t#{state.name.to_s.camelize.singularize}\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
dot << "\tedge [fontname=Helvetica,fontsize=10]\n"
|
15
|
+
aasm_events.each do |name, event|
|
16
|
+
event.all_transitions.each do |t|
|
17
|
+
from = t.opts[:from].to_s.camelize.singularize
|
18
|
+
to = t.opts[:to].to_s.camelize.singularize
|
19
|
+
if from == to
|
20
|
+
extras = "headport=e tailport=s]"
|
21
|
+
else
|
22
|
+
extras = ""
|
23
|
+
end
|
24
|
+
dot << "\t#{from} -> #{to} [label=\"#{name.to_s.humanize}\" arrowhead=vee"
|
25
|
+
dot << extras
|
26
|
+
dot << "]\n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
dot << "}\n"
|
30
|
+
dot
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/stonepath/task.rb
CHANGED
data/lib/stonepath/work_item.rb
CHANGED
@@ -11,6 +11,9 @@ module StonePath
|
|
11
11
|
require File.expand_path(File.dirname(__FILE__)) + "/event_logging.rb"
|
12
12
|
extend StonePath::EventLogging
|
13
13
|
|
14
|
+
require File.expand_path(File.dirname(__FILE__)) + "/dot.rb"
|
15
|
+
extend StonePath::Dot
|
16
|
+
|
14
17
|
def owned_by(owner, options={})
|
15
18
|
options.merge!(:class_name => owner.to_s.classify)
|
16
19
|
belongs_to :owner, options
|
@@ -0,0 +1,45 @@
|
|
1
|
+
namespace :stonepath do
|
2
|
+
|
3
|
+
desc "Generate state diagrams for all classes implementing WorkItem"
|
4
|
+
task :diagrams => :environment do
|
5
|
+
FileUtils.mkdir_p "#{RAILS_ROOT}/doc/stonepath/dot"
|
6
|
+
FileUtils.mkdir_p "#{RAILS_ROOT}/doc/stonepath/png"
|
7
|
+
workitems.each do |workitem|
|
8
|
+
dot_file = File.join(RAILS_ROOT, 'doc', 'stonepath', 'dot', "#{workitem.to_s.tableize.singularize}.dot")
|
9
|
+
png_file = File.join(RAILS_ROOT, 'doc', 'stonepath', 'png', "#{workitem.to_s.tableize.singularize}.png")
|
10
|
+
File.open(dot_file, 'w') {|f| f.write(workitem.to_dot) }
|
11
|
+
`dot -Tpng "#{dot_file}" > "#{png_file}"`
|
12
|
+
end
|
13
|
+
|
14
|
+
tasks.each do |task|
|
15
|
+
dot_file = File.join(RAILS_ROOT, 'doc', 'stonepath', 'dot', "#{task.to_s.tableize.singularize}.dot")
|
16
|
+
png_file = File.join(RAILS_ROOT, 'doc', 'stonepath', 'png', "#{task.to_s.tableize.singularize}.png")
|
17
|
+
File.open(dot_file, 'w') {|f| f.write(task.to_dot) }
|
18
|
+
`dot -Tpng "#{dot_file}" > "#{png_file}"`
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.workitems
|
26
|
+
self.implementing_models("StonePath::WorkItem")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.tasks
|
30
|
+
self.implementing_models("StonePath::SPTask")
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.implementing_models(a_module)
|
34
|
+
tasks = Array.new
|
35
|
+
Dir[File.join(RAILS_ROOT, "app/models/**/*.rb")].each do |file_path|
|
36
|
+
path, file = file_path.split("/models/")
|
37
|
+
class_name = file.sub(/\.rb$/,'').camelize
|
38
|
+
clazz = class_name.split('::').inject(Object) { |package, name| package.const_get(name) } rescue nil
|
39
|
+
if clazz && clazz.included_modules.collect { |m| m.to_s }.include?(a_module)
|
40
|
+
tasks << clazz
|
41
|
+
end rescue nil
|
42
|
+
end
|
43
|
+
tasks
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stonepath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Bock
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- VERSION
|
60
60
|
- lib/stonepath.rb
|
61
61
|
- lib/stonepath/config.rb
|
62
|
+
- lib/stonepath/dot.rb
|
62
63
|
- lib/stonepath/event_logging.rb
|
63
64
|
- lib/stonepath/extensions/action_view.rb
|
64
65
|
- lib/stonepath/extensions/rails_generator_commands.rb
|
@@ -66,6 +67,7 @@ files:
|
|
66
67
|
- lib/stonepath/work_bench.rb
|
67
68
|
- lib/stonepath/work_item.rb
|
68
69
|
- lib/stonepath/work_owner.rb
|
70
|
+
- lib/tasks/stonepath.rake
|
69
71
|
- rails/init.rb
|
70
72
|
- rails_generators/stonepath_event_log/stonepath_event_log_generator.rb
|
71
73
|
- rails_generators/stonepath_event_log/templates/create_event_records.rb
|