railroady 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d861e99e4da72666e52557b3dd4aae91be9c3810
4
+ data.tar.gz: 877a3dfee6e413da3f9a7b93a9e434847675e97c
5
+ SHA512:
6
+ metadata.gz: 968bf68e7072cba4ab255c8b2ab1da9f880a077b5269dbc0f65abf8c1a4bf1a224345cfd278f0a51a98061381574038a68d2b1cd8c62437dbffaff8a74642b43
7
+ data.tar.gz: 78b3e11854e3394ce6db8a9c6554bf807cb356ec68dd6f0075c168b3a4e1682e188f9e25cd1f31a774aba2df1a109881418003c53d6d3ee306febcc6ba406f6d
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.gem
7
+ nbproject
8
+ /.gvimrc
9
+ /.vim*
10
+ .rvmrc
data/AUTHORS.rdoc CHANGED
@@ -12,7 +12,7 @@ http://railroady.prestonlee.com
12
12
  * John McCaffrey
13
13
  * David Jones
14
14
  * Mike Dalessio
15
- * Preston Lee (http://prestonlee.com)
15
+ * Preston Lee (http://prestonlee.com @prestonism)
16
16
  * Tim Harvey
17
17
  * Atli Christiansen
18
18
  * John Bintz (http://www.coswellproductions.com/)
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,12 @@
1
1
  = Changes
2
2
 
3
+ == Version 1.1.1
4
+
5
+ - Merge in a Sinatra support.
6
+ - Merge in other pull requests.
7
+ - Switched from rspec to minitest specs.
8
+ - Removed jeweler dependency and updated to more recent bundler + gemspec format.
9
+
3
10
  == Version 1.0.2
4
11
 
5
12
  - Merged in John Bintz's patch to properly strip leading "::" prefixes from class names.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ railroady (1.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.0.0)
10
+ i18n (~> 0.6, >= 0.6.4)
11
+ minitest (~> 4.2)
12
+ multi_json (~> 1.3)
13
+ thread_safe (~> 0.1)
14
+ tzinfo (~> 0.3.37)
15
+ atomic (1.1.10)
16
+ i18n (0.6.4)
17
+ minitest (4.7.5)
18
+ minitest-spec-context (0.0.3)
19
+ multi_json (1.7.7)
20
+ rake (10.1.0)
21
+ thread_safe (0.1.2)
22
+ atomic
23
+ tzinfo (0.3.37)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ activesupport
30
+ bundler
31
+ minitest
32
+ minitest-spec-context
33
+ railroady!
34
+ rake
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = RailRoady
2
2
 
3
- RailRoady generates Rails 3 model (AcitveRecord, Mongoid, Datamapper) and controller UML diagrams as cross-platform .svg files, as well as in the DOT language.
3
+ RailRoady generates Rails 3/4 model (AcitveRecord, Mongoid, Datamapper) and controller UML diagrams as cross-platform .svg files, as well as in the DOT language.
4
4
 
5
5
  Code is based on the original "railroad" gem, patched and maintained over the years. Lineage can be traced via GitHub.
6
6
 
data/Rakefile CHANGED
@@ -1,47 +1,12 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "railroady"
8
- gem.executables = "railroady"
9
- gem.email = ['conmotto@gmail.com', 'tcrawley@gmail.com', 'peter@hoeg.com', 'p.hoeg@northwind.sg', 'javier@smaldone.com.ar']
10
- gem.homepage = "http://github.com/preston/railroady"
11
- gem.authors = ["Preston Lee", "Tobias Crawley", "Peter Hoeg", "Javier Smaldone"]
12
- gem.summary = "Ruby on Rails 3 model and controller UML class diagram generator."
13
- gem.description = "Ruby on Rails 3 model and controller UML class diagram generator. Originally based on the 'railroad' plugin and contributions of many others. (`sudo port install graphviz` before use!)"
14
- gem.files = FileList["[A-Z]*", "{autotest,bin,lib,spec,tasks}/**/*", ".document"]
15
- gem.extra_rdoc_files = FileList["*.rdoc"]
16
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
- end
18
-
19
- rescue LoadError
20
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
- end
22
-
23
- require 'rspec'
24
- require 'rspec/core/rake_task'
25
- RSpec::Core::RakeTask.new(:spec) do |spec|
26
- # spec.libs << 'lib' << 'rspec'
27
- spec.pattern = FileList['rspec/**/*_spec.rb']
28
- end
29
-
30
- RSpec::Core::RakeTask.new(:rcov) do |spec|
31
- # spec.libs << 'lib' << 'rspec'
32
- spec.pattern = 'rspec/**/*_spec.rb'
33
- spec.rcov = true
34
- end
35
-
36
- task :default => :spec
37
-
38
- require 'rake/rdoctask'
39
- require 'railroady/version'
40
- Rake::RDocTask.new do |rdoc|
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "railroady #{RailRoady::VERSION::STRING}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('CHANGELOG*')
45
- rdoc.rdoc_files.include('AUTHORS*')
46
- rdoc.rdoc_files.include('lib/**/*.rb')
47
- end
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib/railroady'
8
+ t.test_files = FileList['test/lib/railroady/*_spec.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
data/bin/railroady CHANGED
@@ -22,7 +22,7 @@ require 'railroady'
22
22
  APP_NAME = "railroady"
23
23
  APP_HUMAN_NAME = "RailRoady"
24
24
  # APP_VERSION = [RailRoady::VERSION::MAJOR, RailRoady::VERSION::MINOR, RailRoady::VERSION::PATCH]
25
- APP_VERSION = RailRoady::VERSION::STRING
25
+ APP_VERSION = RailRoady::VERSION
26
26
  COPYRIGHT = "Copyright (C) 2007-2008 Javier Smaldone, 2009 Peter Hoeg, 2010 Preston Lee"
27
27
 
28
28
  options = OptionsStruct.new({:app_name => APP_NAME, :app_human_name => APP_HUMAN_NAME, :app_version =>APP_VERSION, :copyright =>COPYRIGHT})
@@ -43,7 +43,7 @@ elsif options.command == 'controllers'
43
43
  elsif options.command == 'aasm'
44
44
  diagram = AasmDiagram.new(options)
45
45
  else
46
- STDERR.print "#{APP_HUMAN_NAME} v#{RailRoady::VERSION::STRING}\n" +
46
+ STDERR.print "#{APP_HUMAN_NAME} v#{APP_VERSION}\n" +
47
47
  "Error: You must supply a command\n" +
48
48
  " (try #{APP_NAME} -h)\n\n"
49
49
  exit 1
@@ -52,7 +52,7 @@ class AppDiagram
52
52
  STDERR.print "Loading application environment\n" if @options.verbose
53
53
  begin
54
54
  disable_stdout
55
- l = File.join(Dir.pwd.to_s, 'config/environment')
55
+ l = File.join(Dir.pwd.to_s, @options.config_file)
56
56
  require l
57
57
  enable_stdout
58
58
  rescue LoadError
@@ -85,11 +85,14 @@ class ControllersDiagram < AppDiagram
85
85
  @graph.add_node ['module', current_class.name]
86
86
  end
87
87
 
88
- # Generate the inheritance edge (only for ApplicationControllers)
89
- if @options.inheritance &&
90
- (ApplicationController.subclasses.include? current_class)
88
+ # Generate the inheritance edge (only for transitive subclasses of ApplicationControllers)
89
+ if @options.inheritance && (transitive_subclasses_of(ApplicationController).include? current_class)
91
90
  @graph.add_edge ['is-a', current_class.superclass.name, current_class.name]
92
91
  end
93
92
  end # process_class
94
93
 
94
+ def transitive_subclasses_of(klass)
95
+ klass.subclasses | klass.subclasses.map {|subklass| transitive_subclasses_of(subklass)}.flatten
96
+ end
97
+
95
98
  end # class ControllersDiagram
@@ -40,7 +40,9 @@ class ModelsDiagram < AppDiagram
40
40
  STDERR.puts "Processing #{current_class}" if @options.verbose
41
41
 
42
42
  generated =
43
- if defined?(Mongoid::Document) && current_class.new.is_a?(Mongoid::Document)
43
+ if defined?(CouchRest::Model::Base) && current_class.new.is_a?(CouchRest::Model::Base)
44
+ process_couchrest_model(current_class)
45
+ elsif defined?(Mongoid::Document) && current_class.new.is_a?(Mongoid::Document)
44
46
  process_mongoid_model(current_class)
45
47
  elsif defined?(DataMapper::Resource) && current_class.new.is_a?(DataMapper::Resource)
46
48
  process_datamapper_model(current_class)
@@ -59,7 +61,9 @@ class ModelsDiagram < AppDiagram
59
61
  end # process_class
60
62
 
61
63
  def include_inheritance?(current_class)
62
- (defined?(ActiveRecord::Base) && current_class.superclass != ActiveRecord::Base) &&
64
+ STDERR.puts current_class.superclass if @options.verbose
65
+ (defined?(ActiveRecord::Base) && current_class.superclass != ActiveRecord::Base) ||
66
+ (defined?(CouchRest::Model::Base) && current_class.superclass != CouchRest::Model::Base) ||
63
67
  (current_class.superclass != Object)
64
68
  end
65
69
 
@@ -82,15 +86,15 @@ class ModelsDiagram < AppDiagram
82
86
  node_type = 'model'
83
87
 
84
88
  # Collect model's content columns
85
- #content_columns = current_class.content_columns
89
+ #content_columns = current_class.content_columns
86
90
 
87
- if @options.hide_magic
91
+ if @options.hide_magic
88
92
  # From patch #13351
89
93
  # http://wiki.rubyonrails.org/rails/pages/MagicFieldNames
90
94
  magic_fields = [
91
- "created_at", "created_on", "updated_at", "updated_on",
92
- "lock_version", "type", "id", "position", "parent_id", "lft",
93
- "rgt", "quote", "template"
95
+ "created_at", "created_on", "updated_at", "updated_on",
96
+ "lock_version", "type", "id", "position", "parent_id", "lft",
97
+ "rgt", "quote", "template"
94
98
  ]
95
99
  magic_fields << current_class.table_name + "_count" if current_class.respond_to? 'table_name'
96
100
  content_columns = current_class.content_columns.select {|c| ! magic_fields.include? c.name}
@@ -162,9 +166,6 @@ class ModelsDiagram < AppDiagram
162
166
  true
163
167
  end
164
168
 
165
-
166
-
167
-
168
169
  def process_mongoid_model(current_class)
169
170
  node_attribs = []
170
171
 
@@ -174,15 +175,15 @@ class ModelsDiagram < AppDiagram
174
175
  node_type = 'model'
175
176
 
176
177
  # Collect model's content columns
177
- content_columns = current_class.fields.values.sort_by(&:name)
178
+ content_columns = current_class.fields.values.sort_by(&:name)
178
179
 
179
- if @options.hide_magic
180
+ if @options.hide_magic
180
181
  # From patch #13351
181
182
  # http://wiki.rubyonrails.org/rails/pages/MagicFieldNames
182
183
  magic_fields = [
183
- "created_at", "created_on", "updated_at", "updated_on",
184
- "lock_version", "_type", "_id", "position", "parent_id", "lft",
185
- "rgt", "quote", "template"
184
+ "created_at", "created_on", "updated_at", "updated_on",
185
+ "lock_version", "_type", "_id", "position", "parent_id", "lft",
186
+ "rgt", "quote", "template"
186
187
  ]
187
188
  content_columns = content_columns.select {|c| !magic_fields.include?(c.name) }
188
189
  end
@@ -200,7 +201,7 @@ class ModelsDiagram < AppDiagram
200
201
  associations = current_class.relations.values
201
202
 
202
203
  if @options.inheritance && !@options.transitive &&
203
- current_class.superclass.respond_to?(:relations)
204
+ current_class.superclass.respond_to?(:relations)
204
205
  associations -= current_class.superclass.relations.values
205
206
  end
206
207
 
@@ -211,6 +212,42 @@ class ModelsDiagram < AppDiagram
211
212
  true
212
213
  end
213
214
 
215
+ ##
216
+ # Some very basic CouchRest::Model support
217
+ #
218
+ # Field types note: the field's type is rendered only if it's explicitly
219
+ # specified in a model.
220
+ #
221
+ def process_couchrest_model(current_class)
222
+ node_attribs = []
223
+
224
+ if @options.brief
225
+ node_type = 'model-brief'
226
+ else
227
+ node_type = 'model'
228
+
229
+ # Collect model's content columns
230
+ content_columns = current_class.properties
231
+
232
+ if @options.hide_magic
233
+ magic_fields = [
234
+ "created_at", "updated_at",
235
+ "type", "_id", "_rev"
236
+ ]
237
+ content_columns = content_columns.select {|c| !magic_fields.include?(c.name) }
238
+ end
239
+
240
+ content_columns.each do |a|
241
+ content_column = a.name
242
+ content_column += " :#{a.type}" unless @options.hide_types || a.type.nil?
243
+ node_attribs << content_column
244
+ end
245
+ end
246
+
247
+ @graph.add_node [node_type, current_class.name, node_attribs]
248
+
249
+ true
250
+ end
214
251
 
215
252
  # Process a model association
216
253
  def process_association(class_name, assoc)
@@ -261,7 +298,6 @@ class ModelsDiagram < AppDiagram
261
298
  # @graph.add_edge [assoc_type, class_name, assoc.class_name, assoc_name]
262
299
  @graph.add_edge [assoc_type, class_name, assoc_class_name, assoc_name]
263
300
  end # process_association
264
- end # class ModelsDiagram
265
301
 
266
302
  # Process a DataMapper relationship
267
303
  def process_datamapper_relationship(class_name, relation)
@@ -298,3 +334,7 @@ end # class ModelsDiagram
298
334
 
299
335
  @graph.add_edge [rel_type, class_name, assoc_class_name, assoc_name ]
300
336
  end
337
+
338
+ end # class ModelsDiagram
339
+
340
+
@@ -34,6 +34,7 @@ class OptionsStruct < OpenStruct
34
34
  :verbose => false,
35
35
  :xmi => false,
36
36
  :command => '',
37
+ :config_file => 'config/environment',
37
38
  :app_name => 'railroady', :app_human_name => 'Railroady', :app_version =>'', :copyright =>'' }
38
39
  super(init_options.merge(args))
39
40
  end # initialize
@@ -132,6 +133,11 @@ class OptionsStruct < OpenStruct
132
133
  exit
133
134
  end
134
135
  opts.separator ""
136
+ opts.on("-c", "--config FILE", "File to load environment (defaults to config/environment)") do |c|
137
+ if c && c != ''
138
+ self.config_file = c
139
+ end
140
+ end
135
141
  opts.separator "Commands (you must supply one of these):"
136
142
  opts.on("-M", "--models", "Generate models diagram") do |c|
137
143
  if self.command != ''
@@ -1,15 +1,3 @@
1
- require 'yaml'
2
1
  module RailRoady
3
- module VERSION #:nodoc:
4
- f = File.join(File.dirname(__FILE__), '..', '..', 'VERSION.yml')
5
- if File.exist?(f)
6
- config = YAML.load(File.read(f))
7
- MAJOR = config[:major]
8
- MINOR = config[:minor]
9
- PATCH = config[:patch]
10
- else
11
- MAJOR = MINOR = PATCH = 0
12
- end
13
- STRING = [MAJOR, MINOR, PATCH].join('.')
14
- end
2
+ VERSION = '1.1.1'
15
3
  end
data/railroady.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'railroady/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "railroady"
8
+ spec.version = RailRoady::VERSION
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!)"
11
+ spec.email = ["conmotto@gmail.com", "tcrawley@gmail.com", "peter@hoeg.com", "p.hoeg@northwind.sg", "javier@smaldone.com.ar"]
12
+ spec.summary = "Ruby on Rails 3/4 model and controller UML class diagram generator."
13
+ spec.homepage = "http://github.com/preston/railroady"
14
+ spec.license = "GPLv2"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "minitest-spec-context"
25
+ spec.add_development_dependency "activesupport"
26
+
27
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe AasmDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the models dir' do
7
+ ad = AasmDiagram.new
8
+ files = ad.get_files("test/file_fixture/")
9
+ files.size.must_equal 3
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/models/dummy1.rb'])
14
+ ad = AasmDiagram.new(options)
15
+ files = ad.get_files("test/file_fixture/")
16
+ files.size.must_equal 2
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/models/*/*.rb'])
21
+ ad = AasmDiagram.new(options)
22
+ files = ad.get_files("test/file_fixture/")
23
+ files.size.must_equal 2
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
28
+ ad = AasmDiagram.new(options)
29
+ files = ad.get_files("test/file_fixture/")
30
+ files.size.must_equal 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
35
+ ad = AasmDiagram.new(options)
36
+ files = ad.get_files("test/file_fixture/")
37
+ files.size.must_equal 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
42
+ :exclude => ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
43
+ ad = AasmDiagram.new(options)
44
+ files = ad.get_files("test/file_fixture/")
45
+ files.size.must_equal 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe AppDiagram do
4
+ describe 'file name processing' do
5
+ it 'should extract a simple name' do
6
+ ad = AppDiagram.new
7
+ name = ad.instance_eval {extract_class_name('app/models/test_this.rb')}
8
+ name.must_equal 'TestThis'
9
+ end
10
+ it 'should constantize a name' do
11
+ 'String'.constantize.must_equal String
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe ControllersDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the controllers dir' do
7
+ cd = ControllersDiagram.new
8
+ files = cd.get_files("test/file_fixture/")
9
+ files.size.must_equal 4
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/controllers/dummy1_controller.rb'])
14
+ cd = ControllersDiagram.new(options)
15
+ files = cd.get_files("test/file_fixture/")
16
+ files.size.must_equal 3
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/controllers/sub-dir/*.rb'])
21
+ cd = ControllersDiagram.new(options)
22
+ files = cd.get_files("test/file_fixture/")
23
+ files.size.must_equal 3
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
28
+ cd = ControllersDiagram.new(options)
29
+ files = cd.get_files("test/file_fixture/")
30
+ files.size.must_equal 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'])
35
+ cd = ControllersDiagram.new(options)
36
+ files = cd.get_files("test/file_fixture/")
37
+ files.size.must_equal 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'],
42
+ :exclude => ['test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
43
+ cd = ControllersDiagram.new(options)
44
+ files = cd.get_files("test/file_fixture/")
45
+ files.size.must_equal 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe String do
4
+ describe '#camelize' do
5
+ it "should upper-camelcase a lower case and underscored word" do
6
+ 'lower_case_and_underscored_word'.camelize.must_equal 'LowerCaseAndUnderscoredWord'
7
+ end
8
+
9
+ it "should lower-camelcase a lower case and underscored word when the :lower parameter is passed" do
10
+ 'lower_case_and_underscored_word'.camelize(:lower).must_equal 'lowerCaseAndUnderscoredWord'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ module CustomDotMatchers
4
+ class HaveDotOptions
5
+ def initialize(expected)
6
+ @expected = expected
7
+ end
8
+ def matches?(target)
9
+ @target = target
10
+ return false unless @target =~ /\[(.*)\]/
11
+ @options = $1
12
+ @options == @expected
13
+ end
14
+ def failure_message
15
+ "expected '#{@target.strip}' to have options '[#{@expected}]'"
16
+ end
17
+ def negative_failure_message
18
+ "expected '#{@target.strip}' to not have options '[#{@expected}]'"
19
+ end
20
+ def description
21
+ "have dot options"
22
+ end
23
+ end
24
+ def have_dot_options(expected)
25
+ HaveDotOptions.new expected
26
+ end
27
+ end
28
+
29
+ describe DiagramGraph do
30
+ include CustomDotMatchers
31
+
32
+ before do
33
+ @diagram_graph = DiagramGraph.new
34
+ end
35
+
36
+ describe ".dot_edge" do
37
+ context "has_a/belongs_to" do
38
+ it { @diagram_graph.send(:dot_edge, "one-one", "source", "target").must_include "arrowtail=odot, arrowhead=dot, dir=both" }
39
+ end
40
+
41
+ context "has_many/belongs_to" do
42
+ it { @diagram_graph.send(:dot_edge, "one-many", "source", "target").must_include "arrowtail=odot, arrowhead=crow, dir=both" }
43
+ end
44
+
45
+ context "habtm" do
46
+ it { @diagram_graph.send(:dot_edge, "many-many", "source", "target").must_include "arrowtail=crow, arrowhead=crow, dir=both" }
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe ModelsDiagram do
4
+ describe 'file processing' do
5
+
6
+ it 'should select all the files under the models dir' do
7
+ md = ModelsDiagram.new
8
+ files = md.get_files("test/file_fixture/")
9
+ files.size.must_equal 3
10
+ end
11
+
12
+ it 'should exclude a specific file' do
13
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/models/dummy1.rb'])
14
+ md = ModelsDiagram.new(options)
15
+ files = md.get_files("test/file_fixture/")
16
+ files.size.must_equal 2
17
+ end
18
+
19
+ it 'should exclude a glob pattern of files' do
20
+ options = OptionsStruct.new(:exclude => ['test/file_fixture/app/models/*/*.rb'])
21
+ md = ModelsDiagram.new(options)
22
+ files = md.get_files("test/file_fixture/")
23
+ files.size.must_equal 2
24
+ end
25
+
26
+ it 'should include only specific file' do
27
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
28
+ md = ModelsDiagram.new(options)
29
+ files = md.get_files("test/file_fixture/")
30
+ files.size.must_equal 1
31
+ end
32
+
33
+ it 'should include only specified files' do
34
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
35
+ md = ModelsDiagram.new(options)
36
+ files = md.get_files("test/file_fixture/")
37
+ files.size.must_equal 2
38
+ end
39
+
40
+ it 'should include only specified files and exclude specified files' do
41
+ options = OptionsStruct.new(:specify => ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
42
+ :exclude => ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
43
+ md = ModelsDiagram.new(options)
44
+ files = md.get_files("test/file_fixture/")
45
+ files.size.must_equal 1
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'minitest-spec-context'
4
+ require 'active_support/core_ext/string'
5
+ require File.expand_path('../../lib/railroady.rb', __FILE__)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railroady
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- prerelease:
4
+ version: 1.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Preston Lee
@@ -12,9 +11,79 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2012-09-12 00:00:00.000000000 Z
16
- dependencies: []
17
- description: Ruby on Rails 3 model and controller UML class diagram generator. Originally
14
+ date: 2013-07-31 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: minitest
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: minitest-spec-context
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ - !ruby/object:Gem::Dependency
73
+ name: activesupport
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ description: Ruby on Rails 3/4 model and controller UML class diagram generator. Originally
18
87
  based on the 'railroad' plugin and contributions of many others. (`sudo port install
19
88
  graphviz` before use!)
20
89
  email:
@@ -26,19 +95,16 @@ email:
26
95
  executables:
27
96
  - railroady
28
97
  extensions: []
29
- extra_rdoc_files:
30
- - AUTHORS.rdoc
31
- - CHANGELOG.rdoc
32
- - LICENSE.rdoc
33
- - README.rdoc
98
+ extra_rdoc_files: []
34
99
  files:
35
- - .document
100
+ - .gitignore
36
101
  - AUTHORS.rdoc
37
102
  - CHANGELOG.rdoc
103
+ - Gemfile
104
+ - Gemfile.lock
38
105
  - LICENSE.rdoc
39
106
  - README.rdoc
40
107
  - Rakefile
41
- - VERSION.yml
42
108
  - bin/railroady
43
109
  - lib/railroady.rb
44
110
  - lib/railroady/aasm_diagram.rb
@@ -49,29 +115,58 @@ files:
49
115
  - lib/railroady/options_struct.rb
50
116
  - lib/railroady/railtie.rb
51
117
  - lib/railroady/version.rb
118
+ - railroady.gemspec
52
119
  - tasks/railroady.rake
120
+ - test/file_fixture/app/controllers/application_controller.rb
121
+ - test/file_fixture/app/controllers/dummy1_controller.rb
122
+ - test/file_fixture/app/controllers/dummy2_controller.rb
123
+ - test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
124
+ - test/file_fixture/app/models/dummy1.rb
125
+ - test/file_fixture/app/models/dummy2.rb
126
+ - test/file_fixture/app/models/sub-dir/sub_dummy.rb
127
+ - test/lib/railroady/aasm_diagram_spec.rb
128
+ - test/lib/railroady/app_diagram_spec.rb
129
+ - test/lib/railroady/controllers_diagram_spec.rb
130
+ - test/lib/railroady/core_ext_spec.rb
131
+ - test/lib/railroady/diagram_graph_spec.rb
132
+ - test/lib/railroady/models_diagram_spec.rb
133
+ - test/spec_helper.rb
53
134
  homepage: http://github.com/preston/railroady
54
- licenses: []
135
+ licenses:
136
+ - GPLv2
137
+ metadata: {}
55
138
  post_install_message:
56
139
  rdoc_options: []
57
140
  require_paths:
58
141
  - lib
59
142
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
143
  requirements:
62
- - - ! '>='
144
+ - - '>='
63
145
  - !ruby/object:Gem::Version
64
146
  version: '0'
65
147
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
148
  requirements:
68
- - - ! '>='
149
+ - - '>='
69
150
  - !ruby/object:Gem::Version
70
151
  version: '0'
71
152
  requirements: []
72
153
  rubyforge_project:
73
- rubygems_version: 1.8.24
154
+ rubygems_version: 2.0.3
74
155
  signing_key:
75
- specification_version: 3
76
- summary: Ruby on Rails 3 model and controller UML class diagram generator.
77
- test_files: []
156
+ specification_version: 4
157
+ summary: Ruby on Rails 3/4 model and controller UML class diagram generator.
158
+ test_files:
159
+ - test/file_fixture/app/controllers/application_controller.rb
160
+ - test/file_fixture/app/controllers/dummy1_controller.rb
161
+ - test/file_fixture/app/controllers/dummy2_controller.rb
162
+ - test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
163
+ - test/file_fixture/app/models/dummy1.rb
164
+ - test/file_fixture/app/models/dummy2.rb
165
+ - test/file_fixture/app/models/sub-dir/sub_dummy.rb
166
+ - test/lib/railroady/aasm_diagram_spec.rb
167
+ - test/lib/railroady/app_diagram_spec.rb
168
+ - test/lib/railroady/controllers_diagram_spec.rb
169
+ - test/lib/railroady/core_ext_spec.rb
170
+ - test/lib/railroady/diagram_graph_spec.rb
171
+ - test/lib/railroady/models_diagram_spec.rb
172
+ - test/spec_helper.rb
data/.document DELETED
@@ -1,7 +0,0 @@
1
- README.rdoc
2
- CHANGELOG.rdoc
3
- AUTHORS.rdoc
4
- LICENSE.rdoc
5
- lib/**/*.rb
6
- bin/*
7
- features/**/*.feature
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 1
3
- :minor: 1
4
- :patch: 0
5
- :build: