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 CHANGED
@@ -1 +1 @@
1
- 2.0.5
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"] && !$websolr_already
5
- $websolr_already = true
4
+ if ENV["WEBSOLR_URL"]
6
5
  require "uri"
7
6
 
8
- def websolr_install_sunspot
9
- eval <<-RUBY
10
- module Sunspot #:nodoc:
11
- module Rails #:nodoc:
12
- class Configuration
13
- def hostname
14
- URI.parse(ENV["WEBSOLR_URL"]).host
15
- end
16
- def port
17
- URI.parse(ENV["WEBSOLR_URL"]).port
18
- end
19
- def path
20
- URI.parse(ENV["WEBSOLR_URL"]).path
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
- RUBY
23
+ end
24
+ rescue LoadError
25
+ #ignore
26
26
  end
27
27
 
28
- def websolr_install_acts_as_solr
29
- eval <<-RUBY
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
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{websolr-rails}
8
- s.version = "2.0.5"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kyle Maxwell"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websolr-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Maxwell