enigmamachine 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -5
- data/VERSION +1 -1
- data/lib/enigmamachine/config.ru +2 -8
- data/lib/enigmamachine/encoding_queue.rb +6 -3
- data/lib/enigmamachine/models/encoder.rb +6 -4
- data/lib/enigmamachine/views/encoding_tasks/edit.erb +23 -21
- data/lib/enigmamachine.rb +203 -132
- data/lib/enigmamachine.sqlite3 +0 -0
- data/lib/init.rb +10 -59
- data/test/test_encoding_queue.rb +34 -0
- metadata +45 -44
- data/test/test_encoder_queue.rb +0 -34
data/Rakefile
CHANGED
@@ -11,14 +11,12 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/futurechimp/enigmamachine"
|
12
12
|
gem.authors = ["dave"]
|
13
13
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
-
gem.add_dependency "
|
14
|
+
gem.add_dependency "data_mapper", "=1.0.0"
|
15
15
|
gem.add_dependency "eventmachine", "=0.12.10"
|
16
|
+
gem.add_dependency "dm-sqlite-adapter", "=1.0.0"
|
16
17
|
gem.add_dependency "rack-flash"
|
17
18
|
gem.add_dependency "ruby-debug"
|
18
|
-
gem.add_dependency "sinatra"
|
19
|
-
gem.add_dependency "datamapper"
|
20
|
-
gem.add_dependency "data_objects"
|
21
|
-
gem.add_dependency "do_sqlite3"
|
19
|
+
gem.add_dependency "sinatra", "=1.0.0"
|
22
20
|
gem.add_dependency "thin"
|
23
21
|
|
24
22
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/enigmamachine/config.ru
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class EncodingQueue
|
2
2
|
|
3
|
+
cattr_accessor :currently_encoding
|
4
|
+
|
3
5
|
# Adds a periodic timer to the Eventmachine reactor loop and immediately
|
4
6
|
# starts looking for unencoded videos.
|
5
7
|
#
|
6
|
-
def
|
8
|
+
def initialize
|
7
9
|
EM.add_periodic_timer(5) {
|
8
10
|
encode_next_video
|
9
11
|
}
|
@@ -16,11 +18,12 @@ class EncodingQueue
|
|
16
18
|
def encode_next_video
|
17
19
|
if Video.unencoded.count > 0 && ::Video.encoding.count == 0
|
18
20
|
video = Video.unencoded.first
|
19
|
-
Log.info("Starting to encode video: #{video.id}")
|
20
21
|
begin
|
21
22
|
video.encoder.encode(video)
|
22
23
|
rescue Exception => ex
|
23
|
-
|
24
|
+
File.open('/home/dave/test.txt', 'w') do |f|
|
25
|
+
f.puts ex
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -31,18 +31,20 @@ class Encoder
|
|
31
31
|
#
|
32
32
|
def ffmpeg(task, video)
|
33
33
|
current_task_index = encoding_tasks.index(task)
|
34
|
-
command_string = "ffmpeg -i #{video.file} #{task.command} #{video.file + task.output_file_suffix}
|
34
|
+
command_string = "ffmpeg -y -i #{video.file} #{task.command} #{video.file + task.output_file_suffix}"
|
35
35
|
encoding_operation = proc {
|
36
36
|
video.state = "encoding"
|
37
37
|
video.save
|
38
|
-
|
39
|
-
|
38
|
+
Open3.popen3 "nice -n 19 #{command_string}" do |stdin, stdout, stderr|
|
39
|
+
while stderr.gets()
|
40
|
+
puts stderr.gets
|
41
|
+
end
|
42
|
+
end
|
40
43
|
}
|
41
44
|
completion_callback = proc {|result|
|
42
45
|
if task == encoding_tasks.last
|
43
46
|
video.state = "complete"
|
44
47
|
video.save
|
45
|
-
Log.info("Video #{video.id} finished")
|
46
48
|
else
|
47
49
|
next_task_index = current_task_index + 1
|
48
50
|
next_task = encoding_tasks[next_task_index]
|
@@ -1,23 +1,25 @@
|
|
1
1
|
<div class="post">
|
2
2
|
<h1 class="title">Edit an encoding task</h1>
|
3
|
-
<div class="entry">
|
4
|
-
|
5
|
-
<% unless @encoding_task.errors.empty? %>
|
6
|
-
<div class="errors">
|
7
|
-
<h2>Errors on Encoding Task</h2>
|
8
|
-
<ul>
|
9
|
-
<% @encoding_task.errors.each do |error| %>
|
10
|
-
<li><%= error %></li>
|
11
|
-
<% end %>
|
12
|
-
</ul>
|
13
|
-
</div>
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
<form id="task-<%= @encoding_task.id%>-edit"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
</
|
22
|
-
|
23
|
-
|
3
|
+
<div class="entry">
|
4
|
+
|
5
|
+
<% unless @encoding_task.errors.empty? %>
|
6
|
+
<div class="errors">
|
7
|
+
<h2>Errors on Encoding Task</h2>
|
8
|
+
<ul>
|
9
|
+
<% @encoding_task.errors.each do |error| %>
|
10
|
+
<li><%= error %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<form id="task-<%= @encoding_task.id%>-edit"
|
17
|
+
action="/encoding_tasks/<%= @encoding_task.id %>"
|
18
|
+
method="POST">
|
19
|
+
<input name="_method" value="PUT" type="hidden"></input>
|
20
|
+
<%= partial(:'encoding_tasks/form') %>
|
21
|
+
</form>
|
22
|
+
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
data/lib/enigmamachine.rb
CHANGED
@@ -1,179 +1,250 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/init
|
1
|
+
require File.dirname(__FILE__) + '/init'
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
get '/' do
|
6
|
-
@videos = Video.all(:limit => 50, :order => [:created_at.asc])
|
7
|
-
erb :index
|
8
|
-
end
|
3
|
+
class EnigmaMachine < Sinatra::Base
|
9
4
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
5
|
+
# Database config
|
6
|
+
#
|
7
|
+
configure :production do
|
8
|
+
db = "sqlite3:///#{Dir.pwd}/enigmamachine.sqlite3"
|
9
|
+
DataMapper.setup(:default, db)
|
10
|
+
end
|
16
11
|
|
12
|
+
configure :development do
|
13
|
+
db = "sqlite3:///#{Dir.pwd}/enigmamachine.sqlite3"
|
14
|
+
DataMapper.setup(:default, db)
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
erb :'encoders/new'
|
23
|
-
end
|
17
|
+
configure :test do
|
18
|
+
db = "sqlite3::memory:"
|
19
|
+
DataMapper.setup(:default, db)
|
20
|
+
end
|
24
21
|
|
22
|
+
configure :production, :test, :development do
|
23
|
+
Video.auto_migrate! unless Video.storage_exists?
|
24
|
+
Encoder.auto_migrate! unless Encoder.storage_exists?
|
25
|
+
EncodingTask.auto_migrate! unless EncodingTask.storage_exists?
|
26
|
+
end
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@encoder = Encoder.get(id)
|
30
|
-
@encoding_task = EncodingTask.new
|
31
|
-
erb :'encoders/show'
|
32
|
-
end
|
28
|
+
configure :production, :development do
|
29
|
+
DataMapper.auto_upgrade!
|
30
|
+
end
|
33
31
|
|
32
|
+
# Set the views to the proper path inside the gem
|
33
|
+
#
|
34
|
+
set :views, File.dirname(__FILE__) + '/enigmamachine/views'
|
35
|
+
set :public, File.dirname(__FILE__) + '/enigmamachine/public'
|
34
36
|
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
37
|
+
# Register helpers
|
38
|
+
#
|
39
|
+
helpers do
|
40
|
+
include Sinatra::Partials
|
41
|
+
alias_method :h, :escape_html
|
42
|
+
end
|
41
43
|
|
44
|
+
# Set up Rack authentication
|
45
|
+
#
|
46
|
+
use Rack::Auth::Basic do |username, password|
|
47
|
+
[username, password] == ['admin', 'admin']
|
48
|
+
end
|
42
49
|
|
43
|
-
#
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
# Include flash notices
|
51
|
+
#
|
52
|
+
use Rack::Session::Cookie
|
53
|
+
use Rack::Flash
|
54
|
+
|
55
|
+
configure do
|
56
|
+
Log = Logger.new("enigma.log")
|
57
|
+
Log.level = Logger::INFO
|
58
|
+
Log.info("Logging started...")
|
59
|
+
Thread.new do
|
60
|
+
until EM.reactor_running?
|
61
|
+
sleep 1
|
62
|
+
end
|
63
|
+
queue = EncodingQueue.new
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Shows the enigma status page.
|
68
|
+
#
|
69
|
+
get '/' do
|
70
|
+
@videos = Video.all(:limit => 50, :order => [:created_at.asc])
|
71
|
+
erb :index
|
72
|
+
end
|
73
|
+
|
74
|
+
# Displays a list of all available encoders.
|
75
|
+
#
|
76
|
+
get '/encoders' do
|
77
|
+
@encoders = Encoder.all
|
78
|
+
erb :'encoders/index'
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# Displays a form to create a new encoder.
|
83
|
+
#
|
84
|
+
get '/encoders/new' do
|
85
|
+
@encoder = Encoder.new
|
51
86
|
erb :'encoders/new'
|
52
87
|
end
|
53
|
-
end
|
54
88
|
|
55
89
|
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
90
|
+
# Displays an encoder.
|
91
|
+
#
|
92
|
+
get '/encoders/:id' do |id|
|
93
|
+
@encoder = Encoder.get(id)
|
94
|
+
@encoding_task = EncodingTask.new
|
95
|
+
erb :'encoders/show'
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# Displays an edit page for an encoder.
|
100
|
+
#
|
101
|
+
get '/encoders/:id/edit' do |id|
|
102
|
+
@encoder = Encoder.get(id)
|
64
103
|
erb :"encoders/edit"
|
65
104
|
end
|
66
|
-
end
|
67
105
|
|
68
|
-
delete '/encoders/:id' do |id|
|
69
|
-
@encoder = Encoder.get(id)
|
70
|
-
@encoder.destroy!
|
71
|
-
redirect '/encoders'
|
72
|
-
end
|
73
106
|
|
107
|
+
# Creates an encoder.
|
108
|
+
#
|
109
|
+
post '/encoders' do
|
110
|
+
@encoder = Encoder.new(params[:encoder])
|
111
|
+
if @encoder.save
|
112
|
+
flash[:notice] = "Encoder created."
|
113
|
+
redirect "/encoders/#{@encoder.id}"
|
114
|
+
else
|
115
|
+
erb :'encoders/new'
|
116
|
+
end
|
117
|
+
end
|
74
118
|
|
75
|
-
# Show a form to make a new encoding task
|
76
|
-
#
|
77
|
-
get '/encoding_tasks/new/:encoder_id' do |encoder_id|
|
78
|
-
@encoding_task = EncodingTask.new
|
79
|
-
@encoding_task.encoder = Encoder.get(encoder_id)
|
80
|
-
erb :'encoding_tasks/new'
|
81
|
-
end
|
82
119
|
|
120
|
+
# Updates an encoder
|
121
|
+
#
|
122
|
+
put '/encoders/:id' do |id|
|
123
|
+
@encoder = Encoder.get(id)
|
124
|
+
if @encoder.update(params[:encoder])
|
125
|
+
flash[:notice] = "Encoder updated."
|
126
|
+
redirect '/encoders'
|
127
|
+
else
|
128
|
+
erb :"encoders/edit"
|
129
|
+
end
|
130
|
+
end
|
83
131
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
132
|
+
delete '/encoders/:id' do |id|
|
133
|
+
@encoder = Encoder.get(id)
|
134
|
+
@encoder.destroy!
|
135
|
+
redirect '/encoders'
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
# Show a form to make a new encoding task
|
140
|
+
#
|
141
|
+
get '/encoding_tasks/new/:encoder_id' do |encoder_id|
|
142
|
+
@encoding_task = EncodingTask.new
|
143
|
+
@encoding_task.encoder = Encoder.get(encoder_id)
|
94
144
|
erb :'encoding_tasks/new'
|
95
145
|
end
|
96
|
-
end
|
97
146
|
|
98
147
|
|
99
|
-
#
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
148
|
+
# Creates an encoding task.
|
149
|
+
#
|
150
|
+
post '/encoding_tasks/:encoder_id' do |encoder_id|
|
151
|
+
@encoding_task = EncodingTask.new(params[:encoding_task])
|
152
|
+
@encoder = Encoder.get(encoder_id)
|
153
|
+
@encoding_task.encoder = @encoder
|
154
|
+
if @encoding_task.save
|
155
|
+
flash[:notice] = "Encoding task created."
|
156
|
+
redirect "/encoders/#{@encoding_task.encoder.id}"
|
157
|
+
else
|
158
|
+
erb :'encoding_tasks/new'
|
159
|
+
end
|
160
|
+
end
|
105
161
|
|
106
162
|
|
107
|
-
#
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
if @encoding_task.update(params[:encoding_task])
|
112
|
-
redirect "/encoders/#{@encoding_task.encoder.id}"
|
113
|
-
else
|
163
|
+
# Gets the edit form for an encoding task
|
164
|
+
#
|
165
|
+
get '/encoding_tasks/:id/edit' do |id|
|
166
|
+
@encoding_task = EncodingTask.get(id)
|
114
167
|
erb :'encoding_tasks/edit'
|
115
168
|
end
|
116
|
-
end
|
117
169
|
|
118
|
-
delete '/encoding_tasks/:id' do |id|
|
119
|
-
@encoding_task = EncodingTask.get(id)
|
120
|
-
@encoder = @encoding_task.encoder
|
121
|
-
@encoding_task.destroy!
|
122
|
-
redirect "/encoders/#{id}"
|
123
|
-
end
|
124
170
|
|
125
|
-
#
|
126
|
-
#
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
171
|
+
# Updates an encoding task.
|
172
|
+
#
|
173
|
+
put '/encoding_tasks/:id' do |id|
|
174
|
+
@encoding_task = EncodingTask.get(id)
|
175
|
+
if @encoding_task.update(params[:encoding_task])
|
176
|
+
redirect "/encoders/#{@encoding_task.encoder.id}"
|
177
|
+
else
|
178
|
+
erb :'encoding_tasks/edit'
|
179
|
+
end
|
180
|
+
end
|
134
181
|
|
182
|
+
# Deletes an encoding task.
|
183
|
+
#
|
184
|
+
delete '/encoding_tasks/:id' do |id|
|
185
|
+
@encoding_task = EncodingTask.get(id)
|
186
|
+
@encoder = @encoding_task.encoder
|
187
|
+
@encoding_task.destroy!
|
188
|
+
redirect "/encoders/#{id}"
|
189
|
+
end
|
135
190
|
|
136
|
-
# Displays a
|
137
|
-
#
|
138
|
-
get '/videos
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
191
|
+
# Displays a list of available videos.
|
192
|
+
#
|
193
|
+
get '/videos' do
|
194
|
+
@completed_videos = Video.complete
|
195
|
+
@encoding_videos = Video.encoding
|
196
|
+
@videos_with_errors = Video.with_errors
|
197
|
+
@unencoded_videos = Video.unencoded
|
198
|
+
erb :'videos/index'
|
199
|
+
end
|
143
200
|
|
144
201
|
|
145
|
-
#
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
@encoder = Encoder.get(params[:encoder_id])
|
150
|
-
@video.encoder = @encoder
|
151
|
-
if @video.save
|
152
|
-
redirect '/videos'
|
153
|
-
else
|
202
|
+
# Displays a form for creating a new video
|
203
|
+
#
|
204
|
+
get '/videos/new' do
|
205
|
+
@video = Video.new
|
154
206
|
@encoders = Encoder.all
|
155
207
|
erb :'videos/new'
|
156
208
|
end
|
157
|
-
end
|
158
209
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
210
|
+
|
211
|
+
# Creates a new video
|
212
|
+
#
|
213
|
+
post '/videos' do
|
214
|
+
@video = Video.new(params[:video])
|
215
|
+
@encoder = Encoder.get(params[:encoder_id])
|
216
|
+
@video.encoder = @encoder
|
217
|
+
if @video.save
|
218
|
+
redirect '/videos'
|
219
|
+
else
|
220
|
+
@encoders = Encoder.all
|
221
|
+
erb :'videos/new'
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
# If any videos are marked as "encoding" when the application starts,
|
227
|
+
# presumably due to an encoding interruption in the last session, they
|
228
|
+
# should be reset.
|
229
|
+
#
|
230
|
+
def reset_encoding_videos
|
231
|
+
Video.encoding.each do |video|
|
232
|
+
video.state = "unencoded"
|
233
|
+
video.save!
|
234
|
+
end
|
163
235
|
end
|
236
|
+
|
164
237
|
end
|
165
238
|
|
166
239
|
|
167
240
|
# Starts the enigma encoding thread. The thread will be reabsorbed into the
|
168
241
|
# main Sinatra/thin thread once the periodic timer is added.
|
169
242
|
#
|
170
|
-
Thread.new do
|
171
|
-
until EM.reactor_running?
|
172
|
-
sleep 1
|
173
|
-
end
|
174
|
-
reset_encoding_videos
|
175
|
-
|
176
|
-
|
177
|
-
queue.start
|
178
|
-
end
|
243
|
+
#Thread.new do
|
244
|
+
# until EM.reactor_running?
|
245
|
+
# sleep 1
|
246
|
+
# end
|
247
|
+
# reset_encoding_videos
|
248
|
+
# queue = EncodingQueue.new
|
249
|
+
#end
|
179
250
|
|
data/lib/enigmamachine.sqlite3
CHANGED
Binary file
|
data/lib/init.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
# Gems
|
2
2
|
#
|
3
3
|
require 'rubygems'
|
4
|
-
require 'sinatra'
|
5
|
-
require '
|
4
|
+
require 'sinatra/base'
|
5
|
+
require 'data_mapper'
|
6
6
|
require 'ruby-debug'
|
7
7
|
require 'eventmachine'
|
8
8
|
require 'rack-flash'
|
9
|
+
require 'dm-validations'
|
10
|
+
require 'dm-migrations'
|
11
|
+
require 'open3'
|
9
12
|
require 'logger'
|
10
13
|
|
14
|
+
# Extensions to Sinatra
|
15
|
+
#
|
16
|
+
require File.dirname(__FILE__) + '/ext/partials'
|
17
|
+
require File.dirname(__FILE__) + '/ext/array_ext'
|
18
|
+
|
11
19
|
# Enigma code
|
12
20
|
#
|
13
21
|
require File.dirname(__FILE__) + '/enigmamachine'
|
@@ -16,60 +24,3 @@ require File.dirname(__FILE__) + '/enigmamachine/models/encoding_task'
|
|
16
24
|
require File.dirname(__FILE__) + '/enigmamachine/models/video'
|
17
25
|
require File.dirname(__FILE__) + '/enigmamachine/encoding_queue'
|
18
26
|
|
19
|
-
# Database config
|
20
|
-
#
|
21
|
-
configure :production do
|
22
|
-
db = "sqlite3:///#{Dir.pwd}/enigmamachine.sqlite3"
|
23
|
-
DataMapper.setup(:default, db)
|
24
|
-
end
|
25
|
-
|
26
|
-
configure :development do
|
27
|
-
db = "sqlite3:///#{Dir.pwd}/enigmamachine.sqlite3"
|
28
|
-
DataMapper.setup(:default, db)
|
29
|
-
end
|
30
|
-
|
31
|
-
configure :test do
|
32
|
-
db = "sqlite3::memory:"
|
33
|
-
DataMapper.setup(:default, db)
|
34
|
-
end
|
35
|
-
|
36
|
-
Video.auto_migrate! unless Video.storage_exists?
|
37
|
-
Encoder.auto_migrate! unless Encoder.storage_exists?
|
38
|
-
EncodingTask.auto_migrate! unless EncodingTask.storage_exists?
|
39
|
-
DataMapper.auto_upgrade!
|
40
|
-
|
41
|
-
# Extensions to Sinatra
|
42
|
-
#
|
43
|
-
require File.dirname(__FILE__) + '/ext/partials'
|
44
|
-
require File.dirname(__FILE__) + '/ext/array_ext'
|
45
|
-
|
46
|
-
# Set the views to the proper path inside the gem
|
47
|
-
#
|
48
|
-
set :views, File.dirname(__FILE__) + '/enigmamachine/views'
|
49
|
-
set :public, File.dirname(__FILE__) + '/enigmamachine/public'
|
50
|
-
|
51
|
-
|
52
|
-
# Register helpers
|
53
|
-
#
|
54
|
-
helpers do
|
55
|
-
include Sinatra::Partials
|
56
|
-
alias_method :h, :escape_html
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
# Set up Rack authentication
|
61
|
-
#
|
62
|
-
use Rack::Auth::Basic do |username, password|
|
63
|
-
[username, password] == ['admin', 'admin']
|
64
|
-
end
|
65
|
-
|
66
|
-
# Include flash notices
|
67
|
-
#
|
68
|
-
use Rack::Session::Cookie
|
69
|
-
use Rack::Flash
|
70
|
-
|
71
|
-
configure do
|
72
|
-
Log = Logger.new("enigma.log")
|
73
|
-
Log.level = Logger::INFO
|
74
|
-
end
|
75
|
-
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
#class TestEncoderQueue < Test::Unit::TestCase
|
4
|
+
|
5
|
+
## context "the encode_next_video method" do
|
6
|
+
## setup do
|
7
|
+
## destroy_all_videos
|
8
|
+
## @video = Video.make
|
9
|
+
## @task = EncodingTask.make(:with_encoder)
|
10
|
+
## @video.encoder = @task.encoder
|
11
|
+
## @video.save
|
12
|
+
### sleep 2
|
13
|
+
## @queue = EncodingQueue.new
|
14
|
+
## @queue.encode_next_video
|
15
|
+
## end
|
16
|
+
|
17
|
+
## should_eventually "exist" do
|
18
|
+
## assert @queue.respond_to? "encode_next_video"
|
19
|
+
## end
|
20
|
+
|
21
|
+
## should_eventually "start encoding the video" do
|
22
|
+
## v = Video.get(@video.id)
|
23
|
+
## assert_equal "encoding", v.state
|
24
|
+
## end
|
25
|
+
## end
|
26
|
+
|
27
|
+
## private
|
28
|
+
|
29
|
+
## def destroy_all_videos
|
30
|
+
## Video.all.each { |v| v.destroy! }
|
31
|
+
## end
|
32
|
+
|
33
|
+
#end
|
34
|
+
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enigmamachine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
8
|
+
- 1
|
7
9
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.2
|
10
|
+
version: 0.1.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- dave
|
@@ -14,42 +15,48 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-07 00:00:00 +01:00
|
18
19
|
default_executable: enigmamachine
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: thoughtbot-shoulda
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
30
33
|
type: :development
|
31
34
|
version_requirements: *id001
|
32
35
|
- !ruby/object:Gem::Dependency
|
33
|
-
name:
|
36
|
+
name: data_mapper
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - "="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
39
44
|
segments:
|
45
|
+
- 1
|
40
46
|
- 0
|
41
|
-
-
|
42
|
-
|
43
|
-
version: 0.10.2
|
47
|
+
- 0
|
48
|
+
version: 1.0.0
|
44
49
|
type: :runtime
|
45
50
|
version_requirements: *id002
|
46
51
|
- !ruby/object:Gem::Dependency
|
47
52
|
name: eventmachine
|
48
53
|
prerelease: false
|
49
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
50
56
|
requirements:
|
51
57
|
- - "="
|
52
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 59
|
53
60
|
segments:
|
54
61
|
- 0
|
55
62
|
- 12
|
@@ -58,89 +65,79 @@ dependencies:
|
|
58
65
|
type: :runtime
|
59
66
|
version_requirements: *id003
|
60
67
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
68
|
+
name: dm-sqlite-adapter
|
62
69
|
prerelease: false
|
63
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
64
72
|
requirements:
|
65
|
-
- - "
|
73
|
+
- - "="
|
66
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 23
|
67
76
|
segments:
|
77
|
+
- 1
|
68
78
|
- 0
|
69
|
-
|
79
|
+
- 0
|
80
|
+
version: 1.0.0
|
70
81
|
type: :runtime
|
71
82
|
version_requirements: *id004
|
72
83
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
84
|
+
name: rack-flash
|
74
85
|
prerelease: false
|
75
86
|
requirement: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
76
88
|
requirements:
|
77
89
|
- - ">="
|
78
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
79
92
|
segments:
|
80
93
|
- 0
|
81
94
|
version: "0"
|
82
95
|
type: :runtime
|
83
96
|
version_requirements: *id005
|
84
97
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
98
|
+
name: ruby-debug
|
86
99
|
prerelease: false
|
87
100
|
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
88
102
|
requirements:
|
89
103
|
- - ">="
|
90
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
91
106
|
segments:
|
92
107
|
- 0
|
93
108
|
version: "0"
|
94
109
|
type: :runtime
|
95
110
|
version_requirements: *id006
|
96
111
|
- !ruby/object:Gem::Dependency
|
97
|
-
name:
|
112
|
+
name: sinatra
|
98
113
|
prerelease: false
|
99
114
|
requirement: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
100
116
|
requirements:
|
101
|
-
- - "
|
117
|
+
- - "="
|
102
118
|
- !ruby/object:Gem::Version
|
119
|
+
hash: 23
|
103
120
|
segments:
|
121
|
+
- 1
|
104
122
|
- 0
|
105
|
-
|
123
|
+
- 0
|
124
|
+
version: 1.0.0
|
106
125
|
type: :runtime
|
107
126
|
version_requirements: *id007
|
108
127
|
- !ruby/object:Gem::Dependency
|
109
|
-
name:
|
128
|
+
name: thin
|
110
129
|
prerelease: false
|
111
130
|
requirement: &id008 !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
112
132
|
requirements:
|
113
133
|
- - ">="
|
114
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
115
136
|
segments:
|
116
137
|
- 0
|
117
138
|
version: "0"
|
118
139
|
type: :runtime
|
119
140
|
version_requirements: *id008
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
|
-
name: do_sqlite3
|
122
|
-
prerelease: false
|
123
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - ">="
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
segments:
|
128
|
-
- 0
|
129
|
-
version: "0"
|
130
|
-
type: :runtime
|
131
|
-
version_requirements: *id009
|
132
|
-
- !ruby/object:Gem::Dependency
|
133
|
-
name: thin
|
134
|
-
prerelease: false
|
135
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - ">="
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
segments:
|
140
|
-
- 0
|
141
|
-
version: "0"
|
142
|
-
type: :runtime
|
143
|
-
version_requirements: *id010
|
144
141
|
description: A RESTful video encoder which you can use as either a front-end to ffmpeg or headless on a server.
|
145
142
|
email: dave@caprica
|
146
143
|
executables:
|
@@ -200,7 +197,7 @@ files:
|
|
200
197
|
- test/support/afile.mpg
|
201
198
|
- test/support/blueprints.rb
|
202
199
|
- test/test_encoder.rb
|
203
|
-
- test/
|
200
|
+
- test/test_encoding_queue.rb
|
204
201
|
- test/test_enigmamachine.rb
|
205
202
|
- test/test_video.rb
|
206
203
|
has_rdoc: true
|
@@ -213,30 +210,34 @@ rdoc_options:
|
|
213
210
|
require_paths:
|
214
211
|
- lib
|
215
212
|
required_ruby_version: !ruby/object:Gem::Requirement
|
213
|
+
none: false
|
216
214
|
requirements:
|
217
215
|
- - ">="
|
218
216
|
- !ruby/object:Gem::Version
|
217
|
+
hash: 3
|
219
218
|
segments:
|
220
219
|
- 0
|
221
220
|
version: "0"
|
222
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
|
+
none: false
|
223
223
|
requirements:
|
224
224
|
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
+
hash: 3
|
226
227
|
segments:
|
227
228
|
- 0
|
228
229
|
version: "0"
|
229
230
|
requirements: []
|
230
231
|
|
231
232
|
rubyforge_project:
|
232
|
-
rubygems_version: 1.3.
|
233
|
+
rubygems_version: 1.3.7
|
233
234
|
signing_key:
|
234
235
|
specification_version: 3
|
235
236
|
summary: A RESTful video encoder.
|
236
237
|
test_files:
|
237
|
-
- test/helper.rb
|
238
238
|
- test/support/blueprints.rb
|
239
|
+
- test/test_encoding_queue.rb
|
240
|
+
- test/helper.rb
|
239
241
|
- test/test_encoder.rb
|
240
|
-
- test/test_encoder_queue.rb
|
241
242
|
- test/test_enigmamachine.rb
|
242
243
|
- test/test_video.rb
|
data/test/test_encoder_queue.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class TestEncoderQueue < Test::Unit::TestCase
|
4
|
-
|
5
|
-
context "the encode_next_video method" do
|
6
|
-
setup do
|
7
|
-
destroy_all_videos
|
8
|
-
@video = Video.make
|
9
|
-
@task = EncodingTask.make(:with_encoder)
|
10
|
-
@video.encoder = @task.encoder
|
11
|
-
@video.save
|
12
|
-
@queue = EncodingQueue.new
|
13
|
-
@queue.encode_next_video
|
14
|
-
sleep 1
|
15
|
-
end
|
16
|
-
|
17
|
-
should "exist" do
|
18
|
-
assert @queue.respond_to? "encode_next_video"
|
19
|
-
end
|
20
|
-
|
21
|
-
should "start encoding the video" do
|
22
|
-
v = Video.get(@video.id)
|
23
|
-
assert_equal "encoding", v.state
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def destroy_all_videos
|
30
|
-
Video.all.each { |v| v.destroy! }
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|