peterhoeg-railroad 0.5.4

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.
@@ -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/railroad.gemspec ADDED
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{railroad}
5
+ s.version = "0.5.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Peter Hoeg", "Javier Smaldone"]
9
+ s.date = %q{2009-05-15}
10
+ s.default_executable = %q{railroad}
11
+ s.email = ["peter@hoeg.com", "p.hoeg@northwind.sg", "javier@smaldone.com.ar"]
12
+ s.executables = ["railroad"]
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.rdoc"
16
+ ]
17
+ s.files = [
18
+ ".document",
19
+ ".gitignore",
20
+ "AUTHORS.rdoc",
21
+ "CHANGELOG.rdoc",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "bin/railroad",
27
+ "lib/aasm_diagram.rb",
28
+ "lib/app_diagram.rb",
29
+ "lib/controllers_diagram.rb",
30
+ "lib/diagram_graph.rb",
31
+ "lib/models_diagram.rb",
32
+ "lib/options_struct.rb",
33
+ "railroad.gemspec",
34
+ "spec/app_diagram_spec.rb",
35
+ "spec/railroad_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.has_rdoc = true
39
+ s.homepage = %q{http://github.com/peterhoeg/RailRoad}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.1}
43
+ s.summary = %q{A DOT diagram generator for Ruby on Rail applications}
44
+ s.test_files = [
45
+ "spec/spec_helper.rb",
46
+ "spec/app_diagram_spec.rb",
47
+ "spec/railroad_spec.rb"
48
+ ]
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 2
53
+
54
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
+ else
56
+ end
57
+ else
58
+ end
59
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe AppDiagram do
4
+ describe 'extracting filenames' do
5
+ describe 'without namespaces' do
6
+ it 'should work with a simple name' do
7
+ ad = AppDiagram.new
8
+ ad.extract_class_name('app/models/test_this.rb').should == 'TestThis'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Railroad" do
4
+ # it "fails" do
5
+ # fail "hey buddy, you should probably rename this file and start specing for real"
6
+ # end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'railroad'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peterhoeg-railroad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.4
5
+ platform: ruby
6
+ authors:
7
+ - Peter Hoeg
8
+ - Javier Smaldone
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-05-15 00:00:00 -07:00
14
+ default_executable: railroad
15
+ dependencies: []
16
+
17
+ description:
18
+ email:
19
+ - peter@hoeg.com
20
+ - p.hoeg@northwind.sg
21
+ - javier@smaldone.com.ar
22
+ executables:
23
+ - railroad
24
+ extensions: []
25
+
26
+ extra_rdoc_files:
27
+ - LICENSE
28
+ - README.rdoc
29
+ files:
30
+ - .document
31
+ - .gitignore
32
+ - AUTHORS.rdoc
33
+ - CHANGELOG.rdoc
34
+ - LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - VERSION.yml
38
+ - bin/railroad
39
+ - lib/aasm_diagram.rb
40
+ - lib/app_diagram.rb
41
+ - lib/controllers_diagram.rb
42
+ - lib/diagram_graph.rb
43
+ - lib/models_diagram.rb
44
+ - lib/options_struct.rb
45
+ - railroad.gemspec
46
+ - spec/app_diagram_spec.rb
47
+ - spec/railroad_spec.rb
48
+ - spec/spec_helper.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/peterhoeg/RailRoad
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.2.0
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: A DOT diagram generator for Ruby on Rail applications
75
+ test_files:
76
+ - spec/spec_helper.rb
77
+ - spec/app_diagram_spec.rb
78
+ - spec/railroad_spec.rb