ponytail 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +8 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/ponytail/application.js +9 -0
- data/app/assets/javascripts/ponytail/collections/.keep +0 -0
- data/app/assets/javascripts/ponytail/models/column.js +43 -6
- data/app/assets/javascripts/ponytail/models/command.js +8 -0
- data/app/assets/javascripts/ponytail/models/create_table_command.js +16 -0
- data/app/assets/javascripts/ponytail/models/drop_table_command.js +8 -0
- data/app/assets/javascripts/ponytail/models/migration_file.js +36 -20
- data/app/assets/javascripts/ponytail/models/rename_table_command.js +9 -0
- data/app/assets/javascripts/ponytail/models/table.js +32 -28
- data/app/assets/javascripts/ponytail/ponytail.js +15 -0
- data/app/assets/javascripts/ponytail/routers/.keep +0 -0
- data/app/assets/javascripts/ponytail/views/column.js +36 -0
- data/app/assets/javascripts/ponytail/views/migration_file.js +24 -0
- data/app/assets/javascripts/ponytail/views/new_migrations.js +36 -0
- data/app/assets/javascripts/ponytail/views/table.js +61 -0
- data/app/assets/stylesheets/ponytail/application.css +2 -2
- data/app/controllers/ponytail/migrations_controller.rb +7 -0
- data/app/views/ponytail/migrations/_column.html.erb +22 -0
- data/app/views/ponytail/migrations/_column_view_template.html.erb +22 -0
- data/app/views/ponytail/migrations/_migration.html.erb +1 -0
- data/app/views/ponytail/migrations/_migration_file.html.erb +23 -0
- data/app/views/ponytail/migrations/_table.html.erb +7 -6
- data/app/views/ponytail/migrations/_table_view_template.html.erb +23 -0
- data/app/views/ponytail/migrations/index.html.erb +1 -2
- data/app/views/ponytail/migrations/new.html.erb +6 -26
- data/lib/ponytail/migration.rb +4 -0
- data/lib/ponytail/version.rb +1 -1
- data/lib/rails/mapper.rb +1 -1
- data/ponytail.gemspec +4 -2
- data/spec/controllers/migrations_controller_spec.rb +1 -1
- 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 +13 -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/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/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 +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -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 +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -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 +2 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20131202142657_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20131202142714_create_books.rb +10 -0
- data/spec/dummy/db/schema.rb +30 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/migrations/index_spec.rb +8 -0
- data/spec/javascripts/helpers/build_model.js +11 -0
- data/spec/javascripts/ponytail/models/column_spec.js +0 -12
- data/spec/javascripts/ponytail/models/command_spec.js +8 -0
- data/spec/javascripts/ponytail/models/create_command_spec.js +16 -0
- data/spec/javascripts/ponytail/models/migration_file_spec.js +12 -5
- data/spec/javascripts/ponytail/models/table_spec.js +15 -24
- data/spec/javascripts/support/jasmine.yml +6 -1
- data/spec/spec_helper.rb +6 -1
- data/vendor/assets/javascripts/backbone-min.js +2 -0
- data/vendor/assets/javascripts/jquery.min.js +6 -0
- data/vendor/assets/javascripts/jquery_ujs.js +394 -0
- data/vendor/assets/javascripts/underscore-min.js +6 -0
- metadata +140 -15
- data/app/assets/javascripts/ponytail/index.js +0 -20
- data/app/assets/javascripts/ponytail/models/create_table.js +0 -13
- data/app/assets/javascripts/ponytail/models/rename_table.js +0 -8
- data/app/assets/javascripts/ponytail/views/migration_file_view.js +0 -39
- data/app/assets/javascripts/ponytail/views/new_migration_view.js +0 -60
- data/app/assets/javascripts/ponytail/views/table_view.js +0 -68
- data/spec/javascripts/ponytail/views/migration_file_view_spec.js +0 -17
- data/spec/javascripts/ponytail/views/new_migration_view_spec.js +0 -17
- data/spec/javascripts/ponytail/views/table_view_spec.js +0 -17
@@ -1,20 +0,0 @@
|
|
1
|
-
function toggleMigrationRawContent() {
|
2
|
-
var elems = document.querySelectorAll(".pt_migration .pt_migration_header");
|
3
|
-
var func = function() {
|
4
|
-
var content = this.nextElementSibling;
|
5
|
-
content.style.display = content.style.display === "" ? "block" : "";
|
6
|
-
};
|
7
|
-
for(var i = 0; i < elems.length; i++) {
|
8
|
-
elems[i].onclick = func;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
function closeNotice() {
|
13
|
-
var elem = document.querySelector(".pt_close_notice");
|
14
|
-
if (elem !== null) {
|
15
|
-
elem.onclick = function() {
|
16
|
-
this.parentElement.style.display = "none";
|
17
|
-
return false;
|
18
|
-
};
|
19
|
-
}
|
20
|
-
}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
function CreateTable() {
|
2
|
-
this.tableName = "";
|
3
|
-
}
|
4
|
-
CreateTable.prototype = {
|
5
|
-
setTableName: function(tableName) {
|
6
|
-
this.tableName = tableName;
|
7
|
-
},
|
8
|
-
toString: function() {
|
9
|
-
return ["create_table :" + this.tableName + " do |t|",
|
10
|
-
" t.timestamps",
|
11
|
-
"end"].join("\n");
|
12
|
-
}
|
13
|
-
};
|
@@ -1,39 +0,0 @@
|
|
1
|
-
function MigrationFileView(option) {
|
2
|
-
var init = option.init !== undefined ? option.init : true;
|
3
|
-
if (init) { this.init(option); }
|
4
|
-
}
|
5
|
-
MigrationFileView.prototype = {
|
6
|
-
init: function(option) {
|
7
|
-
var _this = this;
|
8
|
-
this.element = option.element;
|
9
|
-
this.callbacks = [];
|
10
|
-
this.checkBox = document.querySelector(".pt_checkbox");
|
11
|
-
this.checkBox.onclick = function() {
|
12
|
-
_this.toggleEditRawContent();
|
13
|
-
};
|
14
|
-
this.classNameElement = document.querySelector(".pt_class_name input");
|
15
|
-
this.classNameElement.onkeyup = function() {
|
16
|
-
_this.callbacks.forEach(function(func) {
|
17
|
-
func();
|
18
|
-
});
|
19
|
-
};
|
20
|
-
this.rawContentElement = document.querySelector(".pt_raw_content textarea");
|
21
|
-
this.submitButton = document.querySelector(".pt_submit");
|
22
|
-
this.submitButton.onclick = function() {
|
23
|
-
_this.rawContentElement.disabled = false;
|
24
|
-
};
|
25
|
-
},
|
26
|
-
toggleEditRawContent: function() {
|
27
|
-
this.rawContentElement.disabled = !(this.rawContentElement.disabled);
|
28
|
-
},
|
29
|
-
getClassName: function() {
|
30
|
-
var elem = document.querySelector(".pt_class_name input");
|
31
|
-
return elem.value;
|
32
|
-
},
|
33
|
-
setRawContent: function(rawContent) {
|
34
|
-
this.rawContentElement.value = rawContent;
|
35
|
-
},
|
36
|
-
addChangeListener: function(callback) {
|
37
|
-
this.callbacks.push(callback);
|
38
|
-
}
|
39
|
-
};
|
@@ -1,60 +0,0 @@
|
|
1
|
-
function NewMigrationView(option) {
|
2
|
-
var init = option.init !== undefined ? option.init : true;
|
3
|
-
if (init) { this.init(option); }
|
4
|
-
}
|
5
|
-
NewMigrationView.prototype = {
|
6
|
-
init: function(option) {
|
7
|
-
this.element = option.element;
|
8
|
-
this.tableViews = [];
|
9
|
-
this.newTableLink = null;
|
10
|
-
this.migrationFileView = null;
|
11
|
-
this.initTableViews();
|
12
|
-
this.initMigrationView();
|
13
|
-
this.initNewTableLink();
|
14
|
-
},
|
15
|
-
initTableViews: function() {
|
16
|
-
var elems = document.querySelectorAll(".pt_table");
|
17
|
-
var _this = this;
|
18
|
-
var func = function() {
|
19
|
-
_this.updateMigrationFileView();
|
20
|
-
};
|
21
|
-
for(var i=0; i<elems.length; i++) {
|
22
|
-
var tableView = new TableView({element: elems[i]});
|
23
|
-
tableView.addChangeListener(func);
|
24
|
-
this.tableViews.push(tableView);
|
25
|
-
}
|
26
|
-
},
|
27
|
-
initNewTableLink: function() {
|
28
|
-
var _this = this;
|
29
|
-
this.newTableLink = document.querySelector(".pt_new_table a");
|
30
|
-
this.newTableLink.onclick = function() {
|
31
|
-
var schema = document.querySelector(".pt_new .pt_schema");
|
32
|
-
var newTable = document.querySelector(".pt_new .pt_new_table");
|
33
|
-
var tableView = new TableView({});
|
34
|
-
tableView.addChangeListener(function() {
|
35
|
-
_this.updateMigrationFileView();
|
36
|
-
});
|
37
|
-
_this.tableViews.push(tableView);
|
38
|
-
schema.insertBefore(tableView.toElement(), newTable);
|
39
|
-
return false;
|
40
|
-
};
|
41
|
-
},
|
42
|
-
initMigrationView: function() {
|
43
|
-
var elem = document.querySelector("form.new_ponytail_migration");
|
44
|
-
this.migrationFileView = new MigrationFileView({element: elem});
|
45
|
-
var _this = this;
|
46
|
-
this.migrationFileView.addChangeListener(function() {
|
47
|
-
_this.updateMigrationFileView();
|
48
|
-
});
|
49
|
-
},
|
50
|
-
updateMigrationFileView: function() {
|
51
|
-
var file = new MigrationFile();
|
52
|
-
file.setClassName(this.migrationFileView.getClassName());
|
53
|
-
this.tableViews.forEach(function(tableView) {
|
54
|
-
tableView.getCommands().forEach(function(command) {
|
55
|
-
file.addCommand(command);
|
56
|
-
});
|
57
|
-
});
|
58
|
-
this.migrationFileView.setRawContent(file.toString());
|
59
|
-
}
|
60
|
-
};
|
@@ -1,68 +0,0 @@
|
|
1
|
-
function TableView(option) {
|
2
|
-
var init = option.init !== undefined ? option.init : true;
|
3
|
-
if (init) { this.init(option); }
|
4
|
-
}
|
5
|
-
TableView.prototype = {
|
6
|
-
init: function(option) {
|
7
|
-
var _this = this;
|
8
|
-
this.element = option.element;
|
9
|
-
var isSaved = true;
|
10
|
-
if (this.element === undefined) {
|
11
|
-
this.element = this.createTable();
|
12
|
-
isSaved = false;
|
13
|
-
}
|
14
|
-
this.tableNameElement = this.element.querySelector(".pt_table_name");
|
15
|
-
this.tableNameSpanElement = this.tableNameElement.querySelector("span");
|
16
|
-
this.inputTableNameElement = this.tableNameElement.querySelector("input");
|
17
|
-
this.tableNameSpanElement.onclick = function() {
|
18
|
-
_this.tableNameSpanElement.style.display = "none";
|
19
|
-
_this.inputTableNameElement.style.display = "block";
|
20
|
-
_this.inputTableNameElement.value = _this.tableNameSpanElement.innerHTML;
|
21
|
-
};
|
22
|
-
this.inputTableNameElement.onblur = function() {
|
23
|
-
_this.tableNameSpanElement.style.display = "block";
|
24
|
-
_this.inputTableNameElement.style.display = "none";
|
25
|
-
_this.setTableName(this.value);
|
26
|
-
_this.callbacks.forEach(function(func) {
|
27
|
-
func();
|
28
|
-
});
|
29
|
-
};
|
30
|
-
this.columnElements = this.element.querySelectorAll(".pt_column");
|
31
|
-
this.dropTableLink = this.element.querySelector("a.pt_drop_table");
|
32
|
-
this.dropTableLink.onclick = function() {
|
33
|
-
_this.table.drop();
|
34
|
-
_this.callbacks.forEach(function(func) {
|
35
|
-
func();
|
36
|
-
});
|
37
|
-
return false;
|
38
|
-
};
|
39
|
-
this.callbacks = [];
|
40
|
-
|
41
|
-
this.table = new Table({tableName: this.tableNameSpanElement.innerHTML, isSaved: isSaved});
|
42
|
-
for(var i=0; i<this.columnElements.length; i++) {
|
43
|
-
var name = this.columnElements[i].querySelector(".pt_column_name");
|
44
|
-
var type = this.columnElements[i].querySelector(".pt_column_type");
|
45
|
-
var column = new Column({name: name.innerHTML, type: type.innerHTML});
|
46
|
-
this.table.addColumn(column);
|
47
|
-
}
|
48
|
-
},
|
49
|
-
setTableName: function(tableName) {
|
50
|
-
this.tableNameSpanElement.innerHTML = tableName;
|
51
|
-
this.table.tableName = tableName;
|
52
|
-
},
|
53
|
-
addChangeListener: function(callback) {
|
54
|
-
this.callbacks.push(callback);
|
55
|
-
},
|
56
|
-
getCommands: function() {
|
57
|
-
return this.table.getCommands();
|
58
|
-
},
|
59
|
-
toElement: function() {
|
60
|
-
return this.element;
|
61
|
-
},
|
62
|
-
createTable: function() {
|
63
|
-
var elem = document.createElement("div");
|
64
|
-
elem.setAttribute("class", "pt_table");
|
65
|
-
elem.innerHTML = '<div class="pt_table_name"><span>tables</span><input type="text" /></div><a href="#" class="pt_drop_table">drop</a><div class="pt_columns"></div>';
|
66
|
-
return elem;
|
67
|
-
}
|
68
|
-
};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
describe("MigrationFileView", function() {
|
2
|
-
describe("#constructor", function() {
|
3
|
-
var init;
|
4
|
-
beforeEach(function() {
|
5
|
-
init = MigrationFileView.prototype.init;
|
6
|
-
spyOn(MigrationFileView.prototype, "init");
|
7
|
-
});
|
8
|
-
afterEach(function() {
|
9
|
-
MigrationFileView.prototype.init = init;
|
10
|
-
});
|
11
|
-
|
12
|
-
it("should be able to initialize without init", function() {
|
13
|
-
var view = new MigrationFileView({init: false});
|
14
|
-
expect(view.init).not.toHaveBeenCalled();
|
15
|
-
});
|
16
|
-
});
|
17
|
-
});
|
@@ -1,17 +0,0 @@
|
|
1
|
-
describe("NewMigrationView", function() {
|
2
|
-
describe("#constructor", function() {
|
3
|
-
var init;
|
4
|
-
beforeEach(function() {
|
5
|
-
init = NewMigrationView.prototype.init;
|
6
|
-
spyOn(NewMigrationView.prototype, "init");
|
7
|
-
});
|
8
|
-
afterEach(function() {
|
9
|
-
NewMigrationView.prototype.init = init;
|
10
|
-
});
|
11
|
-
|
12
|
-
it("should be able to initialize without init", function() {
|
13
|
-
var view = new NewMigrationView({init: false});
|
14
|
-
expect(view.init).not.toHaveBeenCalled();
|
15
|
-
});
|
16
|
-
});
|
17
|
-
});
|
@@ -1,17 +0,0 @@
|
|
1
|
-
describe("TableView", function() {
|
2
|
-
describe("#constructor", function() {
|
3
|
-
var init;
|
4
|
-
beforeEach(function() {
|
5
|
-
init = TableView.prototype.init;
|
6
|
-
spyOn(TableView.prototype, "init");
|
7
|
-
});
|
8
|
-
afterEach(function() {
|
9
|
-
TableView.prototype.init = init;
|
10
|
-
});
|
11
|
-
|
12
|
-
it("should be able to initialize without init", function() {
|
13
|
-
var view = new TableView({init: false});
|
14
|
-
expect(view.init).not.toHaveBeenCalled();
|
15
|
-
});
|
16
|
-
});
|
17
|
-
});
|