zencodable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +116 -0
  3. data/Rakefile +37 -0
  4. data/lib/generators/zencodable/migration_generator.rb +36 -0
  5. data/lib/generators/zencodable/templates/create_association_table.rb +17 -0
  6. data/lib/generators/zencodable/templates/create_association_thumbnails_table.rb +12 -0
  7. data/lib/zencodable/version.rb +3 -0
  8. data/lib/zencodable.rb +239 -0
  9. data/test/debug.log +3394 -0
  10. data/test/dummy/Rakefile +7 -0
  11. data/test/dummy/app/assets/javascripts/application.js +9 -0
  12. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  13. data/test/dummy/app/controllers/application_controller.rb +3 -0
  14. data/test/dummy/app/helpers/application_helper.rb +2 -0
  15. data/test/dummy/app/models/video.rb +10 -0
  16. data/test/dummy/app/models/video_file.rb +3 -0
  17. data/test/dummy/app/models/video_file_thumbnail.rb +2 -0
  18. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  19. data/test/dummy/config/amazon_s3.yml +4 -0
  20. data/test/dummy/config/application.rb +45 -0
  21. data/test/dummy/config/boot.rb +10 -0
  22. data/test/dummy/config/database.yml +25 -0
  23. data/test/dummy/config/environment.rb +5 -0
  24. data/test/dummy/config/environments/development.rb +30 -0
  25. data/test/dummy/config/environments/production.rb +60 -0
  26. data/test/dummy/config/environments/test.rb +42 -0
  27. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  28. data/test/dummy/config/initializers/inflections.rb +10 -0
  29. data/test/dummy/config/initializers/mime_types.rb +5 -0
  30. data/test/dummy/config/initializers/secret_token.rb +7 -0
  31. data/test/dummy/config/initializers/session_store.rb +8 -0
  32. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  33. data/test/dummy/config/locales/en.yml +5 -0
  34. data/test/dummy/config/routes.rb +58 -0
  35. data/test/dummy/config.ru +4 -0
  36. data/test/dummy/db/development.sqlite3 +0 -0
  37. data/test/dummy/db/migrate/20111130180309_create_dummy_videos.rb +13 -0
  38. data/test/dummy/db/migrate/20111130192331_create_video_files.rb +18 -0
  39. data/test/dummy/db/migrate/20111130193231_create_video_thumbnails.rb +12 -0
  40. data/test/dummy/db/migrate/20111201135457_rename_video_thumbnails.rb +5 -0
  41. data/test/dummy/db/schema.rb +52 -0
  42. data/test/dummy/db/test.sqlite3 +0 -0
  43. data/test/dummy/log/development.log +22 -0
  44. data/test/dummy/log/test.log +42 -0
  45. data/test/dummy/public/404.html +26 -0
  46. data/test/dummy/public/422.html +26 -0
  47. data/test/dummy/public/500.html +26 -0
  48. data/test/dummy/public/favicon.ico +0 -0
  49. data/test/dummy/script/rails +6 -0
  50. data/test/dummy/tmp/db/migrate/20111202054112_create_encoded_kitteh_vids.rb +17 -0
  51. data/test/factories.rb +17 -0
  52. data/test/test_helper.rb +17 -0
  53. data/test/zencodable_generators_test.rb +28 -0
  54. data/test/zencodable_test.rb +64 -0
  55. metadata +226 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,17 @@
