dm-visualizer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.specopts +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/dm-visualizer.gemspec +100 -0
- data/lib/dm-visualizer.rb +2 -0
- data/lib/dm-visualizer/graphviz.rb +168 -0
- data/lib/dm-visualizer/project.rb +315 -0
- data/lib/dm-visualizer/rake/graphviz_task.rb +67 -0
- data/lib/dm-visualizer/rake/rails/graphviz_task.rb +16 -0
- data/lib/dm-visualizer/rake/rails/tasks.rb +24 -0
- data/lib/dm-visualizer/rake/task.rb +34 -0
- data/lib/dm-visualizer/visualization.rb +204 -0
- data/spec/dm_visualizer_spec.rb +9 -0
- data/spec/helpers/project.rb +9 -0
- data/spec/helpers/projects/library/lib/blog.rb +3 -0
- data/spec/helpers/projects/library/lib/blog/comment.rb +17 -0
- data/spec/helpers/projects/library/lib/blog/post.rb +21 -0
- data/spec/helpers/projects/library/lib/blog/user.rb +17 -0
- data/spec/helpers/projects/rails/app/models/comment.rb +11 -0
- data/spec/helpers/projects/rails/app/models/post.rb +15 -0
- data/spec/helpers/projects/rails/app/models/user.rb +11 -0
- data/spec/project_examples.rb +19 -0
- data/spec/project_spec.rb +47 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/visualization_spec.rb +92 -0
- metadata +189 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'dm-visualizer/project'
|
2
|
+
|
3
|
+
shared_examples_for "a Ruby project" do
|
4
|
+
it "should add the include directories to the $LOAD_PATH" do
|
5
|
+
@project.activate!
|
6
|
+
|
7
|
+
@project.include_dirs.all? { |dir|
|
8
|
+
$LOAD_PATH.include?(dir)
|
9
|
+
}.should == true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should remove the include directories to the $LOAD_PATH" do
|
13
|
+
@project.deactivate!
|
14
|
+
|
15
|
+
@project.include_dirs.all? { |dir|
|
16
|
+
$LOAD_PATH.include?(dir)
|
17
|
+
}.should == false
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'dm-visualizer/project'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'helpers/project'
|
5
|
+
require 'project_examples'
|
6
|
+
|
7
|
+
describe DataMapper::Visualizer::Project do
|
8
|
+
include Helpers::Project
|
9
|
+
|
10
|
+
context "library" do
|
11
|
+
before(:all) do
|
12
|
+
@dir = project_dir('library')
|
13
|
+
@project = DataMapper::Visualizer::Project.new(
|
14
|
+
:include => [File.join(@dir,'lib')],
|
15
|
+
:require => ['blog']
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
it_should_behave_like "a Ruby project"
|
20
|
+
|
21
|
+
it "should require the specified paths" do
|
22
|
+
@project.load!
|
23
|
+
|
24
|
+
Object.const_defined?('Blog').should == true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "rails" do
|
29
|
+
before(:all) do
|
30
|
+
@dir = project_dir('rails')
|
31
|
+
@project = DataMapper::Visualizer::Project.new(
|
32
|
+
:include => [@dir],
|
33
|
+
:require_all => ['app/models/*.rb']
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
it_should_behave_like "a Ruby project"
|
38
|
+
|
39
|
+
it "should require all paths that match the specified glob patterns" do
|
40
|
+
@project.load!
|
41
|
+
|
42
|
+
Object.const_defined?('User').should == true
|
43
|
+
Object.const_defined?('Post').should == true
|
44
|
+
Object.const_defined?('Comment').should == true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'dm-visualizer/visualization'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'helpers/project'
|
5
|
+
|
6
|
+
describe DataMapper::Visualizer::Visualization do
|
7
|
+
include Helpers::Project
|
8
|
+
|
9
|
+
it "should detect which inflector DataMapper is using" do
|
10
|
+
DataMapper::Visualizer::Visualization::Inflector.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "defaults" do
|
14
|
+
before(:all) do
|
15
|
+
@vis = DataMapper::Visualizer::Visualization.new(
|
16
|
+
:include => [File.join(project_dir('library'),'lib')],
|
17
|
+
:require => ['blog']
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return the class names of Classes" do
|
22
|
+
@vis.class_name(Blog::User).should == 'User'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return the class names of Objects" do
|
26
|
+
@vis.class_name(Blog::Post.body).should == 'Property'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return the names of properties" do
|
30
|
+
@vis.property_name(Blog::Post.body).should == 'body'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the names of models" do
|
34
|
+
@vis.model_name(Blog::User).should == 'User'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "repository names" do
|
39
|
+
before(:all) do
|
40
|
+
@vis = DataMapper::Visualizer::Visualization.new(
|
41
|
+
:include => [File.join(project_dir('library'),'lib')],
|
42
|
+
:require => ['blog'],
|
43
|
+
:repository_names => {:default => 'blogdb'}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should map the DataMapper repository names" do
|
48
|
+
@vis.model_repository_name(Blog::User).should == 'blogdb'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "Schema naming convention" do
|
53
|
+
before(:all) do
|
54
|
+
@vis = DataMapper::Visualizer::Visualization.new(
|
55
|
+
:include => [File.join(project_dir('library'),'lib')],
|
56
|
+
:require => ['blog'],
|
57
|
+
:repository_names => {:default => 'blogdb'},
|
58
|
+
:naming => :schema
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return the database and table names for a model name" do
|
63
|
+
@vis.model_name(Blog::User).should == 'blogdb.blog_users'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "full names" do
|
68
|
+
before(:all) do
|
69
|
+
@vis = DataMapper::Visualizer::Visualization.new(
|
70
|
+
:include => [File.join(project_dir('library'),'lib')],
|
71
|
+
:require => ['blog'],
|
72
|
+
:full_names => true
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should not demodulize the names of Classes" do
|
77
|
+
@vis.class_name(Blog::User).should == 'Blog::User'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not demodulize the names of Objects" do
|
81
|
+
@vis.class_name(Blog::Post.body).should == 'DataMapper::Property'
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should not demodulize property type names" do
|
85
|
+
@vis.property_type_name(Blog::Post.body).should == 'DataMapper::Types::Text'
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not demodulize model names" do
|
89
|
+
@vis.model_name(Blog::User).should == 'Blog::User'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dm-visualizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Postmodern
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-05-27 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ruby-graphviz
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 47
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 9
|
33
|
+
- 10
|
34
|
+
version: 0.9.10
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: dm-core
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 51
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 10
|
49
|
+
- 2
|
50
|
+
version: 0.10.2
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: thor
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 35
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 13
|
65
|
+
- 4
|
66
|
+
version: 0.13.4
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 27
|
78
|
+
segments:
|
79
|
+
- 1
|
80
|
+
- 3
|
81
|
+
- 0
|
82
|
+
version: 1.3.0
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: yard
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 13
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 5
|
97
|
+
- 3
|
98
|
+
version: 0.5.3
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
101
|
+
description: DataMapper Visualizer is both a library and a command-line utility for visualizing the Models, Properties and Relationships defined in a DataMapper based Ruby project.
|
102
|
+
email: postmodern.mod3@gmail.com
|
103
|
+
executables: []
|
104
|
+
|
105
|
+
extensions: []
|
106
|
+
|
107
|
+
extra_rdoc_files:
|
108
|
+
- ChangeLog.md
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
files:
|
112
|
+
- .gitignore
|
113
|
+
- .specopts
|
114
|
+
- .yardopts
|
115
|
+
- ChangeLog.md
|
116
|
+
- LICENSE.txt
|
117
|
+
- README.md
|
118
|
+
- Rakefile
|
119
|
+
- VERSION
|
120
|
+
- dm-visualizer.gemspec
|
121
|
+
- lib/dm-visualizer.rb
|
122
|
+
- lib/dm-visualizer/graphviz.rb
|
123
|
+
- lib/dm-visualizer/project.rb
|
124
|
+
- lib/dm-visualizer/rake/graphviz_task.rb
|
125
|
+
- lib/dm-visualizer/rake/rails/graphviz_task.rb
|
126
|
+
- lib/dm-visualizer/rake/rails/tasks.rb
|
127
|
+
- lib/dm-visualizer/rake/task.rb
|
128
|
+
- lib/dm-visualizer/visualization.rb
|
129
|
+
- spec/dm_visualizer_spec.rb
|
130
|
+
- spec/helpers/project.rb
|
131
|
+
- spec/helpers/projects/library/lib/blog.rb
|
132
|
+
- spec/helpers/projects/library/lib/blog/comment.rb
|
133
|
+
- spec/helpers/projects/library/lib/blog/post.rb
|
134
|
+
- spec/helpers/projects/library/lib/blog/user.rb
|
135
|
+
- spec/helpers/projects/rails/app/models/comment.rb
|
136
|
+
- spec/helpers/projects/rails/app/models/post.rb
|
137
|
+
- spec/helpers/projects/rails/app/models/user.rb
|
138
|
+
- spec/project_examples.rb
|
139
|
+
- spec/project_spec.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/visualization_spec.rb
|
142
|
+
has_rdoc: yard
|
143
|
+
homepage: http://github.com/postmodern/dm-visualizer
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options:
|
148
|
+
- --charset=UTF-8
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
version: "0"
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
hash: 3
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
version: "0"
|
169
|
+
requirements: []
|
170
|
+
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 1.3.7
|
173
|
+
signing_key:
|
174
|
+
specification_version: 3
|
175
|
+
summary: Visualizes the Models, Properties and Relationships defined in a DataMapper based Ruby project.
|
176
|
+
test_files:
|
177
|
+
- spec/project_spec.rb
|
178
|
+
- spec/spec_helper.rb
|
179
|
+
- spec/visualization_spec.rb
|
180
|
+
- spec/project_examples.rb
|
181
|
+
- spec/helpers/project.rb
|
182
|
+
- spec/helpers/projects/library/lib/blog.rb
|
183
|
+
- spec/helpers/projects/library/lib/blog/post.rb
|
184
|
+
- spec/helpers/projects/library/lib/blog/user.rb
|
185
|
+
- spec/helpers/projects/library/lib/blog/comment.rb
|
186
|
+
- spec/helpers/projects/rails/app/models/post.rb
|
187
|
+
- spec/helpers/projects/rails/app/models/user.rb
|
188
|
+
- spec/helpers/projects/rails/app/models/comment.rb
|
189
|
+
- spec/dm_visualizer_spec.rb
|