ponytail 0.3.0 → 0.4.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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +11 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +191 -0
  6. data/README.md +6 -0
  7. data/Rakefile +10 -6
  8. data/app/assets/javascripts/ponytail/models/column.coffee +41 -0
  9. data/app/assets/javascripts/ponytail/models/command.coffee +5 -0
  10. data/app/assets/javascripts/ponytail/models/create_table_command.coffee +11 -0
  11. data/app/assets/javascripts/ponytail/models/drop_table_command.coffee +5 -0
  12. data/app/assets/javascripts/ponytail/models/migration_file.coffee +38 -0
  13. data/app/assets/javascripts/ponytail/models/rename_table_command.coffee +5 -0
  14. data/app/assets/javascripts/ponytail/models/table.coffee +42 -0
  15. data/app/assets/javascripts/ponytail/ponytail.coffee +5 -0
  16. data/app/assets/javascripts/ponytail/views/column.coffee +70 -0
  17. data/app/assets/javascripts/ponytail/views/index.coffee +29 -0
  18. data/app/assets/javascripts/ponytail/views/migration_file.coffee +25 -0
  19. data/app/assets/javascripts/ponytail/views/new.coffee +58 -0
  20. data/app/assets/javascripts/ponytail/views/table.coffee +56 -0
  21. data/app/assets/stylesheets/ponytail/_base.scss +38 -0
  22. data/app/assets/stylesheets/ponytail/_index.scss +68 -0
  23. data/app/assets/stylesheets/ponytail/_new.scss +133 -0
  24. data/app/assets/stylesheets/ponytail/application.scss +5 -0
  25. data/app/views/ponytail/migrations/index.html.erb +49 -9
  26. data/app/views/ponytail/migrations/new.html.erb +84 -13
  27. data/app/views/ponytail/{migrations/_column_view_template.html.erb → templates/_column.html.erb} +7 -5
  28. data/app/views/ponytail/templates/_table.html.erb +14 -0
  29. data/bin/rails +3 -0
  30. data/lib/ponytail/version.rb +1 -1
  31. data/lib/ponytail.rb +3 -0
  32. data/lib/rails/mapper.rb +2 -2
  33. data/ponytail.gemspec +4 -1
  34. data/spec/dummy/config/environments/production.rb +1 -1
  35. data/spec/dummy/config/initializers/ponytail_on_heroku.rb +21 -0
  36. data/spec/features/migrations/index_spec.rb +1 -0
  37. data/spec/javascripts/ponytail/models/command_spec.coffee +5 -0
  38. data/spec/javascripts/ponytail/models/create_command_spec.js +0 -1
  39. data/spec/javascripts/ponytail/models/migration_file_spec.js +1 -1
  40. data/spec/javascripts/support/boots/boot.coffee +16 -0
  41. data/spec/javascripts/support/coffee-script.js +12 -0
  42. data/spec/javascripts/support/jasmine.yml +6 -5
  43. data/spec/javascripts/support/jasmine_helper.rb +16 -0
  44. data/spec/javascripts/support/run.html.erb +22 -0
  45. data/spec/rails/mapper_spec.rb +1 -1
  46. metadata +79 -28
  47. data/app/assets/javascripts/ponytail/models/column.js +0 -43
  48. data/app/assets/javascripts/ponytail/models/command.js +0 -8
  49. data/app/assets/javascripts/ponytail/models/create_table_command.js +0 -16
  50. data/app/assets/javascripts/ponytail/models/drop_table_command.js +0 -8
  51. data/app/assets/javascripts/ponytail/models/migration_file.js +0 -40
  52. data/app/assets/javascripts/ponytail/models/rename_table_command.js +0 -9
  53. data/app/assets/javascripts/ponytail/models/table.js +0 -44
  54. data/app/assets/javascripts/ponytail/ponytail.js +0 -15
  55. data/app/assets/javascripts/ponytail/views/column.js +0 -36
  56. data/app/assets/javascripts/ponytail/views/migration_file.js +0 -24
  57. data/app/assets/javascripts/ponytail/views/new_migrations.js +0 -36
  58. data/app/assets/javascripts/ponytail/views/table.js +0 -61
  59. data/app/assets/stylesheets/ponytail/application.css +0 -126
  60. data/app/views/ponytail/migrations/_column.html.erb +0 -22
  61. data/app/views/ponytail/migrations/_migration.html.erb +0 -13
  62. data/app/views/ponytail/migrations/_migration_file.html.erb +0 -23
  63. data/app/views/ponytail/migrations/_new_errors.html.erb +0 -10
  64. data/app/views/ponytail/migrations/_notice.html.erb +0 -6
  65. data/app/views/ponytail/migrations/_table.html.erb +0 -18
  66. data/app/views/ponytail/migrations/_table_view_template.html.erb +0 -23
  67. data/spec/javascripts/ponytail/models/command_spec.js +0 -8
