hydra-works 0.12.1 → 0.13.0

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: fca7c38076bbdfc973e048b9c9a313c861566213
4
- data.tar.gz: 3a4734587bccdc93b9c355536133a48241955ace
3
+ metadata.gz: b5992ee7b9f7184fd70053978e0604cd9ed10ccc
4
+ data.tar.gz: 20f024bb82a6b76da36d5197dc7709879d44c690
5
5
  SHA512:
6
- metadata.gz: 49fbe343eccfbc3ec73163dd1cd334636d8268ddb55a350fa2de50f780cfd1185909d9e9c40cf87fdbd31fceda4ed2eaf9e9cc5b5af106fff9e11f33207beb07
7
- data.tar.gz: 1f84ba460edfafc07cec0f66e1a1bf14372d8d7b896cf836b16a33b8a77abba0a6edc97ecdfc30e265ea6b7cfcd1c71223464d4cd3c5f26864fcaa3bd350de67
6
+ metadata.gz: 76b34210f7d2fbb513108ed8637d0d7b302ee35f205ed9a2333dd479f34d576caf7bc8c3c399724de9100980ebe2a2e18efc6500e437924f41d657735ab9c593
7
+ data.tar.gz: 3a213fa47a3feafd53474ede6e5b2211ee9706e647694e393655b3744e1b0f8b062a37adc461731561300876b123702ab6a65cf709aafe5f630dc9999187ce1e
data/.rubocop.yml CHANGED
@@ -14,7 +14,7 @@ Metrics/LineLength:
14
14
 
15
15
  Metrics/ClassLength:
16
16
  Exclude:
17
- - lib/hydra/works/characterization/fits_datastream.rb
17
+ - lib/hydra/works/characterization/fits_document.rb
18
18
 
19
19
  Style/CollectionMethods:
20
20
  PreferredMethods:
data/.travis.yml CHANGED
@@ -6,6 +6,7 @@ env:
6
6
  global:
7
7
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
8
8
  rvm:
9
+ - 2.2.5
9
10
  - 2.3.1
10
11
  before_script:
11
12
  - jdk_switcher use oraclejdk8
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # Hydra::Works
2
2
 
