solrizer 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ gem "nokogiri"
4
4
  gem "xml-simple"
5
5
  gem "om", ">= 1.0.0" # only required by xml/terminology_based_solrizer ...
6
6
  gem "mediashelf-loggable"
7
+ gem "stomp"
8
+ gem "daemons"
7
9
 
8
10
  group :development, :test do
9
11
  gem "jeweler"
@@ -11,4 +13,4 @@ group :development, :test do
11
13
  gem 'ruby-debug-base'
12
14
  gem 'rspec', '<2.0.0'
13
15
  gem 'mocha'
14
- end
16
+ end
data/Gemfile.lock CHANGED
@@ -2,21 +2,19 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  columnize (0.3.2)
5
- facets (2.9.1)
5
+ daemons (1.1.2)
6
6
  git (1.2.5)
7
7
  jeweler (1.5.2)
8
8
  bundler (~> 1.0.0)
9
9
  git (>= 1.2.5)
10
10
  rake
11
11
  linecache (0.43)
12
- mediashelf-loggable (0.4.0)
12
+ mediashelf-loggable (0.4.2)
13
13
  mocha (0.9.12)
14
14
  nokogiri (1.4.4)
15
- om (1.0.2)
16
- facets
17
- facets
18
- nokogiri
15
+ om (1.2.2)
19
16
  nokogiri (>= 1.4.2)
17
+ om
20
18
  rake (0.8.7)
21
19
  rspec (1.3.1)
22
20
  ruby-debug (0.10.4)
@@ -24,12 +22,14 @@ GEM
24
22
  ruby-debug-base (~> 0.10.4.0)
25
23
  ruby-debug-base (0.10.4)
26
24
  linecache (>= 0.3)
27
- xml-simple (1.0.14)
25
+ stomp (1.1.8)
26
+ xml-simple (1.0.15)
28
27
 
29
28
  PLATFORMS
30
29
  ruby
31
30
 
32
31
  DEPENDENCIES
32
+ daemons
33
33
  jeweler
34
34
  mediashelf-loggable
35
35
  mocha
@@ -38,4 +38,5 @@ DEPENDENCIES
38
38
  rspec (< 2.0.0)
39
39
  ruby-debug
40
40
  ruby-debug-base
41
+ stomp
41
42
  xml-simple
data/Rakefile CHANGED
@@ -10,6 +10,7 @@ begin
10
10
  gem.email = "matt.zumwalt@yourmediashelf.com"
11
11
  gem.homepage = "http://github.com/projecthydra/solrizer"
12
12
  gem.authors = ["Matt Zumwalt"]
13
+ gem.executables = ["solrizer","solrizerd"]
13
14
  gem.add_dependency "nokogiri"
14
15
  gem.add_dependency "om"
15
16
  gem.add_dependency "nokogiri"
@@ -19,6 +20,7 @@ begin
19
20
  gem.add_development_dependency 'ruby-debug-base'
20
21
  gem.add_development_dependency 'rspec', '<2.0.0'
21
22
  gem.add_development_dependency 'mocha'
23
+
22
24
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
25
  end
24
26
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
data/bin/solrizer ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'optparse'
5
+ require 'stomp'
6
+
7
+ options = {}
8
+
9
+ optparse = OptionParser.new do|opts|
10
+ opts.banner = "Usage: solrizer [options]"
11
+
12
+ options[:hydra_home] = nil
13
+ opts.on( '--hydra_home PATH', 'Load the Hydra instance at this path' ) do |path|
14
+ if File.exist?(File.join(path,"config","environment.rb"))
15
+ options[:hydra_home] = path
16
+ else
17
+ puts "#{path} does not appear to be a valid rails home"
18
+ exit
19
+ end
20
+ end
21
+
22
+ options[:port] = 61613
23
+ opts.on('-p','--port NUM', 'Stomp port') do |port|
24
+ options[:port] = port
25
+ end
26
+
27
+ options[:host] = 'localhost'
28
+ opts.on('-o','--host HOSTNAME', 'Host to connect to') do |host|
29
+ options[:host] = host
30
+ end
31
+
32
+ options[:user] = 'fedoraStomper'
33
+ opts.on('-u', '--user USERNAME', 'User name for stomp listener') do |user|
34
+ options[:user] = user
35
+ end
36
+
37
+ options[:password] = 'fedoraStomper'
38
+ opts.on('-w', '--password PASSWORD', 'Password for stomp listener') do |password|
39
+ options[:password] = password
40
+ end
41
+
42
+ options[:destination] = '/topic/fedora.apim.update'
43
+ opts.on('-d','--destination TOPIC', 'Topic to listen to') do |destination|
44
+ options[:destination] = destination
45
+ end
46
+
47
+ opts.on('-h', '--help', 'Display this screen') do
48
+ puts opts
49
+ exit
50
+ end
51
+ end
52
+
53
+ optparse.parse!
54
+
55
+ begin; require 'rubygems'; rescue; end
56
+
57
+ if options[:hydra_home]
58
+ puts "Loading app..."
59
+ Dir.chdir(options[:hydra_home])
60
+ require File.join(options[:hydra_home],"config","environment.rb")
61
+
62
+ puts "app loaded"
63
+ else
64
+ "The --hydra_home PATH option is mandatory. Please provide the path to the root of a valid Hydra instance."
65
+ exit 1
66
+ end
67
+
68
+ puts "loading listener"
69
+
70
+ begin
71
+ @port = options[:port]
72
+ @host = options[:host]
73
+ @user = options[:user]
74
+ @password = options[:password]
75
+ @reliable = true
76
+ @clientid = "fedora_stomper"
77
+ @destination = options[:destination]
78
+
79
+
80
+ $stderr.print "Connecting to stomp://#{@host}:#{@port} as #{@user}\n"
81
+ @conn = Stomp::Connection.open(@user, @password, @host, @port, @reliable, 5, {"client-id" => @clientid} )
82
+ $stderr.print "Getting output from #{@destination}\n"
83
+
84
+ @conn.subscribe(@destination, {"activemq.subscriptionName" => @clientid, :ack =>"client" })
85
+ while true
86
+ @msg = @conn.receive
87
+ pid = @msg.headers["pid"]
88
+ method = @msg.headers["methodName"]
89
+
90
+ puts @msg.headers.inspect
91
+ puts "\nPID: #{@msg.headers["pid"]}\n"
92
+ if ["addDatastream", "addRelationship","ingest","modifyDatastream","modifyObject","purgeDatastream","urgeRelationship"].include? method
93
+ solrizer = Solrizer::Fedora::Solrizer.new
94
+ solrizer.solrize @msg.headers["pid"]
95
+ elsif method == "purgeObject"
96
+ ActiveFedora::SolrService.instance.conn.delete(pid)
97
+ end
98
+ puts "updated solr index for #{@msg.headers["pid"]}\n"
99
+ @conn.ack @msg.headers["message-id"]
100
+ end
101
+ @conn.join
102
+
103
+ rescue Exception => e
104
+ p e
105
+ end
106
+
data/bin/solrizerd ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'daemons'
5
+ require 'stomp'
6
+
7
+ banner=<<-EOC
8
+ Usage: solrizerd command --hydra_home PATH [options]
9
+ PATH must point to a valid hydra application
10
+ Commands:
11
+ start start an instance of the application
12
+ stop stop all instances of the application
13
+ restart stop all instances and restart them afterwards
14
+ status show status (PID) of application instances
15
+ Options:
16
+ --hydra_home PATH Load the hydra instance at this path
17
+ -p, --port NUM Stomp port (default 61613)
18
+ -o, --host HOSTNAME Host to connect to
19
+ -u, --user USERNAME User name for stomp listener
20
+ -w, --password PASSWORD Password for stomp listener
21
+ -d, --destination TOPIC Topic to listen to (default: /topic/fedora.apim.update)
22
+ -h, --help Display this screen
23
+ EOC
24
+
25
+
26
+ # check for a valid command
27
+ unless ['start','stop','restart','status'].include? ARGV[0]
28
+ puts banner
29
+ exit 7
30
+ end
31
+
32
+ if ARGV.include?('-h') || ARGV.include?('--help')
33
+ puts banner
34
+ exit 0
35
+ end
36
+
37
+ # Make sure --hydra_home was set for the start and restart commands
38
+ if ARGV[0] == 'start' || ARGV[0] == 'restart'
39
+ unless ARGV[1] == '--hydra_home'
40
+ puts "ERROR: You must --hydra_home to specify the path to a valid hydra application"
41
+ exit 8
42
+ end
43
+
44
+ # make sure valid path was set for hydra_home
45
+ unless ARGV[2] && File.exist?(File.join(ARGV[2],"config","environment.rb"))
46
+ puts "ERROR: the path entered does not appear to be a valid hydra instance"
47
+ exit 9
48
+ end
49
+ end
50
+
51
+
52
+ options = {
53
+ :multiple=>false,
54
+ :dir_mode=>:normal,
55
+ :dir=>'/tmp',
56
+ :backtrace=>true
57
+ }
58
+ argv_array = []
59
+ argv_array << ARGV[0]
60
+ argv_array << '--'
61
+ ARGV[1..-1].each {|ele| argv_array << ele }
62
+ options[:ARGV] = argv_array
63
+
64
+ version = '>=0'
65
+ app = Gem.bin_path('solrizer','solrizer',version)
66
+
67
+ Daemons.run(app,options)
68
+
data/solrizer.gemspec CHANGED
@@ -5,13 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{solrizer}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt"]
12
- s.date = %q{2011-03-03}
12
+ s.date = %q{2011-03-31}
13
13
  s.description = %q{Use solrizer to populate solr indexes from Fedora repository content or from other sources. You can run solrizer from within your apps, using the provided rake tasks, or as a JMS listener}
