ddr-models 3.0.0.beta.9 → 3.0.0.beta.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 423038a832d4b54a31f8f97b4db56125f018baae
4
- data.tar.gz: c0a001fc155f0d5b810974cd7800b3b2cd4c2dac
3
+ metadata.gz: acfc5ee132f67a3bcd39524c3cb2b3b54e6904a3
4
+ data.tar.gz: 8ee6e1cf1e7cbd8cd023d3ccc851b7eea2950803
5
5
  SHA512:
6
- metadata.gz: d9fc9f1685c4cd2401742d4604da2f36e68cb02f5a4a40e6933e5c460b15c48f14f39d1e0eccb5f78cfb608504b4569fdb80bf6dabb0805a22ced925fc322775
7
- data.tar.gz: 1ebe59d6ab822b9abbecbde28876a0bdc050533e6b3cf965056bf4a4105de19037bf5e48dc64e25777f2433936e90432ac58d1e7fbc2b6bdd9595193cb91fdf6
6
+ metadata.gz: 7e470d2d199991ca2d8f8cdcd0300cc8c9c28f5d5339132c18d5f892ede55197577a030adbcbcf5966edfd3f79d72b2825c4e78216902760f0582337d23a0a90
7
+ data.tar.gz: 17a7d44df2345a1c740afc6f4f9fb08243858cbb4b9a8bd1a16c8b91c8567b4db633c7a33c661d18bf02b9e148deb3e3a0d7030bda432611b9e9bcca472edae7
@@ -37,13 +37,8 @@ ActiveFedora::Base.class_eval do
37
37
  governable? && admin_policy.present?
38
38
  end
39
39
 
40
- def has_rights_metadata?
41
- ds = self.datastreams[Ddr::Datastreams::RIGHTS_METADATA]
42
- ds && ds.size && ds.size > 0
43
- end
44
-
45
40
  def can_have_struct_metadata?
46
- datastreams.key? Ddr::Datastreams::STRUCT_METADATA
41
+ datastreams.key? Ddr::Models::File::STRUCT_METADATA
47
42
  end
48
43
 
49
44
  def has_struct_metadata?
@@ -8,11 +8,11 @@ module Ddr
8
8
  # Datastreams not listed cannot be downloaded, except of
9
9
  # course by the :manage ability.
10
10
  DATASTREAM_DOWNLOAD_ABILITIES = {
11
- Ddr::Datastreams::CONTENT => :download,
12
- Ddr::Datastreams::EXTRACTED_TEXT => :download,
13
- Ddr::Datastreams::FITS => :read,
14
- Ddr::Datastreams::STRUCT_METADATA => :read,
15
- Ddr::Datastreams::THUMBNAIL => :read,
11
+ Ddr::Models::File::CONTENT => :download,
12
+ Ddr::Models::File::EXTRACTED_TEXT => :download,
13
+ Ddr::Models::File::FITS => :read,
14
+ Ddr::Models::File::STRUCT_METADATA => :read,
15
+ Ddr::Models::File::THUMBNAIL => :read,
16
16
  }.freeze
17
17
 
18
18
  def call
@@ -3,13 +3,6 @@ module Ddr
3
3
  extend ActiveSupport::Autoload
4
4
  extend Deprecation
5
5
 
6
- CONTENT = "content".freeze
7
- DESC_METADATA = "descMetadata".freeze
8
- EXTRACTED_TEXT = "extractedText".freeze
9
- FITS = "fits".freeze
10
- STRUCT_METADATA = "structMetadata".freeze
11
- THUMBNAIL = "thumbnail".freeze
12
-
13
6
  CHECKSUM_TYPE_MD5 = "MD5"
14
7
  CHECKSUM_TYPE_SHA1 = "SHA-1"
15
8
  CHECKSUM_TYPE_SHA256 = "SHA-256"
@@ -20,6 +13,10 @@ module Ddr
20
13
 
21
14
  def self.const_missing(name)
22
15
  case name
16
+ when :CONTENT, :DESC_METADATA, :EXTRACTED_TEXT, :FITS, :STRUCT_METADATA, :THUMBNAIL
17
+ Deprecation.warn(self, "Ddr::Datastreams::#{name} is deprecated." \
18
+ " Use Ddr::Models::File::#{name} instead.")
19
+ Ddr::Models::File.const_get(name)
23
20
  when :FitsDatastream
24
21
  Deprecation.warn(self, "Ddr::Datastreams::FitsDatastream is deprecated." \
25
22
  " Use Ddr::Models::FitsXmlFile instead.")
@@ -28,9 +28,9 @@ module Ddr::Derivatives
28
28
  def store(object, output_path)
29
29
  output_file = File.open(output_path, 'rb')
30
30
  object.reload if object.persisted?
31
- object.add_file output_file, path: Ddr::Datastreams::THUMBNAIL, mime_type: generator.class.output_mime_type
31
+ object.add_file output_file, path: Ddr::Models::File::THUMBNAIL, mime_type: generator.class.output_mime_type
32
32
  object.save!
33
33
  end
34
34
 
35
35
  end
36
- end
36
+ end
@@ -88,8 +88,8 @@ module Ddr::Index
88
88
  end
89
89
 
90
90
  def self.descmd
91
- @descmd ||= Ddr::Datastreams::DescriptiveMetadataDatastream.properties.map do |base, config|
92
- Field.new base, *(config.behaviors)
91
+ @descmd ||= Ddr::Models::DescriptiveMetadata.field_names.map do |base|
92
+ Field.new(base, :stored_searchable)
93
93
  end
94
94
  end
95
95
 
@@ -2,9 +2,15 @@ require 'tempfile'
2
2
 
3
3
  module Ddr::Models
4
4
  class File < ActiveFedora::File
5
- extend AutoVersion
6
5
  extend Deprecation
7
6
 
7
+ CONTENT = "content".freeze
8
+ DESC_METADATA = "descMetadata".freeze
9
+ EXTRACTED_TEXT = "extractedText".freeze
10
+ FITS = "fits".freeze
11
+ STRUCT_METADATA = "structMetadata".freeze
12
+ THUMBNAIL = "thumbnail".freeze
13
+
8
14
  DEFAULT_FILE_EXTENSION = "bin"
9
15
  STRFTIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%LZ"
10
16
 
@@ -1,6 +1,5 @@
1
1
  module Ddr::Models
2
2
  class FitsXmlFile < ActiveFedora::OmDatastream
3
- extend AutoVersion
4
3
 
5
4
  FITS_XMLNS = "http://hul.harvard.edu/ois/xml/ns/fits/fits_output".freeze
6
5
  FITS_SCHEMA = "http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd".freeze
@@ -9,26 +9,6 @@ module Ddr
9
9
  class_name: "Collection"
10
10
  end
11
11
 
12
- def inherited_permissions
13
- admin_policy ? admin_policy.default_permissions : []
14
- end
15
-
16
- def inherited_rights
17
- admin_policy.datastreams[Ddr::Datastreams::DEFAULT_RIGHTS] if admin_policy
18
- end
19
-
20
- # Creates convenience methods:
21
- # inherited_discover_users, inherited_discover_groups,
22
- # inherited_read_users, inherited_read_groups,
23
- # inherited_edit_user, inherited_edit_groups
24
- ["discover", "read", "edit"].each do |access|
25
- ["user", "group"].each do |type|
26
- define_method("inherited_#{access}_#{type}s") do
27
- admin_policy ? admin_policy.send("default_#{access}_#{type}s") : []
28
- end
29
- end
30
- end
31
-
32
12
  def copy_admin_policy_from(other)
33
13
  if admin_policy = other.admin_policy
34
14
  self.admin_policy = admin_policy
@@ -5,9 +5,9 @@ module Ddr
5
5
  extend Deprecation
6
6
 
7
7
  included do
8
- contains Ddr::Datastreams::CONTENT, class_name: 'Ddr::Models::File'
9
- contains Ddr::Datastreams::EXTRACTED_TEXT, class_name: 'Ddr::Models::File'
10
- contains Ddr::Datastreams::FITS, class_name: 'Ddr::Models::FitsXmlFile'
8
+ contains Ddr::Models::File::CONTENT, class_name: 'Ddr::Models::File'
9
+ contains Ddr::Models::File::EXTRACTED_TEXT, class_name: 'Ddr::Models::File'
10
+ contains Ddr::Models::File::FITS, class_name: 'Ddr::Models::FitsXmlFile'
11
11
 
12
12
  property :legacy_original_filename,
13
13
  predicate: RDF::Vocab::PREMIS.hasOriginalName,
@@ -26,7 +26,7 @@ module Ddr
26
26
 
27
27
  # Convenience method wrapping FileManagement#add_file
28
28
  def upload(file, opts={})
29
- add_file(file, opts.merge(path: Ddr::Datastreams::CONTENT))
29
+ add_file(file, opts.merge(path: Ddr::Models::File::CONTENT))
30
30
  end
31
31
 
32
32
  # Set content to file and save
@@ -4,13 +4,14 @@ module Ddr
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- contains Ddr::Datastreams::STRUCT_METADATA, class_name: 'Ddr::Datastreams::StructuralMetadataDatastream'
7
+ contains Ddr::Models::File::STRUCT_METADATA,
8
+ class_name: 'Ddr::Models::StructuralMetadataFile'
8
9
  end
9
10
 
10
11
  def structure
11
12
  unless @structure
12
- if datastreams[Ddr::Datastreams::STRUCT_METADATA].content
13
- @structure = Ddr::Models::Structure.new(Nokogiri::XML(datastreams[Ddr::Datastreams::STRUCT_METADATA].content))
13
+ if datastreams[Ddr::Models::File::STRUCT_METADATA].content
14
+ @structure = Ddr::Models::Structure.new(Nokogiri::XML(datastreams[Ddr::Models::File::STRUCT_METADATA].content))
14
15
  end
15
16
  end
16
17
  @structure
@@ -3,7 +3,7 @@ module Ddr::Models
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- contains Ddr::Datastreams::THUMBNAIL, class_name: "Ddr::Models::File"
6
+ contains Ddr::Models::File::THUMBNAIL, class_name: "Ddr::Models::File"
7
7
  end
8
8
 
9
9
  def thumbnail_changed?
@@ -135,15 +135,15 @@ module Ddr::Models
135
135
  end
136
136
 
137
137
  def has_thumbnail?
138
- has_datastream?(Ddr::Datastreams::THUMBNAIL)
138
+ has_datastream?(Ddr::Models::File::THUMBNAIL)
139
139
  end
140
140
 
141
141
  def has_content?
142
- has_datastream?(Ddr::Datastreams::CONTENT)
142
+ has_datastream?(Ddr::Models::File::CONTENT)
143
143
  end
144
144
 
145
145
  def content_ds
146
- datastreams[Ddr::Datastreams::CONTENT]
146
+ datastreams[Ddr::Models::File::CONTENT]
147
147
  end
148
148
 
149
149
  def content_mime_type
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0.beta.9"
3
+ VERSION = "3.0.0.beta.10"
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ module Ddr
24
24
  end
25
25
 
26
26
  describe "generators called" do
27
- before { object.add_file file, path: Ddr::Datastreams::CONTENT }
27
+ before { object.add_file file, path: Ddr::Models::File::CONTENT }
28
28
  context "all derivatives" do
29
29
  context "not multires_image_able" do
30
30
  let(:object) { ContentBearing.new }
@@ -85,10 +85,10 @@ module Ddr
85
85
  describe "thumbnail" do
86
86
  let(:object) { ContentBearing.create }
87
87
  it "should create content in the thumbnail datastream" do
88
- expect(object.datastreams[Ddr::Datastreams::THUMBNAIL]).to_not be_present
88
+ expect(object.datastreams[Ddr::Models::File::THUMBNAIL]).to_not be_present
89
89
  object.derivatives.generate_derivative Ddr::Derivatives::DERIVATIVES[:thumbnail]
90
- expect(object.datastreams[Ddr::Datastreams::THUMBNAIL]).to be_present
91
- expect(object.datastreams[Ddr::Datastreams::THUMBNAIL].size).to be > 0
90
+ expect(object.datastreams[Ddr::Models::File::THUMBNAIL]).to be_present
91
+ expect(object.datastreams[Ddr::Models::File::THUMBNAIL].size).to be > 0
92
92
  end
93
93
  end
94
94
  describe "ptif" do
@@ -95,7 +95,7 @@ RSpec.describe ActiveFedora::Base do
95
95
  end
96
96
  describe "#has_thumbnail?" do
97
97
  let(:thumbnailable) { Thumbnailable.new }
98
- before { allow(thumbnailable.datastreams[Ddr::Datastreams::THUMBNAIL]).to receive(:has_content?).and_return(true) }
98
+ before { allow(thumbnailable.datastreams[Ddr::Models::File::THUMBNAIL]).to receive(:has_content?).and_return(true) }
99
99
  it "should return true if object has a thumbnail, else false" do
100
100
  expect(thumbnailable).to have_thumbnail
101
101
  expect(Thumbnailable.new).not_to have_thumbnail
@@ -121,7 +121,7 @@ RSpec.describe ActiveFedora::Base do
121
121
  end
122
122
  describe "#has_content?" do
123
123
  let(:contentable) { Contentable.new }
124
- before { allow(contentable.datastreams[Ddr::Datastreams::CONTENT]).to receive(:has_content?).and_return(true) }
124
+ before { allow(contentable.datastreams[Ddr::Models::File::CONTENT]).to receive(:has_content?).and_return(true) }
125
125
  it "should return true if object has content, else false" do
126
126
  expect(contentable).to have_content
127
127
  expect(Contentable.new).not_to have_content
@@ -3,28 +3,6 @@ require 'spec_helper'
3
3
  module Ddr::Models
4
4
  RSpec.describe File do
5
5
 
6
- describe "versioning" do
7
- let(:obj) { FactoryGirl.build(:component) }
8
- describe "on create" do
9
- it "creates a version" do
10
- expect { obj.save }.to change { obj.content.has_versions? }.from(false).to(true)
11
- obj.save
12
- expect(obj.content.versions.all.size).to eq 1
13
- end
14
- end
15
- describe "on update" do
16
- it "creates a version" do
17
- obj.save
18
- expect {
19
- obj.upload fixture_file_upload("imageB.tif", "image/tiff")
20
- obj.save
21
- }.to change {
22
- obj.content.versions.all.size
23
- }.by(1)
24
- end
25
- end
26
- end
27
-
28
6
  describe "#tempfile" do
29
7
  describe "when the datastream has no content" do
30
8
  it "should raise an exception" do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- module Ddr::Datastreams
4
- RSpec.describe FitsDatastream do
3
+ module Ddr::Models
4
+ RSpec.describe FitsXmlFile do
5
5
 
6
6
  let(:fits_xml) do
7
7
  <<-XML
@@ -13,7 +13,7 @@ module Ddr
13
13
  end
14
14
  end
15
15
  context "existing structural metadata" do
16
- before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = simple_structure }
16
+ before { item.datastreams[Ddr::Models::File::STRUCT_METADATA].content = simple_structure }
17
17
  it "should return the structural metadata" do
18
18
  expect(item.structure.to_xml).to be_equivalent_to(simple_structure)
19
19
  end
@@ -35,7 +35,7 @@ module Ddr
35
35
 
36
36
  describe "indexing" do
37
37
  let(:expected_json) { multiple_struct_maps_structure_to_json }
38
- before { item.datastreams[Ddr::Datastreams::STRUCT_METADATA].content = multiple_struct_maps_structure }
38
+ before { item.datastreams[Ddr::Models::File::STRUCT_METADATA].content = multiple_struct_maps_structure }
39
39
  it "should index the JSON representation of the structure" do
40
40
  indexing = item.to_solr
41
41
  expect(indexing.keys).to include(Ddr::Index::Fields::STRUCT_MAPS)
@@ -45,4 +45,4 @@ module Ddr
45
45
 
46
46
  end
47
47
  end
48
- end
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.9
4
+ version: 3.0.0.beta.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-09 00:00:00.000000000 Z
12
+ date: 2016-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -469,8 +469,6 @@ files:
469
469
  - lib/ddr/auth/user.rb
470
470
  - lib/ddr/auth/web_auth_context.rb
471
471
  - lib/ddr/datastreams.rb
472
- - lib/ddr/datastreams/descriptive_metadata_datastream.rb
473
- - lib/ddr/datastreams/fits_datastream.rb
474
472
  - lib/ddr/derivatives.rb
475
473
  - lib/ddr/derivatives/derivative.rb
476
474
  - lib/ddr/derivatives/generators/generator.rb
@@ -604,7 +602,6 @@ files:
604
602
  - spec/auth/web_auth_context_spec.rb
605
603
  - spec/controllers/application_controller_spec.rb
606
604
  - spec/controllers/users/sessions_controller_spec.rb
607
- - spec/datastreams/fits_datastream_spec.rb
608
605
  - spec/derivatives/multires_image_spec.rb
609
606
  - spec/derivatives/png_generator_spec.rb
610
607
  - spec/derivatives/ptif_generator_spec.rb
@@ -704,6 +701,7 @@ files:
704
701
  - spec/models/file_management_spec.rb
705
702
  - spec/models/file_spec.rb
706
703
  - spec/models/finding_aid_spec.rb
704
+ - spec/models/fits_xml_file_spec.rb
707
705
  - spec/models/has_admin_metadata_spec.rb
708
706
  - spec/models/has_children_spec.rb
709
707
  - spec/models/has_struct_metadata_spec.rb
@@ -778,7 +776,6 @@ test_files:
778
776
  - spec/auth/web_auth_context_spec.rb
779
777
  - spec/controllers/application_controller_spec.rb
780
778
  - spec/controllers/users/sessions_controller_spec.rb
781
- - spec/datastreams/fits_datastream_spec.rb
782
779
  - spec/derivatives/multires_image_spec.rb
783
780
  - spec/derivatives/png_generator_spec.rb
784
781
  - spec/derivatives/ptif_generator_spec.rb
@@ -878,6 +875,7 @@ test_files:
878
875
  - spec/models/file_management_spec.rb
879
876
  - spec/models/file_spec.rb
880
877
  - spec/models/finding_aid_spec.rb
878
+ - spec/models/fits_xml_file_spec.rb
881
879
  - spec/models/has_admin_metadata_spec.rb
882
880
  - spec/models/has_children_spec.rb
883
881
  - spec/models/has_struct_metadata_spec.rb
