solr_ead 0.7.1 → 0.7.2
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 +5 -13
- data/.travis.yml +11 -5
- data/LICENSE +1067 -3
- data/Rakefile +3 -3
- data/lib/solr_ead/indexer.rb +4 -4
- data/lib/solr_ead/version.rb +1 -1
- data/lib/solr_ead.rb +5 -2
- data/lib/tasks/dev.rake +9 -0
- data/solr_ead.gemspec +2 -2
- data/spec/behaviors_spec.rb +23 -32
- data/spec/component_spec.rb +33 -42
- data/spec/document_spec.rb +38 -39
- data/spec/formatting_spec.rb +5 -6
- data/spec/indexer_spec.rb +43 -52
- data/spec/spec_helper.rb +2 -11
- data/{lib/tasks → tasks}/solr_ead.rake +1 -1
- metadata +32 -34
- data/.rvmrc +0 -1
- data/lib/solr_ead/railtie.rb +0 -7
- data/lib/tasks/solr_ead_dev.rake +0 -22
data/Rakefile
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env rake
|
|
2
|
-
require "bundler/gem_tasks"
|
|
3
2
|
require "rspec/core/rake_task"
|
|
4
|
-
require "jettywrapper"
|
|
5
3
|
Bundler::GemHelper.install_tasks
|
|
4
|
+
|
|
6
5
|
# load rake tasks in lib/tasks
|
|
7
6
|
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
|
7
|
+
|
|
8
8
|
RSpec::Core::RakeTask.new(:spec)
|
|
9
|
-
task :default => :ci
|
|
9
|
+
task :default => :ci
|
data/lib/solr_ead/indexer.rb
CHANGED
|
@@ -123,13 +123,13 @@ class Indexer
|
|
|
123
123
|
# Determines the url to our solr service by consulting yaml files
|
|
124
124
|
def solr_url
|
|
125
125
|
if defined?(Rails.root)
|
|
126
|
-
YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url']
|
|
126
|
+
::YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url']
|
|
127
127
|
elsif ENV['RAILS_ENV']
|
|
128
|
-
YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
|
|
128
|
+
::YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
|
|
129
129
|
else
|
|
130
|
-
YAML.load(ERB.new(File.read("config/solr.yml")).result)['development']['url']
|
|
130
|
+
::YAML.load(ERB.new(File.read("config/solr.yml")).result)['development']['url']
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
end
|
|
135
|
-
end
|
|
135
|
+
end
|
data/lib/solr_ead/version.rb
CHANGED
data/lib/solr_ead.rb
CHANGED
|
@@ -3,6 +3,10 @@ require 'solrizer'
|
|
|
3
3
|
require 'om'
|
|
4
4
|
require 'rsolr'
|
|
5
5
|
require 'active_support'
|
|
6
|
+
require 'yaml'
|
|
7
|
+
|
|
8
|
+
# Load these rake tasks when the gem is included in a Rails application
|
|
9
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__),"../tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
|
|
6
10
|
|
|
7
11
|
module SolrEad
|
|
8
12
|
extend ActiveSupport::Autoload
|
|
@@ -13,9 +17,8 @@ module SolrEad
|
|
|
13
17
|
autoload :Indexer
|
|
14
18
|
autoload :Document
|
|
15
19
|
autoload :Component
|
|
16
|
-
autoload :Railtie if defined?(Rails)
|
|
17
20
|
|
|
18
21
|
def self.version
|
|
19
22
|
SolrEad::VERSION
|
|
20
23
|
end
|
|
21
|
-
end
|
|
24
|
+
end
|
data/lib/tasks/dev.rake
ADDED
data/solr_ead.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
|
10
10
|
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
13
|
-
gem.test_files = gem.files.grep(%r{^(
|
|
13
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
|
14
14
|
gem.name = "solr_ead"
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
16
|
gem.version = SolrEad::VERSION
|
|
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
|
|
|
26
26
|
gem.add_development_dependency 'redcarpet'
|
|
27
27
|
gem.add_development_dependency 'rake'
|
|
28
28
|
gem.add_development_dependency 'rspec'
|
|
29
|
-
gem.add_development_dependency '
|
|
29
|
+
gem.add_development_dependency 'byebug'
|
|
30
30
|
gem.add_development_dependency 'rdoc'
|
|
31
31
|
gem.add_development_dependency 'jettywrapper'
|
|
32
32
|
end
|
data/spec/behaviors_spec.rb
CHANGED
|
@@ -2,51 +2,42 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe SolrEad::Behaviors do
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@numbered = fixture "pp002010.xml"
|
|
8
|
-
@messy = fixture "ead_messy_format.xml"
|
|
9
|
-
class TestClass
|
|
10
|
-
include SolrEad::Behaviors
|
|
11
|
-
end
|
|
12
|
-
@test = TestClass.new
|
|
5
|
+
class TestClass
|
|
6
|
+
include SolrEad::Behaviors
|
|
13
7
|
end
|
|
14
8
|
|
|
15
9
|
describe "#components" do
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@messy_nodeset = @test.components(@messy)
|
|
21
|
-
end
|
|
11
|
+
let(:non_numbered_nodeset) { TestClass.new.components(fixture("ARC-0005.xml")) }
|
|
12
|
+
let(:numbered_nodeset) { TestClass.new.components(fixture("pp002010.xml")) }
|
|
13
|
+
let(:messy_nodeset) { TestClass.new.components(fixture("ead_messy_format.xml")) }
|
|
22
14
|
|
|
23
15
|
it "should return a nodeset" do
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
expect(non_numbered_nodeset).to be_a_kind_of(Nokogiri::XML::NodeSet)
|
|
17
|
+
expect(non_numbered_nodeset.first).to be_a_kind_of(Nokogiri::XML::Element)
|
|
26
18
|
end
|
|
27
19
|
|
|
28
20
|
it "should be able to handle both numbered and non-numbered <c> nodes" do
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
expect(non_numbered_nodeset.count).to eq(135)
|
|
22
|
+
expect(numbered_nodeset.count).to eq(83)
|
|
31
23
|
end
|
|
32
24
|
|
|
33
25
|
it "should find some components even if ead is messily formatted" do
|
|
34
|
-
|
|
26
|
+
expect(messy_nodeset.count).to be > 0
|
|
35
27
|
end
|
|
36
28
|
|
|
37
29
|
end
|
|
38
30
|
|
|
39
31
|
describe "#prep" do
|
|
32
|
+
let(:subject) { TestClass.new.prep(fixture("pp002010.xml")) }
|
|
40
33
|
it "should return a single component document" do
|
|
41
|
-
|
|
42
|
-
part.should be_a_kind_of(Nokogiri::XML::Document)
|
|
34
|
+
expect(subject).to be_a_kind_of(Nokogiri::XML::Document)
|
|
43
35
|
end
|
|
44
36
|
end
|
|
45
37
|
|
|
46
38
|
describe "#component_children?" do
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@true = '
|
|
39
|
+
let(:true_node) do
|
|
40
|
+
Nokogiri::XML('
|
|
50
41
|
<c id="ref167" level="file">
|
|
51
42
|
<did>
|
|
52
43
|
<unittitle>Zines</unittitle>
|
|
@@ -68,27 +59,27 @@ describe SolrEad::Behaviors do
|
|
|
68
59
|
</did>
|
|
69
60
|
</c>
|
|
70
61
|
</c>
|
|
71
|
-
'
|
|
72
|
-
|
|
62
|
+
')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
let(:false_node) do
|
|
66
|
+
Nokogiri::XML('
|
|
73
67
|
<c id="ref167" level="file">
|
|
74
68
|
<did>
|
|
75
69
|
<unittitle>Zines</unittitle>
|
|
76
70
|
</did>
|
|
77
71
|
</c>
|
|
78
|
-
'
|
|
72
|
+
')
|
|
79
73
|
end
|
|
80
74
|
|
|
81
|
-
|
|
82
75
|
it "should return true for components that have c nodes below them" do
|
|
83
|
-
|
|
84
|
-
@test.component_children?(node.elements.first).should be_true
|
|
76
|
+
expect(TestClass.new.component_children?(true_node.elements.first)).to be true
|
|
85
77
|
end
|
|
86
78
|
|
|
87
79
|
it "should return false for components that do not have c nodes below them" do
|
|
88
|
-
|
|
89
|
-
@test.component_children?(node.elements.first).should be_false
|
|
80
|
+
expect(TestClass.new.component_children?(false_node.elements.first)).to be false
|
|
90
81
|
end
|
|
91
82
|
|
|
92
83
|
end
|
|
93
84
|
|
|
94
|
-
end
|
|
85
|
+
end
|
data/spec/component_spec.rb
CHANGED
|
@@ -2,40 +2,35 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe SolrEad::Component do
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
context "with parent components" do
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
let(:subject) do
|
|
8
|
+
additional_fields = {
|
|
9
|
+
"id" => "TEST-0001ref010",
|
|
10
|
+
Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
|
|
11
|
+
Solrizer.solr_name("parent", :stored_sortable) => "ref001",
|
|
12
|
+
Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
|
|
13
|
+
Solrizer.solr_name("parent_unittitles", :displayable) => ["Series I", "Subseries A", "Subseries 1"],
|
|
14
|
+
Solrizer.solr_name("component_children", :type => :boolean) => FALSE
|
|
15
|
+
}
|
|
16
|
+
SolrEad::Component.from_xml(fixture "component_template.xml").to_solr(additional_fields)
|
|
10
17
|
end
|
|
11
18
|
|
|
12
|
-
|
|
19
|
+
it "should accept additional fields from a hash" do
|
|
20
|
+
expect(subject["id"]).to eq("TEST-0001ref010")
|
|
21
|
+
expect(subject[Solrizer.solr_name("level", :facetable)]).to include "item"
|
|
22
|
+
expect(subject[Solrizer.solr_name("accessrestrict", :displayable)].first).to match /^This item .* is available.$/
|
|
23
|
+
end
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
|
|
18
|
-
Solrizer.solr_name("parent", :stored_sortable) => "ref001",
|
|
19
|
-
Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
|
|
20
|
-
Solrizer.solr_name("parent_unittitles", :displayable) => ["Series I", "Subseries A", "Subseries 1"],
|
|
21
|
-
Solrizer.solr_name("component_children", :type => :boolean) => FALSE
|
|
22
|
-
}
|
|
23
|
-
@solr_doc = @doc.to_solr(additional_fields)
|
|
24
|
-
end
|
|
25
|
+
it "should create fields using type" do
|
|
26
|
+
expect(subject[Solrizer.solr_name("ref", :stored_sortable)]).to eq("ref215")
|
|
27
|
+
end
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
@solr_doc["id"].should == "TEST-0001ref010"
|
|
28
|
-
@solr_doc[Solrizer.solr_name("level", :facetable)].should include "item"
|
|
29
|
-
@solr_doc[Solrizer.solr_name("accessrestrict", :displayable)].first.should match /^This item .* is available.$/
|
|
30
|
-
end
|
|
29
|
+
end
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
@solr_doc[Solrizer.solr_name("ref", :stored_sortable)].should == "ref215"
|
|
34
|
-
end
|
|
31
|
+
context "without parent components" do
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
it "should format heading_display with only one element" do
|
|
33
|
+
let(:subject) do
|
|
39
34
|
additional_fields = {
|
|
40
35
|
"id" => "TEST-0001ref010",
|
|
41
36
|
Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
|
|
@@ -44,25 +39,21 @@ describe SolrEad::Component do
|
|
|
44
39
|
Solrizer.solr_name("parent_unittitles", :displayable) => [],
|
|
45
40
|
Solrizer.solr_name("component_children", :type => :boolean) => FALSE
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
SolrEad::Component.from_xml(fixture "component_template.xml").to_solr(additional_fields)
|
|
43
|
+
end
|
|
44
|
+
it "should format heading_display with only one element" do
|
|
45
|
+
expect(subject["id"]).to eq("TEST-0001ref010")
|
|
46
|
+
expect(subject[Solrizer.solr_name("level", :facetable)]).to include "item"
|
|
47
|
+
expect(subject[Solrizer.solr_name("accessrestrict", :displayable)].first).to match /^This item .* is available.$/
|
|
48
|
+
end
|
|
52
49
|
|
|
53
|
-
end
|
|
50
|
+
end
|
|
54
51
|
|
|
55
52
|
describe "formatting fields as html" do
|
|
56
|
-
|
|
57
|
-
before :all do
|
|
58
|
-
file = "html_component.xml"
|
|
59
|
-
@sample = SolrEad::Component.from_xml(fixture file)
|
|
60
|
-
end
|
|
61
|
-
|
|
53
|
+
let(:subject) { SolrEad::Component.from_xml(fixture "html_component.xml") }
|
|
62
54
|
it "should format as term as html" do
|
|
63
|
-
|
|
55
|
+
expect(subject.term_to_html("scopecontent")).to include "<em>OPAL</em> "
|
|
64
56
|
end
|
|
65
|
-
|
|
66
57
|
end
|
|
67
58
|
|
|
68
|
-
end
|
|
59
|
+
end
|
data/spec/document_spec.rb
CHANGED
|
@@ -2,77 +2,76 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe SolrEad::Document do
|
|
4
4
|
|
|
5
|
-
before(:all) do
|
|
6
|
-
@ex1 = SolrEad::Document.from_xml(fixture "ARC-0005.xml")
|
|
7
|
-
@ex2 = SolrEad::Document.from_xml(fixture "pp002010.xml")
|
|
8
|
-
@ex3 = SolrEad::Document.from_xml(fixture "ARC-0161.xml")
|
|
9
|
-
@solr_ex1 = @ex1.to_solr
|
|
10
|
-
@solr_ex2 = @ex2.to_solr
|
|
11
|
-
@solr_ex3 = @ex3.to_solr
|
|
12
|
-
end
|
|
13
|
-
|
|
14
5
|
describe "#terminology" do
|
|
15
6
|
|
|
7
|
+
let(:ex1) { SolrEad::Document.from_xml(fixture "ARC-0005.xml") }
|
|
8
|
+
let(:ex2) { SolrEad::Document.from_xml(fixture "pp002010.xml") }
|
|
9
|
+
let(:ex3) { SolrEad::Document.from_xml(fixture "ARC-0161.xml") }
|
|
10
|
+
|
|
16
11
|
it "should have an id field" do
|
|
17
|
-
|
|
12
|
+
expect(ex1.eadid.first).to eq("ARC-0005")
|
|
18
13
|
end
|
|
19
14
|
|
|
20
15
|
it "should have a simple title" do
|
|
21
|
-
|
|
16
|
+
expect(ex1.title.first).to match "Eddie Cochran Historical Organization Collection"
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
it "should have some subject headings" do
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
expect(ex1.persname).to include "Cochran, Eddie, 1938-1960"
|
|
21
|
+
expect(ex1.genreform).to include "Newspapers"
|
|
22
|
+
expect(ex1.subject).to include "Rockabilly music"
|
|
23
|
+
expect(ex2.corpname).to include "Tuskegee Normal and Industrial Institute--1880-1940."
|
|
24
|
+
expect(ex2.genreform).to include "Group portraits--1880-1940."
|
|
25
|
+
expect(ex2.geogname).to include "Washington, D.C."
|
|
26
|
+
expect(ex2.name).to include "Bell, J.S., Portland, OR"
|
|
27
|
+
expect(ex2.persname).to include "Johnston, Frances Benjamin, 1864-1952, photographer."
|
|
28
|
+
expect(ex2.subject).to include "Buildings--1880-1940."
|
|
34
29
|
end
|
|
35
30
|
|
|
36
31
|
it "should have scope and contents" do
|
|
37
|
-
|
|
32
|
+
expect(ex2.scopecontent.first).to match /^Photographs/
|
|
38
33
|
end
|
|
39
34
|
|
|
40
35
|
it "should have one separatedmaterial material note from the archdesc section" do
|
|
41
|
-
|
|
36
|
+
expect(ex1.separatedmaterial.first).to match /^Commercially-released publications.*materials are available.$/
|
|
42
37
|
end
|
|
43
38
|
|
|
44
39
|
it "should have its xml" do
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
expect(ex1.to_xml).to match "<c\s"
|
|
41
|
+
expect(ex2.to_xml).to match "<c01\s"\
|
|
47
42
|
end
|
|
48
43
|
|
|
49
44
|
it "should have a bibliography" do
|
|
50
|
-
|
|
45
|
+
expect(ex3.bibliography.first).to eq("All Music Guide. Accessed February 4, 2013. http://www.allmusic.com/.")
|
|
51
46
|
end
|
|
52
47
|
|
|
53
48
|
end
|
|
54
49
|
|
|
55
50
|
describe ".to_solr" do
|
|
56
51
|
|
|
52
|
+
let(:ex1) { SolrEad::Document.from_xml(fixture "ARC-0005.xml").to_solr }
|
|
53
|
+
let(:ex2) { SolrEad::Document.from_xml(fixture "pp002010.xml").to_solr }
|
|
54
|
+
let(:ex3) { SolrEad::Document.from_xml(fixture "ARC-0161.xml").to_solr }
|
|
55
|
+
|
|
57
56
|
it "should have the appropriate id fields" do
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
expect(ex2["id"]).to eq("http://hdl.loc.gov/loc.pnp/eadpnp.pp002010")
|
|
58
|
+
expect(ex1["id"]).to eq("ARC-0005")
|
|
59
|
+
expect(ex2[Solrizer.solr_name("ead", :stored_sortable)]).to eq("http://hdl.loc.gov/loc.pnp/eadpnp.pp002010")
|
|
60
|
+
expect(ex1[Solrizer.solr_name("ead", :stored_sortable)]).to eq("ARC-0005")
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
it "should have faceted terms created from subject headings" do
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
expect(ex1[Solrizer.solr_name("persname", :facetable)]).to include "Cochran, Eddie, 1938-1960"
|
|
65
|
+
expect(ex1[Solrizer.solr_name("genreform", :facetable)]).to include "Newspapers"
|
|
66
|
+
expect(ex1[Solrizer.solr_name("subject", :facetable)]).to include "Rockabilly music"
|
|
67
|
+
expect(ex2[Solrizer.solr_name("corpname", :facetable)]).to include "Tuskegee Normal and Industrial Institute--1880-1940."
|
|
68
|
+
expect(ex2[Solrizer.solr_name("genreform", :facetable)]).to include "Group portraits--1880-1940."
|
|
69
|
+
expect(ex2[Solrizer.solr_name("geogname", :facetable)]).to include "Washington, D.C."
|
|
70
|
+
expect(ex2[Solrizer.solr_name("name", :facetable)]).to include "Bell, J.S., Portland, OR"
|
|
71
|
+
expect(ex2[Solrizer.solr_name("persname", :facetable)]).to include "Johnston, Frances Benjamin, 1864-1952, photographer."
|
|
72
|
+
expect(ex2[Solrizer.solr_name("subject", :facetable)]).to include "Buildings--1880-1940."
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
end
|
|
77
76
|
|
|
78
|
-
end
|
|
77
|
+
end
|
data/spec/formatting_spec.rb
CHANGED
|
@@ -2,25 +2,24 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe SolrEad::Formatting do
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
let(:subject) do
|
|
6
6
|
class SampleClass
|
|
7
7
|
include SolrEad::Formatting
|
|
8
8
|
end
|
|
9
|
-
|
|
9
|
+
return SampleClass.new
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
describe "#ead_to_html" do
|
|
13
13
|
|
|
14
14
|
it "should convert ead markup to html" do
|
|
15
15
|
xml = 'This is some text with <title render="italics">italics</title> included in it.'
|
|
16
|
-
|
|
16
|
+
expect(subject.ead_to_html(xml)).to eq('This is some text with <em>italics</em> included in it.')
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should remove other tags" do
|
|
20
20
|
xml = 'Blah blah <title render="italics">italics</title> blah <span>blah</span> <title render="bold">italics</title>'
|
|
21
|
-
|
|
21
|
+
expect(subject.ead_to_html(xml)).to eq('Blah blah <em>italics</em> blah blah <strong>italics</strong>')
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
end
|
|
25
|
+
end
|
data/spec/indexer_spec.rb
CHANGED
|
@@ -2,112 +2,103 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe SolrEad::Indexer do
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
@file = fixture "ARC-0005.xml"
|
|
7
|
-
end
|
|
5
|
+
let(:file) { fixture "ARC-0005.xml" }
|
|
8
6
|
|
|
9
7
|
describe "indexing an ead document into multiple solr documents" do
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
@indexer = SolrEad::Indexer.new
|
|
13
|
-
end
|
|
9
|
+
let(:indexer) { SolrEad::Indexer.new }
|
|
14
10
|
|
|
15
11
|
it "should index a new ead from a file" do
|
|
16
|
-
|
|
17
|
-
q =
|
|
18
|
-
q["response"]["numFound"].
|
|
12
|
+
indexer.create(file)
|
|
13
|
+
q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
|
|
14
|
+
expect(q["response"]["numFound"]).to eq(136)
|
|
19
15
|
end
|
|
20
16
|
|
|
21
|
-
|
|
22
17
|
it "should update an ead from a file" do
|
|
23
|
-
|
|
24
|
-
q =
|
|
25
|
-
q["response"]["numFound"].
|
|
18
|
+
indexer.update(file)
|
|
19
|
+
q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
|
|
20
|
+
expect(q["response"]["numFound"]).to eq(136)
|
|
26
21
|
end
|
|
27
22
|
|
|
28
23
|
it "should delete and ead give an id" do
|
|
29
|
-
|
|
30
|
-
q =
|
|
31
|
-
q["response"]["numFound"].
|
|
24
|
+
indexer.delete("ARC-0005")
|
|
25
|
+
q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
|
|
26
|
+
expect(q["response"]["numFound"]).to eq(0)
|
|
32
27
|
end
|
|
33
28
|
|
|
34
29
|
end
|
|
35
30
|
|
|
36
31
|
describe "indexing ead document into one solr document" do
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
@simple_indexer = SolrEad::Indexer.new(:simple => true)
|
|
40
|
-
end
|
|
33
|
+
let(:indexer) { SolrEad::Indexer.new(:simple => true) }
|
|
41
34
|
|
|
42
35
|
it "should be set to use the simple option" do
|
|
43
|
-
|
|
36
|
+
expect(indexer.options[:simple]).to be true
|
|
44
37
|
end
|
|
45
38
|
|
|
46
39
|
it "should index a new ead from a file as a single solr document" do
|
|
47
|
-
|
|
48
|
-
q =
|
|
49
|
-
q["response"]["numFound"].
|
|
40
|
+
indexer.create(file)
|
|
41
|
+
q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
|
|
42
|
+
expect(q["response"]["numFound"]).to eq(1)
|
|
50
43
|
end
|
|
51
44
|
|
|
52
45
|
it "should delete a single ead" do
|
|
53
|
-
|
|
54
|
-
q =
|
|
55
|
-
q["response"]["numFound"].
|
|
46
|
+
indexer.delete("ARC-0005")
|
|
47
|
+
q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
|
|
48
|
+
expect(q["response"]["numFound"]).to eq(0)
|
|
56
49
|
end
|
|
57
50
|
|
|
58
51
|
end
|
|
59
52
|
|
|
60
53
|
describe "specifying custom om definitions" do
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
t.title_num
|
|
72
|
-
end
|
|
55
|
+
class CustomDocument < SolrEad::Document
|
|
56
|
+
include OM::XML::Document
|
|
57
|
+
include OM::XML::TerminologyBasedSolrizer
|
|
58
|
+
include SolrEad::OmBehaviors
|
|
59
|
+
set_terminology do |t|
|
|
60
|
+
t.root(:path=>"ead", :index_as => [:not_searchable])
|
|
61
|
+
t.title
|
|
62
|
+
t.eadid
|
|
63
|
+
t.title_num
|
|
73
64
|
end
|
|
65
|
+
end
|
|
74
66
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
67
|
+
class CustomComponent < SolrEad::Component
|
|
68
|
+
include OM::XML::Document
|
|
69
|
+
include OM::XML::TerminologyBasedSolrizer
|
|
70
|
+
set_terminology do |t|
|
|
71
|
+
t.root(:path=>"c", :index_as => [:not_searchable, :not_displayable])
|
|
72
|
+
t.ref(:path=>"/c/@id")
|
|
73
|
+
t.level(:path=>"/c/@level", :index_as => [:facetable])
|
|
74
|
+
t.title(:path=>"unittitle", :attributes=>{ :type => :none }, :index_as=>[:searchable, :displayable])
|
|
84
75
|
end
|
|
85
76
|
end
|
|
86
77
|
|
|
87
78
|
it "should raise an error if you use an undefined class" do
|
|
88
|
-
|
|
79
|
+
expect {SolrEad::Indexer.new(:document => BogusClass)}.to raise_error NameError
|
|
89
80
|
end
|
|
90
81
|
|
|
91
82
|
it "should accept a document definition" do
|
|
92
83
|
indexer = SolrEad::Indexer.new(:document => CustomDocument)
|
|
93
|
-
indexer.create(
|
|
84
|
+
indexer.create(file)
|
|
94
85
|
end
|
|
95
86
|
|
|
96
87
|
it "should accept a component definition" do
|
|
97
88
|
indexer = SolrEad::Indexer.new(:component => CustomComponent)
|
|
98
|
-
indexer.create(
|
|
89
|
+
indexer.create(file)
|
|
99
90
|
end
|
|
100
91
|
|
|
101
92
|
it "should accept a simple custom document definition" do
|
|
102
93
|
indexer = SolrEad::Indexer.new(:document => CustomDocument, :stored_sortable=>true)
|
|
103
|
-
indexer.create(
|
|
94
|
+
indexer.create(file)
|
|
104
95
|
end
|
|
105
96
|
|
|
106
97
|
it "should accept both custom definitions and components" do
|
|
107
98
|
indexer = SolrEad::Indexer.new(:document => CustomDocument, :component => CustomComponent)
|
|
108
|
-
indexer.create(
|
|
99
|
+
indexer.create(file)
|
|
109
100
|
end
|
|
110
101
|
|
|
111
102
|
end
|
|
112
103
|
|
|
113
|
-
end
|
|
104
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
# :nodoc
|
|
2
2
|
require "solr_ead"
|
|
3
|
-
require "
|
|
3
|
+
require "byebug" unless ENV['TRAVIS']
|
|
4
4
|
|
|
5
5
|
RSpec.configure do |config|
|
|
6
|
-
|
|
7
|
-
# == Mock Framework
|
|
8
|
-
# Note: we're not mocking... yet.
|
|
9
|
-
# config.mock_with :mocha
|
|
10
|
-
# config.mock_with :flexmock
|
|
11
|
-
# config.mock_with :rr
|
|
12
|
-
#config.mock_with :rspec
|
|
13
|
-
|
|
14
6
|
config.color = true
|
|
15
|
-
|
|
16
7
|
end
|
|
17
8
|
|
|
18
9
|
def fixture(file) #:nodoc
|
|
@@ -27,4 +18,4 @@ def debug_solr_doc(doc) #:nodoc
|
|
|
27
18
|
puts doc[key]
|
|
28
19
|
end
|
|
29
20
|
end
|
|
30
|
-
end
|
|
21
|
+
end
|