3
3
  [![Version](https://badge.fury.io/rb/hydra-works.png)](http://badge.fury.io/rb/hydra-works)
4
- [![Build Status](https://travis-ci.org/projecthydra-labs/hydra-works.svg?branch=master)](https://travis-ci.org/projecthydra-labs/hydra-works)
5
- [![Coverage Status](https://coveralls.io/repos/projecthydra-labs/hydra-works/badge.svg?branch=master)](https://coveralls.io/r/projecthydra-labs/hydra-works?branch=master)
6
- [![Code Climate](https://codeclimate.com/github/projecthydra-labs/hydra-works/badges/gpa.svg)](https://codeclimate.com/github/projecthydra-labs/hydra-works)
4
+ [![Build Status](https://travis-ci.org/projecthydra/hydra-works.svg?branch=master)](https://travis-ci.org/projecthydra/hydra-works)
5
+ [![Coverage Status](https://coveralls.io/repos/projecthydra/hydra-works/badge.svg?branch=master)](https://coveralls.io/r/projecthydra/hydra-works?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/projecthydra/hydra-works/badges/gpa.svg)](https://codeclimate.com/github/projecthydra/hydra-works)
7
7
  [![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
8
8
  [![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md)
9
9
  [![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/hydra-works)
10
- [![Stories in Ready](https://badge.waffle.io/projecthydra-labs/hydra-works.png?source=projecthydra-labs%2Fhydra-works&label=ready&title=Ready)](https://waffle.io/projecthydra-labs/hydra-works?source=projecthydra-labs%2Fhydra-works)
11
10
 
12
- The Hydra::Works gem implements the [PCDM](https://github.com/duraspace/pcdm/wiki) [Works](https://github.com/duraspace/pcdm/blob/master/pcdm-ext/works.rdf) data model using ActiveFedora-based models. In addition to the models, Hydra::Works includes associated behaviors around the broad concept of describable "works" or intellectual entities, the need for which was expressed by a variety of [Hydra community use cases](https://github.com/projecthydra-labs/hydra-works/tree/master/use-cases). The PCDM Works domain model includes the following high-level entities:
11
+ The Hydra::Works gem implements the [PCDM](https://github.com/duraspace/pcdm/wiki) [Works](https://github.com/duraspace/pcdm/blob/master/pcdm-ext/works.rdf) data model using ActiveFedora-based models. In addition to the models, Hydra::Works includes associated behaviors around the broad concept of describable "works" or intellectual entities, the need for which was expressed by a variety of [Hydra community use cases](https://github.com/projecthydra/hydra-works/tree/master/use-cases). The PCDM Works domain model includes the following high-level entities:
13
12
 
14
13
  * **Collection**: a *pcdm:Collection* that indirectly contains zero or more **Works** and zero or more **Collection**s
15
14
  * **Work**: a *pcdm:Object* that holds zero or more **FileSets** and zero or more **Works**
data/hydra-works.gemspec CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'active-fedora', '>= 9', '< 11.a'
22
21
  spec.add_dependency 'hydra-pcdm', '>= 0.8'
23
22
  spec.add_dependency 'hydra-derivatives', '~> 3.0'
24
23
  spec.add_dependency 'hydra-file_characterization', '~> 0.3', '>= 0.3.3'
24
+ spec.add_dependency 'om', '~> 3.1'
25
25
 
26
26
  spec.add_development_dependency 'bundler', '~> 1.7'
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -1,5 +1,7 @@
1
+ require 'om'
2
+
1
3
  module Hydra::Works::Characterization
2
- class FitsDatastream < ActiveFedora::OmDatastream
4
+ class FitsDocument
3
5
  include OM::XML::Document
4
6
 
5
7
  set_terminology do |t|
@@ -87,7 +89,7 @@ module Hydra::Works::Characterization
87
89
  # fits_version needs a different name than it's target node since they're at the same level
88
90
  t.fits_version(proxy: [:fits, :fits_v])
89
91
  t.format_label(proxy: [:identification, :identity, :format_label])
90
- # Can't use .mime_type because it's already defined for datastream so method missing won't work.
92
+ # Can't use .mime_type because it's already defined for this dcoument so method missing won't work.
91
93
  t.file_mime_type(proxy: [:identification, :identity, :mime_type])
92
94
  t.exif_tool_version(proxy: [:identification, :identity, :tool, :exif_tool_version])
93
95
  t.file_size(proxy: [:fileinfo, :file_size])
@@ -16,7 +16,7 @@ module Hydra::Works
16
16
  end
17
17
  end
18
18
 
19
- autoload :FitsDatastream, 'hydra/works/characterization/fits_datastream.rb'
19
+ autoload :FitsDocument, 'hydra/works/characterization/fits_document.rb'
20
20
 
21
21
  autoload_under 'schema' do
22
22
  autoload :AudioSchema
@@ -3,10 +3,15 @@ module Hydra::Works
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- validate :detect_viruses
7
- def detect_viruses
8
- return true unless original_file && original_file.new_record? # We have a new file to check
9
- return true unless VirusCheckerService.file_has_virus?(original_file)
6
+ validate :must_not_detect_viruses
7
+
8
+ def viruses?
9
+ return false unless original_file && original_file.new_record? # We have a new file to check
10
+ VirusCheckerService.file_has_virus?(original_file)
11
+ end
12
+
13
+ def must_not_detect_viruses
14
+ return true unless viruses?
10
15
  errors.add(:base, "Failed to verify uploaded file is not a virus")
11
16
  false
12
17
  end
@@ -16,12 +16,12 @@ module Hydra::Works
16
16
  @object = object
17
17
  @source = source
18
18
  @mapping = options.fetch(:parser_mapping, Hydra::Works::Characterization.mapper)
19
- @parser_class = options.fetch(:parser_class, Hydra::Works::Characterization::FitsDatastream)
19
+ @parser_class = options.fetch(:parser_class, Hydra::Works::Characterization::FitsDocument)
20
20
  @tools = options.fetch(:ch12n_tool, :fits)
21
21
  end
22
22
 
23
23
  # Get given source into form that can be passed to Hydra::FileCharacterization
24
- # Use Hydra::FileCharacterization to extract metadata (an OM Datastream)
24
+ # Use Hydra::FileCharacterization to extract metadata (an OM XML document)
25
25
  # Get the terms (and their values) from the extracted metadata
26
26
  # Assign the values of the terms to the properties of the object
27
27
  def characterize
@@ -59,19 +59,19 @@ module Hydra::Works
59
59
 
60
60
  # Use OM to parse metadata
61
61
  def parse_metadata(metadata)
62
- datastream = parser_class.new
63
- datastream.ng_xml = metadata if metadata.present?
64
- characterization_terms(datastream)
62
+ omdoc = parser_class.new
63
+ omdoc.ng_xml = Nokogiri::XML(metadata) if metadata.present?
64
+ characterization_terms(omdoc)
65
65
  end
66
66
 
67
67
  # Get proxy terms and values from the parser
68
- def characterization_terms(datastream)
68
+ def characterization_terms(omdoc)
69
69
  h = {}
70
- datastream.class.terminology.terms.each_pair do |key, target|
70
+ omdoc.class.terminology.terms.each_pair do |key, target|
71
71
  # a key is a proxy if its target responds to proxied_term
72
72
  next unless target.respond_to? :proxied_term
73
73
  begin
74
- h[key] = datastream.send(key)
74
+ h[key] = omdoc.send(key)
75
75
  rescue NoMethodError
76
76
  next
77
77
  end
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module Works
3
- VERSION = '0.12.1'.freeze
3
+ VERSION = '0.13.0'.freeze
4
4
  end
5
5
  end
data/lib/hydra/works.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'hydra/works/version'
2
2
  require 'hydra/pcdm'
3
3
  require 'hydra/derivatives'
4
+ require 'rdf/vocab'
4
5
 
5
6
  module Hydra
6
7
  module Works
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Hydra::Works::Characterization::FitsDatastream do
3
+ describe Hydra::Works::Characterization::FitsDocument do
4
4
  it 'defines an xml template' do
5
5
  templ = described_class.xml_template.remove_namespaces!
6
6
  expect(templ.xpath('/fits/identification/identity/@toolname').first.value).to eq('FITS')
@@ -34,7 +34,7 @@ describe Hydra::Works::VirusCheck do
34
34
 
35
35
  it 'does not detect viruses' do
36
36
  expect(Hydra::Works::VirusCheckerService).to receive(:file_has_virus?).and_return(false)
37
- subject.detect_viruses
37
+ expect(subject).not_to be_viruses
38
38
  end
39
39
  end
40
40
  end
@@ -17,7 +17,7 @@ describe Hydra::Works::FileSet do
17
17
 
18
18
  describe "#type" do
19
19
  it "returns Object and FileSet" do
20
- expect(subject.type).to eq [Hydra::PCDM::Vocab::PCDMTerms.Object, Hydra::Works::Vocab::WorksTerms.FileSet]
20
+ expect(subject.type).to contain_exactly(Hydra::PCDM::Vocab::PCDMTerms.Object, Hydra::Works::Vocab::WorksTerms.FileSet)
21
21
  end
22
22
  end
23
23
 
@@ -34,7 +34,7 @@ describe Hydra::Works::FileSet do
34
34
 
35
35
  subject { described_class.find(file_set.id).files }
36
36
 
37
- it { is_expected.to eq [file1, file2] }
37
+ it { is_expected.to contain_exactly(file1, file2) }
38
38
  end
39
39
 
40
40
  describe '#in_works' do
@@ -130,7 +130,7 @@ describe Hydra::Works::CharacterizationService do
130
130
  it 'assigns expected values to image properties.' do
131
131
  expect(file.file_size).to eq(["11043"])
132
132
  expect(file.byte_order).to eq(["big endian"])
133
- expect(file.compression).to eq(["JPEG 2000 Lossless", "JPEG 2000"])
133
+ expect(file.compression).to contain_exactly("JPEG 2000 Lossless", "JPEG 2000")
134
134
  expect(file.width).to eq(["512"])
135
135
  expect(file.height).to eq(["465"])
136
136
  expect(file.color_space).to eq(["sRGB"])
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-works
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-14 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: active-fedora
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '9'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 11.a
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '9'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 11.a
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: hydra-pcdm
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +58,20 @@ dependencies:
78
58
  - - ">="
79
59
  - !ruby/object:Gem::Version
80
60
  version: 0.3.3
61
+ - !ruby/object:Gem::Dependency
62
+ name: om
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.1'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.1'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: bundler
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +205,7 @@ files:
211
205
  - hydra-works.gemspec
212
206
  - lib/hydra/works.rb
213
207
  - lib/hydra/works/characterization.rb
214
- - lib/hydra/works/characterization/fits_datastream.rb
208
+ - lib/hydra/works/characterization/fits_document.rb
215
209
  - lib/hydra/works/characterization/fits_mapper.rb
216
210
  - lib/hydra/works/characterization/schema/audio_schema.rb
217
211
  - lib/hydra/works/characterization/schema/base_schema.rb
@@ -277,7 +271,7 @@ files:
277
271
  - spec/fixtures/updated-file.txt
278
272
  - spec/fixtures/world.png
279
273
  - spec/hydra/works/characterization_spec.rb
280
- - spec/hydra/works/models/characterization/fits_datastream_spec.rb
274
+ - spec/hydra/works/models/characterization/fits_document_spec.rb
281
275
  - spec/hydra/works/models/collection_spec.rb
282
276
  - spec/hydra/works/models/concerns/file_set/contained_files_spec.rb
283
277
  - spec/hydra/works/models/concerns/file_set/mime_types_spec.rb
@@ -324,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
318
  version: '0'
325
319
  requirements: []
326
320
  rubyforge_project:
327
- rubygems_version: 2.5.1
321
+ rubygems_version: 2.4.5
328
322
  signing_key:
329
323
  specification_version: 4
330
324
  summary: Fundamental repository data model for hydra
@@ -351,7 +345,7 @@ test_files:
351
345
  - spec/fixtures/updated-file.txt
352
346
  - spec/fixtures/world.png
353
347
  - spec/hydra/works/characterization_spec.rb
354
- - spec/hydra/works/models/characterization/fits_datastream_spec.rb
348
+ - spec/hydra/works/models/characterization/fits_document_spec.rb
355
349
  - spec/hydra/works/models/collection_spec.rb
356
350
  - spec/hydra/works/models/concerns/file_set/contained_files_spec.rb
357
351
  - spec/hydra/works/models/concerns/file_set/mime_types_spec.rb