hydra-pcdm 0.3.2 → 0.4.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 +4 -4
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/hydra/pcdm/models/concerns/collection_behavior.rb +0 -10
- data/lib/hydra/pcdm/models/concerns/object_behavior.rb +1 -6
- data/lib/hydra/pcdm/models/concerns/pcdm_behavior.rb +0 -25
- data/lib/hydra/pcdm/services/file/get_mime_type.rb +1 -1
- data/lib/hydra/pcdm/validators/ancestor_validator.rb +1 -1
- data/lib/hydra/pcdm/validators/pcdm_object_validator.rb +1 -1
- data/lib/hydra/pcdm/validators/pcdm_validator.rb +1 -1
- data/lib/hydra/pcdm/version.rb +1 -1
- data/spec/hydra/pcdm/models/collection_spec.rb +0 -19
- data/spec/hydra/pcdm/models/object_spec.rb +48 -34
- data/spec/spec_helper.rb +3 -4
- metadata +3 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 34be4330f2d67658ff23d0ca81d507a8148cd017
         | 
| 4 | 
            +
              data.tar.gz: 8a99d7df6d98e0b3d065c808da63b90dcc99fc81
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e0a70541608c6409dd236b136b1c0441200866887f5161d89132e52eb7c373a62ab9d296d8a243a8836515bb2dcc32d3571e5a4d92d1b7b3c8d01fc55d2bcdf0
         | 
| 7 | 
            +
              data.tar.gz: 71ee5d660565ff2accb6f69f7342d9399f9f64c44ec1766a0d8d8d1129c4ff9ca68e5f470a48029ff825367f286c6aded5488a79418179efea17b0cc43c10509
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    
| @@ -50,15 +50,5 @@ module Hydra::PCDM | |
| 50 50 | 
             
                def pcdm_collection?
         | 
| 51 51 | 
             
                  true
         | 
| 52 52 | 
             
                end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                def child_collections
         | 
| 55 | 
            -
                  warn '[DEPRECATION] `child_collections` is deprecated in Hydra::PCDM.  Please use `collections` instead.  This has a target date for removal of 10-31-2015'
         | 
| 56 | 
            -
                  ordered_collections
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                def child_collection_ids
         | 
| 60 | 
            -
                  warn '[DEPRECATION] `child_collection_ids` is deprecated in Hydra::PCDM.  Please use `collection_ids` instead.  This has a target date for removal of 10-31-2015'
         | 
| 61 | 
            -
                  ordered_collection_ids
         | 
| 62 | 
            -
                end
         | 
| 63 53 | 
             
              end
         | 
| 64 54 | 
             
            end
         | 
| @@ -40,12 +40,7 @@ module Hydra::PCDM | |
| 40 40 | 
             
                end
         | 
| 41 41 |  | 
| 42 42 | 
             
                def in_objects
         | 
| 43 | 
            -
                   | 
| 44 | 
            -
                end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                def parent_objects
         | 
| 47 | 
            -
                  warn '[DEPRECATION] `parent_objects` is deprecated in Hydra::PCDM.  Please use `in_objects` instead.  This has a target date for removal of 10-31-2015'
         | 
| 48 | 
            -
                  in_objects
         | 
| 43 | 
            +
                  member_of.select(&:pcdm_object?).to_a
         | 
| 49 44 | 
             
                end
         | 
| 50 45 |  | 
| 51 46 | 
             
                # Returns directly contained files that have the requested RDF Type
         | 
| @@ -48,29 +48,14 @@ module Hydra::PCDM | |
| 48 48 | 
             
                  ordered_objects.map(&:id)
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                def parents
         | 
| 52 | 
            -
                  warn '[DEPRECATION] `parents` is deprecated in Hydra::PCDM.  Please use `ordered_by` instead.  This has a target date for removal of 10-31-2015'
         | 
| 53 | 
            -
                  ordered_by.to_a
         | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
             | 
| 56 51 | 
             
                def in_collections
         | 
| 57 52 | 
             
                  member_of.select(&:pcdm_collection?).to_a
         | 
| 58 53 | 
             
                end
         | 
| 59 54 |  | 
| 60 | 
            -
                def parent_collections
         | 
| 61 | 
            -
                  warn '[DEPRECATION] `parent_collections` is deprecated in Hydra::PCDM.  Please use `in_collections` instead.  This has a target date for removal of 10-31-2015'
         | 
| 62 | 
            -
                  in_collections
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
             | 
| 65 55 | 
             
                def in_collection_ids
         | 
| 66 56 | 
             
                  in_collections.map(&:id)
         | 
| 67 57 | 
             
                end
         | 
| 68 58 |  | 
| 69 | 
            -
                def parent_collection_ids
         | 
| 70 | 
            -
                  warn '[DEPRECATION] `parent_collection_ids` is deprecated in Hydra::PCDM.  Please use `in_collection_ids` instead.  This has a target date for removal of 10-31-2015'
         | 
| 71 | 
            -
                  in_collection_ids
         | 
| 72 | 
            -
                end
         | 
| 73 | 
            -
             | 
| 74 59 | 
             
                def ancestor?(record)
         | 
| 75 60 | 
             
                  ancestor_checker.ancestor?(record)
         | 
| 76 61 | 
             
                end
         | 
| @@ -78,15 +63,5 @@ module Hydra::PCDM | |
| 78 63 | 
             
                def ancestor_checker
         | 
| 79 64 | 
             
                  @ancestor_checker ||= ::Hydra::PCDM::AncestorChecker.new(self)
         | 
| 80 65 | 
             
                end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                def child_objects
         | 
| 83 | 
            -
                  warn '[DEPRECATION] `child_objects` is deprecated in Hydra::PCDM.  Please use `objects` instead.  This has a target date for removal of 10-31-2015'
         | 
| 84 | 
            -
                  ordered_objects
         | 
| 85 | 
            -
                end
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                def child_object_ids
         | 
| 88 | 
            -
                  warn '[DEPRECATION] `child_object_ids` is deprecated in Hydra::PCDM.  Please use `object_ids` instead.  This has a target date for removal of 10-31-2015'
         | 
| 89 | 
            -
                  object_ids
         | 
| 90 | 
            -
                end
         | 
| 91 66 | 
             
              end
         | 
| 92 67 | 
             
            end
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module Hydra::PCDM
         | 
| 2 2 | 
             
              class GetMimeTypeForFile
         | 
| 3 3 | 
             
                def self.call(path)
         | 
| 4 | 
            -
                   | 
| 4 | 
            +
                  raise ArgumentError, 'supplied argument should be a path to a file' unless path.is_a?(String)
         | 
| 5 5 | 
             
                  mime_types = ::MIME::Types.of(::File.basename(path))
         | 
| 6 6 | 
             
                  mime_types.empty? ? 'application/octet-stream' : mime_types.first.content_type
         | 
| 7 7 | 
             
                end
         | 
| @@ -12,7 +12,7 @@ module Hydra::PCDM::Validators | |
| 12 12 |  | 
| 13 13 | 
             
                def validate!
         | 
| 14 14 | 
             
                  return unless owner.ancestor?(record)
         | 
| 15 | 
            -
                   | 
| 15 | 
            +
                  raise ArgumentError, "#{record.class} with ID: #{record.id} failed to pass AncestorChecker validation"
         | 
| 16 16 | 
             
                end
         | 
| 17 17 | 
             
              end
         | 
| 18 18 | 
             
            end
         | 
| @@ -2,7 +2,7 @@ module Hydra::PCDM::Validators | |
| 2 2 | 
             
              class PCDMObjectValidator
         | 
| 3 3 | 
             
                def self.validate!(_association, record)
         | 
| 4 4 | 
             
                  unless record.try(:pcdm_object?)
         | 
| 5 | 
            -
                     | 
| 5 | 
            +
                    raise ActiveFedora::AssociationTypeMismatch, "#{record} is not a PCDM object."
         | 
| 6 6 | 
             
                  end
         | 
| 7 7 | 
             
                end
         | 
| 8 8 | 
             
              end
         | 
| @@ -2,7 +2,7 @@ module Hydra::PCDM::Validators | |
| 2 2 | 
             
              class PCDMValidator
         | 
| 3 3 | 
             
                def self.validate!(_reflection, record)
         | 
| 4 4 | 
             
                  if !record.try(:pcdm_object?) && !record.try(:pcdm_collection?)
         | 
| 5 | 
            -
                     | 
| 5 | 
            +
                    raise ActiveFedora::AssociationTypeMismatch, "#{record} is not a PCDM object or collection."
         | 
| 6 6 | 
             
                  end
         | 
| 7 7 | 
             
                end
         | 
| 8 8 | 
             
              end
         | 
    
        data/lib/hydra/pcdm/version.rb
    CHANGED
    
    
| @@ -609,23 +609,4 @@ describe Hydra::PCDM::Collection do | |
| 609 609 | 
             
                  it { is_expected.to eq IndexingStuff::AltIndexer }
         | 
| 610 610 | 
             
                end
         | 
| 611 611 | 
             
              end
         | 
| 612 | 
            -
             | 
| 613 | 
            -
              describe 'make sure deprecated methods still work' do
         | 
| 614 | 
            -
                it 'deprecated methods should pass' do
         | 
