solr_ead 0.3.4 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/solr_ead/indexer.rb +7 -5
- data/lib/solr_ead/version.rb +1 -1
- data/lib/tasks/solr_ead.rake +21 -5
- metadata +5 -5
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/solr_ead/indexer.rb
CHANGED
@@ -42,17 +42,19 @@ class Indexer
|
|
42
42
|
# using the url supplied in your config/solr.yml file.
|
43
43
|
def initialize(opts={})
|
44
44
|
Solrizer.default_field_mapper = EadMapper.new
|
45
|
-
if
|
46
|
-
url =
|
45
|
+
if ENV['SOLR_URL']
|
46
|
+
url = ENV['SOLR_URL']
|
47
|
+
elsif defined?(Rails.root)
|
48
|
+
url = YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url']
|
47
49
|
elsif ENV['RAILS_ENV']
|
48
|
-
url = YAML.
|
50
|
+
url = YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
|
49
51
|
else
|
50
|
-
url = YAML.
|
52
|
+
url = YAML.load(ERB.new(File.read("config/solr.yml")).result)['development']['url']
|
51
53
|
end
|
52
54
|
self.solr = RSolr.connect :url => url
|
53
55
|
self.options = opts
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
# Indexes your ead and additional component documents with the supplied file, then
|
57
59
|
# commits the results to your solr server.
|
58
60
|
def create(file)
|
data/lib/solr_ead/version.rb
CHANGED
data/lib/tasks/solr_ead.rake
CHANGED
@@ -2,8 +2,8 @@ namespace :solr_ead do
|
|
2
2
|
|
3
3
|
desc "Index and ead into solr using FILE=<path/to/ead.xml>"
|
4
4
|
task :index do
|
5
|
-
raise "Please specify your ead, ex. FILE=<path/to/ead.xml" unless ENV['FILE']
|
6
|
-
indexer =
|
5
|
+
raise "Please specify your ead, ex. FILE=<path/to/ead.xml>" unless ENV['FILE']
|
6
|
+
indexer = load_indexer
|
7
7
|
indexer.update(ENV['FILE'])
|
8
8
|
end
|
9
9
|
|
@@ -14,10 +14,10 @@ namespace :solr_ead do
|
|
14
14
|
indexer.delete(ENV['ID'])
|
15
15
|
end
|
16
16
|
|
17
|
-
desc "Index a directory of ead files given by DIR
|
17
|
+
desc "Index a directory of ead files given by DIR=<path/to/directory>"
|
18
18
|
task :index_dir do
|
19
|
-
raise "Please specify your
|
20
|
-
indexer =
|
19
|
+
raise "Please specify your directory, ex. DIR=<path/to/directory>" unless ENV['DIR']
|
20
|
+
indexer = load_indexer
|
21
21
|
Dir.glob(File.join(ENV['DIR'],"*")).each do |file|
|
22
22
|
print "Indexing #{File.basename(file)}..."
|
23
23
|
indexer.update(file) if File.extname(file).match("xml$")
|
@@ -25,4 +25,20 @@ namespace :solr_ead do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
end
|
29
|
+
|
30
|
+
# Set up a new indexer object
|
31
|
+
#
|
32
|
+
# If CUSTOM_DOCUMENT is present, require the file and instantiate the indexer with it
|
33
|
+
# Otherwise instantiate a default indexer
|
34
|
+
def load_indexer
|
35
|
+
if ENV['CUSTOM_DOCUMENT']
|
36
|
+
raise "Please specify a valid file for your custom document." unless File.exists? ENV['CUSTOM_DOCUMENT']
|
37
|
+
require File.join(Rails.root, ENV['CUSTOM_DOCUMENT'])
|
38
|
+
custom_document = File.basename(ENV['CUSTOM_DOCUMENT']).split(".").first.classify.constantize
|
39
|
+
indexer = SolrEad::Indexer.new(:document=>custom_document)
|
40
|
+
else
|
41
|
+
indexer = SolrEad::Indexer.new
|
42
|
+
end
|
43
|
+
return indexer
|
28
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solr_ead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: om
|
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash:
|
227
|
+
hash: 2881959855902156324
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
none: false
|
230
230
|
requirements:
|
@@ -233,10 +233,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
version: '0'
|
234
234
|
segments:
|
235
235
|
- 0
|
236
|
-
hash:
|
236
|
+
hash: 2881959855902156324
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 1.8.
|
239
|
+
rubygems_version: 1.8.23
|
240
240
|
signing_key:
|
241
241
|
specification_version: 3
|
242
242
|
summary: A gem for indexing ead into solr using OM
|