railroady 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaa6ca5ddf8518e1f146c35ea2973eb013092d4d
4
- data.tar.gz: fc51e067821dff9ecb7dcadf847fe21c67217265
3
+ metadata.gz: 3f6bf55bece6a6c3b86cb259fa55a90450ad0b13
4
+ data.tar.gz: fc6eb6ecccc214f6af1efd3086af702c4e4681f4
5
5
  SHA512:
6
- metadata.gz: 16c28d9206208fd1b5d7e8c7577351096804bf88155c2b2ff285140836a2904d6c70a1f85718490fedfb25f6b80d47c922ac4c68a1bacb10b63fc8d547319f3c
7
- data.tar.gz: 3f505a379bc651ede5693fa72f16d72d52d5777a0c8bb401a8ae621022e392bb034382f5e64179b61a37fb077062f821da4567dda26a04475db9ce89b4902c8e
6
+ metadata.gz: 078660548c41a48bfed350461f7cf211a64c9683e3d2a7cda7ddf3521671ae0dd3b5c613ff237a1c92d9241a0e59fef80b650f0d0eecf97be8ab360ac83257a5
7
+ data.tar.gz: 198e5625e97bec987081fba7a4840929d259f5163fe73c8d20bba98a6c13afb29cabf0e97bae10f0be2613c1f36295ba59e3ac1fe3147d78e4721b618d1afcc9
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- railroady (1.4.2)
4
+ railroady (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activesupport (4.2.5)
9
+ activesupport (4.2.6)
10
10
  i18n (~> 0.7)
11
11
  json (~> 1.7, >= 1.7.7)
12
12
  minitest (~> 5.1)
@@ -14,8 +14,8 @@ GEM
14
14
  tzinfo (~> 1.1)
15
15
  i18n (0.7.0)
16
16
  json (1.8.3)
17
- minitest (5.8.3)
18
- rake (10.4.2)
17
+ minitest (5.9.0)
18
+ rake (11.2.2)
19
19
  thread_safe (0.3.5)
20
20
  tzinfo (1.2.2)
21
21
  thread_safe (~> 0.1)
@@ -31,4 +31,4 @@ DEPENDENCIES
31
31
  rake
32
32
 
33
33
  BUNDLED WITH
34
- 1.10.6
34
+ 1.12.5
@@ -1,4 +1,4 @@
1
- = RailRoady
1
+ # RailRoady
2
2
 
3
3
  RailRoady generates Rails 3/4 model (ActiveRecord, Mongoid, Datamapper) and controller UML diagrams as cross-platform .svg files, as well as in the DOT language.
4
4
 
@@ -6,29 +6,31 @@ Code is based on the original "railroad" gem, patched and maintained over the ye
6
6
 
7
7
  I (Preston Lee) am not trying to hijack Peter Hoeg or Javier's project, but rather create a dedicated, lean gem that can be used without major issue on Rails v3 and v4 projects. Rails v2 is not supported.
8
8
 
9
- = System Requirements
9
+ # System Requirements
10
10
 
11
11
  You MUST have the the following utilities available at the command line.
12
12
  * `dot` and `neato`.
13
13
 
14
14
  * `sed`, which should already be available on all sane UNIX systems.
15
15
 
16
- = Mac users
16
+ ## Mac users
17
17
 
18
- MacPorts users can install in via
18
+ Brew users can install via:
19
+
20
+ brew install graphviz
21
+
22
+ MacPorts users can install in via
19
23
 
20
24
  sudo port install graphviz
21
-
22
- Brew user can install via
23
25
 
24
- brew install graphviz
25
26
 
26
- = Ubuntu users
27
+ ## Ubuntu users
27
28
 
28
- Ubuntu users can install in via
29
+ Ubuntu users can install in via
29
30
 
30
31
  sudo apt-get install graphviz
31
- = Usage
32
+
33
+ # Usage
32
34
 
33
35
  The easiest (and recommend) usage is to include railroady as a development dependency with your Rails 3 Gemfile, like so...
34
36
 
@@ -40,73 +42,79 @@ The easiest (and recommend) usage is to include railroady as a development depen
40
42
 
41
43
  rake diagram:all
42
44
 
43
- This should generate four doc/*.svg files that can be opened in (most) web browsers as well as dedicated document viewers supporting the Scalable Vector Graphics format.
45
+ This should generate four doc/\*.svg files that can be opened in (most) web browsers as well as dedicated document viewers supporting the Scalable Vector Graphics format.
44
46
 
45
- = Support for Engines
47
+ ## Support for Engines
46
48
 
47
49
  Generate diagram for models and controllers including those in the engines.
48
50
 
49
- rake diagram:all_with_engines
51
+ rake diagram:all_with_engines
50
52
 
51
- = Alternate Usage
53
+ ## Alternate Usage
52
54
 
53
55
  Alternatively, you may run the 'railroady' command-line program at the Rails application's root directory. You can redirect its output to a .dot file or pipe it to the dot or neato utilities to produce a graphic. Model diagrams are intended to be processed using dot and controller diagrams are best processed using neato.
54
56
 
55
57
  railroady [options] command
56
-
57
- == Options
58
-
59
- Common options:
60
- -b, --brief Generate compact diagram
61
- (no attributes nor methods)
62
- -s, --specify file1[,fileN] Specify given files only for the diagram
63
- (can take a glob pattern)
64
- -e, --exclude file1[,fileN] Exclude given files
65
- (can take a glob pattern)
66
- -i, --inheritance Include inheritance relations
67
- -l, --label Add a label with diagram information
68
- (type, date, migration, version)
69
- -o, --output FILE Write diagram to file FILE
70
- -v, --verbose Enable verbose output
71
- (produce messages to STDOUT)
72
- --alphabetize Sort methods alphabetically
73
58
 
74
- Models diagram options:
75
- -a, --all Include all models
76
- (not only ActiveRecord::Base derived)
77
- --all-columns Show all columns
78
- (not just content columns)
79
- --hide-magic Hide magic field names
80
- --hide-types Hide attributes type
81
- --hide-through Hide through associations
82
- -j, --join Concentrate edges
83
- -m, --modules Include modules
84
- -p, --plugins-models Include plugins models
85
- -z, --engine-models Include engine models
86
- -t, --transitive Include transitive associations
87
- (through inheritance)
88
-
89
- Controllers diagram options:
90
- --hide-public Hide public methods
91
- --hide-protected Hide protected methods
92
- --hide-private Hide private methods
93
- --engine-controllers Show engine controllers
94
- Other options:
95
- -h, --help Show this message
96
- --version Show version and copyright
97
-
98
- == Commands
59
+ ## Options
60
+
61
+ Common options:
62
+ -b, --brief Generate compact diagram
63
+ (no attributes nor methods)
64
+ -s, --specify file1[,fileN] Specify only given files
65
+ -e, --exclude file1[,fileN] Exclude given files
66
+ -i, --inheritance Include inheritance relations
67
+ -l, --label Add a label with diagram information
68
+ (type, date, migration, version)
69
+ -o, --output FILE Write diagram to file FILE
70
+ -r, --root PATH Set PATH as the application root
71
+ -v, --verbose Enable verbose output
72
+ (produce messages to STDOUT)
73
+ -x, --xmi Produce XMI instead of DOT
74
+ (for UML tools)
75
+ --alphabetize Sort methods alphabetically
76
+
77
+ Models diagram options:
78
+ -a, --all Include all models
79
+ (not only ActiveRecord::Base derived)
80
+ --show-belongs_to Show belongs_to associations
81
+ --hide-through Hide through associations
82
+ --all-columns Show all columns (not just content columns)
83
+ --hide-magic Hide magic field names
84
+ --hide-types Hide attributes type
85
+ -j, --join Concentrate edges
86
+ -m, --modules Include modules
87
+ -p, --plugins-models Include plugins models
88
+ -z, --engine-models Include engine models
89
+ --include-concerns Include models in concerns subdirectory
90
+ -t, --transitive Include transitive associations
91
+ (through inheritance)
92
+
93
+ Controllers diagram options:
94
+ --hide-public Hide public methods
95
+ --hide-protected Hide protected methods
96
+ --hide-private Hide private methods
97
+ --engine-controllers Include engine controllers
98
+
99
+ Other options:
100
+ -h, --help Show this message
101
+ --version Show version and copyright
102
+
103
+ -c, --config FILE File to load environment (defaults to config/environment)
104
+
105
+ ## Commands
106
+
107
+ You must supply one of these:
99
108
 
100
109
  -M, --models Generate models diagram
101
110
  -C, --controllers Generate controllers diagram
102
111
  -A, --aasm Generate "acts as state machine" diagram
103
112
 
113
+ ## Examples
104
114
 
105
- == Examples
106
-
107
- railroady -o models.dot -M
115
+ railroady -o models.dot -M
108
116
  Produces a models diagram to the file 'models.dot'
109
- railroady -a -i -o full_models.dot -M
117
+ railroady -a -i -o full_models.dot -M
110
118
  Models diagram with all classes showing inheritance relations
111
119
  railroady -M | dot -Tsvg > models.svg
112
120
  Model diagram in SVG format
@@ -116,7 +124,7 @@ Other options:
116
124
  Shows usage help
117
125
 
118
126
 
119
- = Processing DOT files
127
+ # Processing DOT files
120
128
 
121
129
  To produce a PNG image from model diagram generated by RailRoady you can
122
130
  issue the following command:
@@ -137,7 +145,7 @@ the following:
137
145
  Important: There is a bug in Graphviz tools when generating SVG files that
138
146
  cause a text overflow. You can solve this problem editing (with a text
139
147
  editor, not a graphical SVG editor) the file and replacing around line 12
140
- "font-size:14.00;" by "font-size:11.00;", or by issuing the following command
148
+ "font-size:14.00;" by "font-size:11.00;", or by issuing the following command
141
149
  (see "man sed"):
142
150
 
143
151
  sed -i 's/font-size:14.00/font-size:11.00/g' file.svg
@@ -151,15 +159,15 @@ also use Omnigraffle (on Mac OS X).
151
159
  As of Preston Lee's Rails 3/4 modifications, including RailRoady as a project development dependency will automatically add a set of rake tasks to your project. Sweet! (Run `rake -T` to check them out.)
152
160
 
153
161
 
154
- = Requirements
162
+ # Requirements
155
163
 
156
164
  RailRoady has been tested with the following Ruby and Rails versions
157
165
 
158
- == Ruby
166
+ ## Ruby
159
167
  * 1.9.2+
160
168
  * 2.0.0+
161
169
 
162
- == Rails
170
+ ## Rails
163
171
  * 3.0.3+
164
172
  * 4.0.0+
165
173
 
@@ -173,15 +181,15 @@ from Graphviz.
173
181
 
174
182
  http://railroady.prestonlee.com
175
183
 
176
- = License
184
+ # License
177
185
 
178
186
  RailRoady is distributed under the terms of the GNU General Public License
179
- as published by the Free Software Foundation; either version 2 of the
187
+ as published by the Free Software Foundation; either version 2 of the
180
188
  License, or (at your option) any later version.
181
189
 
182
190
  See LICENSE for details.
183
191
 
184
- == Copyright
192
+ ## Copyright
185
193
 
186
194
  Copyright (c) 2007-2008 Javier Smaldone
187
195
  Copyright (c) 2009 Peter Hoeg
@@ -189,6 +197,6 @@ Copyright (c) 2010 Preston Lee
189
197
 
190
198
  See LICENSE for details.
191
199
 
192
- == Authors
200
+ ## Authors
193
201
 
194
202
  See AUTHORS for details.
@@ -62,7 +62,7 @@ class AasmDiagram < AppDiagram
62
62
 
63
63
  STDERR.print "\t\tprocessing as acts_as_state_machine\n" if @options.verbose
64
64
  current_class.states.each do |state_name|
65
- state = current_class.read_inheritable_attribute(:states)[state_name]
65
+ # state = current_class.read_inheritable_attribute(:states)[state_name]
66
66
  node_shape = (current_class.initial_state == state_name) ? ', peripheries = 2' : ''
67
67
  node_attribs << "#{current_class.name.downcase}_#{state_name} [label=#{state_name} #{node_shape}];"
68
68
  end
@@ -39,26 +39,26 @@ class ModelsDiagram < AppDiagram
39
39
  def engine_files
40
40
  engines.collect { |engine| Dir.glob("#{engine.root}/app/models/**/*.rb") }.flatten
41
41
  end
42
-
42
+
43
43
  def extract_class_name(filename)
44
44
  filename_was, class_name = filename, nil
45
-
46
- filename = "app/models/#{filename.split('app/models')[1]}"
47
-
45
+
46
+ filename = "app/models/#{filename.split('app/models')[1]}"
47
+
48
48
  while filename.split('/').length > 2
49
49
  begin
50
50
  class_name = filename.match(/.*\/models\/(.*).rb$/)[1].camelize
51
51
  class_name.constantize
52
-
52
+
53
53
  break
54
- rescue Exception => e
54
+ rescue Exception # => e
55
55
  class_name = nil
56
56
  filename_end = filename.split('/')[2..-1]
57
57
  filename_end.shift
58
58
  filename = "#{filename.split('/')[0, 2].join('/')}/#{filename_end.join('/')}"
59
59
  end
60
60
  end
61
-
61
+
62
62
  if class_name.nil?
63
63
  filename_was.match(/.*\/models\/(.*).rb$/)[1].camelize
64
64
  else
@@ -92,8 +92,8 @@ class ModelsDiagram < AppDiagram
92
92
 
93
93
  def include_inheritance?(current_class)
94
94
  STDERR.puts current_class.superclass if @options.verbose
95
- (defined?(ActiveRecord::Base) && current_class.superclass != ActiveRecord::Base) ||
96
- (defined?(CouchRest::Model::Base) && current_class.superclass != CouchRest::Model::Base) ||
95
+ (defined?(ActiveRecord::Base) ? current_class.superclass != ActiveRecord::Base : true) &&
96
+ (defined?(CouchRest::Model::Base) ? current_class.superclass != CouchRest::Model::Base : true) &&
97
97
  (current_class.superclass != Object)
98
98
  end
99
99
 
@@ -1,3 +1,3 @@
1
1
  module RailRoady
2
- VERSION = '1.4.2'
2
+ VERSION = '1.5.0'
3
3
  end
data/railroady.gemspec CHANGED
@@ -7,13 +7,13 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'railroady'
8
8
  spec.version = RailRoady::VERSION
9
9
  spec.authors = ['Preston Lee', 'Tobias Crawley', 'Peter Hoeg', 'Javier Smaldone']
10
- spec.description = "Ruby on Rails 3/4 model and controller UML class diagram generator. Originally based on the 'railroad' plugin and contributions of many others. (`sudo port install graphviz` before use!)"
10
+ spec.description = "Ruby on Rails 3/4 model and controller UML class diagram generator. Originally based on the 'railroad' plugin and contributions of many others. (`brew install graphviz` before use!)"
11
11
  spec.email = ['preston.lee@prestonlee.com', 'tcrawley@gmail.com', 'peter@hoeg.com', 'p.hoeg@northwind.sg', 'javier@smaldone.com.ar']
12
12
  spec.summary = 'Ruby on Rails 3/4 model and controller UML class diagram generator.'
13
13
  spec.homepage = 'http://github.com/preston/railroady'
14
14
  spec.license = 'GPLv2'
15
15
 
16
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.files = `git ls-files`.split("\n")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
@@ -96,4 +96,67 @@ describe ModelsDiagram do
96
96
  end
97
97
  end
98
98
  end
99
+
100
+ describe '#include_inheritance?' do
101
+ after do
102
+ Object.send(:remove_const, :Child)
103
+ end
104
+ describe 'when class inherits from another app class' do
105
+ before do
106
+ class Parent; end;
107
+ class Child < Parent; end;
108
+ end
109
+ it 'returns true' do
110
+ md = ModelsDiagram.new(OptionsStruct.new)
111
+ md.include_inheritance?(Child).must_equal true
112
+ end
113
+ after do
114
+ Object.send(:remove_const, :Parent)
115
+ end
116
+ end
117
+
118
+ describe 'when class inherits from Object' do
119
+ before do
120
+ class Child < Object; end;
121
+ end
122
+ it 'returns false' do
123
+ md = ModelsDiagram.new(OptionsStruct.new)
124
+ md.include_inheritance?(Child).must_equal false
125
+ end
126
+ end
127
+
128
+ describe 'when class inherits from ActiveRecord::Base' do
129
+ before do
130
+ module ActiveRecord
131
+ class Base; end;
132
+ end
133
+ class Child < ActiveRecord::Base; end;
134
+ end
135
+ it 'returns false' do
136
+ md = ModelsDiagram.new(OptionsStruct.new)
137
+ md.include_inheritance?(Child).must_equal false
138
+ end
139
+ after do
140
+ Object.send(:remove_const, :ActiveRecord)
141
+ end
142
+ end
143
+
144
+ describe 'when class inherits from CouchRest::Model::Base' do
145
+ before do
146
+ module CouchRest
147
+ module Model
148
+ class Base; end;
149
+ end
150
+ end
151
+ class Child < CouchRest::Model::Base; end;
152
+ end
153
+ it 'returns false' do
154
+ md = ModelsDiagram.new(OptionsStruct.new)
155
+ md.include_inheritance?(Child).must_equal false
156
+ end
157
+ after do
158
+ Object.send(:remove_const, :CouchRest)
159
+ end
160
+ end
161
+ end
99
162
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railroady
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Preston Lee
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-09 00:00:00.000000000 Z
14
+ date: 2016-06-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -70,7 +70,7 @@ dependencies:
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  description: Ruby on Rails 3/4 model and controller UML class diagram generator. Originally
73
- based on the 'railroad' plugin and contributions of many others. (`sudo port install
73
+ based on the 'railroad' plugin and contributions of many others. (`brew install
74
74
  graphviz` before use!)
75
75
  email:
76
76
  - preston.lee@prestonlee.com
@@ -90,7 +90,7 @@ files:
90
90
  - Gemfile.lock
91
91
  - Guardfile
92
92
  - LICENSE.rdoc
93
- - README.rdoc
93
+ - README.md
94
94
  - Rakefile
95
95
  - bin/railroady
96
96
  - lib/railroady.rb
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.4.5.1
145
+ rubygems_version: 2.6.4
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Ruby on Rails 3/4 model and controller UML class diagram generator.