websolr-rails 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/websolr-rails.rb +31 -45
- data/websolr-rails.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/lib/websolr-rails.rb
CHANGED
@@ -1,61 +1,47 @@
|
|
1
1
|
# Post-require hooks for acts_as_solr and sunspot if this
|
2
2
|
# gem is loaded and WEBSOLR_URL is defined.
|
3
3
|
|
4
|
-
if ENV["WEBSOLR_URL"]
|
5
|
-
$websolr_already = true
|
4
|
+
if ENV["WEBSOLR_URL"]
|
6
5
|
require "uri"
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
7
|
+
begin
|
8
|
+
require "sunspot/rails/configuration"
|
9
|
+
module Sunspot #:nodoc:
|
10
|
+
module Rails #:nodoc:
|
11
|
+
class Configuration
|
12
|
+
def hostname
|
13
|
+
URI.parse(ENV["WEBSOLR_URL"]).host
|
14
|
+
end
|
15
|
+
def port
|
16
|
+
URI.parse(ENV["WEBSOLR_URL"]).port
|
17
|
+
end
|
18
|
+
def path
|
19
|
+
URI.parse(ENV["WEBSOLR_URL"]).path
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
25
|
-
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
#ignore
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
28
|
+
begin
|
29
|
+
require "acts_as_solr"
|
30
|
+
module ActsAsSolr
|
31
|
+
class Post
|
32
|
+
def self.execute(request)
|
33
|
+
begin
|
34
|
+
connection = Solr::Connection.new(ENV["WEBSOLR_URL"])
|
35
|
+
return connection.send(request)
|
36
|
+
rescue
|
37
|
+
raise "Couldn't connect to the Solr server at \#{url}. \#{$!}"
|
38
|
+
false
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
43
|
-
RUBY
|
44
|
-
end
|
45
|
-
|
46
|
-
websolr_install_sunspot
|
47
|
-
websolr_install_acts_as_solr
|
48
|
-
|
49
|
-
module Kernel #:nodoc: all
|
50
|
-
alias_method :require_without_solr_hooks, :require
|
51
|
-
def require(string)
|
52
|
-
require_without_solr_hooks(string)
|
53
|
-
case string
|
54
|
-
when "acts_as_solr"
|
55
|
-
websolr_install_acts_as_solr
|
56
|
-
when "sunspot"
|
57
|
-
websolr_install_sunspot
|
58
|
-
end
|
59
42
|
end
|
43
|
+
rescue LoadError
|
44
|
+
#ignore
|
60
45
|
end
|
46
|
+
|
61
47
|
end
|
data/websolr-rails.gemspec
CHANGED