@@ -1,43 +0,0 @@
1
- module Ddr
2
- module Datastreams
3
- class DescriptiveMetadataDatastream < MetadataDatastream
4
-
5
- class_attribute :vocabularies
6
- self.vocabularies = [RDF::DC, Ddr::Vocab::DukeTerms].freeze
7
-
8
- def self.default_attributes
9
- super.merge(:mimeType => 'application/n-triples')
10
- end
11
-
12
- def self.indexers
13
- # Add term_name => [indexers] mapping to customize indexing
14
- {}
15
- end
16
-
17
- def self.default_indexers
18
- [:stored_searchable]
19
- end
20
-
21
- def self.indexers_for(term_name)
22
- indexers.fetch(term_name, default_indexers)
23
- end
24
-
25
- # Add terms from the vocabularies as properties
26
- vocabularies.each do |vocab|
27
- Ddr::Vocab::Vocabulary.property_terms(vocab).each do |term|
28
- term_name = Ddr::Vocab::Vocabulary.term_name(vocab, term)
29
- property term_name, predicate: term do |index|
30
- index.as *indexers_for(term_name)
31
- end
32
- end
33
- end
34
-
35
- # Override ActiveFedora::Rdf::Indexing#apply_prefix(name) to not
36
- # prepend the index field name with a string based on the datastream id.
37
- def apply_prefix(name)
38
- name
39
- end
40
-
41
- end
42
- end
43
- end
@@ -1,85 +0,0 @@
1
- module Ddr::Datastreams
2
- class FitsDatastream < ActiveFedora::OmDatastream
3
- extend AutoVersion
4
-
5
- FITS_XMLNS = "http://hul.harvard.edu/ois/xml/ns/fits/fits_output".freeze
6
- FITS_SCHEMA = "http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd".freeze
7
-
8
- EXIFTOOL = "Exiftool"
9
-
10
- set_terminology do |t|
11
- t.root(path: "fits",
12
- xmlns: FITS_XMLNS,
13
- schema: FITS_SCHEMA)
14
- t.version(path: {attribute: "version"})
15
- t.timestamp(path: {attribute: "timestamp"})
16
- t.identification {
17
- t.identity {
18
- t.mimetype(path: {attribute: "mimetype"})
19
- t.format_label(path: {attribute: "format"})
20
- t.version
21
- t.externalIdentifier
22
- t.pronom_identifier(path: "externalIdentifier", attributes: {type: "puid"})
23
- }
24
- }
25
- t.fileinfo {
26
- t.size
27
- t.creatingApplicationName
28
- t.created
29
- t.lastmodified
30
- }
31
- t.filestatus {
32
- t.valid
33
- t.well_formed(path: "well-formed")
34
- }
35
- t.metadata {
36
- t.image {
37
- t.imageWidth
38
- t.imageHeight
39
- t.colorSpace
40
- }
41
- t.document {
42
- # TODO - configure to get from Tika?
43
- # t.encoding
44
- }
45
- t.text
46
- t.audio
47
- t.video
48
- }
49
-
50
- ## proxy terms
51
- # identification / identity
52
- t.media_type proxy: [:identification, :identity, :mimetype]
53
- t.format_label proxy: [:identification, :identity, :format_label]
54
- t.format_version proxy: [:identification, :identity, :version]
55
- t.pronom_identifier proxy: [:identification, :identity, :pronom_identifier]
56
- # filestatus
57
- t.valid proxy: [:filestatus, :valid]
58
- t.well_formed proxy: [:filestatus, :well_formed]
59
- # fileinfo
60
- t.created proxy: [:fileinfo, :created]
61
- t.creating_application proxy: [:fileinfo, :creatingApplicationName]
62
- t.extent proxy: [:fileinfo, :size]
63
- # image metadata
64
- t.image_width proxy: [:metadata, :image, :imageWidth]
65
- t.image_height proxy: [:metadata, :image, :imageHeight]
66
- t.color_space proxy: [:metadata, :image, :colorSpace]
67
- end
68
-
69
- def self.xml_template
70
- builder = Nokogiri::XML::Builder.new do |xml|
71
- xml.fits("xmlns"=>FITS_XMLNS,
72
- "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
73
- "xsi:schemaLocation"=>"http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd")
74
- end
75
- builder.doc
76
- end
77
-
78
- def modified
79
- ng_xml
80
- .xpath("//fits:fileinfo/fits:lastmodified[@toolname != '#{EXIFTOOL}']", fits: FITS_XMLNS)
81
- .map(&:text)
82
- end
83
-
84
- end
85
- end