| 615 | 
            -
                  collection1.ordered_members = [collection2]
         | 
| 616 | 
            -
                  expect(collection1.ordered_members << collection3).to eq [collection2, collection3]
         | 
| 617 | 
            -
                  expect(collection1.ordered_members += [collection4]).to eq [collection2, collection3, collection4]
         | 
| 618 | 
            -
                  expect(collection1.ordered_members << object1).to eq [collection2, collection3, collection4, object1]
         | 
| 619 | 
            -
                  expect(collection1.ordered_members << object2).to eq [collection2, collection3, collection4, object1, object2]
         | 
| 620 | 
            -
                  expect(collection1.ordered_members += [object3]).to eq [collection2, collection3, collection4, object1, object2, object3]
         | 
| 621 | 
            -
                  collection1.save # required until issue AF-Agg-75 is fixed
         | 
| 622 | 
            -
                  expect(collection2.parent_collections).to eq [collection1]
         | 
| 623 | 
            -
                  expect(collection2.parents).to eq [collection1]
         | 
| 624 | 
            -
                  expect(collection2.parent_collection_ids).to eq [collection1.id]
         | 
| 625 | 
            -
                  expect(collection1.child_objects).to eq [object1, object2, object3]
         | 
| 626 | 
            -
                  expect(collection1.child_object_ids).to eq [object1.id, object2.id, object3.id]
         | 
| 627 | 
            -
                  expect(collection1.child_collections).to eq [collection2, collection3, collection4]
         | 
| 628 | 
            -
                  expect(collection1.child_collection_ids).to eq [collection2.id, collection3.id, collection4.id]
         | 
| 629 | 
            -
                end
         | 
| 630 | 
            -
              end
         | 
| 631 612 | 
             
            end
         | 
| @@ -151,37 +151,67 @@ describe Hydra::PCDM::Object do | |
| 151 151 | 
             
                subject { object.in_objects }
         | 
| 152 152 | 
             
                let(:collection) { Hydra::PCDM::Collection.new }
         | 
| 153 153 | 
             
                let(:parent_object) { described_class.new }
         | 
| 154 | 
            -
                 | 
| 155 | 
            -
                   | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 154 | 
            +
                context 'using ordered_members' do
         | 
| 155 | 
            +
                  before do
         | 
| 156 | 
            +
                    collection.ordered_members = [object]
         | 
| 157 | 
            +
                    parent_object.ordered_members = [object]
         | 
| 158 | 
            +
                    parent_object.save
         | 
| 159 | 
            +
                    collection.save
         | 
| 160 | 
            +
                  end
         | 
| 161 | 
            +
             | 
| 162 | 
            +
                  it 'finds objects that aggregate the object' do
         | 
| 163 | 
            +
                    expect(subject).to eq [parent_object]
         | 
| 164 | 
            +
                  end
         | 
| 159 165 | 
             
                end
         | 
| 166 | 
            +
                context 'using members' do
         | 
| 167 | 
            +
                  before do
         | 
| 168 | 
            +
                    collection.members = [object]
         | 
| 169 | 
            +
                    parent_object.members = [object]
         | 
| 170 | 
            +
                    parent_object.save
         | 
| 171 | 
            +
                    collection.save
         | 
| 172 | 
            +
                  end
         | 
| 160 173 |  | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 174 | 
            +
                  it 'finds objects that aggregate the object' do
         | 
| 175 | 
            +
                    expect(subject).to eq [parent_object]
         | 
| 176 | 
            +
                  end
         | 
| 163 177 | 
             
                end
         | 
| 164 178 | 
             
              end
         | 
| 165 179 |  | 
| 166 180 | 
             
              describe 'in_collections' do
         | 
| 167 | 
            -
                let(:object) { described_class.create }
         | 
| 168 181 | 
             
                subject { object.in_collections }
         | 
| 169 182 | 
             
                let(:object) { described_class.create }
         | 
| 170 183 | 
             
                let(:collection1) { Hydra::PCDM::Collection.new }
         | 
| 171 184 | 
             
                let(:collection2) { Hydra::PCDM::Collection.new }
         | 
| 172 185 | 
             
                let(:parent_object) { described_class.new }
         | 
| 173 | 
            -
                 | 
| 174 | 
            -
                   | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 186 | 
            +
                context 'using ordered_members' do
         | 
| 187 | 
            +
                  before do
         | 
| 188 | 
            +
                    collection1.ordered_members = [object]
         | 
| 189 | 
            +
                    collection2.ordered_members = [object]
         | 
| 190 | 
            +
                    parent_object.ordered_members = [object]
         | 
| 191 | 
            +
                    parent_object.save
         | 
| 192 | 
            +
                    collection1.save
         | 
| 193 | 
            +
                    collection2.save
         | 
| 194 | 
            +
                  end
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                  it 'finds collections that aggregate the object' do
         | 
| 197 | 
            +
                    expect(subject).to match_array [collection1, collection2]
         | 
| 198 | 
            +
                    expect(subject.count).to eq 2
         | 
| 199 | 
            +
                  end
         | 
| 180 200 | 
             
                end
         | 
| 201 | 
            +
                context 'using members' do
         | 
| 202 | 
            +
                  before do
         | 
| 203 | 
            +
                    collection1.members = [object]
         | 
| 204 | 
            +
                    collection2.members = [object]
         | 
| 205 | 
            +
                    parent_object.members = [object]
         | 
| 206 | 
            +
                    parent_object.save
         | 
| 207 | 
            +
                    collection1.save
         | 
| 208 | 
            +
                    collection2.save
         | 
| 209 | 
            +
                  end
         | 
| 181 210 |  | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 211 | 
            +
                  it 'finds collections that aggregate the object' do
         | 
| 212 | 
            +
                    expect(subject).to match_array [collection1, collection2]
         | 
| 213 | 
            +
                    expect(subject.count).to eq 2
         | 
| 214 | 
            +
                  end
         | 
| 185 215 | 
             
                end
         | 
| 186 216 | 
             
              end
         | 
| 187 217 |  | 
| @@ -486,20 +516,4 @@ describe Hydra::PCDM::Object do | |
| 486 516 | 
             
                  it { is_expected.to eq IndexingStuff::AltIndexer }
         | 
| 487 517 | 
             
                end
         | 
| 488 518 | 
             
              end
         | 
| 489 | 
            -
             | 
| 490 | 
            -
              describe 'make sure deprecated methods still work' do
         | 
| 491 | 
            -
                let(:object1) { described_class.new }
         | 
| 492 | 
            -
                let(:object2) { described_class.new }
         | 
| 493 | 
            -
                let(:object3) { described_class.new }
         | 
| 494 | 
            -
                let(:object4) { described_class.new }
         | 
| 495 | 
            -
             | 
| 496 | 
            -
                it 'deprecated methods should pass' do
         | 
| 497 | 
            -
                  object1.ordered_members = [object2]
         | 
| 498 | 
            -
                  expect(object1.ordered_members << object3).to eq [object2, object3]
         | 
| 499 | 
            -
                  expect(object1.ordered_members += [object4]).to eq [object2, object3, object4]
         | 
| 500 | 
            -
                  object1.save # required until issue AF-Agg-75 is fixed
         | 
| 501 | 
            -
                  expect(object2.parent_objects).to eq [object1]
         | 
| 502 | 
            -
                  expect(object2.parents).to eq [object1]
         | 
| 503 | 
            -
                end
         | 
| 504 | 
            -
              end
         | 
| 505 519 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -2,10 +2,9 @@ ENV['environment'] ||= 'test' | |
| 2 2 | 
             
            require 'simplecov'
         | 
| 3 3 | 
             
            require 'coveralls'
         | 
| 4 4 |  | 
| 5 | 
            -
            SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter | 
| 6 | 
            -
              SimpleCov::Formatter::HTMLFormatter,
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            ]
         | 
| 5 | 
            +
            SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
         | 
| 6 | 
            +
              [SimpleCov::Formatter::HTMLFormatter,
         | 
| 7 | 
            +
               Coveralls::SimpleCov::Formatter])
         | 
| 9 8 | 
             
            SimpleCov.start 'rails'
         | 
| 10 9 |  | 
| 11 10 | 
             
            require 'bundler/setup'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hydra-pcdm
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - E. Lynette Rayle
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-02-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: active-fedora
         | 
| @@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 191 191 | 
             
                  version: '0'
         | 
| 192 192 | 
             
            requirements: []
         | 
| 193 193 | 
             
            rubyforge_project: 
         | 
| 194 | 
            -
            rubygems_version: 2.4. | 
| 194 | 
            +
            rubygems_version: 2.4.8
         | 
| 195 195 | 
             
            signing_key: 
         | 
| 196 196 | 
             
            specification_version: 4
         | 
| 197 197 | 
             
            summary: Portland Common Data Model (PCDM)
         | 
| @@ -206,4 +206,3 @@ test_files: | |
| 206 206 | 
             
            - spec/hydra/pcdm/services/file/get_mime_type_spec.rb
         | 
| 207 207 | 
             
            - spec/hydra/pcdm_spec.rb
         | 
| 208 208 | 
             
            - spec/spec_helper.rb
         | 
| 209 | 
            -
            has_rdoc: 
         |