14
14
  s.email = %q{matt.zumwalt@yourmediashelf.com}
15
+ s.executables = ["solrizer", "solrizerd"]
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE",
17
18
  "README.textile"
@@ -24,6 +25,8 @@ Gem::Specification.new do |s|
24
25
  "README.textile",
25
26
  "Rakefile",
26
27
  "VERSION",
28
+ "bin/solrizer",
29
+ "bin/solrizerd",
27
30
  "config/fedora.yml",
28
31
  "config/hydra_types.yml",
29
32
  "config/solr.yml",
@@ -78,6 +81,8 @@ Gem::Specification.new do |s|
78
81
  s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
79
82
  s.add_runtime_dependency(%q<om>, [">= 1.0.0"])
80
83
  s.add_runtime_dependency(%q<mediashelf-loggable>, [">= 0"])
84
+ s.add_runtime_dependency(%q<stomp>, [">= 0"])
85
+ s.add_runtime_dependency(%q<daemons>, [">= 0"])
81
86
  s.add_development_dependency(%q<jeweler>, [">= 0"])
82
87
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
83
88
  s.add_development_dependency(%q<ruby-debug-base>, [">= 0"])
@@ -97,6 +102,8 @@ Gem::Specification.new do |s|
97
102
  s.add_dependency(%q<xml-simple>, [">= 0"])
98
103
  s.add_dependency(%q<om>, [">= 1.0.0"])
99
104
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
105
+ s.add_dependency(%q<stomp>, [">= 0"])
106
+ s.add_dependency(%q<daemons>, [">= 0"])
100
107
  s.add_dependency(%q<jeweler>, [">= 0"])
101
108
  s.add_dependency(%q<ruby-debug>, [">= 0"])
102
109
  s.add_dependency(%q<ruby-debug-base>, [">= 0"])
@@ -117,6 +124,8 @@ Gem::Specification.new do |s|
117
124
  s.add_dependency(%q<xml-simple>, [">= 0"])
118
125
  s.add_dependency(%q<om>, [">= 1.0.0"])
119
126
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
127
+ s.add_dependency(%q<stomp>, [">= 0"])
128
+ s.add_dependency(%q<daemons>, [">= 0"])
120
129
  s.add_dependency(%q<jeweler>, [">= 0"])
121
130
  s.add_dependency(%q<ruby-debug>, [">= 0"])
122
131
  s.add_dependency(%q<ruby-debug-base>, [">= 0"])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solrizer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -15,12 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-03 00:00:00 -06:00
18
+ date: 2011-03-31 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
22
  prerelease: false
23
+ type: :runtime
24
24
  name: nokogiri
25
25
  version_requirements: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
@@ -33,8 +33,8 @@ dependencies:
33
33
  version: "0"
34
34
  requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- type: :runtime
37
36
  prerelease: false
37
+ type: :runtime
38
38
  name: xml-simple
