synchrony_sunspot 0.0.1

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/CHANGELOG.md ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Sujal Shah
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # synchrony-sunspot
2
+ __WORK IN PROGRESS__
3
+
4
+ This is a simple shim that replaces the Net::HTTP driver in RSolr with an em-synchrony+em-http-request driver and then wires it into Sunspot.
5
+
6
+ ## Usage
7
+
8
+ It's a pretty simple usage. Just include the gem in your project and it will do the rest.
9
+
10
+ ### NOTE
11
+
12
+ This driver will NOT work if you are not running in an em-synchrony loop. If you run this in a regular eventmachine loop or in regular old code, it will simply hang or error out.
13
+
14
+ ----
15
+
16
+ See the LICENSE file for licensing details.
@@ -0,0 +1,35 @@
1
+ require 'em-synchrony'
2
+ require 'em-synchrony/em-http'
3
+ require "rsolr"
4
+
5
+ module RSolr
6
+ class SynchronyConnection
7
+
8
+ def execute client, request_context
9
+
10
+ method = request_context[:method]
11
+ options = {}
12
+ options[:head] = request_context[:headers] || {}
13
+ options[:body] = request_context[:data] if request_context[:body].to_s
14
+ options[:proxy] ||= request_context[:proxy] if request_context[:proxy]
15
+
16
+ # add basic auth and remove it from URL
17
+ if request_context[:uri].user && request_context[:uri].password
18
+ options[:head]['authorization'] = [ request_context[:uri].user, request_context[:uri].password ]
19
+ request_context[:uri].user = nil
20
+ request_context[:uri].password = nil
21
+ end
22
+
23
+ # create em http object
24
+ http_request = EventMachine::HttpRequest.new(request_context[:uri].to_s)
25
+
26
+ # send the call
27
+ response = http_request.send(method, options)
28
+
29
+ # return the response
30
+ { status: response.response_header.status, headers: response.response_header, body: response.response }
31
+
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module Sunspot
2
+ module Synchrony
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ require "sunspot"
2
+ require "rsolr/synchrony_connection"
3
+
4
+ module Sunspot
5
+ class Session
6
+
7
+ private
8
+
9
+ # override connection to return a synchrony ready connection
10
+ def connection
11
+ @connection ||=
12
+ self.class.connection_class.connect(RSolr::SynchronyConnection,
13
+ { :url => config.solr.url })
14
+ end
15
+
16
+
17
+ end
18
+ end
19
+
@@ -0,0 +1,2 @@
1
+ require "rsolr/synchrony_connection"
2
+ require "sunspot/synchrony"
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: synchrony_sunspot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sujal Shah
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: em-synchrony
16
+ requirement: &70107040732180 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70107040732180
25
+ - !ruby/object:Gem::Dependency
26
+ name: em-http-request
27
+ requirement: &70107040728820 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70107040728820
36
+ - !ruby/object:Gem::Dependency
37
+ name: sunspot
38
+ requirement: &70107040741060 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70107040741060
47
+ description: Provides an em-synchrony compatible rsolr connection driver & overrides
48
+ Sunspot's connection method.
49
+ email:
50
+ - codesujal@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - lib/rsolr/synchrony_connection.rb
56
+ - lib/sunspot/synchrony/version.rb
57
+ - lib/sunspot/synchrony.rb
58
+ - lib/synchrony_sunspot.rb
59
+ - LICENSE
60
+ - CHANGELOG.md
61
+ - README.md
62
+ homepage: https://github.com/sujal/synchrony-sunspot
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ segments:
75
+ - 0
76
+ hash: 4137746282220004761
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.10
83
+ requirements: []
84
+ rubyforge_project: synchrony-sunspot
85
+ rubygems_version: 1.8.10
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Tweaks RSolr to use em-synchrony's em-http-request.
89
+ test_files: []