spotlight-dor-resources 0.0.2 → 0.0.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:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5b035c7c9d1aa81f28332f8304294beb43a960ab
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 1658a13bf5ff55aa7f0d67cf7770c89e17648f2d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fa6d70d3f6530b159e9bec06a3c8b2219bb836a5a3608d291c047ae7d405d653ccf02d0f4b028523a0a942848d1b9cd2070fe42cd28e786496a8059c670c28df
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a99351ec2d515332d76582c6b178be12021834c499d3725225b2cf2727871dd794c800a913dd87a40091cf807b76145489797cddf00ad04b1f7f97209c04ec03
         
     | 
| 
         @@ -1,17 +1,47 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Spotlight::Resources
         
     | 
| 
       2 
2 
     | 
    
         
             
              class DorResource < Spotlight::Resource
         
     | 
| 
      
 3 
     | 
    
         
            +
                ##
         
     | 
| 
      
 4 
     | 
    
         
            +
                # Generate solr documents for the DOR resources identified by this object
         
     | 
| 
      
 5 
     | 
    
         
            +
                #
         
     | 
| 
      
 6 
     | 
    
         
            +
                # @return [Enumerator] an enumerator of solr document hashes for indexing
         
     | 
| 
       3 
7 
     | 
    
         
             
                def to_solr
         
     | 
| 
       4 
8 
     | 
    
         
             
                  return to_enum :to_solr unless block_given?
         
     | 
| 
       5 
9 
     | 
    
         | 
| 
       6 
10 
     | 
    
         
             
                  base_doc = super
         
     | 
| 
       7 
11 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                   
     | 
| 
       9 
     | 
    
         
            -
                    yield base_doc.merge( 
     | 
| 
      
 12 
     | 
    
         
            +
                  indexable_resources.each do |res|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    yield base_doc.merge(to_solr_document(res))
         
     | 
| 
       10 
14 
     | 
    
         
             
                  end
         
     | 
| 
       11 
15 
     | 
    
         
             
                end
         
     | 
| 
       12 
16 
     | 
    
         | 
| 
       13 
17 
     | 
    
         
             
                def resource
         
     | 
| 
       14 
18 
     | 
    
         
             
                  @resource ||= Spotlight::Dor::Resources.indexer.resource doc_id
         
     | 
| 
       15 
19 
     | 
    
         
             
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                private
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                ##
         
     | 
| 
      
 24 
     | 
    
         
            +
                # Enumerate the resource, and any collection members, that should be indexed
         
     | 
| 
      
 25 
     | 
    
         
            +
                # into this exhibit
         
     | 
| 
      
 26 
     | 
    
         
            +
                #
         
     | 
| 
      
 27 
     | 
    
         
            +
                # @return [Enumerator] an enumerator of resources to index
         
     | 
| 
      
 28 
     | 
    
         
            +
                def indexable_resources
         
     | 
| 
      
 29 
     | 
    
         
            +
                  return to_enum(:indexable_resources) unless block_given?
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  yield resource
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  resource.items.each do |r|
         
     | 
| 
      
 34 
     | 
    
         
            +
                    yield r
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                ##
         
     | 
| 
      
 39 
     | 
    
         
            +
                # Generate the solr document hash for a given resource by applying the current
         
     | 
| 
      
 40 
     | 
    
         
            +
                # indexer steps.
         
     | 
| 
      
 41 
     | 
    
         
            +
                #
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @return [Hash]
         
     | 
| 
      
 43 
     | 
    
         
            +
                def to_solr_document(resource)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  Spotlight::Dor::Resources.indexer.solr_document(resource)
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
       16 
46 
     | 
    
         
             
              end
         
     | 
| 
       17 
47 
     | 
    
         
             
            end
         
     | 
| 
         @@ -67,8 +67,9 @@ module Spotlight::Dor 
     | 
|
| 
       67 
67 
     | 
    
         
             
                    # note that this will also find Flatbox or Flat-box
         
     | 
| 
       68 
68 
     | 
    
         
             
                    match_data = val.match(/Box ?:? ?([^,|(Folder)]+)/i)
         
     | 
| 
       69 
69 
     | 
    
         
             
                    match_data[1].strip if match_data.present?
         
     | 
| 
       70 
     | 
    
         
            -
                  end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                  end.compact
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  solr_doc['box_ssi'] = box_num.first
         
     | 
| 
       72 
73 
     | 
    
         
             
                end
         
     | 
| 
       73 
74 
     | 
    
         | 
| 
       74 
75 
     | 
    
         
             
                # This new donor_tags_sim field was added in October 2015 specifically for the Feigenbaum exhibit.  It is very likely
         
     | 
| 
         @@ -97,9 +98,9 @@ module Spotlight::Dor 
     | 
|
| 
       97 
98 
     | 
    
         
             
                                 end
         
     | 
| 
       98 
99 
     | 
    
         | 
| 
       99 
100 
     | 
    
         
             
                    match_data[1].strip if match_data.present?
         
     | 
| 
       100 
     | 
    
         
            -
                  end
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end.compact
         
     | 
| 
       101 
102 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
                  solr_doc['folder_ssi'] = folder_num.first 
     | 
| 
      
 103 
     | 
    
         
            +
                  solr_doc['folder_ssi'] = folder_num.first
         
     | 
| 
       103 
104 
     | 
    
         
             
                end
         
     | 
| 
       104 
105 
     | 
    
         | 
| 
       105 
106 
     | 
    
         
             
                # add the folder name to solr_doc as folder_name_ssi field (note: single valued!)
         
     | 
| 
         @@ -127,8 +128,9 @@ module Spotlight::Dor 
     | 
|
| 
       127 
128 
     | 
    
         
             
                    # feigenbaum uses 'Accession'
         
     | 
| 
       128 
129 
     | 
    
         
             
                    match_data = val.match(/(?:(?:Series)|(?:Accession)):? ([^,|]+)/i)
         
     | 
| 
       129 
130 
     | 
    
         
             
                    match_data[1].strip if match_data.present?
         
     | 
| 
       130 
     | 
    
         
            -
                  end
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
                  end.compact
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                  solr_doc['series_ssi'] = series_num.first
         
     | 
| 
       132 
134 
     | 
    
         
             
                end
         
     | 
| 
       133 
135 
     | 
    
         | 
| 
       134 
136 
     | 
    
         
             
                # rubocop:disable Metrics/AbcSize
         
     | 
| 
         @@ -28,6 +28,17 @@ describe Spotlight::Dor::Indexer do 
     | 
|
| 
       28 
28 
     | 
    
         
             
                EOF
         
     | 
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
              let(:mods_loc_multiple_phys_loc) do
         
     | 
| 
      
 32 
     | 
    
         
            +
                Nokogiri::XML <<-EOF
         
     | 
| 
      
 33 
     | 
    
         
            +
                  <mods xmlns="#{Mods::MODS_NS}">
         
     | 
| 
      
 34 
     | 
    
         
            +
                    <location>
         
     | 
| 
      
 35 
     | 
    
         
            +
                      <physicalLocation>Irrelevant Data</physicalLocation>
         
     | 
| 
      
 36 
     | 
    
         
            +
                      <physicalLocation>#{example}</physicalLocation>
         
     | 
| 
      
 37 
     | 
    
         
            +
                    </location>
         
     | 
| 
      
 38 
     | 
    
         
            +
                  </mods>
         
     | 
| 
      
 39 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       31 
42 
     | 
    
         
             
              before do
         
     | 
| 
       32 
43 
     | 
    
         
             
                # ignore noisy logs
         
     | 
| 
       33 
44 
     | 
    
         
             
                allow(r).to receive(:harvestdor_client)
         
     | 
| 
         @@ -86,6 +97,15 @@ describe Spotlight::Dor::Indexer do 
     | 
|
| 
       86 
97 
     | 
    
         
             
                        expect(solr_doc['series_ssi']).to eq expected
         
     | 
| 
       87 
98 
     | 
    
         
             
                      end
         
     | 
| 
       88 
99 
     | 
    
         
             
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
                    context 'with multiple physicalLocation elements' do
         
     | 
| 
      
 101 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 102 
     | 
    
         
            +
                        allow(r).to receive(:mods).and_return(mods_loc_multiple_phys_loc)
         
     | 
| 
      
 103 
     | 
    
         
            +
                        subject.send(:add_series, sdb, solr_doc)
         
     | 
| 
      
 104 
     | 
    
         
            +
                      end
         
     | 
| 
      
 105 
     | 
    
         
            +
                      it "has the expected series name '#{expected}'" do
         
     | 
| 
      
 106 
     | 
    
         
            +
                        expect(solr_doc['series_ssi']).to eq expected
         
     | 
| 
      
 107 
     | 
    
         
            +
                      end
         
     | 
| 
      
 108 
     | 
    
         
            +
                    end
         
     | 
| 
       89 
109 
     | 
    
         
             
                  end # for example
         
     | 
| 
       90 
110 
     | 
    
         
             
                end # each
         
     | 
| 
       91 
111 
     | 
    
         
             
              end # add_series
         
     | 
| 
         @@ -140,6 +160,16 @@ describe Spotlight::Dor::Indexer do 
     | 
|
| 
       140 
160 
     | 
    
         
             
                        expect(solr_doc['box_ssi']).to eq expected
         
     | 
| 
       141 
161 
     | 
    
         
             
                      end
         
     | 
| 
       142 
162 
     | 
    
         
             
                    end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                    context 'with multiple physicalLocation elements' do
         
     | 
| 
      
 165 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 166 
     | 
    
         
            +
                        allow(r).to receive(:mods).and_return(mods_loc_multiple_phys_loc)
         
     | 
| 
      
 167 
     | 
    
         
            +
                        subject.send(:add_box, sdb, solr_doc)
         
     | 
| 
      
 168 
     | 
    
         
            +
                      end
         
     | 
| 
      
 169 
     | 
    
         
            +
                      it "has the expected series name '#{expected}'" do
         
     | 
| 
      
 170 
     | 
    
         
            +
                        expect(solr_doc['box_ssi']).to eq expected
         
     | 
| 
      
 171 
     | 
    
         
            +
                      end
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
       143 
173 
     | 
    
         
             
                  end # for example
         
     | 
| 
       144 
174 
     | 
    
         
             
                end # each
         
     | 
| 
       145 
175 
     | 
    
         
             
              end # add_box
         
     | 
| 
         @@ -196,6 +226,16 @@ describe Spotlight::Dor::Indexer do 
     | 
|
| 
       196 
226 
     | 
    
         
             
                        expect(solr_doc['folder_ssi']).to eq expected
         
     | 
| 
       197 
227 
     | 
    
         
             
                      end
         
     | 
| 
       198 
228 
     | 
    
         
             
                    end
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                    context 'with multiple physicalLocation elements' do
         
     | 
| 
      
 231 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 232 
     | 
    
         
            +
                        allow(r).to receive(:mods).and_return(mods_loc_multiple_phys_loc)
         
     | 
| 
      
 233 
     | 
    
         
            +
                        subject.send(:add_folder, sdb, solr_doc)
         
     | 
| 
      
 234 
     | 
    
         
            +
                      end
         
     | 
| 
      
 235 
     | 
    
         
            +
                      it "has the expected series name '#{expected}'" do
         
     | 
| 
      
 236 
     | 
    
         
            +
                        expect(solr_doc['folder_ssi']).to eq expected
         
     | 
| 
      
 237 
     | 
    
         
            +
                      end
         
     | 
| 
      
 238 
     | 
    
         
            +
                    end
         
     | 
| 
       199 
239 
     | 
    
         
             
                  end # for example
         
     | 
| 
       200 
240 
     | 
    
         
             
                end # each
         
     | 
| 
       201 
241 
     | 
    
         
             
              end # add_folder
         
     | 
| 
         @@ -20,6 +20,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       20 
20 
     | 
    
         
             
              spec.add_dependency "faraday"
         
     | 
| 
       21 
21 
     | 
    
         
             
              spec.add_dependency 'solrizer'
         
     | 
| 
       22 
22 
     | 
    
         
             
              spec.add_dependency 'gdor-indexer'
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.add_dependency 'harvestdor-indexer', '>= 2.2.0' # 2.2.0 introduced enumerable collections
         
     | 
| 
       23 
24 
     | 
    
         
             
              spec.add_dependency "rails"
         
     | 
| 
       24 
25 
     | 
    
         
             
              spec.add_dependency "blacklight-spotlight", "~> 0.5"
         
     | 
| 
       25 
26 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.5"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: spotlight-dor-resources
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Chris Beer
         
     | 
| 
         @@ -52,6 +52,20 @@ dependencies: 
     | 
|
| 
       52 
52 
     | 
    
         
             
                - - ">="
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
54 
     | 
    
         
             
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: harvestdor-indexer
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: 2.2.0
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: 2.2.0
         
     | 
| 
       55 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       56 
70 
     | 
    
         
             
              name: rails
         
     | 
| 
       57 
71 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |