gdor-indexer 0.2.0 → 0.3.0

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: 64f3819be05778daa18edefbef0db3c415d8a7af
4
- data.tar.gz: 379426de04d4160b4f2334a54d3308fc8d798edd
3
+ metadata.gz: f5512304eceff43f6099aa3de8864b61d587a6cc
4
+ data.tar.gz: 3e9e662af728c9d6de0291bff59e9e1cf41b2173
5
5
  SHA512:
6
- metadata.gz: d42cbf9c5d8ee8b9a2038b2ea77d0b51dc89f0fe7633ab2a6b5b17039fd25544c8e6397ae8c6e29b648cc5ae5ba3580bbe2f17ef9f708dc1134dc3414e13f8f6
7
- data.tar.gz: 4c44ff23c66af8336d00ef80b747dc28a833a9bc1bbf564c0fd048c0cd4b33f022c7ef4338015f5e1a9181f107ae490eb821afd125f6c6eaa6551d6f8630880e
6
+ metadata.gz: 0caa4dada6bbde97f147b3630683ed6b689309fc78584ca1aba47eea7421980e7a0ac6835ab55cef50398e8b03d6eca4d480601ffe2ba567c2e399e8f9aa27d5
7
+ data.tar.gz: 2b3e81c2b3693f4722359ca80efbece1e15b05cd14226986ef1c6bc6578eadcea42a33f1ccb859281c035e3836b0eeed4c8948eeb1444e3f8530f09d910a1b38
data/.rubocop_todo.yml CHANGED
@@ -37,7 +37,8 @@ Metrics/AbcSize:
37
37
  # Offense count: 1
38
38
  # Configuration parameters: CountComments.
39
39
  Metrics/ClassLength:
40
- Max: 242
40
+ Exclude:
41
+ - 'lib/gdor/indexer.rb'
41
42
 
42
43
  # Offense count: 5
43
44
  Metrics/CyclomaticComplexity:
data/lib/gdor/indexer.rb CHANGED
@@ -39,6 +39,7 @@ module GDor
39
39
  options = args.extract_options!
40
40
  yml_path = args.first
41
41
 
42
+ @solr_client = options.delete(:solr_client)
42
43
  @success_count = 0
43
44
  @error_count = 0
44
45
  @total_time_to_solr = 0
@@ -66,7 +67,7 @@ module GDor
66
67
  end
67
68
 
68
69
  def solr_client
69
- harvestdor.solr
70
+ @solr_client ||= harvestdor.solr
70
71
  end
71
72
 
72
73
  def metrics
@@ -29,11 +29,11 @@ module GDor::Indexer::PublicXmlFields
29
29
  ids = []
30
30
  if content_md
31
31
  if display_type == 'image'
32
- content_md.xpath('./resource[@type="image"]/file/@id').each do |node|
32
+ content_md.root.xpath('resource[@type="image"]/file/@id').each do |node|
33
33
  ids << node.text unless node.text.empty?
34
34
  end
35
35
  elsif display_type == 'file'
36
- content_md.xpath('./resource/file/@id').each do |node|
36
+ content_md.root.xpath('resource/file/@id').each do |node|
37
37
  ids << node.text unless node.text.empty?
38
38
  end
39
39
  end
@@ -61,7 +61,7 @@ module GDor::Indexer::PublicXmlFields
61
61
  # @return [String]
62
62
  def dor_content_type
63
63
  @dor_content_type ||= begin
64
- dct = content_md ? content_md.xpath('@type').text : nil
64
+ dct = content_md ? content_md.root.xpath('@type').text : nil
65
65
  logger.error "#{druid} has no DOR content type (<contentMetadata> element may be missing type attribute)" if !dct || dct.empty?
66
66
  dct
67
67
  end
@@ -1,5 +1,5 @@
1
1
  module GDor
2
2
  class Indexer
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -419,6 +419,19 @@ describe GDor::Indexer do
419
419
  end
420
420
  end
421
421
 
422
+ describe '#solr_client' do
423
+ it 'defaults to the harvestdor-configured client' do
424
+ expect(@indexer.solr_client).to eq @indexer.harvestdor.solr
425
+ end
426
+
427
+ it 'can be set as an option' do
428
+ solr_client = double
429
+ @indexer = described_class.new(solr_client: solr_client)
430
+
431
+ expect(@indexer.solr_client).to eq solr_client
432
+ end
433
+ end
434
+
422
435
  # context "skip heartbeat" do
423
436
  # it "allows me to use a fake url for dor-fetcher-client" do
424
437
  # expect {GDor::Indexer.new(@config_yml_path)}.not_to raise_error
@@ -19,7 +19,7 @@ describe GDor::Indexer::PublicXmlFields do
19
19
 
20
20
  def sdb_for_content_md(m)
21
21
  resource = Harvestdor::Indexer::Resource.new(double, @fake_druid)
22
- allow(resource).to receive(:content_metadata).and_return(Nokogiri::XML(m).root)
22
+ allow(resource).to receive(:content_metadata).and_return(Nokogiri::XML(m))
23
23
  allow(resource).to receive(:public_xml).and_return(@empty_pub_xml)
24
24
  allow(resource).to receive(:mods).and_return(@mods_xml)
25
25
  GDor::Indexer::SolrDocBuilder.new(resource, logger)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gdor-indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-28 00:00:00.000000000 Z
13
+ date: 2015-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: harvestdor-indexer