allenwei-railroad 0.7.8
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/COPYING +340 -0
- data/ChangeLog +85 -0
- data/History.txt +42 -0
- data/Manifest.txt +19 -0
- data/README.txt +175 -0
- data/Rakefile +16 -0
- data/bin/railroad +47 -0
- data/init.rb +0 -0
- data/lib/railroad.rb +12 -0
- data/lib/railroad/aasm_diagram.rb +110 -0
- data/lib/railroad/app_diagram.rb +94 -0
- data/lib/railroad/controllers_diagram.rb +98 -0
- data/lib/railroad/diagram_graph.rb +189 -0
- data/lib/railroad/models_diagram.rb +225 -0
- data/lib/railroad/options_struct.rb +193 -0
- data/lib/railroad/tasks/diagrams.rake +48 -0
- data/lib/railroad/tasks/diagrams.rb +1 -0
- metadata +91 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# RailRoad - RoR diagrams generator
|
|
2
|
+
# http://railroad.rubyforge.org
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2007-2008 - Javier Smaldone (http://www.smaldone.com.ar)
|
|
5
|
+
# See COPYING for more details
|
|
6
|
+
|
|
7
|
+
require 'ostruct'
|
|
8
|
+
|
|
9
|
+
# RailRoad command line options parser
|
|
10
|
+
class OptionsStruct < OpenStruct
|
|
11
|
+
|
|
12
|
+
require 'optparse'
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
init_options = { :all => false,
|
|
16
|
+
:brief => false,
|
|
17
|
+
:exclude => [],
|
|
18
|
+
:classes_by_files => {},
|
|
19
|
+
:inheritance => false,
|
|
20
|
+
:join => false,
|
|
21
|
+
:label => false,
|
|
22
|
+
:modules => false,
|
|
23
|
+
:hide_magic => false,
|
|
24
|
+
:hide_types => false,
|
|
25
|
+
:hide_public => false,
|
|
26
|
+
:hide_protected => false,
|
|
27
|
+
:hide_private => false,
|
|
28
|
+
:hide_underscore => false,
|
|
29
|
+
:plugins_models => false,
|
|
30
|
+
:libraries => false,
|
|
31
|
+
:root => '',
|
|
32
|
+
:transitive => false,
|
|
33
|
+
:verbose => false,
|
|
34
|
+
:xmi => false,
|
|
35
|
+
:command => '' }
|
|
36
|
+
super(init_options)
|
|
37
|
+
end # initialize
|
|
38
|
+
|
|
39
|
+
def parse(args)
|
|
40
|
+
@opt_parser = OptionParser.new do |opts|
|
|
41
|
+
opts.banner = "Usage: #{APP_NAME} [options] command"
|
|
42
|
+
opts.separator ""
|
|
43
|
+
opts.separator "Common options:"
|
|
44
|
+
opts.on("-b", "--brief", "Generate compact diagram",
|
|
45
|
+
" (no attributes nor methods)") do |b|
|
|
46
|
+
self.brief = b
|
|
47
|
+
end
|
|
48
|
+
opts.on("-e", "--exclude=file1[,fileN]", Array, "Exclude given files") do |list|
|
|
49
|
+
self.exclude = list
|
|
50
|
+
end
|
|
51
|
+
opts.on("-c", "--class-map=file1,MyClass1[,fileN,MyClassN]", Array, "Map files to classes they contain") do |list|
|
|
52
|
+
self.classes_by_files = Hash[*list]
|
|
53
|
+
end
|
|
54
|
+
opts.on("-i", "--inheritance", "Include inheritance relations") do |i|
|
|
55
|
+
self.inheritance = i
|
|
56
|
+
end
|
|
57
|
+
opts.on("-l", "--label", "Add a label with diagram information",
|
|
58
|
+
" (type, date, migration, version)") do |l|
|
|
59
|
+
self.label = l
|
|
60
|
+
end
|
|
61
|
+
opts.on("-o", "--output FILE", "Write diagram to file FILE") do |f|
|
|
62
|
+
self.output = f
|
|
63
|
+
end
|
|
64
|
+
opts.on("-r", "--root PATH", "Set PATH as the application root") do |r|
|
|
65
|
+
self.root = r
|
|
66
|
+
end
|
|
67
|
+
opts.on("-v", "--verbose", "Enable verbose output",
|
|
68
|
+
" (produce messages to STDOUT)") do |v|
|
|
69
|
+
self.verbose = v
|
|
70
|
+
end
|
|
71
|
+
opts.on("-x", "--xmi", "Produce XMI instead of DOT",
|
|
72
|
+
" (for UML tools)") do |x|
|
|
73
|
+
self.xmi = x
|
|
74
|
+
end
|
|
75
|
+
opts.on("-u", "--yuml", "Produce yuml instead of DOT",
|
|
76
|
+
" (for http://yuml.me)") do |x|
|
|
77
|
+
self.yuml = x
|
|
78
|
+
end
|
|
79
|
+
opts.separator ""
|
|
80
|
+
opts.separator "Models diagram options:"
|
|
81
|
+
opts.on("-a", "--all", "Include all models",
|
|
82
|
+
" (not only ActiveRecord::Base derived)") do |a|
|
|
83
|
+
self.all = a
|
|
84
|
+
end
|
|
85
|
+
opts.on("--hide-magic", "Hide magic field names") do |h|
|
|
86
|
+
self.hide_magic = h
|
|
87
|
+
end
|
|
88
|
+
opts.on("--hide-types", "Hide attributes type") do |h|
|
|
89
|
+
self.hide_types = h
|
|
90
|
+
end
|
|
91
|
+
opts.on("-j", "--join", "Concentrate edges") do |j|
|
|
92
|
+
self.join = j
|
|
93
|
+
end
|
|
94
|
+
opts.on("-m", "--modules", "Include modules") do |m|
|
|
95
|
+
self.modules = m
|
|
96
|
+
end
|
|
97
|
+
opts.on("-p", "--plugins-models", "Include plugins models") do |p|
|
|
98
|
+
self.plugins_models = p
|
|
99
|
+
end
|
|
100
|
+
opts.on("-y", "--libraries", "Include application library") do |y|
|
|
101
|
+
self.libraries = y
|
|
102
|
+
end
|
|
103
|
+
opts.on("-t", "--transitive", "Include transitive associations",
|
|
104
|
+
"(through inheritance)") do |t|
|
|
105
|
+
self.transitive = t
|
|
106
|
+
end
|
|
107
|
+
opts.separator ""
|
|
108
|
+
opts.separator "Controllers diagram options:"
|
|
109
|
+
opts.on("--hide-public", "Hide public methods") do |h|
|
|
110
|
+
self.hide_public = h
|
|
111
|
+
end
|
|
112
|
+
opts.on("--hide-protected", "Hide protected methods") do |h|
|
|
113
|
+
self.hide_protected = h
|
|
114
|
+
end
|
|
115
|
+
opts.on("--hide-private", "Hide private methods") do |h|
|
|
116
|
+
self.hide_private = h
|
|
117
|
+
end
|
|
118
|
+
opts.on("--hide-underscore", "Hide methods that begin with an underscore") do |h|
|
|
119
|
+
self.hide_underscore = h
|
|
120
|
+
end
|
|
121
|
+
opts.separator ""
|
|
122
|
+
opts.separator "Other options:"
|
|
123
|
+
opts.on("-h", "--help", "Show this message") do
|
|
124
|
+
STDOUT.print "#{opts}\n"
|
|
125
|
+
exit
|
|
126
|
+
end
|
|
127
|
+
opts.on("--version", "Show version and copyright") do
|
|
128
|
+
STDOUT.print "#{APP_HUMAN_NAME} version #{APP_VERSION.join('.')}\n\n" +
|
|
129
|
+
"#{COPYRIGHT}\nThis is free software; see the source " +
|
|
130
|
+
"for copying conditions.\n\n"
|
|
131
|
+
exit
|
|
132
|
+
end
|
|
133
|
+
opts.separator ""
|
|
134
|
+
opts.separator "Commands (you must supply one of these):"
|
|
135
|
+
opts.on("-M", "--models", "Generate models diagram") do |c|
|
|
136
|
+
if self.command != ''
|
|
137
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
|
138
|
+
exit 1
|
|
139
|
+
else
|
|
140
|
+
self.command = 'models'
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
opts.on("-C", "--controllers", "Generate controllers diagram") do |c|
|
|
144
|
+
if self.command != ''
|
|
145
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
|
146
|
+
exit 1
|
|
147
|
+
else
|
|
148
|
+
self.command = 'controllers'
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
# From Ana Nelson's patch
|
|
152
|
+
opts.on("-A", "--aasm", "Generate \"acts as state machine\" diagram") do |c|
|
|
153
|
+
if self.command == 'controllers'
|
|
154
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
|
155
|
+
exit 1
|
|
156
|
+
else
|
|
157
|
+
self.command = 'aasm'
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
opts.on("-L", "--lifecycle", "Generate \"Hobo::Lifecycle\" diagram") do |c|
|
|
161
|
+
if self.command == 'controllers'
|
|
162
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
|
163
|
+
exit 1
|
|
164
|
+
else
|
|
165
|
+
self.command = 'lifecycle'
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
opts.separator ""
|
|
169
|
+
opts.separator "For bug reporting and additional information, please see:"
|
|
170
|
+
opts.separator "http://railroad.rubyforge.org/"
|
|
171
|
+
end # do
|
|
172
|
+
|
|
173
|
+
begin
|
|
174
|
+
@opt_parser.parse!(args)
|
|
175
|
+
rescue OptionParser::AmbiguousOption
|
|
176
|
+
option_error "Ambiguous option"
|
|
177
|
+
rescue OptionParser::InvalidOption
|
|
178
|
+
option_error "Invalid option"
|
|
179
|
+
rescue OptionParser::InvalidArgument
|
|
180
|
+
option_error "Invalid argument"
|
|
181
|
+
rescue OptionParser::MissingArgument
|
|
182
|
+
option_error "Missing argument"
|
|
183
|
+
end
|
|
184
|
+
end # parse
|
|
185
|
+
|
|
186
|
+
private
|
|
187
|
+
|
|
188
|
+
def option_error(msg)
|
|
189
|
+
STDERR.print "Error: #{msg}\n\n #{@opt_parser}\n"
|
|
190
|
+
exit 1
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
end # class OptionsStruct
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '../..')
|
|
2
|
+
require 'railroad'
|
|
3
|
+
|
|
4
|
+
namespace :doc do
|
|
5
|
+
namespace :diagrams do
|
|
6
|
+
desc "Draw model diagrams"
|
|
7
|
+
task :models => :environment do
|
|
8
|
+
doc_diagrams_generate(ModelsDiagram, 'models', '-a -m -t -M', 'neato')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "Draw controller diagrams"
|
|
12
|
+
task :controllers do
|
|
13
|
+
doc_diagrams_generate(ControllersDiagram, 'controllers', '-C', 'neato')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "Draw states diagrams"
|
|
17
|
+
task :states do
|
|
18
|
+
doc_diagrams_generate(AasmDiagram, 'states', '-A', 'dot')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "Draw Hobo::Lifecycle diagrams"
|
|
22
|
+
task :lifecycle do
|
|
23
|
+
doc_diagrams_generate(LifecycleDiagram, 'lifecycle', '-L', 'dot')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc "Draw controllers, models & states diagrams"
|
|
28
|
+
task :diagrams => %w(diagrams:models diagrams:controllers diagrams:states diagrams:lifecycle)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def doc_diagrams_generate(generator, type, options, dot_cmd)
|
|
32
|
+
options = OptionsStruct.new
|
|
33
|
+
options.parse "-v -j -l -i #{options}".split
|
|
34
|
+
|
|
35
|
+
output_dir = "doc/diagrams"
|
|
36
|
+
|
|
37
|
+
FileUtils.mkdir(output_dir) unless File.exist?(output_dir)
|
|
38
|
+
|
|
39
|
+
diagram = generator.new options
|
|
40
|
+
diagram.generate
|
|
41
|
+
f=open("#{output_dir}/#{type}.dot", "w")
|
|
42
|
+
f.write(diagram.to_s)
|
|
43
|
+
f.close
|
|
44
|
+
|
|
45
|
+
sh "#{dot_cmd} -Tpng #{output_dir}/#{type}.dot -o #{output_dir}/#{type}.png"
|
|
46
|
+
sh "#{dot_cmd} -Tsvg #{output_dir}/#{type}.dot | sed 's/font-size:14.00/font-size:11px/g' > #{output_dir}/#{type}.svg"
|
|
47
|
+
end
|
|
48
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
load 'railroad/tasks/diagrams.rake'
|
metadata
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: allenwei-railroad
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.7.8
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Javier Smaldone
|
|
8
|
+
- Thomas Ritz
|
|
9
|
+
- Tien Dung
|
|
10
|
+
- Factory Design Labs
|
|
11
|
+
- Mike Mondragon
|
|
12
|
+
- Tero Tilus
|
|
13
|
+
- David Dollar
|
|
14
|
+
- Bruno Michel
|
|
15
|
+
- Allen Wei
|
|
16
|
+
autorequire:
|
|
17
|
+
bindir: bin
|
|
18
|
+
cert_chain: []
|
|
19
|
+
|
|
20
|
+
date: 2010-02-15 00:00:00 +08:00
|
|
21
|
+
default_executable: railroad
|
|
22
|
+
dependencies:
|
|
23
|
+
- !ruby/object:Gem::Dependency
|
|
24
|
+
name: hoe
|
|
25
|
+
type: :development
|
|
26
|
+
version_requirement:
|
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 1.7.0
|
|
32
|
+
version:
|
|
33
|
+
description: RailRoad is a class diagrams generator for Ruby on Rails applications.
|
|
34
|
+
email: digruby@gmail.com
|
|
35
|
+
executables:
|
|
36
|
+
- railroad
|
|
37
|
+
extensions: []
|
|
38
|
+
|
|
39
|
+
extra_rdoc_files:
|
|
40
|
+
- History.txt
|
|
41
|
+
- Manifest.txt
|
|
42
|
+
- README.txt
|
|
43
|
+
files:
|
|
44
|
+
- COPYING
|
|
45
|
+
- ChangeLog
|
|
46
|
+
- History.txt
|
|
47
|
+
- Manifest.txt
|
|
48
|
+
- README.txt
|
|
49
|
+
- Rakefile
|
|
50
|
+
- bin/railroad
|
|
51
|
+
- init.rb
|
|
52
|
+
- lib/railroad.rb
|
|
53
|
+
- lib/railroad/aasm_diagram.rb
|
|
54
|
+
- lib/railroad/app_diagram.rb
|
|
55
|
+
- lib/railroad/controllers_diagram.rb
|
|
56
|
+
- lib/railroad/diagram_graph.rb
|
|
57
|
+
- lib/railroad/models_diagram.rb
|
|
58
|
+
- lib/railroad/options_struct.rb
|
|
59
|
+
- lib/railroad/tasks/diagrams.rb
|
|
60
|
+
- lib/railroad/tasks/diagrams.rake
|
|
61
|
+
has_rdoc: true
|
|
62
|
+
homepage: http://railroad.rubyforge.org
|
|
63
|
+
licenses: []
|
|
64
|
+
|
|
65
|
+
post_install_message:
|
|
66
|
+
rdoc_options:
|
|
67
|
+
- --main
|
|
68
|
+
- README.txt
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: "0"
|
|
76
|
+
version:
|
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: "0"
|
|
82
|
+
version:
|
|
83
|
+
requirements: []
|
|
84
|
+
|
|
85
|
+
rubyforge_project: railroad
|
|
86
|
+
rubygems_version: 1.3.5
|
|
87
|
+
signing_key:
|
|
88
|
+
specification_version: 2
|
|
89
|
+
summary: A DOT diagram generator for Ruby on Rail applications
|
|
90
|
+
test_files: []
|
|
91
|
+
|