erichummel-sunspot 2.0.0.pre.111215b → 2.0.0.pre.111215c

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ module Sunspot
2
+ module SessionProxy
3
+ class MulticoreSessionProxy < AbstractSessionProxy
4
+
5
+ def initialize( cores )
6
+ @sessions = {}
7
+ @cores ||= []
8
+ ( @cores << cores ).flatten!
9
+ cores.each do |core|
10
+
11
+ # can't find a better way grab the sunspot.yml configuration (:user_configuration is a private method)
12
+ modified_config = Marshal.load( Marshal.dump( Sunspot::Rails.configuration.send(:user_configuration) ) )
13
+
14
+ modified_config["solr"]["path"] = File.join(
15
+ ( modified_config["solr"]["path"] || Sunspot::Rails.configuration.path ), core )
16
+
17
+ extended_config = Sunspot::Rails::ExtendedConfiguration.new(modified_config)
18
+ session = @sessions[core] = Sunspot::Rails.build_session(extended_config)
19
+ end
20
+ end
21
+
22
+ attr_accessor :selected_session
23
+
24
+ def method_missing(method, *args, &block)
25
+ inspectable_args = args.flatten
26
+ types = inspectable_args.select(&:searchable?) rescue []
27
+ types += inspectable_args.select{|a| a.class.searchable? rescue false }
28
+
29
+ self.selected_session = session_for_types(types) || self.selected_session
30
+
31
+ if self.selected_session.respond_to?(method)
32
+ begin
33
+ self.selected_session.send(method, *args, &block)
34
+ rescue Exception => e
35
+ (puts "method #{method} caused: #{e.message}")
36
+ end
37
+ else
38
+ # raise NoMethodError, "Method #{method} isn't defined on session"
39
+ # logger.info("do nothing")
40
+ # super
41
+ # self.selected_session.send(method, *args, &block)
42
+ return false
43
+ end
44
+ end
45
+
46
+ protected
47
+ def infer_configuration_options_from_env_url( options )
48
+ if ENV["SOLR_URL"]
49
+
50
+ end
51
+ end
52
+
53
+ def session_for_types(*types)
54
+ cores = types.flatten.map{|t| t.sunspot_options[:core] }.uniq
55
+ raise ArgumentError, "Can't mix and match types that use different solr cores" if cores.length > 1
56
+
57
+ @sessions[cores.first]
58
+ end
59
+
60
+ def session_for_objects(*objects)
61
+ types = objects.map(&:class).uniq
62
+ session_for_types(types)
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module Sunspot
2
- VERSION = '2.0.0.pre.111215b'
2
+ VERSION = '2.0.0.pre.111215c'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erichummel-sunspot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.111215b
4
+ version: 2.0.0.pre.111215c
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -31,7 +31,7 @@ date: 2012-03-12 00:00:00.000000000Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: rsolr
34
- requirement: &2164021700 !ruby/object:Gem::Requirement
34
+ requirement: &2163332680 !ruby/object:Gem::Requirement
35
35
  none: false
36
36
  requirements:
37
37
  - - ~>
@@ -39,10 +39,10 @@ dependencies:
39
39
  version: 1.0.6
40
40
  type: :runtime
41
41
  prerelease: false
42
- version_requirements: *2164021700
42
+ version_requirements: *2163332680
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: escape
45
- requirement: &2164020940 !ruby/object:Gem::Requirement
45
+ requirement: &2163330340 !ruby/object:Gem::Requirement
46
46
  none: false
47
47
  requirements:
48
48
  - - ~>
@@ -50,10 +50,10 @@ dependencies:
50
50
  version: 0.0.4
51
51
  type: :runtime
52
52
  prerelease: false
53
- version_requirements: *2164020940
53
+ version_requirements: *2163330340
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: pr_geohash
56
- requirement: &2164020440 !ruby/object:Gem::Requirement
56
+ requirement: &2163327020 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ~>
@@ -61,10 +61,10 @@ dependencies:
61
61
  version: '1.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
- version_requirements: *2164020440
64
+ version_requirements: *2163327020
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: rspec
67
- requirement: &2164019760 !ruby/object:Gem::Requirement
67
+ requirement: &2163325740 !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
70
70
  - - ~>
@@ -72,10 +72,10 @@ dependencies:
72
72
  version: 2.6.0
73
73
  type: :development
74
74
  prerelease: false
75
- version_requirements: *2164019760
75
+ version_requirements: *2163325740
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: hanna
78
- requirement: &2164019120 !ruby/object:Gem::Requirement
78
+ requirement: &2163324840 !ruby/object:Gem::Requirement
79
79
  none: false
80
80
  requirements:
81
81
  - - ! '>='
@@ -83,7 +83,7 @@ dependencies:
83
83
  version: '0'
84
84
  type: :development
85
85
  prerelease: false
86
- version_requirements: *2164019120
86
+ version_requirements: *2163324840
87
87
  description: ! " Sunspot is a library providing a powerful, all-ruby API for the
88
88
  Solr search engine. Sunspot manages the configuration of persistent\n Ruby classes
89
89
  for search and indexing and exposes Solr's most powerful features through a collection
@@ -174,6 +174,7 @@ files:
174
174
  - lib/sunspot/session_proxy/class_sharding_session_proxy.rb
175
175
  - lib/sunspot/session_proxy/id_sharding_session_proxy.rb
176
176
  - lib/sunspot/session_proxy/master_slave_session_proxy.rb
177
+ - lib/sunspot/session_proxy/multicore_session_proxy.rb
177
178
  - lib/sunspot/session_proxy/sharding_session_proxy.rb
178
179
  - lib/sunspot/session_proxy/silent_fail_session_proxy.rb
179
180
  - lib/sunspot/session_proxy/thread_local_session_proxy.rb