ponytail 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78aeabe758e879167178c1b3ab68880f43561b76
4
- data.tar.gz: ba0bc6eff510a36202b96d31c4d8a5ad3cf37462
3
+ metadata.gz: ee3b29d3740046a1e12155cc766af426c6694523
4
+ data.tar.gz: a9e134360624760a685ab675046022fb8431ff02
5
5
  SHA512:
6
- metadata.gz: 69f19add1e33a3f1ea7a073be5f41fc672ca3db2ba1566368217d2b758812c6bf3c6732c6e045ac4b8e7a68e5ee03f5a3b1b4a933efecd9656988f06bc81a208
7
- data.tar.gz: 54ae11479d174006e6bcd0bcaa7273167bea066cbf3e650f9a8aeee66602cb736bb9000e8367e86a94b1cdb0fc419b3251d429149f14349cc7b7cbbc31516a9a
6
+ metadata.gz: 0812489fcccdfdedb8ae0ed4d8da0796e64a01f99d98b5b0f12eb91f4595c80bfbe41b65c396564080f139ee909ef09f9fb89b715009284b84b062909b805cea
7
+ data.tar.gz: a1d54bf1b29312b846173c82f4eb61843606c6f6e9255502702766f732bd35b5b88d7e5bfa026204a5be53e94b22c771d3f331cc14da032ce33e7e3f76c6975c
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ load "jasmine/tasks/jasmine.rake"
4
+ ENV['JASMINE_SPEC_FORMAT'] = 'documentation'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task :default => [:spec, 'jasmine:ci']
@@ -0,0 +1,22 @@
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
+ };
@@ -0,0 +1,7 @@
1
+ function Song() {
2
+ }
3
+
4
+ Song.prototype.persistFavoriteStatus = function(value) {
5
+ // something complicated
6
+ throw new Error("not yet implemented");
7
+ };
@@ -12,7 +12,7 @@ function onClick(elems, func) {
12
12
  }
13
13
 
