active_encode 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CODE_OF_CONDUCT.md +36 -0
- data/CONTRIBUTING.md +23 -21
- data/LICENSE +11 -199
- data/README.md +66 -24
- data/SUPPORT.md +5 -0
- data/active_encode.gemspec +2 -1
- data/app/controllers/active_encode/encode_record_controller.rb +12 -0
- data/config/routes.rb +4 -0
- data/lib/active_encode/engine_adapters/elastic_transcoder_adapter.rb +115 -39
- data/lib/active_encode/engine_adapters/ffmpeg_adapter.rb +5 -2
- data/lib/active_encode/version.rb +1 -1
- data/lib/file_locator.rb +94 -0
- data/spec/controllers/encode_record_controller_spec.rb +52 -0
- data/spec/integration/elastic_transcoder_adapter_spec.rb +44 -10
- data/spec/integration/ffmpeg_adapter_spec.rb +5 -1
- data/spec/routing/encode_record_controller_routing_spec.rb +9 -0
- data/spec/units/file_locator_spec.rb +128 -0
- metadata +32 -8
@@ -8,6 +8,10 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
8
8
|
Dir.mktmpdir do |dir|
|
9
9
|
@dir = dir
|
10
10
|
example.run
|
11
|
+
Dir.foreach(dir) do |e|
|
12
|
+
next if e == "." || e == ".."
|
13
|
+
FileUtils.rm_rf(File.join(dir,e))
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
ActiveEncode::Base.engine_adapter = :test
|
@@ -33,7 +37,7 @@ describe ActiveEncode::EngineAdapters::FfmpegAdapter do
|
|
33
37
|
let(:failed_job) { find_encode 'failed-id' }
|
34
38
|
let(:completed_tech_metadata) { {:audio_bitrate => 171030,
|
35
39
|
:audio_codec => 'mp4a-40-2',
|
36
|
-
:duration =>
|
40
|
+
:duration => 6315,
|
37
41
|
:file_size => 199160,
|
38
42
|
:frame_rate => 23.719,
|
39
43
|
:height => 110.0,
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ActiveEncode::EncodeRecordController, type: :routing do
|
4
|
+
routes { ActiveEncode::Engine.routes }
|
5
|
+
|
6
|
+
it "routes to the show action" do
|
7
|
+
expect(get: encode_record_path(1)).to route_to(controller: "active_encode/encode_record", action: "show", id: "1")
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Copyright 2011-2018, The Trustees of Indiana University and Northwestern
|
2
|
+
# University. Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
#
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
10
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
12
|
+
# specific language governing permissions and limitations under the License.
|
13
|
+
# --- END LICENSE_HEADER BLOCK ---
|
14
|
+
require 'aws-sdk'
|
15
|
+
require 'rails_helper'
|
16
|
+
|
17
|
+
describe FileLocator, type: :service do
|
18
|
+
before do
|
19
|
+
Aws.config[:stub_responses] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'S3File Class' do
|
23
|
+
let(:bucket) { "mybucket" }
|
24
|
+
let(:key) { "mykey.mp4" }
|
25
|
+
let(:s3file) { FileLocator::S3File.new("s3://#{bucket}/#{key}") }
|
26
|
+
|
27
|
+
it "should be able to initialize from an S3 URI" do
|
28
|
+
expect(s3file.bucket).to eq bucket
|
29
|
+
expect(s3file.key).to eq key
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return an S3 Object" do
|
33
|
+
s3_object = s3file.object
|
34
|
+
expect(s3_object).to be_an Aws::S3::Object
|
35
|
+
expect(s3_object.bucket_name).to eq bucket
|
36
|
+
expect(s3_object.key).to eq key
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Local file" do
|
41
|
+
let(:path) { "/path/to/file.mp4" }
|
42
|
+
let(:source) { "file://#{path}" }
|
43
|
+
let(:locator) { FileLocator.new(source) }
|
44
|
+
|
45
|
+
it "should return the correct uri" do
|
46
|
+
expect(locator.uri).to eq Addressable::URI.parse(source)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return the correct location" do
|
50
|
+
expect(locator.location).to eq path
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should tell if file exists" do
|
54
|
+
allow(File).to receive(:exist?).with(path) { true }
|
55
|
+
expect(locator.exist?).to be_truthy
|
56
|
+
end
|
57
|
+
|
58
|
+
context "return file" do
|
59
|
+
let(:file) { double(File) }
|
60
|
+
before :each do
|
61
|
+
allow(File).to receive(:open).and_return file
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should return reader" do
|
65
|
+
expect(locator.reader).to eq file
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return attachment" do
|
69
|
+
expect(locator.attachment).to eq file
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "s3 file" do
|
75
|
+
let(:bucket) { "mybucket" }
|
76
|
+
let(:key) { "mykey.mp4" }
|
77
|
+
let(:source) { "s3://#{bucket}/#{key}" }
|
78
|
+
let(:locator) { FileLocator.new(source) }
|
79
|
+
|
80
|
+
it "should return the correct uri" do
|
81
|
+
expect(locator.uri).to eq Addressable::URI.parse(source)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return the correct location" do
|
85
|
+
expect(locator.location).to start_with "https://#{bucket}.s3.us-stubbed-1.amazonaws.com/#{key}"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should tell if file exists" do
|
89
|
+
expect(locator.exist?).to be_truthy
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should return reader" do
|
93
|
+
expect(locator.reader).to be_a StringIO
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return attachment" do
|
97
|
+
expect(locator.attachment).to eq Addressable::URI.parse(source)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "Other file" do
|
102
|
+
let(:path) { "/path/to/file.mp4" }
|
103
|
+
let(:source) { "bogus://#{path}" }
|
104
|
+
let(:locator) { FileLocator.new(source) }
|
105
|
+
|
106
|
+
it "should return the correct uri" do
|
107
|
+
expect(locator.uri).to eq Addressable::URI.parse(source)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should return the correct location" do
|
111
|
+
expect(locator.location).to eq source
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should tell if file exists" do
|
115
|
+
expect(locator.exist?).to be_falsy
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should return reader" do
|
119
|
+
io = double(IO)
|
120
|
+
allow(Kernel).to receive(:open).and_return io
|
121
|
+
expect(locator.reader).to eq io
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return attachment" do
|
125
|
+
expect(locator.attachment).to eq locator.location
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_encode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein, Chris Colvard, Phuong Dinh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: database_cleaner
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: engine_cart
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,14 +163,18 @@ files:
|
|
149
163
|
- ".gitignore"
|
150
164
|
- ".rubocop.yml"
|
151
165
|
- ".travis.yml"
|
166
|
+
- CODE_OF_CONDUCT.md
|
152
167
|
- CONTRIBUTING.md
|
153
168
|
- Gemfile
|
154
169
|
- LICENSE
|
155
170
|
- README.md
|
156
171
|
- Rakefile
|
172
|
+
- SUPPORT.md
|
157
173
|
- active_encode.gemspec
|
174
|
+
- app/controllers/active_encode/encode_record_controller.rb
|
158
175
|
- app/jobs/active_encode/polling_job.rb
|
159
176
|
- app/models/active_encode/encode_record.rb
|
177
|
+
- config/routes.rb
|
160
178
|
- db/migrate/20180822021048_create_active_encode_encode_records.rb
|
161
179
|
- lib/active_encode.rb
|
162
180
|
- lib/active_encode/base.rb
|
@@ -178,6 +196,8 @@ files:
|
|
178
196
|
- lib/active_encode/status.rb
|
179
197
|
- lib/active_encode/technical_metadata.rb
|
180
198
|
- lib/active_encode/version.rb
|
199
|
+
- lib/file_locator.rb
|
200
|
+
- spec/controllers/encode_record_controller_spec.rb
|
181
201
|
- spec/fixtures/Bars_512kb.mp4
|
182
202
|
- spec/fixtures/elastic_transcoder/input_completed.json
|
183
203
|
- spec/fixtures/elastic_transcoder/input_generic.json
|
@@ -238,12 +258,14 @@ files:
|
|
238
258
|
- spec/integration/matterhorn_adapter_spec.rb
|
239
259
|
- spec/integration/zencoder_adapter_spec.rb
|
240
260
|
- spec/rails_helper.rb
|
261
|
+
- spec/routing/encode_record_controller_routing_spec.rb
|
241
262
|
- spec/shared_specs/engine_adapter_specs.rb
|
242
263
|
- spec/spec_helper.rb
|
243
264
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
244
265
|
- spec/units/callbacks_spec.rb
|
245
266
|
- spec/units/core_spec.rb
|
246
267
|
- spec/units/engine_adapter_spec.rb
|
268
|
+
- spec/units/file_locator_spec.rb
|
247
269
|
- spec/units/global_id_spec.rb
|
248
270
|
- spec/units/input_spec.rb
|
249
271
|
- spec/units/output_spec.rb
|
@@ -270,12 +292,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
292
|
- !ruby/object:Gem::Version
|
271
293
|
version: '0'
|
272
294
|
requirements: []
|
273
|
-
|
274
|
-
rubygems_version: 2.6.14
|
295
|
+
rubygems_version: 3.0.1
|
275
296
|
signing_key:
|
276
297
|
specification_version: 4
|
277
298
|
summary: Declare encode job classes that can be run by a variety of encoding services
|
278
299
|
test_files:
|
300
|
+
- spec/controllers/encode_record_controller_spec.rb
|
279
301
|
- spec/fixtures/Bars_512kb.mp4
|
280
302
|
- spec/fixtures/elastic_transcoder/input_completed.json
|
281
303
|
- spec/fixtures/elastic_transcoder/input_generic.json
|
@@ -336,12 +358,14 @@ test_files:
|
|
336
358
|
- spec/integration/matterhorn_adapter_spec.rb
|
337
359
|
- spec/integration/zencoder_adapter_spec.rb
|
338
360
|
- spec/rails_helper.rb
|
361
|
+
- spec/routing/encode_record_controller_routing_spec.rb
|
339
362
|
- spec/shared_specs/engine_adapter_specs.rb
|
340
363
|
- spec/spec_helper.rb
|
341
364
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
342
365
|
- spec/units/callbacks_spec.rb
|
343
366
|
- spec/units/core_spec.rb
|
344
367
|
- spec/units/engine_adapter_spec.rb
|
368
|
+
- spec/units/file_locator_spec.rb
|
345
369
|
- spec/units/global_id_spec.rb
|
346
370
|
- spec/units/input_spec.rb
|
347
371
|
- spec/units/output_spec.rb
|