@@ -0,0 +1,38 @@
1
+ .horizontal-box {
2
+ @include display-box;
3
+ @include box-orient(horizontal);
4
+ }
5
+
6
+ .vertical-box {
7
+ @include display-box;
8
+ @include box-orient(vertical);
9
+ }
10
+
11
+ @keyframes highlight {
12
+ 0% { background-color: yellow; }
13
+ 100% { background-color: white; }
14
+ }
15
+
16
+ .header {
17
+ @include border-radius(5px);
18
+ border: 1px solid #000;
19
+ margin-bottom: 5px;
20
+ padding: 5px;
21
+
22
+ > * {
23
+ margin: 0 3px;
24
+ }
25
+ }
26
+
27
+ .notice {
28
+ @include display-box;
29
+ @include border-radius(5px);
30
+ margin: 5px 0;
31
+ padding: 5px;
32
+ background: limegreen;
33
+ color: white;
34
+
35
+ .message {
36
+ @include box-flex(1);
37
+ }
38
+ }
@@ -0,0 +1,68 @@
1
+ .index {
2
+ @extend .vertical-box;
3
+ width: 1024px;
4
+ height: 768px;
5
+
6
+ .container {
7
+ @extend .horizontal-box;
8
+
9
+ > div {
10
+ @include box-flex(1);
11
+ margin: 0 2px;
12
+ }
13
+
14
+ .migration_filepath {
15
+ margin: 2px 0;
16
+ }
17
+
18
+ .migration_files {
19
+ height: 500px;
20
+ overflow-y: auto;
21
+
22
+ table {
23
+ width: 100%;
24
+ }
25
+
26
+ .filename {
27
+ padding: 2px;
28
+ cursor: pointer;
29
+ &:hover {
30
+ background-color: cornsilk;
31
+ }
32
+ }
33
+
34
+ .raw_content {
35
+ display: none;
36
+ }
37
+ }
38
+
39
+ .migration_file {
40
+ .migration_filename {
41
+ margin: 2px 0;
42
+ padding: 2px;
43
+
44
+ &.highlight {
45
+ animation: highlight 1s 1;
46
+ }
47
+ }
48
+ .raw_content {
49
+ @include border-radius(5px);
50
+ background: whitesmoke;
51
+ margin-top: 2px;
52
+ padding: 5px;
53
+
54
+ pre {
55
+ margin: 5px 0;
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ .actions {
62
+ @extend .horizontal-box;
63
+
64
+ .migrate {
65
+ margin-left: 10px;
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,133 @@
1
+ .new {
2
+ @extend .vertical-box;
3
+ width: 1024px;
4
+ height: 768px;
5
+
6
+ .container {
7
+ @extend .horizontal-box;
8
+ margin-top: 5px;
9
+
10
+ > div {
11
+ margin: 0 2px;
12
+ }
13
+
14
+ .tables {
15
+ @extend .vertical-box;
16
+ @include box-flex(1);
17
+ @include border-radius(5px);
18
+ border: solid 1px #000;
19
+ height: 500px;
20
+ overflow-x: hidden;
21
+ overflow-y: auto;
22
+
23
+ .table {
24
+ @extend .vertical-box;
25
+ border-bottom: solid 1px #000;
26
+ padding: 3px;
27
+ .table_name {
28
+ @include box-flex(1);
29
+ input {
30
+ display: none;
31
+ }
32
+ }
33
+ .edit_table {
34
+ width: 40px;
35
+ }
36
+ .drop_table {
37
+ width: 40px;
38
+ }
39
+ .restore_table {
40
+ width: 60px;
41
+ display: none;
42
+ }
43
+ }
44
+
45
+ .new_table {
46
+ padding: 3px;
47
+ margin-top: 3px;
48
+ }
49
+
50
+ .columns {
51
+ margin: 3px 0 0 5px;
52
+ display: none;
53
+
54
+ .column {
55
+ @extend .horizontal-box;
56
+ padding: 2px;
57
+ width: 100%;
58
+ .column_type {
59
+ width: 100px;
60
+ cursor: pointer;
61
+ &:hover {
62
+ background-color: cornsilk;
63
+ }
64
+ select {
65
+ display: none;
66
+ }
67
+ }
68
+ .column_name {
69
+ @include box-flex(1);
70
+ cursor: pointer;
71
+ &:hover {
72
+ background-color: cornsilk;
73
+ }
74
+ input {
75
+ display: none;
76
+ }
77
+ }
78
+ .remove_column {
79
+ width: 60px;
80
+ }
81
+ .restore_column {
82
+ width: 60px;
83
+ display: none;
84
+ }
85
+ }
86
+
87
+ .add_column {
88
+ margin-top: 3px;
89
+ }
90
+ }
91
+
92
+ .table_name {
93
+ cursor: pointer;
94
+ &:hover {
95
+ background-color: cornsilk;
96
+ }
97
+ }
98
+
99
+ .column_name {
100
+ width: 100%;
101
+ }
102
+ }
103
+
104
+ .migration_file {
105
+ @extend .vertical-box;
106
+ width: 500px;
107
+
108
+ .migration_file_header {
109
+ @extend .horizontal-box;
110
+
111
+ .classname {
112
+ @include box-flex(1);
113
+ span {
114
+ display: none;
115
+ }
116
+ }
117
+ }
118
+
119
+ .raw_content {
120
+ @include box-flex(1);
121
+ margin-top: 3px;
122
+ textarea {
123
+ width: 100%;
124
+ height: 500px;
125
+ }
126
+ }
127
+
128
+ .actions {
129
+ margin-top: 3px;
130
+ }
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,5 @@
1
+ @import "compass";
2
+
3
+ @import "base";
4
+ @import "index";
5
+ @import "new";
@@ -1,17 +1,57 @@
1
- <div class="pt_index">
2
- <%= render 'notice' %>
1
+ <div class="index">
2
+ <div class="header">
3
+ <span>index</span>
4
+ <span>|</span>
5
+ <a href="/rails/migrations/new">new</a>
6
+ </div>
3
7
 
4
- <% @migrations.each do |migration| %>
5
- <%= render 'migration', migration: migration, current: @current_version %>
8
+ <% if notice %>
9
+ <div class="notice">
10
+ <div class="message"><%= notice %></div>
11
+ <div class="close"><a href="#">x</a></div>
12
+ </div>
6
13
  <% end %>
7
14
 
8
- <div class="pt_actions">
9
- <%= button_to 'New', new_migration_path, method: :get, disabled: Ponytail::Migration.check_pending? %>
10
- <%= button_to 'Migrate', migrate_migrations_path, disabled: Ponytail::Migration.check_pending? %>
11
- <%= button_to 'Rollback', rollback_migrations_path, disabled: Ponytail::Migration.check_pending? %>
15
+ <div class="container">
16
+ <div>
17
+ <!-- TODO: fake it! -->
18
+ <% path = 'db/migrate/' %>
19
+ <div class="migration_filepath"><%= path %></div>
20
+ <div class="migration_files">
21
+ <table>
22
+ <% @migrations.each do |migration| %>
23
+ <tr>
24
+ <td><%= migration.version == @current_version ? "*" : "" %></td>
25
+ <!-- TODO: fake it!(sub) -->
26
+ <td class="filename"><%= migration.filename.sub(path, "") %></td>
27
+ <td class="raw_content"><%= migration.raw_content %></td>
28
+ </tr>
29
+ <% end %>
30
+ </table>
31
+ </div>
32
+ </div>
33
+
34
+ <div class="migration_file">
35
+ <% migration = @migrations[0] %>
36
+ <!-- TODO: fake it!(sub) -->
37
+ <div class="migration_filename"><%= migration.filename.sub(path, "") %></div>
38
+ <div class="raw_content">
39
+ <pre><%= migration.raw_content %></pre>
40
+ </div>
41
+ </div>
42
+ </div>
43
+
44
+ <div class="actions">
45
+ <div>
46
+ <button class="new_button">New</button>
47
+ </div>
48
+ <div class="migrate">
49
+ <button class="migrate_button" <%= Ponytail::Migration.check_pending? ? 'disabled="disabled"' : '' %>>Migrate</button>
50
+ <button class="rollback_button" <%= Ponytail::Migration.check_pending? ? 'disabled="disabled"' : '' %>>Rollback</button>
51
+ </div>
12
52
  </div>
13
53
  </div>
14
54
 
15
55
  <script type='text/javascript'>
16
- setupIndex();
56
+ new Ponytail.Views.Index({el: $(".index")}).render();
17
57
  </script>
@@ -1,22 +1,93 @@
1
- <%= render 'table_view_template' %>
2
- <%= render 'column_view_template' %>
1
+ <%= render 'ponytail/templates/table' %>
2
+ <%= render 'ponytail/templates/column' %>
3
3
 
4
- <div class="pt_new">
5
- <div class="pt_schema">
6
- <% @schema.tables.each do |t| %>
7
- <%= render 'table', table: t %>
8
- <% end %>
4
+ <div class="new">
5
+ <div class="header">
6
+ <a href="/rails/migrations">index</a>
7
+ <span>|</span>
8
+ <span>new</span>
9
+ </div>
9
10
 
10
- <div class="pt_new_table">
11
- <a href="#">New Table</a>
11
+ <% notice = @migration.errors.full_messages if @migration.errors.any? %>
12
+ <% if notice %>
13
+ <div class="notice">
14
+ <div class="message"><%= notice %></div>
15
+ <div class="close"><a href="#">x</a></div>
16
+ </div>
17
+ <% end %>
18
+
19
+ <div class="container">
20
+ <div class="tables">
21
+ <% @schema.tables.each do |table| %>
22
+ <div class="table">
23
+ <div class="horizontal-box">
24
+ <div class="table_name">
25
+ <span><%= table.name %></span>
26
+ <input type="text" value="<%= table.name %>" />
27
+ </div>
28
+ <div class="edit_table"><a href="#">edit</a></div>
29
+ <div class="drop_table"><a href="#">drop</a></div>
30
+ <div class="restore_table"><a href="#">restore</a></div>
31
+ </div>
32
+ <div class="columns">
33
+ <% table.columns.each do |column| %>
34
+ <div class="column">
35
+ <div class="column_type">
36
+ <span><%= column.type %></span>
37
+ <select>
38
+ <option value="string">string</option>
39
+ <option value="text">text</option>
40
+ <option value="integer">integer</option>
41
+ <option value="float">float</option>
42
+ <option value="decimal">decimal</option>
43
+ <option value="datetime">datetime</option>
44
+ <option value="timestamp">timestamp</option>
45
+ <option value="time">time</option>
46
+ <option value="date">date</option>
47
+ <option value="binary">binary</option>
48
+ <option value="boolean">boolean</option>
49
+ </select>
50
+ </div>
51
+ <div class="column_name">
52
+ <span><%= column.name %></span>
53
+ <input type="text" value="<%= column.name %>" />
54
+ </div>
55
+ <div class="remove_column"><a href="#">remove</a></div>
56
+ <div class="restore_column"><a href="#">restore</a></div>
57
+ </div>
58
+ <% end %>
59
+ <div class="add_column"><a href="#">Add Column</a></div>
60
+ </div>
61
+ </div>
62
+ <% end %>
63
+ <div class="new_table"><a href="#">New Table</a></div>
12
64
  </div>
13
- </div>
14
65
 
15
- <div class="migration_file_view">
16
- <%= render 'migration_file', migration: @migration %>
66
+ <%= form_for @migration, url: migrations_path do |f| %>
67
+ <div class="migration_file">
68
+ <div class="migration_file_header">
69
+ <div class="classname">
70
+ <input type="text" name="ponytail_migration[name]" value="NewMigration" />
71
+ </div>
72
+
73
+ <div class="edit_checkbox">
74
+ <input type="checkbox" />
75
+ <span>edit</span>
76
+ </div>
77
+ </div>
78
+
79
+ <div class="raw_content">
80
+ <textarea name="ponytail_migration[raw_content]" disabled="disabled"></textarea>
81
+ </div>
82
+
83
+ <div class="actions">
84
+ <button class="create_button" <%= Ponytail::Migration.check_pending? ? 'disabled="disabled"' : '' %>>Create File</button>
85
+ </div>
86
+ </div>
87
+ <% end %>
17
88
  </div>
18
89
  </div>
19
90
 
20
91
  <script type='text/javascript'>
21
- new Ponytail.Views.NewMigrationView({el: $(".pt_new")});
92
+ new Ponytail.Views.New({el: $(".new")}).render();
22
93
  </script>
@@ -1,6 +1,6 @@
1
- <script type="text/template" id="column_view_template">
2
- <div class="pt_column_type">
3
- <span style="display: none;"><%%= type %></span>
1
+ <script type="text/template" id="column_template">
2
+ <div class="column_type">
3
+ <span><%%= type %></span>
4
4
  <select>
5
5
  <option value="string">string</option>
6
6
  <option value="text">text</option>
@@ -15,8 +15,10 @@
15
15
  <option value="boolean">boolean</option>
16
16
  </select>
17
17
  </div>
18
- <div class="pt_column_name">
19
- <span style="display: none;"><%%= name %></span>
18
+ <div class="column_name">
19
+ <span><%%= name %></span>
20
20
  <input type="text" value="<%%= name %>" />
21
21
  </div>
22
+ <div class="remove_column"><a href="#">remove</a></div>
23
+ <div class="restore_column"><a href="#">restore</a></div>
22
24
  </script>
@@ -0,0 +1,14 @@
1
+ <script type="text/template" id="table_template">
2
+ <div class="horizontal-box">
3
+ <div class="table_name">
4
+ <span><%%= name %></span>
5
+ <input type="text" value="<%%= name %>" />
6
+ </div>
7
+ <div class="edit_table"><a href="#">edit</a></div>
8
+ <div class="drop_table"><a href="#">drop</a></div>
9
+ <div class="restore_table"><a href="#">restore</a></div>
10
+ </div>
11
+ <div class="columns">
12
+ <div class="add_column"><a href="#">Add Column</a></div>
13
+ </div>
14
+ </script>
data/bin/rails ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ spec/dummy/bin/rails $@
@@ -1,3 +1,3 @@
1
1
  module Ponytail
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/ponytail.rb CHANGED
@@ -2,3 +2,6 @@ require 'ponytail/engine'
2
2
  require 'ponytail/migration'
3
3
  require 'ponytail/schema'
4
4
  require 'rails/mapper'
5
+
6
+ require 'sass-rails'
7
+ require 'compass-rails'
data/lib/rails/mapper.rb CHANGED
@@ -3,8 +3,8 @@ module ActionDispatch::Routing
3
3
  def mount_ponytail
4
4
  resources :migrations, only: [:index, :new, :create, :destroy], module: :ponytail, path: 'rails/migrations' do
5
5
  collection do
6
- post :migrate
7
- post :rollback
6
+ get :migrate
7
+ get :rollback
8
8
  end
9
9
  end
10
10
  end
data/ponytail.gemspec CHANGED
@@ -18,7 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'rails', '~> 4.0'
21
+ spec.add_dependency 'rails', '~> 4.0.0'
22
+ spec.add_dependency 'coffee-rails', '~> 4.0.0'
23
+ spec.add_dependency 'sass-rails', '~> 4.0.0'
24
+ spec.add_dependency 'compass-rails'
22
25
 
23
26
  spec.add_development_dependency "bundler", "~> 1.3"
24
27
  spec.add_development_dependency "rake"
@@ -27,7 +27,7 @@ Dummy::Application.configure do
27
27
  # config.assets.css_compressor = :sass
28
28
 
29
29
  # Do not fallback to assets pipeline if a precompiled asset is missed.
30
- config.assets.compile = false
30
+ # config.assets.compile = false
31
31
 
32
32
  # Generate digests for assets URLs.
33
33
  config.assets.digest = true
@@ -0,0 +1,21 @@
1
+ if Rails.env.production?
2
+ module Ponytail
3
+ class Migration
4
+ def self.migrate
5
+ false
6
+ end
7
+
8
+ def self.rollback
9
+ false
10
+ end
11
+
12
+ def save
13
+ valid?
14
+ end
15
+
16
+ def destroy
17
+ false
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe "/migrations" do
4
4
  it "title is 'Migrations'" do
5
+ pending
5
6
  visit '/rails/migrations'
6
7
  expect(page).to have_title 'Migrations'
7
8
  end
@@ -0,0 +1,5 @@
1
+ describe 'Command', ->
2
+ describe '#toString', ->
3
+ it 'it should be able to get string', ->
4
+ command = new Ponytail.Models.Command("rename_table", ":users", ":new_users")
5
+ expect(command.toString()).toBe("rename_table :users, :new_users")
@@ -2,7 +2,6 @@ describe("CreateTableCommand", function() {
2
2
  describe("#toString", function() {
3
3
  it("it should be able to get string", function() {
4
4
  var column = buildModel({type: 'string', name: 'name'});
5
- console.log(column.get("type"));
6
5
  var command = new Ponytail.Models.CreateTableCommand('users', [column]);
7
6
  var expected = [
8
7
  "create_table :users do |t|",
@@ -4,7 +4,7 @@ describe("MigrationFile", function() {
4
4
  var mFile = new Ponytail.Models.MigrationFile({className: "CreateUsers"});
5
5
  spyOn(mFile, "getContentOfClass").andReturn("");
6
6
  var expected = [
7
- "class CreateUsers < ActiveRecord::MigrationFile",
7
+ "class CreateUsers < ActiveRecord::Migration",
8
8
  "",
9
9
  "end",
10
10
  ].join("\n");
@@ -0,0 +1,16 @@
1
+ jsApiReporter = undefined
2
+ do ->
3
+ jasmineEnv = jasmine.getEnv()
4
+
5
+ jsApiReporter = new jasmine.JsApiReporter()
6
+ htmlReporter = new jasmine.HtmlReporter()
7
+
8
+ jasmineEnv.addReporter jsApiReporter
9
+ jasmineEnv.addReporter htmlReporter
10
+
11
+ jasmineEnv.specFilter = (spec) ->
12
+ htmlReporter.specFilter spec
13
+
14
+ jasmineEnv.execute()
15
+
16
+ @jsApiReporter = jsApiReporter