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