14
14
  function toggleMigrationRawContent() {
15
- var elems = document.querySelectorAll(".pt_migration .pt_header");
15
+ var elems = document.querySelectorAll(".pt_migration .pt_migration_header");
16
16
  onClick(elems, function() {
17
17
  var content = this.nextElementSibling;
18
18
  content.style.display = content.style.display === "" ? "block" : "";
@@ -30,3 +30,6 @@ function setupMigrations() {
30
30
  toggleMigrationRawContent();
31
31
  closeNotice();
32
32
  }
33
+
34
+ function setupNewMigration() {
35
+ }
@@ -16,13 +16,33 @@
16
16
  }
17
17
 
18
18
  /* migration */
19
+ .pt_migration {
20
+ display: -moz-box;
21
+ display: -webkit-box;
22
+ }
23
+
24
+ .pt_migration .pt_current {
25
+ width: 60px;
26
+ }
27
+
28
+ .pt_migration .pt_migration_file {
29
+ margin-left: 5px;
30
+ }
31
+
19
32
  .pt_migration .pt_name {
20
33
  font-size: large;
21
34
  font-weight: bold;
22
35
  }
23
36
 
24
37
  .pt_migration .pt_raw_content {
38
+ background: whitesmoke;
39
+ border-radius: 5px;
25
40
  display: none;
41
+ padding: 5px;
42
+ }
43
+
44
+ .pt_migration .pt_raw_content pre {
45
+ margin: 5px 0;
26
46
  }
27
47
 
28
48
  /* notice */
@@ -45,3 +65,43 @@
45
65
  .pt_new_errors ul {
46
66
  margin: 3px 0;
47
67
  }
68
+
69
+ /* new */
70
+ .pt_new {
71
+ display: -moz-box;
72
+ display: -webkit-box;
73
+ width: 1024px;
74
+ }
75
+
76
+ .pt_new .pt_schema {
77
+ -moz-box-flex: 1;
78
+ -webkit-box-flex: 1;
79
+ }
80
+
81
+ .pt_new .pt_schema .pt_table {
82
+ font-size: large;
83
+ font-weight: bold;
84
+ margin-top: 5px;
85
+ }
86
+
87
+ .pt_new .pt_columns {
88
+ display: -moz-box;
89
+ display: -webkit-box;
90
+ -moz-box-orient: vertical;
91
+ -webkit-box-orient: vertical;
92
+ margin-left: 15px;
93
+ }
94
+
95
+ .pt_new .pt_columns .pt_column {
96
+ display: -moz-box;
97
+ display: -webkit-box;
98
+ -moz-box-orient: horizontal;
99
+ -webkit-box-orient: horizontal;
100
+ }
101
+
102
+ .pt_new .pt_columns .pt_column .pt_column_type {
103
+ width: 100px;
104
+ }
105
+
106
+ .pt_new .pt_columns .pt_column .pt_column_name {
107
+ }
@@ -1,10 +1,12 @@
1
1
  <div class="pt_migration">
2
- <div class="pt_header">
3
- <% if migration.version == @current_version %>
4
- <span class="pt_current">current</span>
5
- <% end %>
6
- <span class="pt_name"><%= migration.name %></span>
7
- <span class="pt_filename"><%= migration.filename %></span>
2
+ <div class="pt_current"><%= migration.version == @current_version ? "current" : "" %></div>
3
+ <div class="pt_migration_file">
4
+ <div class="pt_migration_header">
5
+ <span class="pt_name"><%= migration.name %></span>
6
+ <span class="pt_filename"><%= migration.filename %></span>
7
+ </div>
8
+ <div class="pt_raw_content">
9
+ <pre><%= migration.raw_content %></pre>
10
+ </div>
8
11
  </div>
9
- <pre class="pt_raw_content"><%= migration.raw_content %></pre>
10
12
  </div>
@@ -1,7 +1,9 @@
1
1
  <div class="pt_table"><%= table.name %></div>
2
- <div>
2
+ <div class="pt_columns">
3
3
  <% table.columns.each do |column| %>
4
- <span>t.<%= column.type %></span>
5
- <span><%= column.name %></span>
4
+ <div class="pt_column">
5
+ <div class="pt_column_type">t.<%= column.type %></div>
6
+ <div class="pt_column_name"><%= column.name %></div>
7
+ </div>
6
8
  <% end %>
7
9
  </div>
@@ -6,9 +6,9 @@
6
6
  <% end %>
7
7
 
8
8
  <div class="pt_actions">
9
- <%= button_to 'New', new_migration_path, class: 'pt_new', method: :get, disabled: Ponytail::Migration.check_pending? %>
10
- <%= button_to 'Migrate', migrate_migrations_path, class: 'pt_migrate', disabled: Ponytail::Migration.check_pending? %>
11
- <%= button_to 'Rollback', rollback_migrations_path, class: 'pt_rallback', disabled: Ponytail::Migration.check_pending? %>
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? %>
12
12
  </div>
13
13
  </div>
14
14
 
@@ -1,18 +1,28 @@
1
- <%= form_for @migration, url: migrations_path do |f| %>
2
- <%= render 'new_errors', migration: @migration %>
1
+ <div class="pt_new">
2
+ <div class="pt_schema">
3
+ <% @schema.tables.each do |t| %>
4
+ <%= render 'table', table: t %>
5
+ <% end %>
6
+ </div>
3
7
 
4
- <%= f.label :name %>
5
- <%= f.text_field :name %>
8
+ <div>
9
+ <%= form_for @migration, url: migrations_path do |f| %>
10
+ <%= render 'new_errors', migration: @migration %>
6
11
 
7
- <div class="pt_raw_content">
8
- <%= f.text_area :raw_content, size: '80x20' %>
9
- </div>
12
+ <span>Class Name</span>
13
+ <%= f.text_field :name %>
10
14
 
11
- <%= f.submit 'Submit' %>
12
- <% end %>
15
+ <div class="pt_raw_content">
16
+ <%= f.text_area :raw_content, size: '60x20' %>
17
+ </div>
13
18
 
14
- <%= button_to 'Cancel', migrations_path, method: :get %>
19
+ <%= f.submit 'Update' %>
20
+ <% end %>
21
+
22
+ <%= button_to 'Cancel', migrations_path, method: :get %>
23
+ </div>
24
+ </div>
15
25
 
16
- <% @schema.tables.each do |t| %>
17
- <%= render 'table', table: t %>
18
- <% end %>
26
+ <script type='text/javascript'>
27
+ setupNewMigration();
28
+ </script>
@@ -38,7 +38,7 @@ module Ponytail
38
38
  def save
39
39
  if valid?
40
40
  next_filename = "#{Migration.migrations_path}/#{Migration.next_version}_#{name.underscore}.rb"
41
- open(next_filename, 'w').write(raw_content)
41
+ open(next_filename, 'w') { |f| f.write(raw_content) }
42
42
  true
43
43
  else
44
44
  false
@@ -1,7 +1,12 @@
1
1
  module Ponytail
2
2
  class Schema
3
3
  def tables
4
- ActiveRecord::Base.connection.tables.sort.map { |t| Table.new(t) }
4
+ table_names.sort.map { |t| Table.new(t) }
5
+ end
6
+
7
+ private
8
+ def table_names
9
+ ActiveRecord::Base.connection.tables.delete_if { |t| t == 'schema_migrations' }
5
10
  end
6
11
  end
7
12
 
@@ -1,3 +1,3 @@
1
1
  module Ponytail
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/ponytail.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "jasmine"
26
27
  end
File without changes
@@ -0,0 +1,9 @@
1
+ beforeEach(function() {
2
+ this.addMatchers({
3
+ toBePlaying: function(expectedSong) {
4
+ var player = this.actual;
5
+ return player.currentlyPlayingSong === expectedSong
6
+ && player.isPlaying;
7
+ }
8
+ })
9
+ });
@@ -0,0 +1,58 @@
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
+ });
@@ -0,0 +1,76 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ - app/assets/javascripts/**/*.js
15
+
16
+ # stylesheets
17
+ #
18
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
19
+ # Default: []
20
+ #
21
+ # EXAMPLE:
22
+ #
23
+ # stylesheets:
24
+ # - css/style.css
25
+ # - stylesheets/*.css
26
+ #
27
+ stylesheets:
28
+ - app/stylesheets/**/*.css
29
+
30
+ # helpers
31
+ #
32
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
33
+ # Default: ["helpers/**/*.js"]
34
+ #
35
+ # EXAMPLE:
36
+ #
37
+ # helpers:
38
+ # - helpers/**/*.js
39
+ #
40
+ helpers:
41
+ - helpers/**/*.js
42
+
43
+ # spec_files
44
+ #
45
+ # Return an array of filepaths relative to spec_dir to include.
46
+ # Default: ["**/*[sS]pec.js"]
47
+ #
48
+ # EXAMPLE:
49
+ #
50
+ # spec_files:
51
+ # - **/*[sS]pec.js
52
+ #
53
+ spec_files:
54
+ - '**/*[sS]pec.js'
55
+
56
+ # src_dir
57
+ #
58
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
59
+ # Default: project root
60
+ #
61
+ # EXAMPLE:
62
+ #
63
+ # src_dir: public
64
+ #
65
+ src_dir:
66
+
67
+ # spec_dir
68
+ #
69
+ # Spec directory path. Your spec_files must be returned relative to this path.
70
+ # Default: spec/javascripts
71
+ #
72
+ # EXAMPLE:
73
+ #
74
+ # spec_dir: spec/javascripts
75
+ #
76
+ spec_dir: spec/javascripts
@@ -0,0 +1,13 @@
1
+ #Use this file to set/override Jasmine configuration options
2
+ #You can remove it if you don't need it.
3
+ #This file is loaded *after* jasmine.yml is interpreted.
4
+ #
5
+ #Example: using a different boot file.
6
+ #Jasmine.configure do |config|
7
+ # @config.boot_dir = '/absolute/path/to/boot_dir'
8
+ # @config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
+ #end
10
+ #
11
+ Jasmine.configure do |config|
12
+ config.browser = :phantomjs
13
+ end
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.0.3
4
+ version: 0.0.4
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-09 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jasmine
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Ponytail is a Rails engine that shows the migrations.
70
84
  email:
