mongo_mapper_diagram 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/lib/mongo_mapper_diagram/document.rb +14 -0
- data/lib/mongo_mapper_diagram/engine.rb +9 -0
- data/lib/mongo_mapper_diagram/generator.rb +45 -0
- data/lib/mongo_mapper_diagram/railties/tasks.rake +13 -0
- data/lib/mongo_mapper_diagram/version.rb +3 -0
- data/lib/mongo_mapper_diagram.rb +10 -0
- data/mongo_mapper_diagram.gemspec +25 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3c89aa036dc8970a7e8a51de6db37b709acb1d7
|
4
|
+
data.tar.gz: 34935f40f25b22fdd41408cf3f354243d95f7430
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38365a572b07adbfe99eaffe597ba38272dc5a7f259830b298f39e4a58a99837cc02ff05a69d78b7246ca92a650d86dd67e4fca1f6db14f4ab8e0e28915b569b
|
7
|
+
data.tar.gz: 5d858e5e8cc92e3bd12d66f0b3b6b50ddabd639e18b0c8ffada5c4c6f23fdd5503874df0b157b7ce7ba53fece0b25b8368a83c132883dd78e445d333bc7ec190
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dai Akatsuka
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# MongoMapperDiagram
|
2
|
+
|
3
|
+
Diagram generator for MongoMapper
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mongo_mapper_diagram'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mongo_mapper_diagram
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
$ cd /rails/root
|
22
|
+
$ rake mongo_mapper:diagram
|
23
|
+
$ open ./diagram.png
|
24
|
+
|
25
|
+
## TODO
|
26
|
+
|
27
|
+
- Tests
|
28
|
+
- Support embedded document
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( http://github.com/dakatsuka/mongo_mapper_diagram/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "gviz"
|
2
|
+
|
3
|
+
module MongoMapperDiagram
|
4
|
+
class Generator
|
5
|
+
def initialize(documents = MongoMapperDiagram::Document.all)
|
6
|
+
@documents = documents
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate(filename, extension = :png)
|
10
|
+
gviz = Gviz.new(:G, :digraph)
|
11
|
+
|
12
|
+
@documents.each do |doc|
|
13
|
+
gviz.node symbolize(doc), label: make_label(doc), shape: 'Mrecord'
|
14
|
+
end
|
15
|
+
|
16
|
+
@documents.each do |doc|
|
17
|
+
doc.associations.each do |k, association|
|
18
|
+
if association.instance_of? MongoMapper::Plugins::Associations::BelongsToAssociation
|
19
|
+
gviz.route symbolize(doc) => symbolize(association.class_name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
gviz.save(filename, extension)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def symbolize(document)
|
29
|
+
document.to_s.gsub(/::/, '').to_sym
|
30
|
+
end
|
31
|
+
|
32
|
+
def humanize(document)
|
33
|
+
document.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
def make_label(document)
|
37
|
+
label = "{#{humanize(document)}| "
|
38
|
+
label += document.defined_keys.map {|name, key|
|
39
|
+
name + " : " + key.type.to_s
|
40
|
+
}.join('\l')
|
41
|
+
label += "\\l}"
|
42
|
+
label
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :mongo_mapper do
|
2
|
+
desc "Generate Diagram from MongoMapper Document"
|
3
|
+
task :diagram => :environment do
|
4
|
+
filename = ENV['filename']
|
5
|
+
filename ||= './diagram'
|
6
|
+
|
7
|
+
format = ENV['format']
|
8
|
+
format ||= 'png'
|
9
|
+
|
10
|
+
g = MongoMapperDiagram::Generator.new
|
11
|
+
g.generate(filename, format.to_sym)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "mongo_mapper_diagram/version"
|
2
|
+
require "mongo_mapper_diagram/document"
|
3
|
+
require "mongo_mapper_diagram/generator"
|
4
|
+
require "mongo_mapper_diagram/engine" if defined?(Rails)
|
5
|
+
|
6
|
+
module MongoMapper::Document
|
7
|
+
def self.included(klass)
|
8
|
+
MongoMapperDiagram::Document << klass
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mongo_mapper_diagram/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mongo_mapper_diagram"
|
8
|
+
spec.version = MongoMapperDiagram::VERSION
|
9
|
+
spec.authors = ["Dai Akatsuka"]
|
10
|
+
spec.email = ["d.akatsuka@gmail.com"]
|
11
|
+
spec.summary = %q{Diagram generator for MongoMapper}
|
12
|
+
spec.description = %q{DIagram generator for MongoMapper}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_dependency "mongo_mapper"
|
22
|
+
spec.add_dependency "gviz"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongo_mapper_diagram
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dai Akatsuka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mongo_mapper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gviz
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: DIagram generator for MongoMapper
|
70
|
+
email:
|
71
|
+
- d.akatsuka@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/mongo_mapper_diagram.rb
|
82
|
+
- lib/mongo_mapper_diagram/document.rb
|
83
|
+
- lib/mongo_mapper_diagram/engine.rb
|
84
|
+
- lib/mongo_mapper_diagram/generator.rb
|
85
|
+
- lib/mongo_mapper_diagram/railties/tasks.rake
|
86
|
+
- lib/mongo_mapper_diagram/version.rb
|
87
|
+
- mongo_mapper_diagram.gemspec
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.0
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Diagram generator for MongoMapper
|
112
|
+
test_files: []
|
113
|
+
has_rdoc:
|