erd 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.rdoc +1 -3
- data/app/assets/javascripts/erd/application.js +1 -1
- data/app/assets/javascripts/erd/erd.js.coffee +80 -2
- data/app/assets/stylesheets/erd/erd.css.scss +425 -130
- data/app/controllers/erd/erd_controller.rb +9 -8
- data/app/views/erd/erd/_column.html.erb +14 -1
- data/app/views/erd/erd/_model.html.erb +34 -3
- data/app/views/erd/erd/index.html.erb +10 -4
- data/erd.gemspec +4 -1
- data/lib/erd/railtie.rb +4 -7
- data/lib/erd/version.rb +1 -1
- data/spec/fake_app/fake_app.rb +2 -0
- data/spec/{requests → features}/erd_spec.rb +0 -0
- data/spec/lib/migrator_spec.rb +2 -2
- data/vendor/assets/javascripts/jquery-ui.min.js +12 -0
- metadata +95 -36
@@ -28,13 +28,13 @@ module Erd
|
|
28
28
|
case action
|
29
29
|
when 'remove_model'
|
30
30
|
generated_migration_file = Erd::Migrator.execute_generate_migration "drop_#{model}"
|
31
|
-
gsub_file generated_migration_file, /def up.* end/m, "def change\n drop_table :#{model}\n end"
|
31
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n drop_table :#{model}\n end"
|
32
32
|
Erd::Migrator.run_migrations :up => generated_migration_file
|
33
33
|
executed_migrations << generated_migration_file
|
34
34
|
when 'rename_model'
|
35
35
|
from, to = from.tableize, to.tableize
|
36
36
|
generated_migration_file = Erd::Migrator.execute_generate_migration "rename_#{from}_to_#{to}"
|
37
|
-
gsub_file generated_migration_file, /def up.* end/m, "def change\n rename_table :#{from}, :#{to}\n end"
|
37
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_table :#{from}, :#{to}\n end"
|
38
38
|
Erd::Migrator.run_migrations :up => generated_migration_file
|
39
39
|
executed_migrations << generated_migration_file
|
40
40
|
when 'add_column'
|
@@ -45,12 +45,12 @@ module Erd
|
|
45
45
|
executed_migrations << generated_migration_file
|
46
46
|
when 'rename_column'
|
47
47
|
generated_migration_file = Erd::Migrator.execute_generate_migration "rename_#{model}_#{from}_to_#{to}"
|
48
|
-
gsub_file generated_migration_file, /def up.* end/m, "def change\n rename_column :#{model}, :#{from}, :#{to}\n end"
|
48
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n rename_column :#{model}, :#{from}, :#{to}\n end"
|
49
49
|
Erd::Migrator.run_migrations :up => generated_migration_file
|
50
50
|
executed_migrations << generated_migration_file
|
51
51
|
when 'alter_column'
|
52
52
|
generated_migration_file = Erd::Migrator.execute_generate_migration "change_#{model}_#{column}_type_to_#{to}"
|
53
|
-
gsub_file generated_migration_file, /def up.* end/m, "def change\n change_column :#{model}, :#{column}, :#{to}\n end"
|
53
|
+
gsub_file generated_migration_file, /def (up|change).* end/m, "def change\n change_column :#{model}, :#{column}, :#{to}\n end"
|
54
54
|
Erd::Migrator.run_migrations :up => generated_migration_file
|
55
55
|
executed_migrations << generated_migration_file
|
56
56
|
when 'move'
|
@@ -77,22 +77,23 @@ module Erd
|
|
77
77
|
private
|
78
78
|
def render_plain(plain, positions)
|
79
79
|
_scale, svg_width, svg_height = plain.scan(/\Agraph ([0-9\.]+) ([0-9\.]+) ([0-9\.]+)$/).first
|
80
|
-
ratio = [BigDecimal('4800') / BigDecimal(svg_width), BigDecimal('3200') / BigDecimal(svg_height), 180].min
|
81
80
|
# node name x y width height label style shape color fillcolor
|
82
81
|
models = plain.scan(/^node ([^ ]+) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) ([0-9\.]+) <\{?(<((?!^\}?>).)*)^\}?> [^ ]+ [^ ]+ [^ ]+ [^ ]+\n/m).map {|node_name, x, y, width, height, label|
|
83
82
|
label_doc = Nokogiri::HTML::DocumentFragment.parse(label)
|
84
|
-
model_name = node_name.
|
83
|
+
model_name = node_name.dup
|
84
|
+
model_name[0] = model_name[-1] = '' if (model_name.first == '"') && (model_name.last == '"')
|
85
|
+
model_name = model_name.sub(/^m_/, '')
|
85
86
|
next if model_name == 'ActiveRecord::SchemaMigration'
|
86
87
|
columns = []
|
87
88
|
if (cols_table = label_doc.search('table')[1])
|
88
89
|
columns = cols_table.search('tr > td').map {|col| col_name, col_type = col.text.split(' '); {:name => col_name, :type => col_type}}
|
89
90
|
end
|
90
91
|
custom_x, custom_y = positions[model_name.tableize].try(:split, ',')
|
91
|
-
{:model => model_name, :x => (custom_x || BigDecimal(x) *
|
92
|
+
{:model => model_name, :x => (custom_x || (BigDecimal(x) * 72).round), :y => (custom_y || (BigDecimal(y) * 72).round), :width => (BigDecimal(width) * 72).round, :height => height, :columns => columns}
|
92
93
|
}.compact
|
93
94
|
# edge tail head n x1 y1 .. xn yn [label xl yl] style color
|
94
95
|
edges = plain.scan(/^edge ([^ ]+)+ ([^ ]+)/).map {|from, to| {:from => from.sub(/^m_/, ''), :to => to.sub(/^m_/, '')}}
|
95
|
-
render_to_string 'erd/erd/erd', :layout => nil, :locals => {:width => BigDecimal(svg_width) *
|
96
|
+
render_to_string 'erd/erd/erd', :layout => nil, :locals => {:width => (BigDecimal(svg_width) * 72).round, :height => (BigDecimal(svg_height) * 72).round, :models => models, :edges => edges}
|
96
97
|
end
|
97
98
|
|
98
99
|
def gsub_file(path, flag, *args, &block)
|
@@ -1 +1,14 @@
|
|
1
|
-
<li class="column"
|
1
|
+
<li class="column">
|
2
|
+
<table>
|
3
|
+
<tr>
|
4
|
+
<td>
|
5
|
+
<span class="column_name_text"><%= column[:name] %></span>
|
6
|
+
<form class="rename_column_form"><span><input name="model" type="hidden" value="<%= model[:model] %>" /><input name="column" type="hidden" value="<%= column[:name] %>" /><input name="to" type="text" /><input type="submit" value="Change" /></span><a href="#!" class="cancel">Cancel</a></form>
|
7
|
+
</td>
|
8
|
+
<td>
|
9
|
+
<span class="column_type_text <%= column[:type].delete(" ∗") %>"><%= column[:type] %></span>
|
10
|
+
<form class="alter_column_form"><span><input name="model" type="hidden" value="<%= model[:model] %>" /><input name="column" type="hidden" value="<%= column[:name] %>" /><input name="type" type="hidden" value="<%= column[:type] %>" /><input name="to" type="text" /><input type="submit" value="Change" /></span><a href="#!" class="cancel">Cancel</a></form>
|
11
|
+
</td>
|
12
|
+
</tr>
|
13
|
+
</table>
|
14
|
+
</li>
|
@@ -1,8 +1,20 @@
|
|
1
1
|
<div id="erd-<%= model[:model] %>" class="model" style="top: <%= model[:y] %>px; left: <%= model[:x] %>px;" data-model_name="<%= model[:model] %>">
|
2
|
-
<a href="#!" class="close"
|
2
|
+
<a href="#!" class="close"><%= image_tag 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NTExMTA1MjMzRUMxMTFFMkJDNjQ4QUM5N0I1ODJDNUMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NTExMTA1MjQzRUMxMTFFMkJDNjQ4QUM5N0I1ODJDNUMiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo1MTExMDUyMTNFQzExMUUyQkM2NDhBQzk3QjU4MkM1QyIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo1MTExMDUyMjNFQzExMUUyQkM2NDhBQzk3QjU4MkM1QyIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pjsg+BcAAADiSURBVHjavNaBDcIgEADAtnEBVnCFruAKrkBHcBZdwRFcQVfREV5QSID24Z9//eRTCuQvbcKHEQCGf8RUvFuXs1LtvJb/opAWvvF0OSfzPbmqFReOkIcEsxu1TFw0Lu8KWIlAmMt+nRRDkRKSYFVkC+rBmggGcTASUoMoGBlpQTXsxEEoEIaxECrUwiylxkTsWy+XV2T+QaogOIysQ92L3LiYpK2cOZiorXAwCcLCpAgZ00BImBbSxOKGgwJSw/bYBiu8nKS1/HjYJU1iCU/fUi7Cq9ZSjscfXiBN6IWfeAswAPwFJ+lOAhBOAAAAAElFTkSuQmCC' %></a>
|
3
3
|
<div class="model_name">
|
4
4
|
<div class="model_name_text"><%= model[:model] %></div>
|
5
|
-
<form class="rename_model_form"
|
5
|
+
<form class="rename_model_form">
|
6
|
+
<table>
|
7
|
+
<tr>
|
8
|
+
<td>
|
9
|
+
<input name="model" type="hidden" value="<%= model[:model] %>"/>
|
10
|
+
</td>
|
11
|
+
<td>
|
12
|
+
<input name="to" type="text" /><input type="submit" value="Change"/>
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
</table>
|
16
|
+
<a href="#!" class="cancel">Cancel</a>
|
17
|
+
</form>
|
6
18
|
</div>
|
7
19
|
<div class="columns">
|
8
20
|
<ul>
|
@@ -11,6 +23,25 @@
|
|
11
23
|
</div>
|
12
24
|
<div class="add_column_box">
|
13
25
|
<a href="#!" class="add_column">add column</a>
|
14
|
-
<form class="add_column_form"
|
26
|
+
<form class="add_column_form">
|
27
|
+
<input name="model" type="hidden" value="<%= model[:model] %>" />
|
28
|
+
<table>
|
29
|
+
<tr>
|
30
|
+
<td>
|
31
|
+
<input name="name" type="text" />
|
32
|
+
</td>
|
33
|
+
<td>
|
34
|
+
:
|
35
|
+
</td>
|
36
|
+
<td>
|
37
|
+
<input name="type" type="text" value="string" />
|
38
|
+
</td>
|
39
|
+
<td>
|
40
|
+
<input type="submit" value="Add" />
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
</table>
|
44
|
+
<a href="#!" class="cancel">Cancel</a>
|
45
|
+
</form>
|
15
46
|
</div>
|
16
47
|
</div>
|
@@ -2,8 +2,9 @@
|
|
2
2
|
<div id="erd_container">
|
3
3
|
<%=raw @erd %>
|
4
4
|
</div>
|
5
|
-
|
5
|
+
<div id="open_migration"><%= image_tag "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%20%00%00%006%08%06%00%00%00%A6%F5%9Br%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%03%24iTXtXML%3Acom.adobe.xmp%00%00%00%00%00%3C%3Fxpacket%20begin%3D%22%EF%BB%BF%22%20id%3D%22W5M0MpCehiHzreSzNTczkc9d%22%3F%3E%20%3Cx%3Axmpmeta%20xmlns%3Ax%3D%22adobe%3Ans%3Ameta%2F%22%20x%3Axmptk%3D%22Adobe%20XMP%20Core%205.3-c011%2066.145661%2C%202012%2F02%2F06-14%3A56%3A27%20%20%20%20%20%20%20%20%22%3E%20%3Crdf%3ARDF%20xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%3E%20%3Crdf%3ADescription%20rdf%3Aabout%3D%22%22%20xmlns%3Axmp%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2F%22%20xmlns%3AxmpMM%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2Fmm%2F%22%20xmlns%3AstRef%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2FsType%2FResourceRef%23%22%20xmp%3ACreatorTool%3D%22Adobe%20Photoshop%20CS6%20(Macintosh)%22%20xmpMM%3AInstanceID%3D%22xmp.iid%3A7FB38B03BFF211E29BDCA95598AF2146%22%20xmpMM%3ADocumentID%3D%22xmp.did%3A7FB38B04BFF211E29BDCA95598AF2146%22%3E%20%3CxmpMM%3ADerivedFrom%20stRef%3AinstanceID%3D%22xmp.iid%3A7FB38B01BFF211E29BDCA95598AF2146%22%20stRef%3AdocumentID%3D%22xmp.did%3A7FB38B02BFF211E29BDCA95598AF2146%22%2F%3E%20%3C%2Frdf%3ADescription%3E%20%3C%2Frdf%3ARDF%3E%20%3C%2Fx%3Axmpmeta%3E%20%3C%3Fxpacket%20end%3D%22r%22%3F%3E%1A~%A1%DF%00%00%023IDATx%DA%CC%99%BF%2F%03a%18%C7%AFG%A3%09%95hh%0C%16%83%A9K'%93%C4%C0b%F0c%AA%09%1B%23%FE%00F%1D%DB%0D%2B%83X%BAHL6%8BI%97N%06%89%C1%D0K%88_%11%11%F1%FA%1E%DF%8B7%97%EB%A9%F6%EEy%7B%C9%A7%D1%DE%7B%FD%3E%E9%FB%E3%F9%3E%8F%84R%CA2t-%81%E3n%03%C2%3D%60%1F%AC%80I%E9%00%86%40%05L%80%17pb%B9S%20D%0E%5C%AB%9F%EB%06%E4%BF%A7_H%7C%06%3CR%FC%02%0C%7B%F7%24%C4%D7%C1%07%C5%8F%40J%BF%1F%A7p%12%ECQ%F8%13l%83%84%7F%5C%5C%E2%03%E0%8C%E2%AF%60%B1%D1%D88%C4%C7%C0%15%C5o%C1x%D8%F8%A8%C5%A7%C0%1D%C5%AB%60%E4%AFg%A2%14_%05%EF%14%AF%80%DEf%9E%8BB%B8%0B%94%D4%EFU%04v%B3%CF%B7%2B%9E%06%A7%14~%03%CB%FF%FD%8Ev%C4GA%8D%E2%0E%98h%E5%7BZ%15w%C5%EA%14%AF1%18K*%80e%FE%DC%8A%3F%7F%7F%3B%D3%F8%9F%C1%EE%C2%DA%D1%16%5B%99%0B%D0%92%08%A0%97%5BKq%AB%ADE%B5%7D%9B%19%E4%1E%26%97%14%BF%E7acI%050%CE%E3T%F1x%1D%8B%FA%E8%0E%BBY%60%22QL%2C%998%12W%D0%87n%CA%DCb%0AUL%A9%C9%B8%D2%B6%FF%83%14M%83%A2%89%D8%88%DB%B0%E8o%86i%97%DC%EB%896%CA%92%0A%20O%A3%A8h%1CsRf%D5%7D%99%03%CF%14%3F%07YA%A7l%D9%F0%E6%0B%A0%0F%1C%80i%E0H%16%0A%B6%F6%B7%99%1A-%60%0A%06%25%A7%A0%23%16a%D06%7C%90%DE%86%8D%0E%A2u%E9%00%82%8E%E2%5D%C9%A38%2C%19%0DH%07%60%3C%1D%EB%86%A4%CA%20%EE%A4%0DI%23K%B6*%1D%80gJ%8B%9A)-I%9A%D20%5B%9E%96%0E%C0%2BL%1CS%85IPiV%97.%CD%3C%FAM%16%A7zy%5E%D6%16%E7%8Edy%AE%B3f%AAA%E1o%D1%DC%9Bj%D1tD%93%CA%23%E3k%D3%15%A4%03%F0%1A%95%FB%A6%1A%95%3A%9B%A6Z%B5%FEf%F5%93%A9fuG%B4%EB%3D%B2%B4%FE%8A%A5%C0%BC-%5C%868%AC%BE%0EY%8D%CD%26L%FF%D3%EAK%80%01%00%2B%DD2X)e%A8%3D%00%00%00%00IEND%AEB%60%82" %></div>
|
6
6
|
<div id="migration">
|
7
|
+
<div id="close_migration"><%= image_tag 'data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%20%00%00%006%08%06%00%00%00%A6%F5%9Br%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%03%24iTXtXML%3Acom.adobe.xmp%00%00%00%00%00%3C%3Fxpacket%20begin%3D%22%EF%BB%BF%22%20id%3D%22W5M0MpCehiHzreSzNTczkc9d%22%3F%3E%20%3Cx%3Axmpmeta%20xmlns%3Ax%3D%22adobe%3Ans%3Ameta%2F%22%20x%3Axmptk%3D%22Adobe%20XMP%20Core%205.3-c011%2066.145661%2C%202012%2F02%2F06-14%3A56%3A27%20%20%20%20%20%20%20%20%22%3E%20%3Crdf%3ARDF%20xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%3E%20%3Crdf%3ADescription%20rdf%3Aabout%3D%22%22%20xmlns%3Axmp%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2F%22%20xmlns%3AxmpMM%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2Fmm%2F%22%20xmlns%3AstRef%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2FsType%2FResourceRef%23%22%20xmp%3ACreatorTool%3D%22Adobe%20Photoshop%20CS6%20(Macintosh)%22%20xmpMM%3AInstanceID%3D%22xmp.iid%3A7FB38B07BFF211E29BDCA95598AF2146%22%20xmpMM%3ADocumentID%3D%22xmp.did%3A7FB38B08BFF211E29BDCA95598AF2146%22%3E%20%3CxmpMM%3ADerivedFrom%20stRef%3AinstanceID%3D%22xmp.iid%3A7FB38B05BFF211E29BDCA95598AF2146%22%20stRef%3AdocumentID%3D%22xmp.did%3A7FB38B06BFF211E29BDCA95598AF2146%22%2F%3E%20%3C%2Frdf%3ADescription%3E%20%3C%2Frdf%3ARDF%3E%20%3C%2Fx%3Axmpmeta%3E%20%3C%3Fxpacket%20end%3D%22r%22%3F%3E%F5JG%DA%00%00%01%E8IDATx%DA%E4%99%BFKBQ%18%86%CFU*A%14%94%92%86%96%86%A6%96%A6%267%A7%96%DAts%D4%D1%FA%03j%D41%B7%0C%22%FA%05m%8DMm-N%B989%08%0E%0E%09I%19DDx%FA%3Ez%2F%5D%EE%1F%F0~C%07%9E%BB%DE%07%CE9%DF%AF%13x%EF%17%9Dse%E1%C6Y%2C%118%F3%BF%EBBX%12%1C%13%FD%EC%0A%EF%90x%14%96%D9%02%CA%960%82%C4P%D8d%0B(%ABB%17%12%AF%C2%0E%5B%40I%09%B7%90%F8%16%1Al%01%25%10%0E%859DN%84%05%A6%40HY%F8%80%C4%83%90c%0B(%DB%C2%18%12%03a%83-%A0%AC%09%3DH%BC%08%25%B6%80%92%16%EE%20%F1%25%D4%D8%02JBh%F9%BFu%2C%24%99%02!U%E1%13%12%F7B%86-%A0%14%85%09%24%FA%C2%3A%5B%C0%E1%A7%7DH%3CC%8A*%A0d%B1%0D%1E%DBRe%0B8%1C%C4v%E4p6q%60i%02!u%5CQ%8F%2B%9Bf%0B8%04%A9)%24z%08bT%01%87p%3D%80%C4%18%E1%9C*%A0%E4%91%C0%3C%12Z%99-%E0%90%C2O!%A1%A9%FD%08%A9%9E%26%10r%80%E2%C6%A3%D8I%B1%05%1C%CA%BB%19%24%BA(%FF%A8%02%0E%85%EE%10%12%23%14%C2T%01%A5%80%D2%DF%A3%15%D8c%0B84%3FW%908O8%9B5%8F%B6fLV%2C%B7%C0%F4%10%EA5%7C%B3%BA%86%0D%AB%40%A4%A1%B8c%15%8As%B1dT%F97%E9%B8%84%EE%C9%A4%20%A9Y%95dItI%E1j1%8B%D2%8CeY%1EmL%26%EC%C6%A4%88n%C8%A45%8B7%A7Yf%7B%DE%8C%1C%B66%B3%3D%8F%0F(%EA%EC%11%CD%13~%3Ee%8FhL%87T%F11%5D%DEjP%D9a%0E*%E3%A3%DA%7D%ABa%F5%8C%3D%AC6%1D%D7%C7%1F%2C%0A%EC%07%8B%F0%C9%E6%D2%E2%C9%26%C0%A3UE%B8%B6h%91~%04%18%00%A5%DA%B2x%88g%CF!%00%00%00%00IEND%AEB%60%82' %></div>
|
7
8
|
<%- if flash[:executed_migrations].present? -%>
|
8
9
|
<div id="executed">
|
9
10
|
<h2>Successfully executed following <%= flash[:executed_migrations].values.flatten.count %> migrations!</h2>
|
@@ -38,12 +39,17 @@
|
|
38
39
|
<%= hidden_field_tag 'changes' %>
|
39
40
|
<%= submit_tag 'save changes' %>
|
40
41
|
<% end %>
|
41
|
-
<%= form_tag '/erd/migrate', :method => :put do %>
|
42
|
+
<%= form_tag '/erd/migrate', :method => :put, :id => 'migrate_form' do %>
|
43
|
+
<ul id="open_buttons">
|
44
|
+
<li><button id="open_up" type="button">up</button></li>
|
45
|
+
<li><button id="open_down" type="button">down</button></li>
|
46
|
+
<li><button id="close_all" type="button">close</button></li>
|
47
|
+
</ul>
|
42
48
|
<table id="migration_status">
|
43
49
|
<caption>migration status</caption>
|
44
50
|
<thead>
|
45
|
-
<tr><th>status</th><th>version</th><th>name</th></tr>
|
46
|
-
<tr><td colspan="3">
|
51
|
+
<tr><th class="status">status</th><th class="version">version</th><th class="name">name</th></tr>
|
52
|
+
<tr><td colspan="3" class="migrations">
|
47
53
|
<button>UNFOLD ALL</button>
|
48
54
|
<%= @migrations.count %> migrations in total (up: <%= @migrations.count {|m| m[:status] == 'up'} %>, down: <%= @migrations.count {|m| m[:status] == 'down'} %>)
|
49
55
|
</td></tr>
|
data/erd.gemspec
CHANGED
@@ -18,8 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_runtime_dependency 'rails-erd', ['>= 0.4.5']
|
19
19
|
gem.add_runtime_dependency 'nokogiri'
|
20
20
|
|
21
|
+
gem.add_development_dependency 'rails', '>= 3.2'
|
21
22
|
gem.add_development_dependency 'rspec-rails'
|
22
|
-
gem.add_development_dependency '
|
23
|
+
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'minitest'
|
25
|
+
gem.add_development_dependency 'capybara', '>= 2'
|
23
26
|
gem.add_development_dependency 'rr'
|
24
27
|
gem.add_development_dependency 'sqlite3'
|
25
28
|
end
|
data/lib/erd/railtie.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'erd/engine'
|
3
3
|
|
4
|
-
|
5
4
|
module Erd
|
6
5
|
autoload :Migrator, 'erd/migrator'
|
7
6
|
|
8
7
|
class Railtie < ::Rails::Railtie #:nodoc:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
mount Erd::Engine, :at => '/erd'
|
14
|
-
end
|
8
|
+
config.to_prepare do
|
9
|
+
if Rails.env.development?
|
10
|
+
Rails.application.routes.append do
|
11
|
+
mount Erd::Engine, :at => '/erd'
|
15
12
|
end
|
16
13
|
end
|
17
14
|
end
|
data/lib/erd/version.rb
CHANGED
data/spec/fake_app/fake_app.rb
CHANGED
@@ -12,11 +12,13 @@ module ErdApp
|
|
12
12
|
config.secret_token = 'fall to your knees and repent if you please'
|
13
13
|
config.session_store :cookie_store, :key => '_myapp_session'
|
14
14
|
config.active_support.deprecation = :log
|
15
|
+
config.eager_load = false
|
15
16
|
|
16
17
|
config.app_generators.orm :active_record, :migration => true, :timestamps => true
|
17
18
|
end
|
18
19
|
end
|
19
20
|
ErdApp::Application.initialize!
|
21
|
+
ErdApp::Application.routes.draw {}
|
20
22
|
|
21
23
|
# models
|
22
24
|
class Author < ActiveRecord::Base
|
File without changes
|
data/spec/lib/migrator_spec.rb
CHANGED
@@ -9,14 +9,14 @@ describe Erd::Migrator do
|
|
9
9
|
end
|
10
10
|
describe '.status' do
|
11
11
|
context 'when all migrations are up' do
|
12
|
-
its(:status) { should == [{:status => 'up', :version => '20120428022519', :name => 'create_authors'}, {:status => 'up', :version => '20120428022535', :name => 'create_books'}] }
|
12
|
+
its(:status) { should == [{:status => 'up', :version => '20120428022519', :name => 'create_authors', :filename => '20120428022519_create_authors.rb'}, {:status => 'up', :version => '20120428022535', :name => 'create_books', :filename => '20120428022535_create_books.rb'}] }
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when one is undone' do
|
16
16
|
before do
|
17
17
|
FileUtils.touch Rails.root.join('db/migrate/20999999999999_create_foobars.rb')
|
18
18
|
end
|
19
|
-
its(:status) { should == [{:status => 'up', :version => '20120428022519', :name => 'create_authors'}, {:status => 'up', :version => '20120428022535', :name => 'create_books'}, {:status => 'down', :version => '20999999999999', :name => 'create_foobars'}] }
|
19
|
+
its(:status) { should == [{:status => 'up', :version => '20120428022519', :name => 'create_authors', :filename => '20120428022519_create_authors.rb'}, {:status => 'up', :version => '20120428022535', :name => 'create_books', :filename => '20120428022535_create_books.rb'}, {:status => 'down', :version => '20999999999999', :name => 'create_foobars', :filename => '20999999999999_create_foobars.rb'}] }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|