tarikjn-railroad 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/ChangeLog +85 -0
- data/README +145 -0
- data/bin/railroad +53 -0
- data/lib/railroad/aasm_diagram.rb +81 -0
- data/lib/railroad/app_diagram.rb +89 -0
- data/lib/railroad/controllers_diagram.rb +83 -0
- data/lib/railroad/diagram_graph.rb +133 -0
- data/lib/railroad/models_diagram.rb +155 -0
- data/lib/railroad/options_struct.rb +169 -0
- data/rake.gemspec +18 -0
- metadata +75 -0
@@ -0,0 +1,169 @@
|
|
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
|
+
:inheritance => false,
|
19
|
+
:join => false,
|
20
|
+
:label => false,
|
21
|
+
:modules => false,
|
22
|
+
:hide_magic => false,
|
23
|
+
:hide_types => false,
|
24
|
+
:hide_public => false,
|
25
|
+
:hide_protected => false,
|
26
|
+
:hide_private => false,
|
27
|
+
:plugins_models => false,
|
28
|
+
:root => '',
|
29
|
+
:transitive => false,
|
30
|
+
:verbose => false,
|
31
|
+
:xmi => false,
|
32
|
+
:command => '' }
|
33
|
+
super(init_options)
|
34
|
+
end # initialize
|
35
|
+
|
36
|
+
def parse(args)
|
37
|
+
@opt_parser = OptionParser.new do |opts|
|
38
|
+
opts.banner = "Usage: #{APP_NAME} [options] command"
|
39
|
+
opts.separator ""
|
40
|
+
opts.separator "Common options:"
|
41
|
+
opts.on("-b", "--brief", "Generate compact diagram",
|
42
|
+
" (no attributes nor methods)") do |b|
|
43
|
+
self.brief = b
|
44
|
+
end
|
45
|
+
opts.on("-e", "--exclude file1[,fileN]", Array, "Exclude given files") do |list|
|
46
|
+
self.exclude = list
|
47
|
+
end
|
48
|
+
opts.on("-i", "--inheritance", "Include inheritance relations") do |i|
|
49
|
+
self.inheritance = i
|
50
|
+
end
|
51
|
+
opts.on("-l", "--label", "Add a label with diagram information",
|
52
|
+
" (type, date, migration, version)") do |l|
|
53
|
+
self.label = l
|
54
|
+
end
|
55
|
+
opts.on("-o", "--output FILE", "Write diagram to file FILE") do |f|
|
56
|
+
self.output = f
|
57
|
+
end
|
58
|
+
opts.on("-r", "--root PATH", "Set PATH as the application root") do |r|
|
59
|
+
self.root = r
|
60
|
+
end
|
61
|
+
opts.on("-v", "--verbose", "Enable verbose output",
|
62
|
+
" (produce messages to STDOUT)") do |v|
|
63
|
+
self.verbose = v
|
64
|
+
end
|
65
|
+
opts.on("-x", "--xmi", "Produce XMI instead of DOT",
|
66
|
+
" (for UML tools)") do |x|
|
67
|
+
self.xmi = x
|
68
|
+
end
|
69
|
+
opts.separator ""
|
70
|
+
opts.separator "Models diagram options:"
|
71
|
+
opts.on("-a", "--all", "Include all models",
|
72
|
+
" (not only ActiveRecord::Base derived)") do |a|
|
73
|
+
self.all = a
|
74
|
+
end
|
75
|
+
opts.on("--hide-magic", "Hide magic field names") do |h|
|
76
|
+
self.hide_magic = h
|
77
|
+
end
|
78
|
+
opts.on("--hide-types", "Hide attributes type") do |h|
|
79
|
+
self.hide_types = h
|
80
|
+
end
|
81
|
+
opts.on("-j", "--join", "Concentrate edges") do |j|
|
82
|
+
self.join = j
|
83
|
+
end
|
84
|
+
opts.on("-m", "--modules", "Include modules") do |m|
|
85
|
+
self.modules = m
|
86
|
+
end
|
87
|
+
opts.on("-p", "--plugins-models", "Include plugins models") do |p|
|
88
|
+
self.plugins_models = p
|
89
|
+
end
|
90
|
+
opts.on("-t", "--transitive", "Include transitive associations",
|
91
|
+
"(through inheritance)") do |t|
|
92
|
+
self.transitive = t
|
93
|
+
end
|
94
|
+
opts.separator ""
|
95
|
+
opts.separator "Controllers diagram options:"
|
96
|
+
opts.on("--hide-public", "Hide public methods") do |h|
|
97
|
+
self.hide_public = h
|
98
|
+
end
|
99
|
+
opts.on("--hide-protected", "Hide protected methods") do |h|
|
100
|
+
self.hide_protected = h
|
101
|
+
end
|
102
|
+
opts.on("--hide-private", "Hide private methods") do |h|
|
103
|
+
self.hide_private = h
|
104
|
+
end
|
105
|
+
opts.separator ""
|
106
|
+
opts.separator "Other options:"
|
107
|
+
opts.on("-h", "--help", "Show this message") do
|
108
|
+
STDOUT.print "#{opts}\n"
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
opts.on("--version", "Show version and copyright") do
|
112
|
+
STDOUT.print "#{APP_HUMAN_NAME} version #{APP_VERSION.join('.')}\n\n" +
|
113
|
+
"#{COPYRIGHT}\nThis is free software; see the source " +
|
114
|
+
"for copying conditions.\n\n"
|
115
|
+
exit
|
116
|
+
end
|
117
|
+
opts.separator ""
|
118
|
+
opts.separator "Commands (you must supply one of these):"
|
119
|
+
opts.on("-M", "--models", "Generate models diagram") do |c|
|
120
|
+
if self.command != ''
|
121
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
122
|
+
exit 1
|
123
|
+
else
|
124
|
+
self.command = 'models'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
opts.on("-C", "--controllers", "Generate controllers 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 = 'controllers'
|
133
|
+
end
|
134
|
+
end
|
135
|
+
# From Ana Nelson's patch
|
136
|
+
opts.on("-A", "--aasm", "Generate \"acts as state machine\" diagram") do |c|
|
137
|
+
if self.command == 'controllers'
|
138
|
+
STDERR.print "Error: Can only generate one diagram type\n\n"
|
139
|
+
exit 1
|
140
|
+
else
|
141
|
+
self.command = 'aasm'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
opts.separator ""
|
145
|
+
opts.separator "For bug reporting and additional information, please see:"
|
146
|
+
opts.separator "http://railroad.rubyforge.org/"
|
147
|
+
end # do
|
148
|
+
|
149
|
+
begin
|
150
|
+
@opt_parser.parse!(args)
|
151
|
+
rescue OptionParser::AmbiguousOption
|
152
|
+
option_error "Ambiguous option"
|
153
|
+
rescue OptionParser::InvalidOption
|
154
|
+
option_error "Invalid option"
|
155
|
+
rescue OptionParser::InvalidArgument
|
156
|
+
option_error "Invalid argument"
|
157
|
+
rescue OptionParser::MissingArgument
|
158
|
+
option_error "Missing argument"
|
159
|
+
end
|
160
|
+
end # parse
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
def option_error(msg)
|
165
|
+
STDERR.print "Error: #{msg}\n\n #{@opt_parser}\n"
|
166
|
+
exit 1
|
167
|
+
end
|
168
|
+
|
169
|
+
end # class OptionsStruct
|
data/rake.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
SPEC = Gem::Specification.new do |s|
|
3
|
+
s.name = "tarikjn-railroad"
|
4
|
+
s.version = "0.5.0"
|
5
|
+
s.author = "Javier Smaldone"
|
6
|
+
s.email = "javier@smaldone.com.ar"
|
7
|
+
s.homepage = "http://github.com/tarikjn"
|
8
|
+
s.rubyforge_project = "railroad"
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = "A DOT diagram generator for Ruby on Rail applications"
|
11
|
+
s.files = Dir.glob("lib/railroad/*.rb") +
|
12
|
+
["ChangeLog", "COPYING", "rake.gemspec"]
|
13
|
+
s.bindir = "bin"
|
14
|
+
s.executables = ["railroad"]
|
15
|
+
s.default_executable = "railroad"
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README", "COPYING"]
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tarikjn-railroad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Javier Smaldone
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-03 00:00:00 -07:00
|
18
|
+
default_executable: railroad
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: javier@smaldone.com.ar
|
23
|
+
executables:
|
24
|
+
- railroad
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
- COPYING
|
30
|
+
files:
|
31
|
+
- lib/railroad/aasm_diagram.rb
|
32
|
+
- lib/railroad/app_diagram.rb
|
33
|
+
- lib/railroad/controllers_diagram.rb
|
34
|
+
- lib/railroad/diagram_graph.rb
|
35
|
+
- lib/railroad/models_diagram.rb
|
36
|
+
- lib/railroad/options_struct.rb
|
37
|
+
- ChangeLog
|
38
|
+
- COPYING
|
39
|
+
- rake.gemspec
|
40
|
+
- README
|
41
|
+
- bin/railroad
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/tarikjn
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project: railroad
|
70
|
+
rubygems_version: 1.3.7
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A DOT diagram generator for Ruby on Rail applications
|
74
|
+
test_files: []
|
75
|
+
|