mwmitchell-rsolr 0.8.9 → 0.9.0

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/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 0.9.0 - July 17, 2009
2
+ Added ability to use DirectSolrConnection instance when connecting
3
+ Loading Java classes using full package name
4
+
1
5
  0.8.9 - June 30, 2009
2
6
  Deprecated hash syntax fix from outoftime/rsolr (Mat Brown)
3
7
 
@@ -9,8 +9,11 @@ class RSolr::Adapter::Direct
9
9
 
10
10
  include RSolr::HTTPClient::Util
11
11
 
12
- attr_accessor :opts, :home_dir
12
+ attr_accessor :opts
13
13
 
14
+ # opts can be an instance of org.apache.solr.servlet.DirectSolrConnection
15
+ # if opts is NOT an instance of org.apache.solr.servlet.DirectSolrConnection
16
+ # then...
14
17
  # required: opts[:home_dir] is absolute path to solr home (the directory with "data", "config" etc.)
15
18
  # opts must also contain either
16
19
  # :dist_dir => 'absolute path to solr distribution root
@@ -20,22 +23,24 @@ class RSolr::Adapter::Direct
20
23
  # :select_path => 'the/select/handler'
21
24
  # :update_path => 'the/update/handler'
22
25
  def initialize(opts, &block)
23
- @home_dir = opts[:home_dir].to_s
24
- opts[:data_dir] ||= File.join(@home_dir, 'data')
25
- if opts[:dist_dir] and ! opts[:jar_paths]
26
- # add the standard lib and dist directories to the :jar_paths
27
- opts[:jar_paths] = [File.join(opts[:dist_dir], 'lib'), File.join(opts[:dist_dir], 'dist')]
26
+ if defined?(Java::OrgApacheSolrServlet::DirectSolrConnection) and opts.is_a?(Java::OrgApacheSolrServlet::DirectSolrConnection)
27
+ @connection = opts
28
+ else
29
+ opts[:data_dir] ||= File.join(opts[:home_dir].to_s, 'data')
30
+ if opts[:dist_dir] and ! opts[:jar_paths]
31
+ # add the standard lib and dist directories to the :jar_paths
32
+ opts[:jar_paths] = [File.join(opts[:dist_dir], 'lib'), File.join(opts[:dist_dir], 'dist')]
33
+ end
34
+ @opts = opts
28
35
  end
29
- @opts = opts
30
36
  end
31
37
 
32
38
  # loads/imports the java dependencies
33
- # sets the @connection instance variable
39
+ # sets the @connection instance variable if it has not yet been set
34
40
  def connection
35
41
  @connection ||= (
36
42
  require_jars(@opts[:jar_paths]) if @opts[:jar_paths]
37
- import_dependencies
38
- DirectSolrConnection.new(@home_dir, @opts[:data_dir], nil)
43
+ org.apache.solr.servlet.DirectSolrConnection.new(opts[:home_dir], @opts[:data_dir], nil)
39
44
  )
40
45
  end
41
46
 
@@ -67,17 +72,13 @@ class RSolr::Adapter::Direct
67
72
 
68
73
  protected
69
74
 
70
- # do the java import thingy
71
- def import_dependencies
72
- import org.apache.solr.servlet.DirectSolrConnection
73
- end
74
-
75
75
  # require the jar files
76
76
  def require_jars(paths)
77
77
  paths = [paths] unless paths.is_a?(Array)
78
78
  paths.each do |path|
79
+ raise "Invalid jar path: #{path}" unless File.exists?(path)
79
80
  jar_pattern = File.join(path,"**", "*.jar")
80
- Dir[jar_pattern].each {|jar_file| require jar_file}
81
+ Dir[jar_pattern].each {|jar_file| require jar_file }
81
82
  end
82
83
  end
83
84
 
data/rsolr.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rsolr"
3
- s.version = "0.8.9"
4
- s.date = "2009-06-30"
3
+ s.version = "0.9.0"
4
+ s.date = "2009-07-17"
5
5
  s.summary = "A Ruby client for Apache Solr"
6
6
  s.email = "goodieboy@gmail.com"
7
7
  s.homepage = "http://github.com/mwmitchell/rsolr"
@@ -7,11 +7,14 @@ if defined?(JRUBY_VERSION)
7
7
 
8
8
  include ConnectionTestMethods
9
9
 
10
+ attr :dist
11
+ attr :home
12
+
10
13
  def setup
11
14
  base = File.expand_path( File.dirname(__FILE__) )
12
- dist = File.join(base, '..', '..', 'apache-solr')
13
- home = File.join(dist, 'example', 'solr')
14
- @solr = RSolr.connect(:adapter=>:direct, :home_dir=>home, :dist_dir=>dist)
15
+ @dist = File.join(base, '..', '..', 'apache-solr')
16
+ @home = File.join(dist, 'example', 'solr')
17
+ @solr = RSolr.connect(:adapter=>:direct, :home_dir=>@home, :dist_dir=>@dist)
15
18
  @solr.delete_by_query('*:*')
16
19
  @solr.commit
17
20
  end
@@ -20,6 +23,15 @@ if defined?(JRUBY_VERSION)
20
23
  @solr.adapter.close
21
24
  end
22
25
 
26
+ def test_new_connection_with_existing_core
27
+ Dir["#{@dist}/dist/*.jar"].each { |p| require p }
28
+ dc = org.apache.solr.servlet.DirectSolrConnection.new(@home, "#{@home}/data", nil)
29
+ adapter = RSolr::Adapter::Direct.new dc
30
+ s = RSolr::Connection.new(adapter)
31
+ assert_equal Hash, s.request('/admin/ping').class
32
+ adapter.close
33
+ end
34
+
23
35
  end
24
36
 
25
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwmitchell-rsolr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Mitchell
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-30 00:00:00 -07:00
12
+ date: 2009-07-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency