ponytail 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -3
  3. data/README.md +2 -2
  4. data/app/assets/javascripts/ponytail/application.js +1 -0
  5. data/app/assets/javascripts/ponytail/models/schema.coffee +2 -0
  6. data/app/assets/javascripts/ponytail/views/column.coffee +3 -1
  7. data/app/assets/javascripts/ponytail/views/migrations/migrations_index.coffee +66 -0
  8. data/app/assets/javascripts/ponytail/views/migrations/migrations_new.coffee +53 -0
  9. data/app/assets/javascripts/ponytail/views/preview_create_file.coffee +37 -0
  10. data/app/assets/javascripts/ponytail/views/table.coffee +11 -1
  11. data/app/assets/stylesheets/ponytail/_base.scss +23 -1
  12. data/app/assets/stylesheets/ponytail/_index.scss +8 -8
  13. data/app/assets/stylesheets/ponytail/_new.scss +7 -4
  14. data/app/assets/stylesheets/ponytail/application.scss +3 -0
  15. data/app/controllers/ponytail/migrations_controller.rb +11 -27
  16. data/app/controllers/ponytail/schemas_controller.rb +27 -0
  17. data/app/views/ponytail/migrations/index.html.erb +26 -15
  18. data/app/views/ponytail/migrations/new.html.erb +18 -61
  19. data/lib/ponytail/migration.rb +27 -7
  20. data/lib/ponytail/routing/mapper.rb +10 -0
  21. data/lib/ponytail/schema.rb +24 -14
  22. data/lib/ponytail/version.rb +1 -1
  23. data/lib/ponytail.rb +1 -1
  24. data/spec/controllers/ponytail/migrations_controller_spec.rb +65 -0
  25. data/spec/controllers/ponytail/schemas_controller_spec.rb +40 -0
  26. data/spec/dummy/app/controllers/top_controller.rb +5 -0
  27. data/spec/dummy/config/initializers/ponytail_on_heroku.rb +6 -8
  28. data/spec/dummy/config/routes.rb +1 -0
  29. data/spec/javascripts/helpers/build_model.coffee +7 -0
  30. data/spec/javascripts/ponytail/models/column_spec.coffee +1 -0
  31. data/spec/javascripts/ponytail/models/create_command_spec.coffee +12 -0
  32. data/spec/javascripts/ponytail/models/migration_file_spec.coffee +13 -0
  33. data/spec/javascripts/ponytail/models/table_spec.coffee +18 -0
  34. data/spec/{ponytail → lib/ponytail}/migration_spec.rb +0 -18
  35. data/spec/lib/ponytail/schema_spec.rb +16 -0
  36. data/spec/{ponytail_spec.rb → lib/ponytail/version_spec.rb} +0 -0
  37. data/spec/routing/migrations_routing_spec.rb +19 -0
  38. data/spec/routing/schemas_routing_spec.rb +11 -0
  39. data/vendor/assets/javascripts/highlight.pack.js +1 -0
  40. data/vendor/assets/stylesheets/github.css +130 -0
  41. metadata +36 -28
  42. data/app/assets/javascripts/ponytail/views/index.coffee +0 -29
  43. data/app/assets/javascripts/ponytail/views/migration_file.coffee +0 -25
  44. data/app/assets/javascripts/ponytail/views/new.coffee +0 -58
  45. data/lib/rails/mapper.rb +0 -12
  46. data/spec/controllers/migrations_controller_spec.rb +0 -92
  47. data/spec/javascripts/helpers/.keep +0 -0
  48. data/spec/javascripts/helpers/build_model.js +0 -11
  49. data/spec/javascripts/ponytail/models/column_spec.js +0 -2
  50. data/spec/javascripts/ponytail/models/create_command_spec.js +0 -15
  51. data/spec/javascripts/ponytail/models/migration_file_spec.js +0 -16
  52. data/spec/javascripts/ponytail/models/table_spec.js +0 -24
  53. data/spec/ponytail/schema_spec.rb +0 -23
  54. data/spec/rails/mapper_spec.rb +0 -17
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ponytail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinsoku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-28 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -189,19 +189,21 @@ files:
189
189
  - app/assets/javascripts/ponytail/models/drop_table_command.coffee
190
190
  - app/assets/javascripts/ponytail/models/migration_file.coffee
191
191
  - app/assets/javascripts/ponytail/models/rename_table_command.coffee
192
+ - app/assets/javascripts/ponytail/models/schema.coffee
192
193
  - app/assets/javascripts/ponytail/models/table.coffee
193
194
  - app/assets/javascripts/ponytail/ponytail.coffee
194
195
  - app/assets/javascripts/ponytail/routers/.keep
195
196
  - app/assets/javascripts/ponytail/views/column.coffee
196
- - app/assets/javascripts/ponytail/views/index.coffee
197
- - app/assets/javascripts/ponytail/views/migration_file.coffee
198
- - app/assets/javascripts/ponytail/views/new.coffee
197
+ - app/assets/javascripts/ponytail/views/migrations/migrations_index.coffee
198
+ - app/assets/javascripts/ponytail/views/migrations/migrations_new.coffee
199
+ - app/assets/javascripts/ponytail/views/preview_create_file.coffee
199
200
  - app/assets/javascripts/ponytail/views/table.coffee
200
201
  - app/assets/stylesheets/ponytail/_base.scss
201
202
  - app/assets/stylesheets/ponytail/_index.scss
202
203
  - app/assets/stylesheets/ponytail/_new.scss
203
204
  - app/assets/stylesheets/ponytail/application.scss
204
205
  - app/controllers/ponytail/migrations_controller.rb
206
+ - app/controllers/ponytail/schemas_controller.rb
205
207
  - app/views/layouts/ponytail/application.html.erb
206
208
  - app/views/ponytail/migrations/index.html.erb
207
209
  - app/views/ponytail/migrations/new.html.erb
@@ -212,11 +214,12 @@ files:
212
214
  - lib/ponytail.rb
213
215
  - lib/ponytail/engine.rb
214
216
  - lib/ponytail/migration.rb
217
+ - lib/ponytail/routing/mapper.rb
215
218
  - lib/ponytail/schema.rb
216
219
  - lib/ponytail/version.rb
217
- - lib/rails/mapper.rb
218
220
  - ponytail.gemspec
219
- - spec/controllers/migrations_controller_spec.rb
221
+ - spec/controllers/ponytail/migrations_controller_spec.rb
222
+ - spec/controllers/ponytail/schemas_controller_spec.rb
220
223
  - spec/dummy/README.rdoc
221
224
  - spec/dummy/Rakefile
222
225
  - spec/dummy/app/assets/images/.keep
@@ -224,6 +227,7 @@ files:
224
227
  - spec/dummy/app/assets/stylesheets/application.css
225
228
  - spec/dummy/app/controllers/application_controller.rb
226
229
  - spec/dummy/app/controllers/concerns/.keep
230
+ - spec/dummy/app/controllers/top_controller.rb
227
231
  - spec/dummy/app/helpers/application_helper.rb
228
232
  - spec/dummy/app/mailers/.keep
229
233
  - spec/dummy/app/models/.keep
@@ -260,27 +264,29 @@ files:
260
264
  - spec/dummy/public/500.html
261
265
  - spec/dummy/public/favicon.ico
262
266
  - spec/features/migrations/index_spec.rb
263
- - spec/javascripts/helpers/.keep
264
- - spec/javascripts/helpers/build_model.js
265
- - spec/javascripts/ponytail/models/column_spec.js
267
+ - spec/javascripts/helpers/build_model.coffee
268
+ - spec/javascripts/ponytail/models/column_spec.coffee
266
269
  - spec/javascripts/ponytail/models/command_spec.coffee
267
- - spec/javascripts/ponytail/models/create_command_spec.js
268
- - spec/javascripts/ponytail/models/migration_file_spec.js
269
- - spec/javascripts/ponytail/models/table_spec.js
270
+ - spec/javascripts/ponytail/models/create_command_spec.coffee
271
+ - spec/javascripts/ponytail/models/migration_file_spec.coffee
272
+ - spec/javascripts/ponytail/models/table_spec.coffee
270
273
  - spec/javascripts/support/boots/boot.coffee
271
274
  - spec/javascripts/support/coffee-script.js
272
275
  - spec/javascripts/support/jasmine.yml
273
276
  - spec/javascripts/support/jasmine_helper.rb
274
277
  - spec/javascripts/support/run.html.erb
275
- - spec/ponytail/migration_spec.rb
276
- - spec/ponytail/schema_spec.rb
277
- - spec/ponytail_spec.rb
278
- - spec/rails/mapper_spec.rb
278
+ - spec/lib/ponytail/migration_spec.rb
279
+ - spec/lib/ponytail/schema_spec.rb
280
+ - spec/lib/ponytail/version_spec.rb
281
+ - spec/routing/migrations_routing_spec.rb
282
+ - spec/routing/schemas_routing_spec.rb
279
283
  - spec/spec_helper.rb
280
284
  - vendor/assets/javascripts/backbone-min.js
285
+ - vendor/assets/javascripts/highlight.pack.js
281
286
  - vendor/assets/javascripts/jquery.min.js
282
287
  - vendor/assets/javascripts/jquery_ujs.js
283
288
  - vendor/assets/javascripts/underscore-min.js
289
+ - vendor/assets/stylesheets/github.css
284
290
  homepage: https://github.com/sinsoku/ponytail
285
291
  licenses:
286
292
  - MIT
@@ -306,7 +312,8 @@ signing_key:
306
312
  specification_version: 4
307
313
  summary: Ponytail is a Rails engine that shows the migrations.
308
314
  test_files:
309
- - spec/controllers/migrations_controller_spec.rb
315
+ - spec/controllers/ponytail/migrations_controller_spec.rb
316
+ - spec/controllers/ponytail/schemas_controller_spec.rb
310
317
  - spec/dummy/README.rdoc
311
318
  - spec/dummy/Rakefile
312
319
  - spec/dummy/app/assets/images/.keep
@@ -314,6 +321,7 @@ test_files:
314
321
  - spec/dummy/app/assets/stylesheets/application.css
315
322
  - spec/dummy/app/controllers/application_controller.rb
316
323
  - spec/dummy/app/controllers/concerns/.keep
324
+ - spec/dummy/app/controllers/top_controller.rb
317
325
  - spec/dummy/app/helpers/application_helper.rb
318
326
  - spec/dummy/app/mailers/.keep
319
327
  - spec/dummy/app/models/.keep
@@ -350,20 +358,20 @@ test_files:
350
358
  - spec/dummy/public/500.html
351
359
  - spec/dummy/public/favicon.ico
352
360
  - spec/features/migrations/index_spec.rb
353
- - spec/javascripts/helpers/.keep
354
- - spec/javascripts/helpers/build_model.js
355
- - spec/javascripts/ponytail/models/column_spec.js
361
+ - spec/javascripts/helpers/build_model.coffee
362
+ - spec/javascripts/ponytail/models/column_spec.coffee
356
363
  - spec/javascripts/ponytail/models/command_spec.coffee
357
- - spec/javascripts/ponytail/models/create_command_spec.js
358
- - spec/javascripts/ponytail/models/migration_file_spec.js
359
- - spec/javascripts/ponytail/models/table_spec.js
364
+ - spec/javascripts/ponytail/models/create_command_spec.coffee
365
+ - spec/javascripts/ponytail/models/migration_file_spec.coffee
366
+ - spec/javascripts/ponytail/models/table_spec.coffee
360
367
  - spec/javascripts/support/boots/boot.coffee
361
368
  - spec/javascripts/support/coffee-script.js
362
369
  - spec/javascripts/support/jasmine.yml
363
370
  - spec/javascripts/support/jasmine_helper.rb
364
371
  - spec/javascripts/support/run.html.erb
365
- - spec/ponytail/migration_spec.rb
366
- - spec/ponytail/schema_spec.rb
367
- - spec/ponytail_spec.rb
368
- - spec/rails/mapper_spec.rb
372
+ - spec/lib/ponytail/migration_spec.rb
373
+ - spec/lib/ponytail/schema_spec.rb
374
+ - spec/lib/ponytail/version_spec.rb
375
+ - spec/routing/migrations_routing_spec.rb
376
+ - spec/routing/schemas_routing_spec.rb
369
377
  - spec/spec_helper.rb
@@ -1,29 +0,0 @@
1
- class Ponytail.Views.Index extends Backbone.View
2
- events:
3
- "click .close a": "closeNotice"
4
- "click .migration_files .filename": "clickFileName"
5
- "click .new_button": "clickNewButton"
6
- "click .migrate_button": "clickMigrateButton"
7
- "click .rollback_button": "clickRollbackButton"
8
-
9
- closeNotice: ->
10
- $(".notice").hide()
11
- false
12
-
13
- clickFileName: (e) ->
14
- @$(".migration_file .migration_filename").text(e.target.innerHTML)
15
- @$(".migration_file .migration_filename").removeClass("highlight")
16
- setTimeout( ->
17
- @$(".migration_file .migration_filename").addClass("highlight")
18
- , 100)
19
- raw_content = $(e.target).parent().find(".raw_content").text()
20
- @$(".migration_file .raw_content pre").text(raw_content)
21
-
22
- clickNewButton: ->
23
- window.location.href = "migrations/new"
24
-
25
- clickMigrateButton: ->
26
- window.location.href = "migrations/migrate"
27
-
28
- clickRollbackButton: ->
29
- window.location.href = "migrations/rollback"
@@ -1,25 +0,0 @@
1
- class Ponytail.Views.MigrationFile extends Backbone.View
2
- events:
3
- "click .edit_checkbox input": "clickEditCheckbox"
4
- "keyup .classname input": (e) ->
5
- @model.set({className: e.target.value})
6
- "click .create_button": "clickCreateButton"
7
-
8
- initialize: ->
9
- @model.bind("change", @render)
10
-
11
- render: =>
12
- @$(".raw_content textarea").text(@model.get("rawContent"))
13
-
14
- clickEditCheckbox: ->
15
- disabled = @$(".raw_content textarea").is(":disabled")
16
- @.setRawContentEnabled(disabled)
17
-
18
- setRawContentEnabled: (enabled) ->
19
- if enabled
20
- @$(".raw_content textarea").removeAttr("disabled")
21
- else
22
- @$(".raw_content textarea").attr("disabled", "disabled")
23
-
24
- clickCreateButton: ->
25
- @.setRawContentEnabled(true)
@@ -1,58 +0,0 @@
1
- class Ponytail.Views.New extends Backbone.View
2
- events:
3
- "click .close a": "closeNotice"
4
- "click .table_name": "clickTableName"
5
- "click .new_table a": "clickNewTable"
6
-
7
- initialize: ->
8
- @tables = []
9
-
10
- render: =>
11
- for el in @$(".table")
12
- name = $(el).find('.table_name span').text()
13
- table = new Ponytail.Models.Table({name: name})
14
- new Ponytail.Views.Table({el: el, model: table})
15
- columns = []
16
- for el2 in $(el).find(".column")
17
- column_type = $(el2).find(".column_type span").text()
18
- column_name = $(el2).find(".column_name span").text()
19
- column = new Ponytail.Models.Column({table: table, type: column_type, name: column_name})
20
- new Ponytail.Views.Column({el: el2, model: column})
21
- columns.push(column)
22
- table.set({columns: columns}, {silent: true})
23
- @tables.push(table)
24
-
25
- class_name = @$(".classname input")[0].value
26
- @migrationFile = new Ponytail.Models.MigrationFile({className: class_name})
27
- new Ponytail.Views.MigrationFile({el: @$(".migration_file"), model: @migrationFile})
28
- @migrationFile.update()
29
-
30
- for table in @tables
31
- table.bind("change", =>
32
- @migrationFile.updateByTables(@tables)
33
- )
34
- @
35
-
36
- closeNotice: ->
37
- $(".notice").hide()
38
- false
39
-
40
- clickTableName: (e) ->
41
- tableElem = $(e.target).parent().parent()
42
- columnsElem = tableElem.find(".columns")
43
- if columnsElem.is(':visible')
44
- columnsElem.slideUp()
45
- else
46
- columnsElem.slideDown()
47
-
48
- clickNewTable: ->
49
- table = new Ponytail.Models.Table({isCreated: true})
50
- @tables.push(table)
51
- table.bind("change", =>
52
- @migrationFile.updateByTables(@tables)
53
- )
54
- table.trigger("change")
55
-
56
- view = new Ponytail.Views.Table({model: table})
57
- @$(".new_table").before(view.render().el)
58
- false
data/lib/rails/mapper.rb DELETED
@@ -1,12 +0,0 @@
1
- module ActionDispatch::Routing
2
- class Mapper
3
- def mount_ponytail
4
- resources :migrations, only: [:index, :new, :create, :destroy], module: :ponytail, path: 'rails/migrations' do
5
- collection do
6
- get :migrate
7
- get :rollback
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Ponytail
4
- describe MigrationsController do
5
- # let(:controller) { MigrationsController.new }
6
-
7
- describe "#index" do
8
- before do
9
- Migration.stub(:all)
10
- Migration.stub(:current_version)
11
- controller.index
12
- end
13
- it { expect(controller).to be_instance_variable_defined(:@migrations) }
14
- it { expect(controller).to be_instance_variable_defined(:@current_version) }
15
- end
16
-
17
- describe "#new" do
18
- before do
19
- Migration.stub(:new)
20
- controller.new
21
- end
22
- it { expect(controller).to be_instance_variable_defined(:@migration) }
23
- end
24
-
25
- describe "#create" do
26
- context "save was succeed." do
27
- before do
28
- @migration = Migration.new
29
- @migration.stub(save: true)
30
- Migration.stub(new: @migration)
31
- controller.stub(migraion_params: {})
32
- controller.should_receive(:redirect_to).with(:migrations, notice: 'Migration was successfully created.')
33
- controller.create
34
- end
35
- it "redirect to migrations, and notice" do end
36
- it { expect(controller).to be_instance_variable_defined(:@migration) }
37
- end
38
- context "save was failed." do
39
- before do
40
- @migration = Migration.new
41
- @migration.stub(save: false)
42
- Migration.stub(new: @migration)
43
- controller.stub(migraion_params: {})
44
- controller.should_receive(:render).with(action: :new)
45
- controller.create
46
- end
47
- it "redirect to migrations, and notice" do end
48
- it { expect(controller).to be_instance_variable_defined(:@migration) }
49
- end
50
- end
51
-
52
- describe "#migrate" do
53
- context "migrate was succeed." do
54
- before do
55
- Migration.stub(migrate: true)
56
- controller.should_receive(:redirect_to).with(:migrations, notice: 'Migrate was succeed.')
57
- controller.migrate
58
- end
59
- it "redirect to migrations, and notice" do end
60
- end
61
-
62
- context "migrate was failed." do
63
- before do
64
- Migration.stub(migrate: false)
65
- controller.should_receive(:redirect_to).with(:migrations, notice: 'Migrate was failed.')
66
- controller.migrate
67
- end
68
- it "redirect to migrations, and notice" do end
69
- end
70
- end
71
-
72
- describe "#rollback" do
73
- context "rollback was succeed." do
74
- before do
75
- Migration.stub(rollback: true)
76
- controller.should_receive(:redirect_to).with(:migrations, notice: 'Rollback was succeed.')
77
- controller.rollback
78
- end
79
- it "redirect to migrations, and notice" do end
80
- end
81
-
82
- context "rollback was failed." do
83
- before do
84
- Migration.stub(rollback: false)
85
- controller.should_receive(:redirect_to).with(:migrations, notice: 'Rollback was failed.')
86
- controller.rollback
87
- end
88
- it "redirect to migrations, and notice" do end
89
- end
90
- end
91
- end
92
- end
File without changes
@@ -1,11 +0,0 @@
1
- function buildModel(attrs) {
2
- var Model = function(obj) {
3
- this.obj = obj;
4
- };
5
- Model.prototype = {
6
- get: function(k) {
7
- return this.obj[k];
8
- }
9
- };
10
- return new Model(attrs);
11
- }
@@ -1,2 +0,0 @@
1
- describe("Column", function() {
2
- });
@@ -1,15 +0,0 @@
1
- describe("CreateTableCommand", function() {
2
- describe("#toString", function() {
3
- it("it should be able to get string", function() {
4
- var column = buildModel({type: 'string', name: 'name'});
5
- var command = new Ponytail.Models.CreateTableCommand('users', [column]);
6
- var expected = [
7
- "create_table :users do |t|",
8
- " t.string :name",
9
- " t.timestamps",
10
- "end",
11
- ].join("\n");
12
- expect(command.toString()).toBe(expected);
13
- });
14
- });
15
- });
@@ -1,16 +0,0 @@
1
- describe("MigrationFile", function() {
2
- describe("#update", function() {
3
- it("should be able to set rawContent", function() {
4
- var mFile = new Ponytail.Models.MigrationFile({className: "CreateUsers"});
5
- spyOn(mFile, "getContentOfClass").andReturn("");
6
- var expected = [
7
- "class CreateUsers < ActiveRecord::Migration",
8
- "",
9
- "end",
10
- ].join("\n");
11
- mFile.update();
12
- var actual = mFile.get("rawContent");
13
- expect(actual).toBe(expected);
14
- });
15
- });
16
- });
@@ -1,24 +0,0 @@
1
- describe("Table", function() {
2
- describe("#getCommands", function() {
3
- describe("if table was created", function() {
4
- it("should be a kind of CreateTableCommand ", function() {
5
- var table = new Ponytail.Models.Table({isCreated: true});
6
- var command = table.getCommands()[0];
7
- expect(command).toEqual(jasmine.any(Ponytail.Models.CreateTableCommand));
8
- });
9
- });
10
- describe("if table was dropped", function() {
11
- it("should be a kind of DropTableCommand ", function() {
12
- var table = new Ponytail.Models.Table({isDrop: true});
13
- var command = table.getCommands()[0];
14
- expect(command).toEqual(jasmine.any(Ponytail.Models.DropTableCommand));
15
- });
16
- });
17
- describe("if table was created, and was dropped", function() {
18
- it("should be []", function() {
19
- var table = new Ponytail.Models.Table({isCreated: true, isDrop: true});
20
- expect(table.getCommands()).toEqual([]);
21
- });
22
- });
23
- });
24
- });
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Ponytail
4
- describe Schema do
5
- let(:schema) { Schema.new }
6
- let(:table_names) { [:users, :books] }
7
- before do
8
- ActiveRecord::Base.stub_chain(:connection, :tables).and_return(table_names)
9
- end
10
- it { expect(schema.tables).to include(Table.new(:users)) }
11
- end
12
-
13
- describe Table do
14
- describe "#columns" do
15
- let(:table) { Table.new }
16
- let(:expected_columns) { [] }
17
- before do
18
- ActiveRecord::Base.stub_chain(:connection, :columns).and_return(expected_columns)
19
- end
20
- it { expect(table.columns).to eq expected_columns }
21
- end
22
- end
23
- end
@@ -1,17 +0,0 @@
1
- module ActionDispatch::Routing
2
- describe Mapper do
3
- describe "#mount_ponytail" do
4
- let(:mapper) do
5
- dummy = Class.new { def resources_path_names; end }
6
- Mapper.new(dummy.new)
7
- end
8
-
9
- it "should receive resources" do
10
- mapper.should_receive(:resources) { |*args, &block| block.call }
11
- mapper.should_receive(:collection) { |*args, &block| block.call }
12
- mapper.should_receive(:get).twice
13
- mapper.mount_ponytail
14
- end
15
- end
16
- end
17
- end