1
+ class CreateZencodableOutputFilesAssociationTable < ActiveRecord::Migration
2
+ def change
3
+ create_table "encoded_kitteh_vids" do |t|
4
+ t.string "url"
5
+ t.string "format"
6
+ t.integer "zencoder_file_id"
7
+ t.integer "kitteh_movie_id"
8
+ t.datetime "created_at"
9
+ t.integer "width"
10
+ t.integer "height"
11
+ t.integer "file_size"
12
+ t.string "error_message"
13
+ t.string "state"
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
data/test/factories.rb ADDED
@@ -0,0 +1,17 @@
1
+ FactoryGirl.define do
2
+ factory :video do
3
+ title "At the Foo Bar"
4
+ end
5
+
6
+ factory :video_file do
7
+ format "ogg"
8
+ zencoder_file_id 12345329
9
+ duration_sec 120
10
+ width 800
11
+ height 600
12
+ file_size 19293819
13
+ state "finished"
14
+ sequence(:url) { |n| "http://parallaxp.s3.amazonaws.com/videos/zc/video-title/file.#{n}.off" }
15
+ video
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+ plugin_test_dir = File.dirname(__FILE__)
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+ require "rails/test_help"
7
+ require 'logger'
8
+ require 'factory_girl'
9
+
10
+ require 'factories'
11
+
12
+ Rails.backtrace_cleaner.remove_silencers!
13
+
14
+ ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
15
+
16
+ # Load support files
17
+ #Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+ require 'generators/zencodable/migration_generator'
3
+
4
+ class ZencodableGeneratorTest < Rails::Generators::TestCase
5
+ destination Rails.root
6
+ destination File.join(Rails.root, "tmp")
7
+ tests ::Zencodable::Generators::Migration
8
+ setup :prepare_destination
9
+
10
+ test "creates a migration for the output files model" do
11
+ run_generator %w(KittehMovie encoded_kitteh_vids)
12
+ assert_migration "db/migrate/create_encoded_kitteh_vids.rb" do |migration|
13
+ assert_match /create_table "encoded_kitteh_vids"/, migration
14
+ assert_match /t\.integer\s+\"kitteh_movie_id\"/, migration
15
+ end
16
+ assert_migration "db/migrate/create_encoded_kitteh_vids_thumbnails.rb" do |migration|
17
+ assert_match /create_table "encoded_kitteh_vid_thumbnails"/, migration
18
+ assert_match /t\.integer\s+\"kitteh_movie_id\"/, migration
19
+ end
20
+ end
21
+
22
+ test "does not create a migration for the thumbnails when --skip_thumbnails is given" do
23
+ run_generator %w(KittehMovie encoded_kitteh_vids --skip-thumbnails)
24
+ assert_migration "db/migrate/create_encoded_kitteh_vids.rb"
25
+ assert_no_migration "db/migrate/create_encoded_kitteh_vids_thumbnails.rb"
26
+ end
27
+
28
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ class ZencodableTest < ActiveSupport::TestCase
4
+
5
+ test "updates job status when it needs to" do
6
+ Zencodable::Encoder::Job.any_instance.stubs(:status => 'makin progress')
7
+ vid = Factory :video, :zencoder_job_status => 'new'
8
+ assert_equal 'makin progress', vid.job_status
9
+ end
10
+
11
+ test "doesn't update job status when it doesn't need to" do
12
+ Zencodable::Encoder::Job.any_instance.stubs(:status).returns('makin progress')
13
+ vid = Factory :video, :zencoder_job_status => 'finished'
14
+ assert_equal 'finished', vid.job_status
15
+ end
16
+
17
+ test "updates video files from the Job when job details are updated" do
18
+ testurl = 'http://s3.com/6/7/8.flv'
19
+ Zencodable::Encoder::Job.any_instance.stubs(:status => 'finished', :files => [{:url => testurl, :format => 'flv'}])
20
+ vid = Factory :video, :zencoder_job_status => 'processing'
21
+
22
+ assert_equal 'finished', vid.job_status
23
+ assert_equal 1, vid.video_files.length
24
+ assert_equal 'flv', vid.video_files.first.format
25
+ assert_equal testurl, vid.video_files.first.url
26
+ end
27
+
28
+ test "updates video thumbnails from the Job" do
29
+ testurl = 'http://s3.com/1/2/3.png'
30
+ Zencodable::Encoder::Job.any_instance.stubs(:status => 'finished', :thumbnails => [{:thumbnail_file_name => testurl, :thumbnail_content_type => 'png'}])
31
+ vid = Factory :video, :zencoder_job_status => 'processing'
32
+
33
+ assert_equal 'finished', vid.job_status
34
+ assert_equal 1, vid.video_thumbnails.length
35
+ assert_equal testurl, vid.video_thumbnails.first.thumbnail_file_name
36
+ end
37
+
38
+ test "creates a new zencoder job when origin url is changed" do
39
+ vid = Factory :video
40
+
41
+ Zencodable::Encoder::Job.expects(:create).returns(Zencodable::Encoder::Job.new('123'))
42
+
43
+ vid.origin_url = 'http://foo.com/1/2/4'
44
+ vid.save
45
+
46
+ assert_equal '123', vid.zencoder_job_id
47
+ assert_equal 'new', vid.zencoder_job_status
48
+ end
49
+
50
+ test "has a method to get a specific file format" do
51
+ vid = Factory :video
52
+ file = Factory :video_file, :format => 'webm', :video => vid
53
+ assert_equal file.url, vid.source_file_for('webm').url
54
+ end
55
+
56
+ test "creates a correct S3 url" do
57
+ path = "videos/encoded/:basename"
58
+ origin_url = 'http://foo.com/somepath/2/4/Rainbows and puppies [HD].with unicorns.mov'
59
+ s3_config = '/some/path/to/s3.yml'
60
+ Zencodable::Encoder::Job.expects(:s3_bucket_name).with(s3_config).returns('zenbucket')
61
+ assert_equal "s3://zenbucket.s3.amazonaws.com/videos/encoded/rainbows-and-puppies-hd.with-unicorns/", Zencodable::Encoder::Job.s3_url(origin_url, s3_config, path)
62
+ end
63
+
64
+ end
metadata ADDED
@@ -0,0 +1,226 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zencodable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sam Beam
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &8827040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *8827040
25
+ - !ruby/object:Gem::Dependency
26
+ name: aws-s3
27
+ requirement: &8826460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *8826460
36
+ - !ruby/object:Gem::Dependency
37
+ name: zencoder
38
+ requirement: &8825860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *8825860
47
+ - !ruby/object:Gem::Dependency
48
+ name: typhoeus
49
+ requirement: &8824880 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *8824880
58
+ - !ruby/object:Gem::Dependency
59
+ name: sqlite3
60
+ requirement: &8824040 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *8824040
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: &8822640 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *8822640
80
+ - !ruby/object:Gem::Dependency
81
+ name: factory_girl
82
+ requirement: &8813620 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *8813620
91
+ description: provides a `has_video_encodings` class method to your models that allows
92
+ you to configure and set up any Zencoder settings you will need to create multiple
93
+ output video container formats (mp4, ogg, wmv, etc) from a single uploaded source
94
+ file. Uses the Zencoder API (zencoder.com) and (as of now) expects you to have
95
+ an S3 bucket where we can ask zencoder to place the generated files.
96
+ email:
97
+ - sbeam@onsetcorps.net
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - lib/zencodable/version.rb
103
+ - lib/zencodable.rb
104
+ - lib/generators/zencodable/templates/create_association_table.rb
105
+ - lib/generators/zencodable/templates/create_association_thumbnails_table.rb
106
+ - lib/generators/zencodable/migration_generator.rb
107
+ - MIT-LICENSE
108
+ - Rakefile
109
+ - README.md
110
+ - test/zencodable_generators_test.rb
111
+ - test/factories.rb
112
+ - test/debug.log
113
+ - test/dummy/Rakefile
114
+ - test/dummy/public/404.html
115
+ - test/dummy/public/500.html
116
+ - test/dummy/public/favicon.ico
117
+ - test/dummy/public/422.html
118
+ - test/dummy/app/controllers/application_controller.rb
119
+ - test/dummy/app/views/layouts/application.html.erb
120
+ - test/dummy/app/helpers/application_helper.rb
121
+ - test/dummy/app/assets/stylesheets/application.css
122
+ - test/dummy/app/assets/javascripts/application.js
123
+ - test/dummy/app/models/video_file_thumbnail.rb
124
+ - test/dummy/app/models/video.rb
125
+ - test/dummy/app/models/video_file.rb
126
+ - test/dummy/db/test.sqlite3
127
+ - test/dummy/db/development.sqlite3
128
+ - test/dummy/db/schema.rb
129
+ - test/dummy/db/migrate/20111130180309_create_dummy_videos.rb
130
+ - test/dummy/db/migrate/20111130193231_create_video_thumbnails.rb
131
+ - test/dummy/db/migrate/20111130192331_create_video_files.rb
132
+ - test/dummy/db/migrate/20111201135457_rename_video_thumbnails.rb
133
+ - test/dummy/config/routes.rb
134
+ - test/dummy/config/initializers/secret_token.rb
135
+ - test/dummy/config/initializers/inflections.rb
136
+ - test/dummy/config/initializers/backtrace_silencers.rb
137
+ - test/dummy/config/initializers/wrap_parameters.rb
138
+ - test/dummy/config/initializers/mime_types.rb
139
+ - test/dummy/config/initializers/session_store.rb
140
+ - test/dummy/config/environment.rb
141
+ - test/dummy/config/database.yml
142
+ - test/dummy/config/locales/en.yml
143
+ - test/dummy/config/boot.rb
144
+ - test/dummy/config/application.rb
145
+ - test/dummy/config/amazon_s3.yml
146
+ - test/dummy/config/environments/development.rb
147
+ - test/dummy/config/environments/production.rb
148
+ - test/dummy/config/environments/test.rb
149
+ - test/dummy/log/test.log
150
+ - test/dummy/log/development.log
151
+ - test/dummy/script/rails
152
+ - test/dummy/config.ru
153
+ - test/dummy/tmp/db/migrate/20111202054112_create_encoded_kitteh_vids.rb
154
+ - test/test_helper.rb
155
+ - test/zencodable_test.rb
156
+ homepage: http://onsetcorps.net
157
+ licenses: []
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 1.8.10
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: mindful multiformat video encoding for AR models with Zencoder API
180
+ test_files:
181
+ - test/zencodable_generators_test.rb
182
+ - test/factories.rb
183
+ - test/debug.log
184
+ - test/dummy/Rakefile
185
+ - test/dummy/public/404.html
186
+ - test/dummy/public/500.html
187
+ - test/dummy/public/favicon.ico
188
+ - test/dummy/public/422.html
189
+ - test/dummy/app/controllers/application_controller.rb
190
+ - test/dummy/app/views/layouts/application.html.erb
191
+ - test/dummy/app/helpers/application_helper.rb
192
+ - test/dummy/app/assets/stylesheets/application.css
193
+ - test/dummy/app/assets/javascripts/application.js
194
+ - test/dummy/app/models/video_file_thumbnail.rb
195
+ - test/dummy/app/models/video.rb
196
+ - test/dummy/app/models/video_file.rb
197
+ - test/dummy/db/test.sqlite3
198
+ - test/dummy/db/development.sqlite3
199
+ - test/dummy/db/schema.rb
200
+ - test/dummy/db/migrate/20111130180309_create_dummy_videos.rb
201
+ - test/dummy/db/migrate/20111130193231_create_video_thumbnails.rb
202
+ - test/dummy/db/migrate/20111130192331_create_video_files.rb
203
+ - test/dummy/db/migrate/20111201135457_rename_video_thumbnails.rb
204
+ - test/dummy/config/routes.rb
205
+ - test/dummy/config/initializers/secret_token.rb
206
+ - test/dummy/config/initializers/inflections.rb
207
+ - test/dummy/config/initializers/backtrace_silencers.rb
208
+ - test/dummy/config/initializers/wrap_parameters.rb
209
+ - test/dummy/config/initializers/mime_types.rb
210
+ - test/dummy/config/initializers/session_store.rb
211
+ - test/dummy/config/environment.rb
212
+ - test/dummy/config/database.yml
213
+ - test/dummy/config/locales/en.yml
214
+ - test/dummy/config/boot.rb
215
+ - test/dummy/config/application.rb
216
+ - test/dummy/config/amazon_s3.yml
217
+ - test/dummy/config/environments/development.rb
218
+ - test/dummy/config/environments/production.rb
219
+ - test/dummy/config/environments/test.rb
220
+ - test/dummy/log/test.log
221
+ - test/dummy/log/development.log
222
+ - test/dummy/script/rails
223
+ - test/dummy/config.ru
224
+ - test/dummy/tmp/db/migrate/20111202054112_create_encoded_kitteh_vids.rb
225
+ - test/test_helper.rb
226
+ - test/zencodable_test.rb