solrmarc_wrapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +26 -0
- data/.gitmodules +3 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.rdoc +36 -0
- data/Rakefile +21 -0
- data/config/settings.yml +24 -0
- data/lib/solrmarc_wrapper/settings.rb +22 -0
- data/lib/solrmarc_wrapper/version.rb +3 -0
- data/lib/solrmarc_wrapper.rb +59 -0
- data/lib/tasks/ci.rake +9 -0
- data/lib/tasks/doc.rake +23 -0
- data/lib/tasks/jetty.rake +38 -0
- data/lib/tasks/solrmarc.rake +17 -0
- data/lib/tasks/spec.rake +28 -0
- data/solrmarc_wrapper.gemspec +32 -0
- data/spec/fixtures/add_solrdoc_bare666.xml +21 -0
- data/spec/scripts/curl_add_bare666_to_test.sh +1 -0
- data/spec/scripts/curl_empty_test_solr.sh +1 -0
- data/spec/solr/solr.xml +29 -0
- data/spec/solrmarc_wrapper_spec.rb +30 -0
- data/spec/spec_helper.rb +24 -0
- metadata +154 -0
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## PROJECT
|
2
|
+
.bundle
|
3
|
+
rdoc
|
4
|
+
doc
|
5
|
+
.yardoc
|
6
|
+
*.lock
|
7
|
+
solrmarc.log*
|
8
|
+
pkg
|
9
|
+
|
10
|
+
## vim
|
11
|
+
*.swp
|
12
|
+
|
13
|
+
## rcov
|
14
|
+
coverage.data
|
15
|
+
coverage
|
16
|
+
|
17
|
+
## MAC OS
|
18
|
+
.DS_Store
|
19
|
+
|
20
|
+
## TextMate
|
21
|
+
*.tmproj
|
22
|
+
tmtags
|
23
|
+
|
24
|
+
## Rubymine
|
25
|
+
.idea/*
|
26
|
+
|
data/.gitmodules
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use jruby-1.6.7@solrmarc_wrapper --create
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Naomi Dushay
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
= SolrmarcWrapper
|
2
|
+
|
3
|
+
Ruby wrapper for accessing SolrMarc and Solr objects, such as using org.solrmarc.marc.SolrReIndexer to get a SolrInputDocument from a marc record stored in the Solr index.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'solrmarc_wrapper'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install solrmarc_wrapper
|
18
|
+
|
19
|
+
== Usage
|
20
|
+
|
21
|
+
This gem must be run under JRuby, and also requires a solrmarc dist directory and solr url (see config/settings.yml)
|
22
|
+
|
23
|
+
Example: this retrieves the full marc record stored in the Solr index, runs it through SolrMarc indexing to get a SolrInputDocument from the marcxml. It identifies Solr documents by the Solr "id" field, and expects the marc to be stored in a Solr field "marcxml".
|
24
|
+
|
25
|
+
def solr_input_doc(id)
|
26
|
+
@solrmarc_wrapper.get_solr_input_doc_from_marcxml(id)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
== Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/setup'
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
require 'bundler'
|
7
|
+
|
8
|
+
begin
|
9
|
+
Bundler.setup(:default, :development)
|
10
|
+
rescue Bundler::BundlerError => e
|
11
|
+
$stderr.puts e.message
|
12
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
+
exit e.status_code
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
17
|
+
|
18
|
+
namespace :sm_wrap do
|
19
|
+
task :default => :ci
|
20
|
+
task :rspec => :rspec_core
|
21
|
+
end
|
data/config/settings.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# settings for production
|
2
|
+
prod:
|
3
|
+
solrmarc_dist_dir: your_production_solrmarc_dist_dir
|
4
|
+
solrmarc_conf_props_file: your_solrmarc_config.properties
|
5
|
+
solr_url: your_production_solr_url
|
6
|
+
log_level: error
|
7
|
+
|
8
|
+
# settings for local development
|
9
|
+
dev:
|
10
|
+
solrmarc_dist_dir: your_solrmarc_dist_dir
|
11
|
+
solrmarc_conf_props_file: your_solrmarc_config.properties
|
12
|
+
solr_url: http://127.0.0.1:8983/solr/dev
|
13
|
+
log_level: info
|
14
|
+
|
15
|
+
# settings for continuous integration
|
16
|
+
ci:
|
17
|
+
solrmarc_dist_dir: solrmarc/dist
|
18
|
+
solrmarc_conf_props_file: sw_config.properties
|
19
|
+
solr_url: http://127.0.0.1:8983/solr/test
|
20
|
+
log_level: info
|
21
|
+
|
22
|
+
# add:
|
23
|
+
#solr id field?
|
24
|
+
#solr marcxml field?
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
# Read the .yml file containing the configuration values
|
4
|
+
class Settings
|
5
|
+
|
6
|
+
attr_reader :solrmarc_dist_dir, :solrmarc_conf_props_file, :solr_url
|
7
|
+
|
8
|
+
def initialize(settings_group)
|
9
|
+
yml = YAML.load_file('config/settings.yml')[settings_group]
|
10
|
+
@solrmarc_dist_dir = yml["solrmarc_dist_dir"]
|
11
|
+
@solrmarc_conf_props_file = yml["solrmarc_conf_props_file"]
|
12
|
+
@solr_url = yml["solr_url"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return the attributes of this class as a Hash
|
16
|
+
def as_hash
|
17
|
+
{:solrmarc_dist_dir => @solrmarc_dist_dir,
|
18
|
+
:solrmarc_conf_props_file => @solrmarc_conf_props_file,
|
19
|
+
:solr_url => @solr_url }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
include Java
|
2
|
+
|
3
|
+
require "solrmarc_wrapper/version"
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
# a way to use SolrMarc objects,
|
7
|
+
# such as using SolrReIndexer to get a SolrInputDocument from a marc record stored in the Solr index.
|
8
|
+
class SolrmarcWrapper
|
9
|
+
|
10
|
+
attr_accessor :logger
|
11
|
+
|
12
|
+
# @param solrmarc_dist_dir distribution directory of SolrMarc build
|
13
|
+
# @param solrmarc_conf_props_fname the name of the xx_config.properties file for SolrMarc, relative to solrmarc_dist_dir
|
14
|
+
# @param
|
15
|
+
# solr_url base url of the solr instance
|
16
|
+
def initialize(solrmarc_dist_dir, config_props_fname, solr_url, log_level=Logger::INFO, log_file=STDERR)
|
17
|
+
if not defined? JRUBY_VERSION
|
18
|
+
raise "SolrmarcWrapper only runs under jruby"
|
19
|
+
end
|
20
|
+
load_solrmarc(solrmarc_dist_dir)
|
21
|
+
setup_solr_reindexer(solr_url, config_props_fname)
|
22
|
+
@logger = Logger.new(log_file)
|
23
|
+
@logger.level = log_level
|
24
|
+
end
|
25
|
+
|
26
|
+
# retrieves the full marc rec
|
27
|
+
# ord stored in the Solr index, runs it through SolrMarc indexing to get a SolrInputDocument
|
28
|
+
# note that it identifies Solr documents by the "id" field, and expects the marc to be stored in a Solr field "marcxml"
|
29
|
+
# if there is no single document matching the id, an error is logged and nil is returned
|
30
|
+
# @param doc_id the value of the "id" Solr field for the record to be retrieved
|
31
|
+
# @return a SolrInputDocument for the doc_id, populated via marcxml and SolrMarc
|
32
|
+
def get_solr_input_doc_from_marcxml(doc_id)
|
33
|
+
begin
|
34
|
+
@solr_input_doc = @solrmarc_reindexer.getSolrInputDoc("id", doc_id, "marcxml")
|
35
|
+
rescue java.lang.NullPointerException
|
36
|
+
@logger.error("Can't find single Solr document with id #{doc_id}")
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
@solr_input_doc
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
# require all the necessary jars to use SolrMarc classes
|
46
|
+
def load_solrmarc(solr_marc_dir)
|
47
|
+
Dir["#{solr_marc_dir}/**/*.jar"].each {|jar_file| require jar_file }
|
48
|
+
end
|
49
|
+
|
50
|
+
# initialize the @solrmarc_reindexer object
|
51
|
+
# @param solr_url the url of the Solr server
|
52
|
+
# @param config_props_fname the name of the xx_config.properties file relative to the solr_marc_dir used in initialize method
|
53
|
+
def setup_solr_reindexer(solr_url, config_props_fname)
|
54
|
+
solr_core_loader = org.solrmarc.solr.SolrCoreLoader.loadRemoteSolrServer(solr_url, false, true)
|
55
|
+
@solrmarc_reindexer = org.solrmarc.marc.SolrReIndexer.new(solr_core_loader)
|
56
|
+
@solrmarc_reindexer.init([config_props_fname])
|
57
|
+
end
|
58
|
+
|
59
|
+
end # module SolrmarcWrapper
|
data/lib/tasks/ci.rake
ADDED
data/lib/tasks/doc.rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'yard'
|
2
|
+
require 'yard/rake/yardoc_task'
|
3
|
+
|
4
|
+
namespace :sm_wrap do
|
5
|
+
|
6
|
+
# Use yard to build docs
|
7
|
+
begin
|
8
|
+
project_root = File.expand_path(File.dirname(__FILE__) + "/../..")
|
9
|
+
doc_dest_dir = File.join(project_root, 'doc')
|
10
|
+
|
11
|
+
YARD::Rake::YardocTask.new(:doc) do |yt|
|
12
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
13
|
+
[ File.join(project_root, 'README.rdoc') ]
|
14
|
+
yt.options = ['--output-dir', doc_dest_dir, '--readme', 'README.rdoc', '--title', 'crez-sw-ingest Documentation']
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
desc "Generate YARD Documentation"
|
18
|
+
task :doc do
|
19
|
+
abort "Please install the YARD gem to generate rdoc."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'jettywrapper'
|
2
|
+
|
3
|
+
namespace :sm_wrap do
|
4
|
+
namespace :jetty do
|
5
|
+
|
6
|
+
desc "Modify test jetty solr to be multicore"
|
7
|
+
task :config_ci => ['sm_wrap:solrmarc:setup_test_jetty'] do
|
8
|
+
|
9
|
+
# copy the solr.xml file for multi-core to test jetty solr
|
10
|
+
jetty_solr_dir = "solrmarc/test/jetty/solr"
|
11
|
+
cp('spec/solr/solr.xml', jetty_solr_dir, :verbose => true)
|
12
|
+
|
13
|
+
# set up solr dev and test conf directories
|
14
|
+
dev_conf_dir = "#{jetty_solr_dir}/dev/conf"
|
15
|
+
test_conf_dir = "#{jetty_solr_dir}/test/conf"
|
16
|
+
mkdir_p(dev_conf_dir) unless Dir.exists?(dev_conf_dir)
|
17
|
+
mkdir_p(test_conf_dir) unless Dir.exists?(test_conf_dir)
|
18
|
+
single_core_conf_dir = "#{jetty_solr_dir}/conf"
|
19
|
+
Dir["#{single_core_conf_dir}/*"].each { |f|
|
20
|
+
cp_r(f, dev_conf_dir, :verbose => true)
|
21
|
+
cp_r(f, test_conf_dir, :verbose => true)
|
22
|
+
}
|
23
|
+
|
24
|
+
require 'fileutils'
|
25
|
+
# remove single core conf directory
|
26
|
+
FileUtils.rm_rf("#{jetty_solr_dir}/conf/.", :verbose => true)
|
27
|
+
Dir.foreach(jetty_solr_dir + "/conf") { |f|
|
28
|
+
fn = File.join(jetty_solr_dir, f)
|
29
|
+
File.delete(fn) if f != '.' && f != '..'
|
30
|
+
}
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Copies the SOLR config files and starts up the test-jetty instance"
|
35
|
+
task :load_ci => [:config_ci, 'jetty:start']
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :sm_wrap do
|
2
|
+
namespace :solrmarc do
|
3
|
+
require 'ant'
|
4
|
+
|
5
|
+
desc "run ant dist_site target in solrmarc"
|
6
|
+
task :ant_dist_site do
|
7
|
+
ant '-f solrmarc/build.xml dist_site'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "run ant target to set up testing jetty in solrmarc"
|
11
|
+
task :setup_test_jetty do
|
12
|
+
ant '-f solrmarc/build.xml test_clean_site'
|
13
|
+
ant '-f solrmarc/build.xml site_setup_test_jetty'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/tasks/spec.rake
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
|
3
|
+
namespace :sm_wrap do
|
4
|
+
|
5
|
+
desc "Run all specs, with jetty instance running"
|
6
|
+
task :rspec_wrapped => ['sm_wrap:solrmarc:ant_dist_site', 'sm_wrap:jetty:config_ci'] do
|
7
|
+
test_jetty_dir = File.expand_path(File.dirname(__FILE__) + '../../../solrmarc/test/jetty')
|
8
|
+
require 'jettywrapper'
|
9
|
+
jetty_params = Jettywrapper.load_config.merge({
|
10
|
+
:jetty_home => test_jetty_dir,
|
11
|
+
:solr_home => test_jetty_dir + '/solr',
|
12
|
+
:java_opts => "-Dsolr.data.dir=" + test_jetty_dir + "/solr/test/data",
|
13
|
+
:jetty_port => 8983,
|
14
|
+
:startup_wait => 25
|
15
|
+
})
|
16
|
+
error = Jettywrapper.wrap(jetty_params) do
|
17
|
+
`sh ./spec/scripts/curl_empty_test_solr.sh`
|
18
|
+
`sh ./spec/scripts/curl_add_bare666_to_test.sh`
|
19
|
+
Rake::Task['sm_wrap:rspec_core'].invoke
|
20
|
+
end
|
21
|
+
raise "TEST FAILURES: #{error}" if error
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec::Core::RakeTask.new(:rspec_core) do |spec|
|
25
|
+
spec.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.join(File.dirname(__FILE__), "lib/solrmarc_wrapper/version")
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "solrmarc_wrapper"
|
6
|
+
gem.version = SolrmarcWrapper::VERSION
|
7
|
+
gem.authors = ["Naomi Dushay"]
|
8
|
+
gem.email = ["ndushay@stanford.edu"]
|
9
|
+
gem.summary = "Ruby wrapper for accessing SolrMarc objects and Solr objects"
|
10
|
+
gem.description = "Ruby wrapper for accessing SolrMarc objects and Solr objects, such as using org.solrmarc.marc.SolrReIndexer to get a SolrInputDocument from a marc record stored in the Solr index"
|
11
|
+
gem.requirements = "This gem must be run under JRuby, and also requires a solrmarc dist directory and solr url (see config/settings.yml)"
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
# No Runtime dependencies
|
19
|
+
|
20
|
+
# Bundler will install these gems too if you've checked out solrmarc-wrapper source from git and run 'bundle install'
|
21
|
+
# It will not add these as dependencies if you require solrmarc-wrapper for other projects
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
# docs
|
24
|
+
gem.add_development_dependency "rdoc"
|
25
|
+
gem.add_development_dependency "yard"
|
26
|
+
# tests
|
27
|
+
gem.add_development_dependency 'rspec'
|
28
|
+
gem.add_development_dependency 'simplecov'
|
29
|
+
gem.add_development_dependency 'simplecov-rcov'
|
30
|
+
gem.add_development_dependency "jettywrapper"
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<add>
|
2
|
+
<doc>
|
3
|
+
<field name="id">666</field>
|
4
|
+
<field name="marcxml">
|
5
|
+
<![CDATA[
|
6
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
7
|
+
<collection xmlns="http://www.loc.gov/MARC21/slim">
|
8
|
+
<record>
|
9
|
+
<leader>01320ccm a2200277 4500</leader>
|
10
|
+
<controlfield tag="001">a666</controlfield>
|
11
|
+
<controlfield tag="008">750409s1961||||enk ||| | eng </controlfield>
|
12
|
+
<datafield tag="245" ind1=" " ind2="0">
|
13
|
+
<subfield code="a">Sonata no. 7, in B flat, for violoncello and piano.</subfield>
|
14
|
+
<subfield code="c">Edited with realization of the basso continuo by Fritz Spiegl and Walter Bergamnn. Violoncello part edited by Joan Dickson.</subfield>
|
15
|
+
</datafield>
|
16
|
+
</record>
|
17
|
+
</collection>
|
18
|
+
]]>
|
19
|
+
</field>
|
20
|
+
</doc>
|
21
|
+
</add>
|
@@ -0,0 +1 @@
|
|
1
|
+
curl "http://localhost:8983/solr/test/update?commit=true" -H "Content-Type: text/xml" --data-binary @spec/fixtures/add_solrdoc_bare666.xml
|
@@ -0,0 +1 @@
|
|
1
|
+
curl "http://localhost:8983/solr/test/update?commit=true" -H "Content-Type: application/xml" --data-binary '<delete><query>*:*</query></delete>'
|
data/spec/solr/solr.xml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!--
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
5
|
+
this work for additional information regarding copyright ownership.
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
8
|
+
the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
-->
|
18
|
+
|
19
|
+
<!--
|
20
|
+
All (relative) paths are relative to the installation path
|
21
|
+
persistent: Save changes made via the API to this file
|
22
|
+
sharedLib: path to a lib directory that will be shared across all cores
|
23
|
+
-->
|
24
|
+
<solr persistent="false" sharedLib="lib">
|
25
|
+
<cores adminPath="/admin/cores" shareSchema="true">
|
26
|
+
<core name="dev" instanceDir="dev" />
|
27
|
+
<core name="test" instanceDir="test" />
|
28
|
+
</cores>
|
29
|
+
</solr>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require "solrmarc_wrapper"
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
describe SolrmarcWrapper do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@solrmarc_wrapper = SolrmarcWrapper.new(@@settings.solrmarc_dist_dir, @@settings.solrmarc_conf_props_file, @@settings.solr_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should retrieve the SolrInputDoc generated from the marc record" do
|
12
|
+
sid = @solrmarc_wrapper.get_solr_input_doc_from_marcxml("666")
|
13
|
+
sid.should be_an_instance_of(Java::OrgApacheSolrCommon::SolrInputDocument)
|
14
|
+
sid["id"].getValue.should == "666"
|
15
|
+
sid["title_full_display"].getValue.should_not be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a SolrInputDoc with the non-stored fields present" do
|
19
|
+
sid = @solrmarc_wrapper.get_solr_input_doc_from_marcxml("666")
|
20
|
+
sid["title_245a_search"].getValue.should_not be_nil
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should log an error message when there is no document in the Solr index for the ckey" do
|
24
|
+
lager = double("logger")
|
25
|
+
@solrmarc_wrapper.logger = lager
|
26
|
+
lager.should_receive(:error).with("Can't find single Solr document with id aaa")
|
27
|
+
@solrmarc_wrapper.get_solr_input_doc_from_marcxml("aaa")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# for test coverage
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-rcov'
|
4
|
+
class SimpleCov::Formatter::MergedFormatter
|
5
|
+
def format(result)
|
6
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
7
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter "/spec/"
|
13
|
+
add_filter "/config/"
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'solrmarc_wrapper/settings'
|
17
|
+
|
18
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# Set up the environment for testing and make all variables available to the specs
|
22
|
+
settings_env = ENV["SETTINGS"] ||= 'dev'
|
23
|
+
@@settings = Settings.new(settings_env)
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solrmarc_wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Naomi Dushay
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
version_requirements: &4898 !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
none: false
|
22
|
+
requirement: *4898
|
23
|
+
prerelease: false
|
24
|
+
type: :development
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rdoc
|
27
|
+
version_requirements: &4916 !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
none: false
|
33
|
+
requirement: *4916
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
version_requirements: &4932 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
none: false
|
44
|
+
requirement: *4932
|
45
|
+
prerelease: false
|
46
|
+
type: :development
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
version_requirements: &4948 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
none: false
|
55
|
+
requirement: *4948
|
56
|
+
prerelease: false
|
57
|
+
type: :development
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
version_requirements: &4964 !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
none: false
|
66
|
+
requirement: *4964
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov-rcov
|
71
|
+
version_requirements: &4980 !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
none: false
|
77
|
+
requirement: *4980
|
78
|
+
prerelease: false
|
79
|
+
type: :development
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: jettywrapper
|
82
|
+
version_requirements: &4996 !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
none: false
|
88
|
+
requirement: *4996
|
89
|
+
prerelease: false
|
90
|
+
type: :development
|
91
|
+
description: Ruby wrapper for accessing SolrMarc objects and Solr objects, such as using org.solrmarc.marc.SolrReIndexer to get a SolrInputDocument from a marc record stored in the Solr index
|
92
|
+
email:
|
93
|
+
- ndushay@stanford.edu
|
94
|
+
executables: []
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- .gitignore
|
99
|
+
- .gitmodules
|
100
|
+
- .rvmrc
|
101
|
+
- Gemfile
|
102
|
+
- LICENSE
|
103
|
+
- README.rdoc
|
104
|
+
- Rakefile
|
105
|
+
- config/settings.yml
|
106
|
+
- lib/solrmarc_wrapper.rb
|
107
|
+
- lib/solrmarc_wrapper/settings.rb
|
108
|
+
- lib/solrmarc_wrapper/version.rb
|
109
|
+
- lib/tasks/ci.rake
|
110
|
+
- lib/tasks/doc.rake
|
111
|
+
- lib/tasks/jetty.rake
|
112
|
+
- lib/tasks/solrmarc.rake
|
113
|
+
- lib/tasks/spec.rake
|
114
|
+
- solrmarc_wrapper.gemspec
|
115
|
+
- spec/fixtures/add_solrdoc_bare666.xml
|
116
|
+
- spec/scripts/curl_add_bare666_to_test.sh
|
117
|
+
- spec/scripts/curl_empty_test_solr.sh
|
118
|
+
- spec/solr/solr.xml
|
119
|
+
- spec/solrmarc_wrapper_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
homepage:
|
122
|
+
licenses: []
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
hash: 2
|
134
|
+
version: '0'
|
135
|
+
none: false
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
hash: 2
|
143
|
+
version: '0'
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- This gem must be run under JRuby, and also requires a solrmarc dist directory and solr url (see config/settings.yml)
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 1.8.15
|
149
|
+
signing_key:
|
150
|
+
specification_version: 3
|
151
|
+
summary: Ruby wrapper for accessing SolrMarc objects and Solr objects
|
152
|
+
test_files: []
|
153
|
+
has_rdoc:
|
154
|
+
...
|