hydra-derivatives 3.3.2 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +69 -0
- data/.rubocop.yml +53 -34
- data/.rubocop_todo.yml +42 -9
- data/.solr_wrapper +2 -0
- data/CODE_OF_CONDUCT.md +36 -0
- data/CONTRIBUTING.md +23 -21
- data/Gemfile +5 -3
- data/README.md +74 -5
- data/Rakefile +13 -1
- data/SUPPORT.md +5 -0
- data/VERSION +1 -1
- data/config/fcrepo_wrapper_test.yml +6 -0
- data/config/solr_wrapper_test.yml +2 -0
- data/hydra-derivatives.gemspec +16 -16
- data/lib/hydra/derivatives.rb +2 -2
- data/lib/hydra/derivatives/audio_encoder.rb +1 -1
- data/lib/hydra/derivatives/config.rb +1 -1
- data/lib/hydra/derivatives/io_decorator.rb +13 -6
- data/lib/hydra/derivatives/logger.rb +5 -1
- data/lib/hydra/derivatives/processors/active_encode.rb +1 -1
- data/lib/hydra/derivatives/processors/document.rb +4 -1
- data/lib/hydra/derivatives/processors/full_text.rb +20 -6
- data/lib/hydra/derivatives/processors/jpeg2k_image.rb +7 -16
- data/lib/hydra/derivatives/processors/processor.rb +0 -7
- data/lib/hydra/derivatives/processors/shell_based_processor.rb +5 -3
- data/lib/hydra/derivatives/runners/full_text_extract.rb +1 -1
- data/lib/hydra/derivatives/services/capability_service.rb +1 -1
- data/lib/hydra/derivatives/services/persist_basic_contained_output_file_service.rb +5 -1
- data/lib/hydra/derivatives/services/persist_output_file_service.rb +5 -3
- data/solr/config/schema.xml +0 -2
- data/solr/config/xslt/example.xsl +1 -1
- data/solr/config/xslt/luke.xsl +1 -1
- metadata +187 -138
- data/.travis.yml +0 -26
- data/spec/fixtures/FlashPix.ppt +0 -0
- data/spec/fixtures/adobe1998.tif +0 -0
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/jpeg2k_config.yml +0 -20
- data/spec/fixtures/piano_note.wav +0 -0
- data/spec/fixtures/sample.rtf +0 -68
- data/spec/fixtures/test.dng +0 -0
- data/spec/fixtures/test.doc +0 -0
- data/spec/fixtures/test.docx +0 -0
- data/spec/fixtures/test.pdf +0 -0
- data/spec/fixtures/test.pptx +0 -0
- data/spec/fixtures/test.tif +0 -0
- data/spec/fixtures/test.xls +0 -0
- data/spec/fixtures/test.xlsx +0 -0
- data/spec/fixtures/world.png +0 -0
- data/spec/processors/active_encode_spec.rb +0 -132
- data/spec/processors/document_spec.rb +0 -41
- data/spec/processors/full_text_spec.rb +0 -70
- data/spec/processors/image_spec.rb +0 -122
- data/spec/processors/jpeg2k_spec.rb +0 -82
- data/spec/processors/processor_spec.rb +0 -35
- data/spec/processors/shell_based_processor_spec.rb +0 -19
- data/spec/processors/video_spec.rb +0 -40
- data/spec/runners/active_encode_derivatives_spec.rb +0 -38
- data/spec/services/audio_derivatives_spec.rb +0 -78
- data/spec/services/persist_basic_contained_output_file_service_spec.rb +0 -40
- data/spec/services/persist_external_file_output_file_service_spec.rb +0 -26
- data/spec/services/remote_source_file_spec.rb +0 -33
- data/spec/services/retrieve_source_file_service_spec.rb +0 -60
- data/spec/services/tempfile_service_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -33
- data/spec/units/audio_encoder_spec.rb +0 -23
- data/spec/units/config_spec.rb +0 -50
- data/spec/units/derivatives_spec.rb +0 -62
- data/spec/units/io_decorator_spec.rb +0 -33
- data/spec/units/logger_spec.rb +0 -22
- data/spec/units/transcoding_spec.rb +0 -346
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Derivatives::TempfileService do
|
4
|
-
let(:class_with_metadata_extraction) do
|
5
|
-
Class.new do
|
6
|
-
attr_reader :content, :mime_type, :uri
|
7
|
-
|
8
|
-
def initialize(options = {})
|
9
|
-
@content = options.fetch(:content, '')
|
10
|
-
@mime_uype = options.fetch(:mime_type, nil)
|
11
|
-
@uri = 'http://example.com/pid/123'
|
12
|
-
end
|
13
|
-
|
14
|
-
def has_content?
|
15
|
-
content.present?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:initialization_options) { { content: 'abc', mime_type: 'text/plain' } }
|
21
|
-
|
22
|
-
let(:file) { class_with_metadata_extraction.new(initialization_options) }
|
23
|
-
|
24
|
-
subject { described_class.new(file) }
|
25
|
-
context '#tempfile' do
|
26
|
-
it 'has a method called to_tempfile' do
|
27
|
-
expect { |b| subject.tempfile(&b) }.to yield_with_args(Tempfile)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
ENV['environment'] ||= 'test'
|
2
|
-
|
3
|
-
require 'simplecov'
|
4
|
-
require 'coveralls'
|
5
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter '/spec'
|
8
|
-
end
|
9
|
-
Coveralls.wear!
|
10
|
-
|
11
|
-
# - RSpec adds ./lib to the $LOAD_PATH
|
12
|
-
require 'hydra/derivatives'
|
13
|
-
# Resque.inline = Rails.env.test?
|
14
|
-
require 'byebug' unless ENV['TRAVIS']
|
15
|
-
|
16
|
-
require 'active_fedora/cleaner'
|
17
|
-
ActiveFedora::Base.logger = Logger.new(STDOUT)
|
18
|
-
RSpec.configure do |config|
|
19
|
-
config.before(:each) do
|
20
|
-
ActiveFedora::Cleaner.clean!
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Workaround for RAW image support until these are pushed upstream to
|
25
|
-
# the MIME Types gem
|
26
|
-
require 'mime-types'
|
27
|
-
dng_format = MIME::Type.new('image/x-adobe-dng')
|
28
|
-
dng_format.extensions = 'dng'
|
29
|
-
MIME::Types.add(dng_format)
|
30
|
-
|
31
|
-
def fixture_path
|
32
|
-
File.expand_path("../fixtures", __FILE__)
|
33
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Derivatives::AudioEncoder do
|
4
|
-
before do
|
5
|
-
@audio_encoder = described_class.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe 'fdk_aac?' do
|
9
|
-
it 'outpus libfdk_aac if your ffmpeg was compiled with the library' do
|
10
|
-
enable_libfdk_flags = '--enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --with-fdk-aac'
|
11
|
-
@audio_encoder.instance_variable_set(:@ffmpeg_output, enable_libfdk_flags)
|
12
|
-
audio_encoder = @audio_encoder.audio_encoder
|
13
|
-
expect(audio_encoder).to eq('libfdk_aac')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'outputs aac if your ffmpeg was compiled with the library' do
|
17
|
-
enable_libfdk_flags = '--enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample'
|
18
|
-
@audio_encoder.instance_variable_set(:@ffmpeg_output, enable_libfdk_flags)
|
19
|
-
audio_encoder = @audio_encoder.audio_encoder
|
20
|
-
expect(audio_encoder).to eq('aac')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/spec/units/config_spec.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "the configuration" do
|
4
|
-
subject { Hydra::Derivatives::Config.new }
|
5
|
-
|
6
|
-
before do
|
7
|
-
# It's not always /tmp; it depends on OS and ENV vars
|
8
|
-
allow(Dir).to receive(:tmpdir).and_return('/tmp')
|
9
|
-
end
|
10
|
-
|
11
|
-
it "has some configuration defaults" do
|
12
|
-
expect(subject.ffmpeg_path).to eq('ffmpeg')
|
13
|
-
expect(subject.enable_ffmpeg).to be true
|
14
|
-
expect(subject.libreoffice_path).to eq('soffice')
|
15
|
-
expect(subject.temp_file_base).to eq('/tmp')
|
16
|
-
expect(subject.fits_path).to eq('fits.sh')
|
17
|
-
expect(subject.kdu_compress_path).to eq('kdu_compress')
|
18
|
-
expect(subject.output_file_service).to eq(Hydra::Derivatives::PersistBasicContainedOutputFileService)
|
19
|
-
expect(subject.source_file_service).to eq(Hydra::Derivatives::RetrieveSourceFileService)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "lets you change the configuration" do
|
23
|
-
subject.ffmpeg_path = '/usr/local/ffmpeg-1.0/bin/ffmpeg'
|
24
|
-
expect(subject.ffmpeg_path).to eq('/usr/local/ffmpeg-1.0/bin/ffmpeg')
|
25
|
-
|
26
|
-
subject.kdu_compress_path = '/opt/local/bin/kdu_compress'
|
27
|
-
expect(subject.kdu_compress_path).to eq('/opt/local/bin/kdu_compress')
|
28
|
-
|
29
|
-
subject.enable_ffmpeg = false
|
30
|
-
expect(subject.enable_ffmpeg).to be false
|
31
|
-
end
|
32
|
-
|
33
|
-
it "lets you set a custom output file service" do
|
34
|
-
output_file_service = double("MyOutputFileService")
|
35
|
-
subject.output_file_service = output_file_service
|
36
|
-
expect(subject.output_file_service).to eq(output_file_service)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "lets you set a custom source file service" do
|
40
|
-
source_file_service = double("MyRetriveSourceFileService")
|
41
|
-
subject.source_file_service = source_file_service
|
42
|
-
expect(subject.source_file_service).to eq(source_file_service)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "lets you set the poll time for ActiveEncode jobs" do
|
46
|
-
expect(subject.active_encode_poll_time).to eq 10
|
47
|
-
subject.active_encode_poll_time = 15
|
48
|
-
expect(subject.active_encode_poll_time).to eq 15
|
49
|
-
end
|
50
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Derivatives do
|
4
|
-
before(:all) do
|
5
|
-
class CustomFile < ActiveFedora::Base
|
6
|
-
include Hydra::Derivatives
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:all) { Object.send(:remove_const, :CustomFile) }
|
11
|
-
|
12
|
-
describe "source_file_service" do
|
13
|
-
before { subject.source_file_service = custom_source_file_service }
|
14
|
-
|
15
|
-
context "as a global configuration setting" do
|
16
|
-
let(:custom_source_file_service) { "fake service" }
|
17
|
-
subject { CustomFile }
|
18
|
-
|
19
|
-
it "utilizes the default source file service" do
|
20
|
-
expect(subject.source_file_service).to eq(custom_source_file_service)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "as an instance level configuration setting" do
|
25
|
-
let(:custom_source_file_service) { "another fake service" }
|
26
|
-
subject { CustomFile.new }
|
27
|
-
|
28
|
-
it "accepts a custom source file service as an option" do
|
29
|
-
expect(subject.source_file_service).to eq(custom_source_file_service)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
Hydra::Derivatives::CONFIG_METHODS.each do |method|
|
35
|
-
describe method.to_s do
|
36
|
-
it 'returns the config value' do
|
37
|
-
expect(subject.send(method)).to eq subject.config.send(method)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
describe "#{method}=" do
|
41
|
-
it 'stores config changes' do
|
42
|
-
expect { subject.send("#{method}=", "new_value") }.to change { subject.config.send(method) }.from(subject.config.send(method)).to("new_value")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'reset_config!' do
|
48
|
-
it "resets the configuration" do
|
49
|
-
subject.ffmpeg_path = '/usr/local/ffmpeg-1.0/bin/ffmpeg'
|
50
|
-
subject.reset_config!
|
51
|
-
expect(subject.ffmpeg_path).to eq('ffmpeg')
|
52
|
-
|
53
|
-
subject.kdu_compress_path = '/usr/local/bin/kdu_compress'
|
54
|
-
subject.reset_config!
|
55
|
-
expect(subject.kdu_compress_path).to eq('kdu_compress')
|
56
|
-
|
57
|
-
subject.active_encode_poll_time = 2
|
58
|
-
subject.reset_config!
|
59
|
-
expect(subject.active_encode_poll_time).to eq 10
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
describe Hydra::Derivatives::IoDecorator do
|
5
|
-
let(:file) { StringIO.new('hello') }
|
6
|
-
|
7
|
-
context "one argument" do
|
8
|
-
let(:decorator) { described_class.new(file) }
|
9
|
-
describe "#read" do
|
10
|
-
subject { decorator.read }
|
11
|
-
it { is_expected.to eq 'hello' }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "three arguments" do
|
16
|
-
let(:decorator) { described_class.new(file, 'text/plain', 'help.txt') }
|
17
|
-
|
18
|
-
describe "#read" do
|
19
|
-
subject { decorator.read }
|
20
|
-
it { is_expected.to eq 'hello' }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "mime_type" do
|
24
|
-
subject { decorator.mime_type }
|
25
|
-
it { is_expected.to eq 'text/plain' }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "original_name" do
|
29
|
-
subject { decorator.original_name }
|
30
|
-
it { is_expected.to eq 'help.txt' }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/units/logger_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hydra::Derivatives::Logger do
|
4
|
-
context "with log levels" do
|
5
|
-
let(:levels) { %w(unknown fatal error warn info debug) }
|
6
|
-
|
7
|
-
it "responds successfully" do
|
8
|
-
levels.each do |level|
|
9
|
-
expect(described_class.respond_to?(level)).to be_truthy
|
10
|
-
end
|
11
|
-
end
|
12
|
-
it "accepts messages" do
|
13
|
-
expect(described_class.warn("message")).to be_truthy
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context "with garbage" do
|
18
|
-
it "raises an error" do
|
19
|
-
expect { described_class.garbage }.to raise_error(NoMethodError)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,346 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Transcoding" do
|
4
|
-
before(:all) do
|
5
|
-
class GenericFile < ActiveFedora::Base
|
6
|
-
include Hydra::Derivatives
|
7
|
-
property :mime_type_from_fits, predicate: ::RDF::URI('http://example.com/mime'), multiple: false
|
8
|
-
has_subresource 'original_file'
|
9
|
-
|
10
|
-
def create_derivatives(_filename)
|
11
|
-
case mime_type_from_fits
|
12
|
-
when 'application/pdf'
|
13
|
-
PdfDerivatives.create(self, source: :original_file,
|
14
|
-
outputs: [{ label: :thumb, size: "100x100>", url: "#{uri}/original_file_thumb" }])
|
15
|
-
FullTextExtract.create(self, source: :original_file, outputs: [{ url: "#{uri}/fulltext" }])
|
16
|
-
when 'audio/x-wav'
|
17
|
-
AudioDerivatives.create(self, source: :original_file,
|
18
|
-
outputs: [
|
19
|
-
{ label: :mp3, format: 'mp3', url: "#{uri}/original_file_mp3" },
|
20
|
-
{ label: :ogg, format: 'ogg', url: "#{uri}/original_file_ogg" }])
|
21
|
-
when 'video/x-msvideo'
|
22
|
-
VideoDerivatives.create(self, source: :original_file,
|
23
|
-
outputs: [
|
24
|
-
{ label: :mp4, format: 'mp4', url: "#{uri}/original_file_mp4" },
|
25
|
-
{ label: :webm, format: 'webm', url: "#{uri}/original_file_webm" },
|
26
|
-
{ label: :thumbnail, format: 'jpg', url: "#{uri}/thumbnail" }])
|
27
|
-
when 'image/png', 'image/jpg'
|
28
|
-
ImageDerivatives.create(self, source: :original_file,
|
29
|
-
outputs: [
|
30
|
-
{ label: :medium, size: "300x300>", url: "#{uri}/original_file_medium" },
|
31
|
-
{ label: :thumb, size: "100x100>", url: "#{uri}/original_file_thumb" },
|
32
|
-
{ label: :access, format: 'jpg', url: "#{uri}/access" },
|
33
|
-
])
|
34
|
-
when 'application/vnd.ms-powerpoint'
|
35
|
-
DocumentDerivatives.create(self, source: :original_file,
|
36
|
-
outputs: [
|
37
|
-
{ label: :preservation, format: 'pptx', url: "#{uri}/original_file_preservation" },
|
38
|
-
{ label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
|
39
|
-
{ label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
|
40
|
-
when 'text/rtf'
|
41
|
-
DocumentDerivatives.create(self, source: :original_file,
|
42
|
-
outputs: [
|
43
|
-
{ label: :preservation, format: 'odt', url: "#{uri}/original_file_preservation" },
|
44
|
-
{ label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
|
45
|
-
{ label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
|
46
|
-
when 'application/msword'
|
47
|
-
DocumentDerivatives.create(self, source: :original_file,
|
48
|
-
outputs: [
|
49
|
-
{ label: :preservation, format: 'docx', url: "#{uri}/original_file_preservation" },
|
50
|
-
{ label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
|
51
|
-
{ label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
|
52
|
-
when 'application/vnd.ms-excel'
|
53
|
-
DocumentDerivatives.create(self, source: :original_file,
|
54
|
-
outputs: [
|
55
|
-
{ label: :preservation, format: 'xlsx', url: "#{uri}/original_file_preservation" },
|
56
|
-
{ label: :access, format: 'pdf', url: "#{uri}/original_file_access" },
|
57
|
-
{ label: :thumnail, format: 'jpg', url: "#{uri}/original_file_thumbnail" }])
|
58
|
-
when 'image/tiff'
|
59
|
-
Jpeg2kImageDerivatives.create(self, source: :original_file,
|
60
|
-
outputs: [
|
61
|
-
{ label: :resized, format: 'jp2', recipe: :default, processor: 'jpeg2k_image', resize: "600x600>", url: "#{uri}/resized" },
|
62
|
-
{ label: :config_lookup, format: 'jp2', recipe: :default, processor: 'jpeg2k_image', url: "#{uri}/config_lookup" },
|
63
|
-
{ label: :string_recipe, format: 'jp2', recipe: '-jp2_space sRGB', processor: 'jpeg2k_image', url: "#{uri}/string_recipe" },
|
64
|
-
{ label: :diy, format: 'jp2', processor: 'jpeg2k_image', url: "#{uri}/original_file_diy" }])
|
65
|
-
when 'image/x-adobe-dng'
|
66
|
-
ImageDerivatives.create(self, source: :original_file,
|
67
|
-
outputs: [
|
68
|
-
{ label: :access, size: "300x300>", format: 'jpg', processor: :raw_image, url: "#{uri}/original_file_access" },
|
69
|
-
{ label: :thumb, size: "100x100>", format: 'jpg', processor: :raw_image, url: "#{uri}/original_file_thumb" }])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
after(:all) do
|
76
|
-
Object.send(:remove_const, :GenericFile)
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "with an attached image" do
|
80
|
-
let(:filename) { File.expand_path('../../fixtures/world.png', __FILE__) }
|
81
|
-
let(:attachment) { File.open(filename) }
|
82
|
-
let(:file) do
|
83
|
-
GenericFile.new(mime_type_from_fits: 'image/png') do |f|
|
84
|
-
f.original_file.content = attachment
|
85
|
-
f.original_file.mime_type = f.mime_type_from_fits
|
86
|
-
f.save!
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
it "transcodes" do
|
91
|
-
expect(file.attached_files.key?('original_file_medium')).to be_falsey
|
92
|
-
file.create_derivatives(filename)
|
93
|
-
file.reload
|
94
|
-
expect(file.attached_files['original_file_medium']).to have_content
|
95
|
-
expect(file.attached_files['original_file_medium'].mime_type).to eq('image/png')
|
96
|
-
expect(file.attached_files['original_file_thumb']).to have_content
|
97
|
-
expect(file.attached_files['original_file_thumb'].mime_type).to eq('image/png')
|
98
|
-
expect(file.attached_files['access']).to have_content
|
99
|
-
expect(file.attached_files['access'].mime_type).to eq('image/jpeg')
|
100
|
-
expect(file.attached_files.key?('original_file_text')).to be_falsey
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "with an attached RAW image", requires_imagemagick: true do
|
105
|
-
let(:filename) { File.expand_path('../../fixtures/test.dng', __FILE__) }
|
106
|
-
let(:attachment) { File.open(filename) }
|
107
|
-
let(:file) do
|
108
|
-
GenericFile.new(mime_type_from_fits: 'image/x-adobe-dng') do |f|
|
109
|
-
f.original_file.content = attachment
|
110
|
-
f.original_file.mime_type = f.mime_type_from_fits
|
111
|
-
f.save!
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
it "transcodes" do
|
116
|
-
expect(file.attached_files.key?('original_file_access')).to be_falsey
|
117
|
-
expect(file.attached_files.key?('original_file_thumb')).to be_falsey
|
118
|
-
|
119
|
-
file.create_derivatives(filename)
|
120
|
-
file.reload
|
121
|
-
expect(file.attached_files['original_file_access']).to have_content
|
122
|
-
expect(file.attached_files['original_file_access'].mime_type).to eq('image/jpeg')
|
123
|
-
expect(file.attached_files['original_file_thumb']).to have_content
|
124
|
-
expect(file.attached_files['original_file_thumb'].mime_type).to eq('image/jpeg')
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "with an attached pdf", requires_imagemagick: true do
|
129
|
-
let(:filename) { File.expand_path('../../fixtures/test.pdf', __FILE__) }
|
130
|
-
let(:attachment) { File.open(filename) }
|
131
|
-
let(:file) do
|
132
|
-
GenericFile.new(mime_type_from_fits: 'application/pdf') do |t|
|
133
|
-
t.original_file.content = attachment
|
134
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
135
|
-
t.save
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it "transcodes" do
|
140
|
-
expect(file.attached_files.key?('original_file_thumb')).to be_falsey
|
141
|
-
file.create_derivatives(filename)
|
142
|
-
file.reload
|
143
|
-
expect(file.attached_files['original_file_thumb']).to have_content
|
144
|
-
expect(file.attached_files['original_file_thumb'].mime_type).to eq('image/png')
|
145
|
-
expect(file.attached_files['fulltext'].content).to match(/This PDF file was created using CutePDF/)
|
146
|
-
expect(file.attached_files['fulltext'].mime_type).to eq 'text/plain'
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "with an attached audio", requires_ffmpeg: true do
|
151
|
-
let(:filename) { File.expand_path('../../fixtures/piano_note.wav', __FILE__) }
|
152
|
-
let(:attachment) { File.open(filename) }
|
153
|
-
let(:file) do
|
154
|
-
GenericFile.new(mime_type_from_fits: 'audio/x-wav').tap do |t|
|
155
|
-
t.original_file.content = attachment
|
156
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
157
|
-
t.save
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
it "transcodes" do
|
162
|
-
file.create_derivatives(filename)
|
163
|
-
file.reload
|
164
|
-
expect(file.attached_files['original_file_mp3']).to have_content
|
165
|
-
expect(file.attached_files['original_file_mp3'].mime_type).to eq('audio/mpeg')
|
166
|
-
expect(file.attached_files['original_file_ogg']).to have_content
|
167
|
-
expect(file.attached_files['original_file_ogg'].mime_type).to eq('audio/ogg')
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "when the source datastrem has an unknown mime_type", requires_ffmpeg: true do
|
172
|
-
let(:filename) { File.expand_path('../../fixtures/piano_note.wav', __FILE__) }
|
173
|
-
let(:attachment) { File.open(filename) }
|
174
|
-
let(:file) do
|
175
|
-
GenericFile.new(mime_type_from_fits: 'audio/x-wav').tap do |t|
|
176
|
-
t.original_file.content = attachment
|
177
|
-
t.original_file.mime_type = 'audio/vnd.wav'
|
178
|
-
t.save
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
it "transcodes" do
|
183
|
-
allow_any_instance_of(::Logger).to receive(:warn)
|
184
|
-
file.create_derivatives(filename)
|
185
|
-
file.reload
|
186
|
-
expect(file.attached_files['original_file_mp3']).to have_content
|
187
|
-
expect(file.attached_files['original_file_mp3'].mime_type).to eq('audio/mpeg')
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe "with an attached video", requires_ffmpeg: true do
|
192
|
-
let(:filename) { File.expand_path('../../fixtures/countdown.avi', __FILE__) }
|
193
|
-
let(:attachment) { File.open(filename) }
|
194
|
-
let(:file) do
|
195
|
-
GenericFile.create(mime_type_from_fits: 'video/x-msvideo') do |t|
|
196
|
-
t.original_file.content = attachment
|
197
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
198
|
-
t.save
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
it "transcodes" do
|
203
|
-
file.create_derivatives(filename)
|
204
|
-
file.reload
|
205
|
-
expect(file.attached_files['original_file_mp4']).to have_content
|
206
|
-
expect(file.attached_files['original_file_mp4'].mime_type).to eq('video/mp4')
|
207
|
-
expect(file.attached_files['original_file_webm']).to have_content
|
208
|
-
expect(file.attached_files['original_file_webm'].mime_type).to eq('video/webm')
|
209
|
-
expect(file.attached_files['thumbnail']).to have_content
|
210
|
-
expect(file.attached_files['thumbnail'].mime_type).to eq('image/jpeg')
|
211
|
-
end
|
212
|
-
|
213
|
-
context "and the timeout is set" do
|
214
|
-
before do
|
215
|
-
Hydra::Derivatives::Processors::Video::Processor.timeout = 0.2 # 200ms
|
216
|
-
end
|
217
|
-
after do
|
218
|
-
Hydra::Derivatives::Processors::Video::Processor.timeout = nil # clear timeout
|
219
|
-
end
|
220
|
-
|
221
|
-
it "raises a timeout" do
|
222
|
-
expect { file.create_derivatives(filename) }.to raise_error Hydra::Derivatives::TimeoutError
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
describe "with an attached Powerpoint", requires_libreoffice: true do
|
228
|
-
let(:filename) { File.expand_path('../../fixtures/FlashPix.ppt', __FILE__) }
|
229
|
-
let(:attachment) { File.open(filename) }
|
230
|
-
let(:file) do
|
231
|
-
GenericFile.create(mime_type_from_fits: 'application/vnd.ms-powerpoint') do |t|
|
232
|
-
t.original_file.content = attachment
|
233
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
234
|
-
t.save
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
it "transcodes" do
|
239
|
-
file.create_derivatives(filename)
|
240
|
-
file.reload
|
241
|
-
expect(file.attached_files['original_file_thumbnail']).to have_content
|
242
|
-
expect(file.attached_files['original_file_thumbnail'].mime_type).to eq('image/jpeg')
|
243
|
-
expect(file.attached_files['original_file_access']).to have_content
|
244
|
-
expect(file.attached_files['original_file_access'].mime_type).to eq('application/pdf')
|
245
|
-
expect(file.attached_files['original_file_preservation']).to have_content
|
246
|
-
expect(file.attached_files['original_file_preservation'].mime_type).to eq('application/vnd.openxmlformats-officedocument.presentationml.presentation')
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "with an attached rich text format", requires_libreoffice: true do
|
251
|
-
let(:filename) { File.expand_path('../../fixtures/sample.rtf', __FILE__) }
|
252
|
-
let(:attachment) { File.open(filename) }
|
253
|
-
let(:file) do
|
254
|
-
GenericFile.new(mime_type_from_fits: 'text/rtf').tap do |t|
|
255
|
-
t.original_file.content = attachment
|
256
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
257
|
-
t.save
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
it "transcodes" do
|
262
|
-
file.create_derivatives(filename)
|
263
|
-
file.reload
|
264
|
-
expect(file.attached_files['original_file_thumbnail']).to have_content
|
265
|
-
expect(file.attached_files['original_file_thumbnail'].mime_type).to eq('image/jpeg')
|
266
|
-
expect(file.attached_files['original_file_access']).to have_content
|
267
|
-
expect(file.attached_files['original_file_access'].mime_type).to eq('application/pdf')
|
268
|
-
expect(file.attached_files['original_file_preservation']).to have_content
|
269
|
-
expect(file.attached_files['original_file_preservation'].mime_type).to eq('application/vnd.oasis.opendocument.text')
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
describe "with an attached word doc format", requires_libreoffice: true do
|
274
|
-
let(:filename) { File.expand_path('../../fixtures/test.doc', __FILE__) }
|
275
|
-
let(:attachment) { File.open(filename) }
|
276
|
-
|
277
|
-
let(:file) do
|
278
|
-
GenericFile.new(mime_type_from_fits: 'application/msword').tap do |t|
|
279
|
-
t.original_file.content = attachment
|
280
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
281
|
-
t.save
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
it "transcodes" do
|
286
|
-
file.create_derivatives(filename)
|
287
|
-
file.reload
|
288
|
-
expect(file.attached_files['original_file_thumbnail']).to have_content
|
289
|
-
expect(file.attached_files['original_file_thumbnail'].mime_type).to eq('image/jpeg')
|
290
|
-
expect(file.attached_files['original_file_access']).to have_content
|
291
|
-
expect(file.attached_files['original_file_access'].mime_type).to eq('application/pdf')
|
292
|
-
expect(file.attached_files['original_file_preservation']).to have_content
|
293
|
-
expect(file.attached_files['original_file_preservation'].mime_type).to eq('application/vnd.openxmlformats-officedocument.wordprocessingml.document')
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "with an attached excel format", requires_libreoffice: true do
|
298
|
-
let(:filename) { File.expand_path('../../fixtures/test.xls', __FILE__) }
|
299
|
-
let(:attachment) { File.open(filename) }
|
300
|
-
|
301
|
-
let(:file) do
|
302
|
-
GenericFile.new(mime_type_from_fits: 'application/vnd.ms-excel').tap do |t|
|
303
|
-
t.original_file.content = attachment
|
304
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
305
|
-
t.save
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
it "transcodes" do
|
310
|
-
file.create_derivatives(filename)
|
311
|
-
file.reload
|
312
|
-
expect(file.attached_files['original_file_thumbnail']).to have_content
|
313
|
-
expect(file.attached_files['original_file_thumbnail'].mime_type).to eq('image/jpeg')
|
314
|
-
expect(file.attached_files['original_file_access']).to have_content
|
315
|
-
expect(file.attached_files['original_file_access'].mime_type).to eq('application/pdf')
|
316
|
-
expect(file.attached_files['original_file_preservation']).to have_content
|
317
|
-
expect(file.attached_files['original_file_preservation'].mime_type).to eq('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
describe "with an attached tiff", requires_kdu_compress: true do
|
322
|
-
let(:filename) { File.expand_path('../../fixtures/test.tif', __FILE__) }
|
323
|
-
let(:attachment) { File.open(filename) }
|
324
|
-
|
325
|
-
let(:file) do
|
326
|
-
GenericFile.new(mime_type_from_fits: 'image/tiff').tap do |t|
|
327
|
-
t.original_file.content = attachment
|
328
|
-
t.original_file.mime_type = t.mime_type_from_fits
|
329
|
-
t.save
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
it "transcodes" do
|
334
|
-
file.create_derivatives(filename)
|
335
|
-
file.reload
|
336
|
-
expect(file.attached_files['original_file_diy']).to have_content
|
337
|
-
expect(file.attached_files['original_file_diy'].mime_type).to eq('image/jp2')
|
338
|
-
expect(file.attached_files['config_lookup']).to have_content
|
339
|
-
expect(file.attached_files['config_lookup'].mime_type).to eq('image/jp2')
|
340
|
-
expect(file.attached_files['resized']).to have_content
|
341
|
-
expect(file.attached_files['resized'].mime_type).to eq('image/jp2')
|
342
|
-
expect(file.attached_files['string_recipe']).to have_content
|
343
|
-
expect(file.attached_files['string_recipe'].mime_type).to eq('image/jp2')
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|