hydra-derivatives 3.4.1 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +59 -0
  3. data/.solr_wrapper +2 -0
  4. data/CODE_OF_CONDUCT.md +36 -0
  5. data/CONTRIBUTING.md +23 -21
  6. data/Gemfile +3 -1
  7. data/README.md +79 -6
  8. data/Rakefile +13 -1
  9. data/SUPPORT.md +5 -0
  10. data/VERSION +1 -1
  11. data/config/fcrepo_wrapper_test.yml +2 -2
  12. data/config/solr_wrapper_test.yml +2 -0
  13. data/hydra-derivatives.gemspec +12 -8
  14. data/lib/hydra/derivatives/config.rb +1 -1
  15. data/lib/hydra/derivatives/logger.rb +2 -2
  16. data/lib/hydra/derivatives/processors/document.rb +4 -1
  17. data/lib/hydra/derivatives/processors/full_text.rb +16 -7
  18. data/lib/hydra/derivatives/processors/image.rb +4 -2
  19. data/lib/hydra/derivatives/processors/jpeg2k_image.rb +2 -8
  20. data/lib/hydra/derivatives/processors/processor.rb +0 -7
  21. data/lib/hydra/derivatives/processors/shell_based_processor.rb +5 -3
  22. data/lib/hydra/derivatives/services/persist_output_file_service.rb +1 -1
  23. data/solr/config/schema.xml +0 -2
  24. data/solr/config/xslt/example.xsl +1 -1
  25. data/solr/config/xslt/luke.xsl +1 -1
  26. metadata +155 -93
  27. data/.travis.yml +0 -38
  28. data/spec/fixtures/FlashPix.ppt +0 -0
  29. data/spec/fixtures/adobe1998.tif +0 -0
  30. data/spec/fixtures/countdown.avi +0 -0
  31. data/spec/fixtures/jpeg2k_config.yml +0 -20
  32. data/spec/fixtures/piano_note.wav +0 -0
  33. data/spec/fixtures/sample.rtf +0 -68
  34. data/spec/fixtures/test.dng +0 -0
  35. data/spec/fixtures/test.doc +0 -0
  36. data/spec/fixtures/test.docx +0 -0
  37. data/spec/fixtures/test.pdf +0 -0
  38. data/spec/fixtures/test.pptx +0 -0
  39. data/spec/fixtures/test.tif +0 -0
  40. data/spec/fixtures/test.xls +0 -0
  41. data/spec/fixtures/test.xlsx +0 -0
  42. data/spec/fixtures/world.png +0 -0
  43. data/spec/processors/active_encode_spec.rb +0 -132
  44. data/spec/processors/document_spec.rb +0 -41
  45. data/spec/processors/full_text_spec.rb +0 -90
  46. data/spec/processors/image_spec.rb +0 -124
  47. data/spec/processors/jpeg2k_spec.rb +0 -82
  48. data/spec/processors/processor_spec.rb +0 -35
  49. data/spec/processors/shell_based_processor_spec.rb +0 -19
  50. data/spec/processors/video_spec.rb +0 -42
  51. data/spec/runners/active_encode_derivatives_spec.rb +0 -38
  52. data/spec/services/audio_derivatives_spec.rb +0 -78
  53. data/spec/services/persist_basic_contained_output_file_service_spec.rb +0 -42
  54. data/spec/services/persist_external_file_output_file_service_spec.rb +0 -26
  55. data/spec/services/remote_source_file_spec.rb +0 -33
  56. data/spec/services/retrieve_source_file_service_spec.rb +0 -60
  57. data/spec/services/tempfile_service_spec.rb +0 -31
  58. data/spec/spec_helper.rb +0 -33
  59. data/spec/units/audio_encoder_spec.rb +0 -23
  60. data/spec/units/config_spec.rb +0 -50
  61. data/spec/units/derivatives_spec.rb +0 -64
  62. data/spec/units/io_decorator_spec.rb +0 -45
  63. data/spec/units/logger_spec.rb +0 -22
  64. data/spec/units/transcoding_spec.rb +0 -354
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hydra::Derivatives::RetrieveSourceFileService do
4
- before(:all) do
5
- # Need a class that:
6
- # 1) Allows you to set .uri= (to work with directly_contains)
7
- # 2) has a metadata_node (to work with directly_contains_one)
8
- class FileWithMetadata < ActiveFedora::File
9
- include ActiveFedora::WithMetadata
10
- end
11
-
12
- class ObjectWithBasicContainer < ActiveFedora::Base
13
- has_subresource "contained_file"
14
- end
15
-
16
- class DirectContainerObject < ActiveFedora::Base
17
- directly_contains :files, has_member_relation: ::RDF::URI("http://pcdm.org/use#hasFile"),
18
- class_name: "FileWithMetadata"
19
- directly_contains_one :directly_contained_file, through: :files, type: ::RDF::URI("http://pcdm.org/use#OriginalFile")
20
- end
21
- end
22
-
23
- context "when file is in basic container (default assumption)" do # alas, we have to support this as the default because all legacy code (and fedora 3 systems) created indirectly contained files
24
- let(:object) { ObjectWithBasicContainer.new }
25
- let(:content) { "fake file content (basic container)" }
26
- let(:source_name) { 'contained_file' }
27
-
28
- before do
29
- allow(object).to receive(:uri).and_return('http://foo/bar')
30
- allow(object.contained_file).to receive(:new_record?).and_return(false)
31
- allow(object.contained_file).to receive(:has_content?).and_return(true)
32
- allow(object.contained_file).to receive(:mime_type).and_return('text/html')
33
- # attaches the file as an indirectly contained object
34
- object.contained_file.content = content
35
- end
36
-
37
- it "persists the file to the specified destination on the given object" do
38
- described_class.call(object, source: source_name) do |f|
39
- expect(f.read).to eq(object.contained_file.content)
40
- end
41
- end
42
- end
43
-
44
- context "when file is directly contained" do # direct containers are more efficient, but most legacy code will have indirect containers
45
- let(:object) { DirectContainerObject.new }
46
- let(:content) { "fake file content (direct container)" }
47
- let(:source_name) { 'directly_contained_file' }
48
-
49
- before do
50
- object.save # can't build directly contained objects without saving the parent first
51
- object.build_directly_contained_file
52
- object.directly_contained_file.content = content
53
- end
54
- it "retrieves the file from the specified location on the given object" do
55
- described_class.call(object, source: source_name) do |f|
56
- expect(f.read).to eq(object.directly_contained_file.content)
57
- end
58
- end
59
- end
60
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hydra::Derivatives::TempfileService do
4
- subject { described_class.new(file) }
5
-
6
- let(:class_with_metadata_extraction) do
7
- Class.new do
8
- attr_reader :content, :mime_type, :uri
9
-
10
- def initialize(options = {})
11
- @content = options.fetch(:content, '')
12
- @mime_uype = options.fetch(:mime_type, nil)
13
- @uri = 'http://example.com/pid/123'
14
- end
15
-
16
- def has_content?
17
- content.present?
18
- end
19
- end
20
- end
21
-
22
- let(:initialization_options) { { content: 'abc', mime_type: 'text/plain' } }
23
-
24
- let(:file) { class_with_metadata_extraction.new(initialization_options) }
25
-
26
- describe '#tempfile' do
27
- it 'has a method called to_tempfile' do
28
- expect { |b| subject.tempfile(&b) }.to yield_with_args(Tempfile)
29
- end
30
- end
31
- 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
@@ -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 = instance_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 = instance_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,64 +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 "with a global configuration setting" do
16
- subject { CustomFile }
17
-
18
- let(:custom_source_file_service) { "fake service" }
19
-
20
- it "utilizes the default source file service" do
21
- expect(subject.source_file_service).to eq(custom_source_file_service)
22
- end
23
- end
24
-
25
- context "with an instance level configuration setting" do
26
- subject { CustomFile.new }
27
-
28
- let(:custom_source_file_service) { "another fake service" }
29
-
30
- it "accepts a custom source file service as an option" do
31
- expect(subject.source_file_service).to eq(custom_source_file_service)
32
- end
33
- end
34
- end
35
-
36
- Hydra::Derivatives::CONFIG_METHODS.each do |method|
37
- describe method.to_s do
38
- it 'returns the config value' do
39
- expect(subject.send(method)).to eq subject.config.send(method)
40
- end
41
- end
42
- describe "#{method}=" do
43
- it 'stores config changes' do
44
- expect { subject.send("#{method}=", "new_value") }.to change { subject.config.send(method) }.from(subject.config.send(method)).to("new_value")
45
- end
46
- end
47
- end
48
-
49
- describe 'reset_config!' do
50
- it "resets the configuration" do
51
- subject.ffmpeg_path = '/usr/local/ffmpeg-1.0/bin/ffmpeg'
52
- subject.reset_config!
53
- expect(subject.ffmpeg_path).to eq('ffmpeg')
54
-
55
- subject.kdu_compress_path = '/usr/local/bin/kdu_compress'
56
- subject.reset_config!
57
- expect(subject.kdu_compress_path).to eq('kdu_compress')
58
-
59
- subject.active_encode_poll_time = 2
60
- subject.reset_config!
61
- expect(subject.active_encode_poll_time).to eq 10
62
- end
63
- end
64
- end
@@ -1,45 +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 "with one argument" do
8
- let(:decorator) { described_class.new(file) }
9
-
10
- describe "#read" do
11
- subject { decorator.read }
12
-
13
- it { is_expected.to eq 'hello' }
14
- end
15
- end
16
-
17
- context "with three arguments" do
18
- let(:decorator) { described_class.new(file, 'text/plain', 'help.txt') }
19
-
20
- describe "#read" do
21
- subject { decorator.read }
22
-
23
- it { is_expected.to eq 'hello' }
24
- end
25
-
26
- describe "mime_type" do
27
- subject { decorator.mime_type }
28
-
29
- it { is_expected.to eq 'text/plain' }
30
- end
31
-
32
- describe "original_filename" do
33
- subject { decorator.original_filename }
34
-
35
- it { is_expected.to eq 'help.txt' }
36
- end
37
-
38
- describe "original_name" do
39
- subject { decorator.original_name }
40
-
41
- before { allow(Deprecation).to receive(:warn) }
42
- it { is_expected.to eq 'help.txt' }
43
- end
44
- end
45
- end
@@ -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