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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a7fa0d96074617758610fbbb1d18b7bbe69c379
4
- data.tar.gz: 4ad8fd7e21e1a2b9c277498862d8463a446e377d
3
+ metadata.gz: 043d4fabd22b5dd3d3dc0a609893e4fd64ed487b
4
+ data.tar.gz: 77bfad01bdee0e9ef6a1df0a129fb266f437281b
5
5
  SHA512:
6
- metadata.gz: 9eeea0a386b4acecb19a053cf8fb2327dc2c5cd1e6f30afda00e5162648c6d464eb8af2e5befe984ce3f0579c2e942cd3c3cb3e911de86cdf341b025cfaf0dfc
7
- data.tar.gz: 2222c3470ec2585ad2428ee14c6939064da0e7a2026acb15fa2bfa8f8c875232b2d9f7fce7ec26f17d6eed723808b864b72d99908df1b4967619a20e3dd21764
6
+ metadata.gz: 7d8b22d0ef7a702a6b071fa6d6237976b9fbeecb3f3533e8f16cfcf9f53543bfff45b768f0802da32e53aa1db21f49d0cfd622052210b59775b1cc23f735e50a
7
+ data.tar.gz: d3f34e56283d7d6deb889b92b021821706be5be3468bf6c54fdd667716bc972e5e3b5378e307a562c299c727f0b8ec2a458796539d4810975664483b13a52db9
@@ -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
- # Modification 2010 by Preston Lee.
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.match(/.*\/models\/(.*).rb$/)[1].camelize
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
@@ -1,3 +1,3 @@
1
1
  module RailRoady
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -0,0 +1,12 @@
1
+ module AuthorSettings
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_validation :set_up_author
6
+ end
7
+
8
+ def set_up_author
9
+ self.created_by = 'Admin'
10
+ self.updated_by = 'Admin'
11
+ end
12
+ end
@@ -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 4
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 4
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.0
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-19 00:00:00.000000000 Z
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.8
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: