railroady 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/railroady +1 -1
- data/lib/railroady/models_diagram.rb +24 -2
- data/lib/railroady/version.rb +1 -1
- data/test/file_fixture/app/models/concerns/author_settings.rb +12 -0
- data/test/lib/railroady/aasm_diagram_spec.rb +1 -1
- data/test/lib/railroady/models_diagram_spec.rb +37 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 043d4fabd22b5dd3d3dc0a609893e4fd64ed487b
|
4
|
+
data.tar.gz: 77bfad01bdee0e9ef6a1df0a129fb266f437281b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8b22d0ef7a702a6b071fa6d6237976b9fbeecb3f3533e8f16cfcf9f53543bfff45b768f0802da32e53aa1db21f49d0cfd622052210b59775b1cc23f735e50a
|
7
|
+
data.tar.gz: d3f34e56283d7d6deb889b92b021821706be5be3468bf6c54fdd667716bc972e5e3b5378e307a562c299c727f0b8ec2a458796539d4810975664483b13a52db9
|
data/bin/railroady
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
# the Free Software Foundation; either version 2 of the License, or
|
14
14
|
# (at your option) any later version.
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# Modifications 2010-2015 by Preston Lee.
|
17
17
|
#
|
18
18
|
|
19
19
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -39,9 +39,31 @@ 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
|
-
filename
|
44
|
+
filename_was, class_name = filename, nil
|
45
|
+
|
46
|
+
filename = "app/models/#{filename.split('app/models')[1]}"
|
47
|
+
|
48
|
+
while filename.split('/').length > 2
|
49
|
+
begin
|
50
|
+
class_name = filename.match(/.*\/models\/(.*).rb$/)[1].camelize
|
51
|
+
class_name.constantize
|
52
|
+
|
53
|
+
break
|
54
|
+
rescue Exception => e
|
55
|
+
class_name = nil
|
56
|
+
filename_end = filename.split('/')[2..-1]
|
57
|
+
filename_end.shift
|
58
|
+
filename = "#{filename.split('/')[0, 2].join('/')}/#{filename_end.join('/')}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if class_name.nil?
|
63
|
+
filename_was.match(/.*\/models\/(.*).rb$/)[1].camelize
|
64
|
+
else
|
65
|
+
class_name
|
66
|
+
end
|
45
67
|
end
|
46
68
|
|
47
69
|
# Process a model class
|
data/lib/railroady/version.rb
CHANGED
@@ -12,7 +12,7 @@ describe AasmDiagram do
|
|
12
12
|
options = OptionsStruct.new(include_concerns: true)
|
13
13
|
ad = AasmDiagram.new(options)
|
14
14
|
files = ad.get_files('test/file_fixture/')
|
15
|
-
files.size.must_equal
|
15
|
+
files.size.must_equal 5
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should exclude a specific file' do
|
@@ -12,7 +12,7 @@ describe ModelsDiagram do
|
|
12
12
|
options = OptionsStruct.new(include_concerns: true)
|
13
13
|
ad = ModelsDiagram.new(options)
|
14
14
|
files = ad.get_files('test/file_fixture/')
|
15
|
-
files.size.must_equal
|
15
|
+
files.size.must_equal 5
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should exclude a specific file' do
|
@@ -60,4 +60,40 @@ describe ModelsDiagram do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
+
|
64
|
+
describe '#extract_class_name' do
|
65
|
+
describe 'class can be found' do
|
66
|
+
describe 'module without namespace' do
|
67
|
+
module AuthorSettings
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'does not take every models subdirectory as a namespace' do
|
71
|
+
md = ModelsDiagram.new(OptionsStruct.new)
|
72
|
+
|
73
|
+
md.extract_class_name('test/file_fixture/app/models/concerns/author_settings.rb').must_equal 'AuthorSettings'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'module with parent namespace / class' do
|
78
|
+
class User
|
79
|
+
module Authentication
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'does not take every models subdirectory as a namespace' do
|
84
|
+
md = ModelsDiagram.new(OptionsStruct.new)
|
85
|
+
|
86
|
+
md.extract_class_name('test/file_fixture/app/models/concerns/user/authentication.rb').must_equal 'User::Authentication'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'class cannot be found' do
|
92
|
+
it 'returns the full class name' do
|
93
|
+
md = ModelsDiagram.new(OptionsStruct.new)
|
94
|
+
|
95
|
+
md.extract_class_name('test/file_fixture/app/models/concerns/dummy.rb').must_equal 'Concerns::Dummy'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
63
99
|
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.
|
4
|
+
version: 1.4.1
|
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-10-
|
14
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- test/file_fixture/app/controllers/dummy1_controller.rb
|
109
109
|
- test/file_fixture/app/controllers/dummy2_controller.rb
|
110
110
|
- test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
|
111
|
+
- test/file_fixture/app/models/concerns/author_settings.rb
|
111
112
|
- test/file_fixture/app/models/concerns/taggable.rb
|
112
113
|
- test/file_fixture/app/models/dummy1.rb
|
113
114
|
- test/file_fixture/app/models/dummy2.rb
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
144
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.4.
|
145
|
+
rubygems_version: 2.4.6
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: Ruby on Rails 3/4 model and controller UML class diagram generator.
|
@@ -150,6 +151,7 @@ test_files:
|
|
150
151
|
- test/file_fixture/app/controllers/dummy1_controller.rb
|
151
152
|
- test/file_fixture/app/controllers/dummy2_controller.rb
|
152
153
|
- test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb
|
154
|
+
- test/file_fixture/app/models/concerns/author_settings.rb
|
153
155
|
- test/file_fixture/app/models/concerns/taggable.rb
|
154
156
|
- test/file_fixture/app/models/dummy1.rb
|
155
157
|
- test/file_fixture/app/models/dummy2.rb
|
@@ -163,3 +165,4 @@ test_files:
|
|
163
165
|
- test/lib/railroady/diagram_graph_spec.rb
|
164
166
|
- test/lib/railroady/models_diagram_spec.rb
|
165
167
|
- test/spec_helper.rb
|
168
|
+
has_rdoc:
|