71
85
  - sinsoku.listy@gmail.com
@@ -81,6 +95,8 @@ files:
81
95
  - LICENSE.txt
82
96
  - README.md
83
97
  - Rakefile
98
+ - app/assets/javascripts/jasmine_examples/Player.js
99
+ - app/assets/javascripts/jasmine_examples/Song.js
84
100
  - app/assets/javascripts/ponytail/application.js
85
101
  - app/assets/javascripts/ponytail/migrations.js
86
102
  - app/assets/stylesheets/ponytail/application.css
@@ -101,6 +117,11 @@ files:
101
117
  - lib/rails/mapper.rb
102
118
  - ponytail.gemspec
103
119
  - spec/controllers/migrations_controller_spec.rb
120
+ - spec/javascripts/helpers/.keep
121
+ - spec/javascripts/helpers/SpecHelper.js
122
+ - spec/javascripts/jasmine_examples/PlayerSpec.js
123
+ - spec/javascripts/support/jasmine.yml
124
+ - spec/javascripts/support/jasmine_helper.rb
104
125
  - spec/ponytail/migration_spec.rb
105
126
  - spec/ponytail/schema_spec.rb
106
127
  - spec/ponytail_spec.rb
@@ -132,6 +153,11 @@ specification_version: 4
132
153
  summary: Ponytail is a Rails engine that shows the migrations.
133
154
  test_files:
134
155
  - spec/controllers/migrations_controller_spec.rb
156
+ - spec/javascripts/helpers/.keep
157
+ - spec/javascripts/helpers/SpecHelper.js
158
+ - spec/javascripts/jasmine_examples/PlayerSpec.js
159
+ - spec/javascripts/support/jasmine.yml
160
+ - spec/javascripts/support/jasmine_helper.rb
135
161
  - spec/ponytail/migration_spec.rb
136
162
  - spec/ponytail/schema_spec.rb
137
163
  - spec/ponytail_spec.rb