39
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
40
  none: false
@@ -47,8 +47,8 @@ dependencies:
47
47
  version: "0"
48
48
  requirement: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- type: :runtime
51
50
  prerelease: false
51
+ type: :runtime
52
52
  name: om
53
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
@@ -63,8 +63,8 @@ dependencies:
63
63
  version: 1.0.0
64
64
  requirement: *id003
65
65
  - !ruby/object:Gem::Dependency
66
- type: :runtime
67
66
  prerelease: false
67
+ type: :runtime
68
68
  name: mediashelf-loggable
69
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
@@ -77,9 +77,9 @@ dependencies:
77
77
  version: "0"
78
78
  requirement: *id004
79
79
  - !ruby/object:Gem::Dependency
80
- type: :development
81
80
  prerelease: false
82
- name: jeweler
81
+ type: :runtime
82
+ name: stomp
83
83
  version_requirements: &id005 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
@@ -91,9 +91,9 @@ dependencies:
91
91
  version: "0"
92
92
  requirement: *id005
93
93
  - !ruby/object:Gem::Dependency
94
- type: :development
95
94
  prerelease: false
96
- name: ruby-debug
95
+ type: :runtime
96
+ name: daemons
97
97
  version_requirements: &id006 !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
@@ -105,9 +105,9 @@ dependencies:
105
105
  version: "0"
106
106
  requirement: *id006
107
107
  - !ruby/object:Gem::Dependency
108
- type: :development
109
108
  prerelease: false
110
- name: ruby-debug-base
109
+ type: :development
110
+ name: jeweler
111
111
  version_requirements: &id007 !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -119,25 +119,23 @@ dependencies:
119
119
  version: "0"
120
120
  requirement: *id007
121
121
  - !ruby/object:Gem::Dependency
122
- type: :development
123
122
  prerelease: false
124
- name: rspec
123
+ type: :development
124
+ name: ruby-debug
125
125
  version_requirements: &id008 !ruby/object:Gem::Requirement
126
126
  none: false
127
127
  requirements:
128
- - - <
128
+ - - ">="
129
129
  - !ruby/object:Gem::Version
130
- hash: 15
130
+ hash: 3
131
131
  segments:
132
- - 2
133
132
  - 0
134
- - 0
135
- version: 2.0.0
133
+ version: "0"
136
134
  requirement: *id008
137
135
  - !ruby/object:Gem::Dependency
138
- type: :development
139
136
  prerelease: false
140
- name: mocha
137
+ type: :development
138
+ name: ruby-debug-base
141
139
  version_requirements: &id009 !ruby/object:Gem::Requirement
142
140
  none: false
143
141
  requirements:
@@ -149,23 +147,25 @@ dependencies:
149
147
  version: "0"
150
148
  requirement: *id009
151
149
  - !ruby/object:Gem::Dependency
152
- type: :runtime
153
150
  prerelease: false
154
- name: nokogiri
151
+ type: :development
152
+ name: rspec
155
153
  version_requirements: &id010 !ruby/object:Gem::Requirement
156
154
  none: false
157
155
  requirements:
158
- - - ">="
156
+ - - <
159
157
  - !ruby/object:Gem::Version
160
- hash: 3
158
+ hash: 15
161
159
  segments:
160
+ - 2
162
161
  - 0
163
- version: "0"
162
+ - 0
163
+ version: 2.0.0
164
164
  requirement: *id010
165
165
  - !ruby/object:Gem::Dependency
166
- type: :runtime
167
166
  prerelease: false
168
- name: om
167
+ type: :development
168
+ name: mocha
169
169
  version_requirements: &id011 !ruby/object:Gem::Requirement
170
170
  none: false
171
171
  requirements:
@@ -177,8 +177,8 @@ dependencies:
177
177
  version: "0"
178
178
  requirement: *id011
179
179
  - !ruby/object:Gem::Dependency
180
- type: :runtime
181
180
  prerelease: false
181
+ type: :runtime
182
182
  name: nokogiri
183
183
  version_requirements: &id012 !ruby/object:Gem::Requirement
184
184
  none: false
@@ -191,9 +191,9 @@ dependencies:
191
191
  version: "0"
192
192
  requirement: *id012
193
193
  - !ruby/object:Gem::Dependency
