ponytail 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/ponytail/migrations.js +99 -0
- data/app/assets/stylesheets/ponytail/application.css +18 -1
- data/app/views/ponytail/migrations/new.html.erb +21 -3
- data/lib/ponytail/version.rb +1 -1
- data/spec/javascripts/ponytail/MigrationSpec.js +9 -0
- metadata +3 -7
- data/app/assets/javascripts/jasmine_examples/Player.js +0 -22
- data/app/assets/javascripts/jasmine_examples/Song.js +0 -7
- data/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/spec/javascripts/jasmine_examples/PlayerSpec.js +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4860fce199d282dff06bc5b4911950a090aca57
|
4
|
+
data.tar.gz: 7ff4d13fa13bffe3837a43aa54203ae8dac58061
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4733c9df76043623e1e3654d68a0f22852c18c8d14c722002869a8ba3ee5632d5617d5702e5b2b02d2ff089e5a3c93733c22e29cb388382d34d4d46ec93943
|
7
|
+
data.tar.gz: d736ba57fa0667af73b60ce55b6560b965f3c7a6a9839c90df61edb6e804a581fa3a9303978d66d1c987bc1bf3e59242919de97e1ccfceb13fb7df492c635642
|
@@ -26,10 +26,109 @@ function closeNotice() {
|
|
26
26
|
});
|
27
27
|
}
|
28
28
|
|
29
|
+
function toggleEditRawContent() {
|
30
|
+
var elems = document.querySelectorAll(".pt_checkbox");
|
31
|
+
onClick(elems, function() {
|
32
|
+
var raw_content = document.querySelectorAll(".pt_raw_content");
|
33
|
+
var text_area = raw_content[0].children[0];
|
34
|
+
text_area.disabled = !(text_area.disabled);
|
35
|
+
});
|
36
|
+
}
|
37
|
+
|
38
|
+
function MigrationFile() {
|
39
|
+
this.className = "";
|
40
|
+
this.commands = [];
|
41
|
+
}
|
42
|
+
|
43
|
+
MigrationFile.prototype.setClassName = function(className) {
|
44
|
+
this.className = className;
|
45
|
+
};
|
46
|
+
|
47
|
+
MigrationFile.prototype.toString = function() {
|
48
|
+
return ["class " + this.className + " < ActiveRecord::Migration",
|
49
|
+
" def change",
|
50
|
+
this.toStringOfCommands(),
|
51
|
+
" end",
|
52
|
+
"end"].join("\n");
|
53
|
+
};
|
54
|
+
|
55
|
+
MigrationFile.prototype.addCommand = function(command) {
|
56
|
+
this.commands.push(command);
|
57
|
+
};
|
58
|
+
|
59
|
+
MigrationFile.prototype.toStringOfCommands = function() {
|
60
|
+
return this.commands.map(function(command) {
|
61
|
+
return command.toString();
|
62
|
+
}).join("\n").replace(/^/, " ").replace(/\n/g, "\n ");
|
63
|
+
};
|
64
|
+
|
65
|
+
function CreateTable() {
|
66
|
+
this.tableName = "";
|
67
|
+
}
|
68
|
+
|
69
|
+
CreateTable.prototype.setTableName = function(tableName) {
|
70
|
+
this.tableName = tableName;
|
71
|
+
};
|
72
|
+
|
73
|
+
CreateTable.prototype.toString = function() {
|
74
|
+
return ["create_table :" + this.tableName + " do |t|",
|
75
|
+
" t.timestamps",
|
76
|
+
"end"].join("\n");
|
77
|
+
};
|
78
|
+
|
79
|
+
function getMigrationClassName() {
|
80
|
+
var elem = document.querySelectorAll(".pt_class_name input")[0];
|
81
|
+
return elem.value;
|
82
|
+
}
|
83
|
+
|
84
|
+
function getNewTableName() {
|
85
|
+
var elem = document.querySelectorAll(".pt_new_class_name input")[0];
|
86
|
+
return elem.value;
|
87
|
+
}
|
88
|
+
|
89
|
+
function inputClassName() {
|
90
|
+
var elems = document.querySelectorAll(".pt_class_name input");
|
91
|
+
elems[0].onkeyup = function() {
|
92
|
+
var file = new MigrationFile();
|
93
|
+
file.setClassName(this.value);
|
94
|
+
var command = new CreateTable();
|
95
|
+
command.setTableName(getNewTableName());
|
96
|
+
file.addCommand(command);
|
97
|
+
var area = document.querySelectorAll(".pt_raw_content textarea")[0];
|
98
|
+
area.value = file.toString();
|
99
|
+
};
|
100
|
+
}
|
101
|
+
|
102
|
+
function clickNewTable() {
|
103
|
+
var elem = document.querySelectorAll(".pt_new_table")[0];
|
104
|
+
elem.onclick = function() {
|
105
|
+
this.style.display = "none";
|
106
|
+
var form = document.querySelectorAll(".pt_new_table_form")[0];
|
107
|
+
form.style.display = "block";
|
108
|
+
};
|
109
|
+
}
|
110
|
+
|
111
|
+
function inputNewTableName() {
|
112
|
+
var elem = document.querySelectorAll(".pt_new_class_name input")[0];
|
113
|
+
elem.onkeyup = function() {
|
114
|
+
var file = new MigrationFile();
|
115
|
+
file.setClassName(getMigrationClassName());
|
116
|
+
var command = new CreateTable();
|
117
|
+
command.setTableName(this.value);
|
118
|
+
file.addCommand(command);
|
119
|
+
var area = document.querySelectorAll(".pt_raw_content textarea")[0];
|
120
|
+
area.value = file.toString();
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
29
124
|
function setupMigrations() {
|
30
125
|
toggleMigrationRawContent();
|
31
126
|
closeNotice();
|
32
127
|
}
|
33
128
|
|
34
129
|
function setupNewMigration() {
|
130
|
+
toggleEditRawContent();
|
131
|
+
inputClassName();
|
132
|
+
clickNewTable();
|
133
|
+
inputNewTableName();
|
35
134
|
}
|
@@ -84,6 +84,15 @@
|
|
84
84
|
margin-top: 5px;
|
85
85
|
}
|
86
86
|
|
87
|
+
.pt_new .pt_schema .pt_new_table {
|
88
|
+
margin-top: 5px;
|
89
|
+
}
|
90
|
+
|
91
|
+
.pt_new .pt_schema .pt_new_table_form {
|
92
|
+
display: none;
|
93
|
+
margin-top: 5px;
|
94
|
+
}
|
95
|
+
|
87
96
|
.pt_new .pt_columns {
|
88
97
|
display: -moz-box;
|
89
98
|
display: -webkit-box;
|
@@ -103,5 +112,13 @@
|
|
103
112
|
width: 100px;
|
104
113
|
}
|
105
114
|
|
106
|
-
.pt_new .
|
115
|
+
.pt_new .pt_form_header {
|
116
|
+
display: -moz-box;
|
117
|
+
display: -webkit-box;
|
118
|
+
width: 100%;
|
119
|
+
}
|
120
|
+
|
121
|
+
.pt_new .pt_form_header .pt_class_name {
|
122
|
+
-moz-box-flex: 1;
|
123
|
+
-webkit-box-flex: 1;
|
107
124
|
}
|
@@ -3,17 +3,35 @@
|
|
3
3
|
<% @schema.tables.each do |t| %>
|
4
4
|
<%= render 'table', table: t %>
|
5
5
|
<% end %>
|
6
|
+
|
7
|
+
<div class="pt_new_table">
|
8
|
+
<a href="#">New Table</a>
|
9
|
+
</div>
|
10
|
+
<div class="pt_new_table_form">
|
11
|
+
<div class="pt_new_class_name">
|
12
|
+
<input type="text" />
|
13
|
+
</div>
|
14
|
+
</div>
|
6
15
|
</div>
|
7
16
|
|
8
17
|
<div>
|
9
18
|
<%= form_for @migration, url: migrations_path do |f| %>
|
10
19
|
<%= render 'new_errors', migration: @migration %>
|
11
20
|
|
12
|
-
<
|
13
|
-
|
21
|
+
<div class="pt_form_header">
|
22
|
+
<div class="pt_class_name">
|
23
|
+
<span>Class Name</span>
|
24
|
+
<%= f.text_field :name %>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="pt_edit_checkbox">
|
28
|
+
<input type="checkbox" class="pt_checkbox" />
|
29
|
+
<span>edit</span>
|
30
|
+
</div>
|
31
|
+
</div>
|
14
32
|
|
15
33
|
<div class="pt_raw_content">
|
16
|
-
<%= f.text_area :raw_content, size: '60x20' %>
|
34
|
+
<%= f.text_area :raw_content, size: '60x20', disabled: true %>
|
17
35
|
</div>
|
18
36
|
|
19
37
|
<%= f.submit 'Update' %>
|
data/lib/ponytail/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
describe("MigrationFile", function() {
|
2
|
+
describe("#setClassName", function() {
|
3
|
+
it("should be able to set className", function() {
|
4
|
+
var file = new MigrationFile();
|
5
|
+
file.setClassName("CreateUsers");
|
6
|
+
expect(file.className).toBe("CreateUsers");
|
7
|
+
});
|
8
|
+
});
|
9
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ponytail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sinsoku
|
@@ -95,8 +95,6 @@ files:
|
|
95
95
|
- LICENSE.txt
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
-
- app/assets/javascripts/jasmine_examples/Player.js
|
99
|
-
- app/assets/javascripts/jasmine_examples/Song.js
|
100
98
|
- app/assets/javascripts/ponytail/application.js
|
101
99
|
- app/assets/javascripts/ponytail/migrations.js
|
102
100
|
- app/assets/stylesheets/ponytail/application.css
|
@@ -118,8 +116,7 @@ files:
|
|
118
116
|
- ponytail.gemspec
|
119
117
|
- spec/controllers/migrations_controller_spec.rb
|
120
118
|
- spec/javascripts/helpers/.keep
|
121
|
-
- spec/javascripts/
|
122
|
-
- spec/javascripts/jasmine_examples/PlayerSpec.js
|
119
|
+
- spec/javascripts/ponytail/MigrationSpec.js
|
123
120
|
- spec/javascripts/support/jasmine.yml
|
124
121
|
- spec/javascripts/support/jasmine_helper.rb
|
125
122
|
- spec/ponytail/migration_spec.rb
|
@@ -154,8 +151,7 @@ summary: Ponytail is a Rails engine that shows the migrations.
|
|
154
151
|
test_files:
|
155
152
|
- spec/controllers/migrations_controller_spec.rb
|
156
153
|
- spec/javascripts/helpers/.keep
|
157
|
-
- spec/javascripts/
|
158
|
-
- spec/javascripts/jasmine_examples/PlayerSpec.js
|
154
|
+
- spec/javascripts/ponytail/MigrationSpec.js
|
159
155
|
- spec/javascripts/support/jasmine.yml
|
160
156
|
- spec/javascripts/support/jasmine_helper.rb
|
161
157
|
- spec/ponytail/migration_spec.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
function Player() {
|
2
|
-
}
|
3
|
-
Player.prototype.play = function(song) {
|
4
|
-
this.currentlyPlayingSong = song;
|
5
|
-
this.isPlaying = true;
|
6
|
-
};
|
7
|
-
|
8
|
-
Player.prototype.pause = function() {
|
9
|
-
this.isPlaying = false;
|
10
|
-
};
|
11
|
-
|
12
|
-
Player.prototype.resume = function() {
|
13
|
-
if (this.isPlaying) {
|
14
|
-
throw new Error("song is already playing");
|
15
|
-
}
|
16
|
-
|
17
|
-
this.isPlaying = true;
|
18
|
-
};
|
19
|
-
|
20
|
-
Player.prototype.makeFavorite = function() {
|
21
|
-
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
22
|
-
};
|
@@ -1,58 +0,0 @@
|
|
1
|
-
describe("Player", function() {
|
2
|
-
var player;
|
3
|
-
var song;
|
4
|
-
|
5
|
-
beforeEach(function() {
|
6
|
-
player = new Player();
|
7
|
-
song = new Song();
|
8
|
-
});
|
9
|
-
|
10
|
-
it("should be able to play a Song", function() {
|
11
|
-
player.play(song);
|
12
|
-
expect(player.currentlyPlayingSong).toEqual(song);
|
13
|
-
|
14
|
-
//demonstrates use of custom matcher
|
15
|
-
expect(player).toBePlaying(song);
|
16
|
-
});
|
17
|
-
|
18
|
-
describe("when song has been paused", function() {
|
19
|
-
beforeEach(function() {
|
20
|
-
player.play(song);
|
21
|
-
player.pause();
|
22
|
-
});
|
23
|
-
|
24
|
-
it("should indicate that the song is currently paused", function() {
|
25
|
-
expect(player.isPlaying).toBeFalsy();
|
26
|
-
|
27
|
-
// demonstrates use of 'not' with a custom matcher
|
28
|
-
expect(player).not.toBePlaying(song);
|
29
|
-
});
|
30
|
-
|
31
|
-
it("should be possible to resume", function() {
|
32
|
-
player.resume();
|
33
|
-
expect(player.isPlaying).toBeTruthy();
|
34
|
-
expect(player.currentlyPlayingSong).toEqual(song);
|
35
|
-
});
|
36
|
-
});
|
37
|
-
|
38
|
-
// demonstrates use of spies to intercept and test method calls
|
39
|
-
it("tells the current song if the user has made it a favorite", function() {
|
40
|
-
spyOn(song, 'persistFavoriteStatus');
|
41
|
-
|
42
|
-
player.play(song);
|
43
|
-
player.makeFavorite();
|
44
|
-
|
45
|
-
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
46
|
-
});
|
47
|
-
|
48
|
-
//demonstrates use of expected exceptions
|
49
|
-
describe("#resume", function() {
|
50
|
-
it("should throw an exception if song is already playing", function() {
|
51
|
-
player.play(song);
|
52
|
-
|
53
|
-
expect(function() {
|
54
|
-
player.resume();
|
55
|
-
}).toThrow("song is already playing");
|
56
|
-
});
|
57
|
-
});
|
58
|
-
});
|