solrizer-fedora 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in solrizer.gemspec
4
4
  gemspec
5
+
6
+
7
+ gem 'rcov', :platform => :mri_18
8
+ gem 'simplecov', :platform => :mri_19
9
+ gem 'simplecov-rcov', :platform => :mri_19
@@ -61,6 +61,7 @@ GEM
61
61
  mime-types (1.18)
62
62
  mocha (0.10.0)
63
63
  metaclass (~> 0.0.1)
64
+ multi_json (1.3.5)
64
65
  multipart-post (1.1.2)
65
66
  nokogiri (1.5.2)
66
67
  nori (1.1.0)
@@ -68,6 +69,7 @@ GEM
68
69
  mediashelf-loggable
69
70
  nokogiri (>= 1.4.2)
70
71
  rack (1.4.1)
72
+ rake (0.9.2.2)
71
73
  rcov (1.0.0)
72
74
  rdf (0.3.5.2)
73
75
  addressable (>= 2.2.6)
@@ -104,6 +106,12 @@ GEM
104
106
  nokogiri (>= 1.4.0)
105
107
  nori (~> 1.1)
106
108
  wasabi (~> 2.1)
109
+ simplecov (0.6.4)
110
+ multi_json (~> 1.0)
111
+ simplecov-html (~> 0.5.3)
112
+ simplecov-html (0.5.3)
113
+ simplecov-rcov (0.2.3)
114
+ simplecov (>= 0.4.1)
107
115
  solrizer (1.2.0)
108
116
  daemons
109
117
  mediashelf-loggable (~> 0.4.7)
@@ -124,8 +132,11 @@ DEPENDENCIES
124
132
  RedCloth
125
133
  jettywrapper (>= 1.1)
126
134
  mocha
135
+ rake
127
136
  rcov
128
137
  rdoc
129
- rspec (~> 2.6.0)
138
+ rspec (~> 2.6)
139
+ simplecov
140
+ simplecov-rcov
130
141
  solrizer-fedora!
131
142
  yard
@@ -1,3 +1,8 @@
1
+ h2. 2.2.0
2
+ HYDRA-808 don't quit the whole job if one object fails to solrize
3
+ create_document in lib/solrizer/fedora/indexer.rb is public. Used by solrizer-rabbit
4
+ code cleanup in lib/solrizer/fedora/indexer.rb
5
+
1
6
  h2. 2.1.0
2
7
  Requiring active-fedora >= 4.0 (so it will happily use 4.1.0)
3
8
  Relaxed jetty-wrapper requirement to >= 1.1
@@ -182,6 +182,23 @@ Now your solr doc with the "changeme:123" ID will include the following:
182
182
  </pre>
183
183
 
184
184
 
185
+ h3. Rake tasks
186
+
187
+ h4. solrizer:fedora:solrize
188
+
189
+ Required Argument:
190
+ * PID=ns:123 The pid of the object to index
191
+
192
+ Optional Arguments:
193
+ * FULL_TEXT=true does a full text index
194
+
195
+ h4. solrizer:fedora:solrize_objects
196
+
197
+ Optional Arguments:
198
+ * FULL_TEXT=true does a full text index
199
+ * INDEX_LIST=_filename.csv_ indexes only the pids in the csv file
200
+
201
+
185
202
  h2. Modifying and Testing the Solrizer-Fedora gem
186
203
 
187
204
  In order to run the RSpec tests, it is necessary to have a hydra-jetty instance running. This can be accomplished two ways:
@@ -4,16 +4,6 @@ require 'solrizer/fedora/repository'
4
4
 
5
5
  module Solrizer::Fedora
6
6
  class Indexer
7
- #
8
- # Class variables
9
- #
10
- @@unique_id = 0
11
-
12
- def self.unique_id
13
- @@unique_id
14
- end
15
-
16
-
17
7
  # The instance of solr that updates will be written to
18
8
  attr_accessor :solr
19
9
 
@@ -162,7 +152,7 @@ class Indexer
162
152
  # Load the object as an instance of each of its other models and get the corresponding solr fields
163
153
  # Include :model_only=>true in the options in order to avoid adding the metadata from ActiveFedora::Base every time.
164
154
  model_klazz_array.each do |klazz|
165
- instance = klazz.load_instance(obj.pid)
155
+ instance = klazz.find(obj.pid)
166
156
  solr_doc = instance.to_solr(solr_doc, :model_only=>true)
167
157
  logger.debug " added solr fields from #{klazz.to_s}"
168
158
  end
@@ -170,9 +160,6 @@ class Indexer
170
160
  ::Solrizer::Extractor.insert_solr_field_value(solr_doc, :id_t, "#{obj.pid}" )
171
161
  ::Solrizer::Extractor.insert_solr_field_value(solr_doc, :id, "#{obj.pid}" ) unless solr_doc[:id]
172
162
 
173
- # increment the unique id to ensure that all documents in the search index are unique
174
- @@unique_id += 1
175
-
176
163
  return solr_doc
177
164
  end
178
165
 
@@ -180,30 +167,12 @@ class Indexer
180
167
  # This method adds a document to the Solr search index
181
168
  #
182
169
  def index( obj )
183
- # print "Indexing '#{obj.pid}'..."
184
- begin
185
-
186
- solr_doc = create_document( obj )
187
-
188
- begin
189
- solr.add( solr_doc )
190
- solr.commit
191
- # rescue
192
- # debugger
193
- end
194
-
195
- # puts solr.url
196
- #puts solr_doc
197
- # puts "done"
198
-
199
- # rescue Exception => e
200
- # p "unable to index #{obj.pid}. Failed with #{e.inspect}"
201
- end
202
-
170
+ solr.add( create_document( obj ) )
171
+ solr.commit
203
172
  end
204
173
 
205
174
 
206
- private :connect, :create_document
175
+ private :connect
207
176
 
208
177
  end
209
178
  end
@@ -73,7 +73,7 @@ module Solrizer::Fedora
73
73
 
74
74
  rescue Exception => e
75
75
  if opts[:suppress_errors]
76
- logger.debug "SOLRIZER unable to index #{obj}. Failed with #{e.inspect}"
76
+ logger.error "SOLRIZER unable to index #{obj}. Failed with #{e.inspect}"
77
77
  else
78
78
  raise e
79
79
  end
@@ -1,5 +1,5 @@
1
1
  module Solrizer
2
2
  module Fedora
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ namespace :solrizer do
21
21
  :startup_wait => 25
22
22
  }
23
23
  error = Jettywrapper.wrap(jetty_params) do
24
- Rake::Task["solrizer:fedora:spec_w_cov"].invoke
24
+ Rake::Task["solrizer:fedora:coverage"].invoke
25
25
  Rake::Task["solrizer:fedora:doc"].invoke
26
26
  end
27
27
  raise "test failures: #{error}" if error
@@ -36,26 +36,18 @@ namespace :solrizer do
36
36
  spec.pattern = 'spec/**/*_spec.rb'
37
37
  end
38
38
 
39
- desc "Run specs with coverage"
40
- RSpec::Core::RakeTask.new(:spec_w_cov) do |spec|
41
- # spec.libs << 'lib' << 'spec'
42
- spec.pattern = 'spec/**/*_spec.rb'
43
- spec.rcov = true
44
- spec.rcov_opts = %w{--exclude spec,gems}
45
- end
39
+ desc "Execute specs with coverage"
40
+ task :coverage do
41
+ # Put spec opts in a file named .rspec in root
42
+ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
43
+ ENV['COVERAGE'] = 'true' unless ruby_engine == 'jruby'
46
44
 
47
- begin
48
- require 'rcov/rcovtask'
49
- Rcov::RcovTask.new do |test|
50
- test.libs << 'test'
51
- test.pattern = 'test/**/test_*.rb'
52
- test.verbose = true
53
- end
54
- rescue LoadError
55
- task :rcov do
56
- abort "RCov is not available. "
57
- end
58
- end
45
+
46
+ Rake::Task['solrizer:fedora:spec'].invoke
47
+ end
48
+
49
+
50
+ desc "Run specs with coverage"
59
51
 
60
52
  # Use yard to build docs
61
53
  begin
@@ -22,12 +22,11 @@ namespace :solrizer do
22
22
  end
23
23
 
24
24
  puts "Re-indexing Fedora Repository."
25
- puts "Fedora URL: #{ActiveFedora.config.credentials[:url]}"
26
25
  puts "Fedora Solr URL: #{ActiveFedora.solr_config[:url]}"
27
26
  puts "Doing full text index." if index_full_text
28
27
  solrizer = Solrizer::Fedora::Solrizer.new :index_full_text=> index_full_text
29
- solrizer.solrize_objects
28
+ solrizer.solrize_objects :suppress_errors=>true
30
29
  puts "Solrizer task complete."
31
30
  end
32
31
  end
33
- end
32
+ end
@@ -23,8 +23,8 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency('active-fedora', '~> 4.0')
24
24
  s.add_development_dependency('jettywrapper', '>=1.1')
25
25
  s.add_development_dependency('rdoc')
26
- s.add_development_dependency('rcov')
27
- s.add_development_dependency('rspec', '~>2.6.0') #'>=2.8.0'
26
+ s.add_development_dependency('rake')
27
+ s.add_development_dependency('rspec', '~>2.6') #'>=2.8.0'
28
28
  s.add_development_dependency('mocha')
29
29
  s.add_development_dependency('yard')
30
30
  s.add_development_dependency('RedCloth')
@@ -1,5 +1,14 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
5
+ require 'simplecov'
6
+ require 'simplecov-rcov'
7
+
8
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
9
+ SimpleCov.start
10
+ end
11
+
3
12
  require 'solrizer/fedora'
4
13
  require 'solrizer'
5
14
  require 'rspec'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrizer-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 2.1.0
10
+ version: 2.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-10 00:00:00 Z
18
+ date: 2012-05-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: active-fedora
@@ -62,7 +62,7 @@ dependencies:
62
62
  type: :development
63
63
  version_requirements: *id003
64
64
  - !ruby/object:Gem::Dependency
65
- name: rcov
65
+ name: rake
66
66
  prerelease: false
67
67
  requirement: &id004 !ruby/object:Gem::Requirement
68
68
  none: false
@@ -83,12 +83,11 @@ dependencies:
83
83
  requirements:
84
84
  - - ~>
85
85
  - !ruby/object:Gem::Version
86
- hash: 23
86
+ hash: 15
87
87
  segments:
88
88
  - 2
89
89
  - 6
90
- - 0
91
- version: 2.6.0
90
+ version: "2.6"
92
91
  type: :development
93
92
  version_requirements: *id005
94
93
  - !ruby/object:Gem::Dependency