194
- type: :runtime
195
194
  prerelease: false
196
- name: mediashelf-loggable
195
+ type: :runtime
196
+ name: om
197
197
  version_requirements: &id013 !ruby/object:Gem::Requirement
198
198
  none: false
199
199
  requirements:
@@ -205,9 +205,9 @@ dependencies:
205
205
  version: "0"
206
206
  requirement: *id013
207
207
  - !ruby/object:Gem::Dependency
208
- type: :development
209
208
  prerelease: false
210
- name: jeweler
209
+ type: :runtime
210
+ name: nokogiri
211
211
  version_requirements: &id014 !ruby/object:Gem::Requirement
212
212
  none: false
213
213
  requirements:
@@ -219,9 +219,9 @@ dependencies:
219
219
  version: "0"
220
220
  requirement: *id014
221
221
  - !ruby/object:Gem::Dependency
222
- type: :development
223
222
  prerelease: false
224
- name: ruby-debug
223
+ type: :runtime
224
+ name: mediashelf-loggable
225
225
  version_requirements: &id015 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
@@ -233,9 +233,9 @@ dependencies:
233
233
  version: "0"
234
234
  requirement: *id015
235
235
  - !ruby/object:Gem::Dependency
236
- type: :development
237
236
  prerelease: false
238
- name: ruby-debug-base
237
+ type: :development
238
+ name: jeweler
239
239
  version_requirements: &id016 !ruby/object:Gem::Requirement
240
240
  none: false
241
241
  requirements:
@@ -247,10 +247,38 @@ dependencies:
247
247
  version: "0"
248
248
  requirement: *id016
249
249
  - !ruby/object:Gem::Dependency
250
+ prerelease: false
251
+ type: :development
252
+ name: ruby-debug
253
+ version_requirements: &id017 !ruby/object:Gem::Requirement
254
+ none: false
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ hash: 3
259
+ segments:
260
+ - 0
261
+ version: "0"
262
+ requirement: *id017
263
+ - !ruby/object:Gem::Dependency
264
+ prerelease: false
250
265
  type: :development
266
+ name: ruby-debug-base
267
+ version_requirements: &id018 !ruby/object:Gem::Requirement
268
+ none: false
269
+ requirements:
270
+ - - ">="
271
+ - !ruby/object:Gem::Version
272
+ hash: 3
273
+ segments:
274
+ - 0
275
+ version: "0"
276
+ requirement: *id018
277
+ - !ruby/object:Gem::Dependency
251
278
  prerelease: false
279
+ type: :development
252
280
  name: rspec
253
- version_requirements: &id017 !ruby/object:Gem::Requirement
281
+ version_requirements: &id019 !ruby/object:Gem::Requirement
254
282
  none: false
255
283
  requirements:
256
284
  - - <
@@ -261,12 +289,12 @@ dependencies:
261
289
  - 0
262
290
  - 0
263
291
  version: 2.0.0
264
- requirement: *id017
292
+ requirement: *id019
265
293
  - !ruby/object:Gem::Dependency
266
- type: :development
267
294
  prerelease: false
295
+ type: :development
268
296
  name: mocha
269
- version_requirements: &id018 !ruby/object:Gem::Requirement
297
+ version_requirements: &id020 !ruby/object:Gem::Requirement
270
298
  none: false
271
299
  requirements:
272
300
  - - ">="
@@ -275,11 +303,12 @@ dependencies:
275
303
  segments:
276
304
  - 0
277
305
  version: "0"
278
- requirement: *id018
306
+ requirement: *id020
279
307
  description: Use solrizer to populate solr indexes from Fedora repository content or from other sources. You can run solrizer from within your apps, using the provided rake tasks, or as a JMS listener
280
308
  email: matt.zumwalt@yourmediashelf.com
281
- executables: []
282
-
309
+ executables:
310
+ - solrizer
311
+ - solrizerd
283
312
  extensions: []
284
313
 
285
314
  extra_rdoc_files:
@@ -293,6 +322,8 @@ files:
293
322
  - README.textile
294
323
  - Rakefile
295
324
  - VERSION
325
+ - bin/solrizer
326
+ - bin/solrizerd
296
327
  - config/fedora.yml
297
328
  - config/hydra_types.yml
298
329
  - config/solr.yml