hydra-file_characterization 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34fca572cbda0f223170f1a23ae8cd43dcd1b6f0
4
- data.tar.gz: a13e96336fa3a2327d92f1e77938c1bf1e3510a4
3
+ metadata.gz: 8c3e177907738ef60151151394669f403baf76e9
4
+ data.tar.gz: 9c76f5edba884d3a0308f493c41748827b9dc531
5
5
  SHA512:
6
- metadata.gz: d65d9d4e65cc7275859bcf6fe1798f9e854bd40c31a966be4846de5717cb1f0b19de1cbe2bfbdfb8d4e0cae134adf5e7f4a9d7c698f2f6e64b49175f355c359e
7
- data.tar.gz: 5beff9b3009b44f25dd362137befa286673b92dfdc36fdb9f63cd69c482773ee8f3cb998772ac66a0f50a0873bc51decfc147aa7eff8f889354a3bc5e51a974b
6
+ metadata.gz: 84ee01ddc01e363e95d1eb253e836feb6c1666233f9d0f5cc40ed4d40c0be2e8cbc49a02a50441b5ca97ea938e848604b4729c724f889d5400031ef2e0b2edc4
7
+ data.tar.gz: 0c511f76ddb998a39f84971ccf180e5397d1ae042fc37370de061a97ccb231d1531978aa5593a5234958b5972ca9c06ac3af0424262321e06e8d29f59bff9c9b
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ bundler_args: --without debug
5
+ env:
6
+ global:
7
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
8
+ rvm:
9
+ - 2.2
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -29,6 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.require_paths = ["lib"]
30
30
 
31
31
  gem.add_dependency "activesupport", ">= 3.0.0"
32
+ gem.add_development_dependency "rake"
32
33
  gem.add_development_dependency "rspec"
33
34
  gem.add_development_dependency "guard"
34
35
  gem.add_development_dependency 'guard-rspec'
@@ -26,6 +26,10 @@ module Hydra::FileCharacterization
26
26
  @tool_path || self.class.tool_path || convention_based_tool_name
27
27
  end
28
28
 
29
+ def logger
30
+ @logger ||= activefedora_logger || Logger.new(STDERR)
31
+ end
32
+
29
33
  protected
30
34
 
31
35
  # Override this method if you want your processor to mutate the
@@ -66,5 +70,9 @@ module Hydra::FileCharacterization
66
70
  internal_call
67
71
  end
68
72
  end
73
+
74
+ def activefedora_logger
75
+ ActiveFedora::Base.logger if defined? ActiveFedora
76
+ end
69
77
  end
70
78
  end
@@ -1,5 +1,6 @@
1
1
  require 'hydra/file_characterization/exceptions'
2
2
  require 'hydra/file_characterization/characterizer'
3
+ require 'logger'
3
4
  module Hydra::FileCharacterization::Characterizers
4
5
  class Fits < Hydra::FileCharacterization::Characterizer
5
6
 
@@ -9,10 +10,14 @@ module Hydra::FileCharacterization::Characterizers
9
10
  "#{tool_path} -i \"#{filename}\""
10
11
  end
11
12
 
12
- # Remove any residual non-XML from JHOVE
13
+ # Remove any non-XML output that precedes the <?xml> tag
13
14
  # See: https://github.com/harvard-lts/fits/issues/20
15
+ # https://github.com/harvard-lts/fits/issues/40
16
+ # https://github.com/harvard-lts/fits/issues/46
14
17
  def post_process(raw_output)
15
- raw_output.sub(/^READBOX seen=true\n/, '')
18
+ md = /\A(.*)(<\?xml.*)\Z/m.match(raw_output)
19
+ logger.warn "FITS produced non-xml output: \"#{md[1].chomp}\"" unless md[1].empty?
20
+ md[2]
16
21
  end
17
22
  end
18
23
  end
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module FileCharacterization
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ module Hydra::FileCharacterization::Characterizers
5
5
  describe Fits do
6
6
  let(:fits) { Fits.new(filename) }
7
7
 
8
- describe "#call" do
8
+ describe "#call", unless: ENV['TRAVIS'] do
9
9
  subject { fits.call }
10
10
 
11
11
  context 'validfile' do
@@ -29,20 +29,40 @@ module Hydra::FileCharacterization::Characterizers
29
29
  let(:filename) { fixture_file('archive.zip') }
30
30
  it { is_expected.to include(%(<identity format="ZIP Format" mimetype="application/zip"))}
31
31
  end
32
+ end
33
+
34
+ context 'when JHOVE adds non-xml' do
35
+ # https://github.com/harvard-lts/fits/issues/20
36
+ subject { fits.call }
32
37
 
33
- context 'when JHOVE adds non-xml' do
34
- # https://github.com/harvard-lts/fits/issues/20
35
- before do
36
- allow(fits).to receive(:internal_call).and_return(
37
- 'READBOX seen=true
38
+ before do
39
+ expect(fits.logger).to receive(:warn)
40
+ allow(fits).to receive(:internal_call).and_return(
41
+ 'READBOX seen=true
38
42
  <?xml version="1.0" encoding="UTF-8"?>
39
43
  <fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="0.8.2" timestamp="15/09/14 10:00 AM">
40
- <identification/></fits>')
41
- end
44
+ <identification/></fits>')
45
+ end
42
46
 
43
- let(:filename) { fixture_file('brendan_behan.jpeg') }
44
- it { is_expected.not_to include('READBOX') }
47
+ let(:filename) { fixture_file('brendan_behan.jpeg') }
48
+ it { is_expected.not_to include('READBOX') }
49
+ end
50
+
51
+ context "when FITS itself adds non-xml" do
52
+ # https://github.com/harvard-lts/fits/issues/46
53
+ subject { fits.call }
54
+
55
+ before do
56
+ expect(fits.logger).to receive(:warn)
57
+ allow(fits).to receive(:internal_call).and_return(
58
+ '2015-10-15 17:14:25,761 ERROR [main] ToolBelt:79 - Thread 1 error initializing edu.harvard.hul.ois.fits.tools.droid.Droid: edu.harvard.hul.ois.fits.exceptions.FitsToolException Message: DROID cannot run under Java 8
59
+ <?xml version="1.0" encoding="UTF-8"?>
60
+ <fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="0.8.2" timestamp="15/09/14 10:00 AM">
61
+ <identification/></fits>')
45
62
  end
63
+
64
+ let(:filename) { fixture_file('brendan_behan.jpeg') }
65
+ it { is_expected.not_to include('FitsToolException') }
46
66
  end
47
67
  end
48
68
  end
@@ -6,7 +6,7 @@ module Hydra
6
6
 
7
7
  describe FileCharacterization do
8
8
 
9
- describe '.characterize' do
9
+ describe '.characterize', unless: ENV['TRAVIS'] do
10
10
  describe "for content in memory" do
11
11
  let(:content) { "class Test; end\n" }
12
12
  let(:filename) { 'test.rb' }
@@ -89,7 +89,7 @@ module Hydra
89
89
  Hydra::FileCharacterization::Characterizers::Fits.tool_path = old_tool_path
90
90
  end
91
91
 
92
- it 'without configuration' do
92
+ it 'without configuration', unless: ENV['TRAVIS'] do
93
93
  Hydra::FileCharacterization.configure do |config|
94
94
  config.tool_path(:fits, nil)
95
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-file_characterization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Treacy
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-08-31 00:00:00.000000000 Z
14
+ date: 2015-10-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -27,6 +27,20 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: rspec
32
46
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +95,7 @@ extra_rdoc_files: []
81
95
  files:
82
96
  - ".gitignore"
83
97
  - ".rspec"
98
+ - ".travis.yml"
84
99
  - CONTRIBUTING.md
85
100
  - Gemfile
86
101
  - Guardfile
@@ -130,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
145
  version: '0'
131
146
  requirements: []
132
147
  rubyforge_project:
133
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.4.5.1
134
149
  signing_key:
135
150
  specification_version: 4
136
151
  summary: To provide a wrapper for file characterization