draw_smd 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 +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +19 -0
- data/app/assets/javascripts/draw_smd/application.js +13 -0
- data/app/assets/javascripts/draw_smd/base.js +11 -0
- data/app/assets/stylesheets/draw_smd/application.css +15 -0
- data/app/assets/stylesheets/draw_smd/base.css +46 -0
- data/app/controllers/draw_smd/application_controller.rb +4 -0
- data/app/controllers/draw_smd/diagram_controller.rb +18 -0
- data/app/helpers/draw_smd/application_helper.rb +4 -0
- data/app/models/draw_smd/diagram.rb +32 -0
- data/app/views/draw_smd/diagram/index.html.erb +36 -0
- data/app/views/layouts/draw_smd/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/draw_smd.gemspec +26 -0
- data/lib/draw_smd.rb +2 -0
- data/lib/draw_smd/engine.rb +5 -0
- data/lib/draw_smd/version.rb +3 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +82 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fixtures/user.rb +8 -0
- data/spec/lib/version_spec.rb +9 -0
- data/spec/models/diagram_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -0
- metadata +211 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 197142faab6a2b26db213b71b4d5aa9787306dfe
|
4
|
+
data.tar.gz: 629670c1f46266cfbe7d97a23ba3c95b891b6328
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c85169a1db7c5f70586e300169a1e33d2a1d46c302371aad58e99983efa494e2cc7d0ca4607f74b4a3d3bfee78d226c32ed267615e61d492e7f1ffed99731dc
|
7
|
+
data.tar.gz: 04faf2fadf3daaa5ca22f166f3e342a45282657b7d58f4e2bed094b25644284f9957d4537cf9f25fe2ca8bd29b3be69558d5a99b94ead5645290c8df49d58b6a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 ogom
|
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,39 @@
|
|
1
|
+
# Draw SMD
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/draw_smd.png)](https://rubygems.org/gems/draw_smd) [![Build Status](https://travis-ci.org/ogom/draw_smd.png?branch=master)](https://travis-ci.org/ogom/draw_smd)
|
4
|
+
|
5
|
+
Drawing the Entity-Relationship Diagram of Rails.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem 'draw_smd'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add this line to your `config/routes.rb`:
|
24
|
+
|
25
|
+
```
|
26
|
+
mount Drawsmd::Engine, at: '/rails/draw/smd'
|
27
|
+
```
|
28
|
+
|
29
|
+
Draw by selecting the schemas:
|
30
|
+
|
31
|
+
![example_smd](http://ogom.github.io/draw_smd/assets/img/example_smd.png)
|
32
|
+
|
33
|
+
## Use
|
34
|
+
|
35
|
+
* [state_machine](https://github.com/pluginaweek/state_machine)
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
* MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
8
|
+
load 'rails/tasks/engine.rake'
|
9
|
+
|
10
|
+
require 'bundler/gem_tasks'
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
require 'rspec/core/rake_task'
|
14
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
15
|
+
task.rspec_opts = ['--color', '--format', 'doc']
|
16
|
+
end
|
17
|
+
|
18
|
+
task test: :spec
|
19
|
+
task default: :spec
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,11 @@
|
|
1
|
+
function check_schema() {
|
2
|
+
var schema = '';
|
3
|
+
|
4
|
+
for (var i = 0, n = document.form_schema.length; i < n; i++) {
|
5
|
+
if (document.form_schema.elements[i].checked) {
|
6
|
+
schema = document.form_schema.elements[i].value;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
location.href = document.form_schema.action + '?schema=' + schema;
|
11
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,46 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: helvetica, verdana, arial, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
white-space: pre-wrap;
|
14
|
+
}
|
15
|
+
|
16
|
+
h2 { padding-left: 10px; }
|
17
|
+
|
18
|
+
#schema_table {
|
19
|
+
border-collapse: collapse;
|
20
|
+
}
|
21
|
+
|
22
|
+
#schema_table td {
|
23
|
+
padding: 0 30px;
|
24
|
+
}
|
25
|
+
|
26
|
+
#schema_table tr.bottom th {
|
27
|
+
padding-bottom: 10px;
|
28
|
+
line-height: 15px;
|
29
|
+
}
|
30
|
+
|
31
|
+
input.bottom {
|
32
|
+
font-size: 15px;
|
33
|
+
font-weight: bold;
|
34
|
+
border:none;
|
35
|
+
background:transparent;
|
36
|
+
}
|
37
|
+
|
38
|
+
div.schemas {
|
39
|
+
padding-top: 18px;
|
40
|
+
float:left;
|
41
|
+
}
|
42
|
+
|
43
|
+
div.draw img {
|
44
|
+
padding-top: 30px;
|
45
|
+
padding-left: 40px;
|
46
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DrawSmd
|
2
|
+
class DiagramController < ::DrawSmd::ApplicationController
|
3
|
+
def index
|
4
|
+
@schemas = DrawSmd::Diagram.schemas
|
5
|
+
|
6
|
+
title = 'smd'
|
7
|
+
path = 'draw-smd'
|
8
|
+
@image_file = File.join(path, "#{title}.png")
|
9
|
+
|
10
|
+
@schema = ''
|
11
|
+
@schema = params['schema'] if params.key?('schema')
|
12
|
+
@schema = params['check']['schema'] if params.key?('check')
|
13
|
+
|
14
|
+
diagram = DrawSmd::Diagram.new(File.join('public', 'images', path))
|
15
|
+
diagram.create(title, @schema)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DrawSmd
|
2
|
+
class Diagram
|
3
|
+
class << self
|
4
|
+
def schemas
|
5
|
+
schemas = ActiveRecord::Base.connection.tables
|
6
|
+
schemas.delete('schema_migrations')
|
7
|
+
schemas.map! {|schema| schema.singularize.camelize}
|
8
|
+
schemas.each do |schema|
|
9
|
+
schemas.delete(schema) unless Object.const_get(schema).respond_to?(:state_machines)
|
10
|
+
end
|
11
|
+
schemas.sort
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(path)
|
16
|
+
@path = File.expand_path(path, Rails.root)
|
17
|
+
FileUtils.mkdir_p(@path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create(title, domain)
|
21
|
+
options = {
|
22
|
+
path: @path,
|
23
|
+
name: title
|
24
|
+
}
|
25
|
+
|
26
|
+
Rails.application.eager_load!
|
27
|
+
StateMachine::Machine.draw(domain, options)
|
28
|
+
rescue => e
|
29
|
+
Rails.logger.error(e)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<h2>Schemas</h2>
|
2
|
+
<p>Drawing the State Machine Diagram</p>
|
3
|
+
|
4
|
+
<div class='schemas'>
|
5
|
+
<%= form_tag({}, method: :get, name: 'form_schema') do %>
|
6
|
+
<table id='schema_table' class='schema_table'>
|
7
|
+
<thead>
|
8
|
+
<tr>
|
9
|
+
<th>Schema</th>
|
10
|
+
</tr>
|
11
|
+
<tr class='bottom'>
|
12
|
+
<th>
|
13
|
+
<%= submit_tag :draw, class: 'bottom' %>
|
14
|
+
</th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
<tbody>
|
18
|
+
<% @schemas.each do |schema| %>
|
19
|
+
<tr>
|
20
|
+
<td>
|
21
|
+
<%= radio_button 'check', 'schema', schema, {id: "check_#{schema}", checked: @schema == schema,
|
22
|
+
onclick: 'check_schema()'} %>
|
23
|
+
<%= label_tag "check[#{schema}]", schema %>
|
24
|
+
</td>
|
25
|
+
</tr>
|
26
|
+
<% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div class='draw'>
|
33
|
+
<% if @schema.present? %>
|
34
|
+
<%= image_tag(@image_file) %>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Schemas</title>
|
5
|
+
<%= stylesheet_link_tag "draw_smd/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "draw_smd/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/draw_smd.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'draw_smd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "draw_smd"
|
8
|
+
spec.version = DrawSmd::VERSION
|
9
|
+
spec.authors = ["ogom"]
|
10
|
+
spec.email = ["ogom@hotmail.co.jp"]
|
11
|
+
spec.summary = %q{Drawing the State Machine Diagram.}
|
12
|
+
spec.description = %q{Drawing the State Machine Diagram of Rails.}
|
13
|
+
spec.homepage = "http://ogom.github.io/draw_smd"
|
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 'rails'
|
22
|
+
spec.add_dependency 'state_machine'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
end
|
data/lib/draw_smd.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|