solr_ead 0.3.4 → 0.4.4

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.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
17
  .DS_Store
18
+ bin
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solr_ead (0.3.4)
4
+ solr_ead (0.4.4)
5
5
  om
6
6
  rsolr
7
7
  sanitize
@@ -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 defined?(Rails.root)
46
- url = YAML.load_file(File.join(Rails.root,"config","solr.yml"))[Rails.env]['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.load_file(File.join(Rails.root,"config","solr.yml"))[ENV['RAILS_ENV']]['url']
50
+ url = YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
49
51
  else
50
- url = YAML.load_file("config/solr.yml")['development']['url']
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)
@@ -1,3 +1,3 @@
1
1
  module SolrEad
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -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 = SolrEad::Indexer.new
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=path/to/directory"
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 direction, ex. DIR=path/to/directory" unless ENV['DIR']
20
- indexer = SolrEad::Indexer.new
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.3.4
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-03-20 00:00:00.000000000 Z
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: 1892170810412435467
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: 1892170810412435467
236
+ hash: 2881959855902156324
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 1.8.24
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