websolr-sunspot_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kyle Maxwell
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.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = websolr-rails
2
+
3
+ This overrides Sunspot to use the value of the environment variable
4
+ WEBSOLR_URL as the Solr Search server, provided that it's defined.
5
+
6
+ After installing the gem, you can include websolr-rails in your
7
+ app by either starting the webapp like:
8
+
9
+ WEBSOLR_URL=http://index.websolr.com/solr/<api-key> ./script/server
10
+
11
+ Or, you can put the following in /environment/production.rb, or an
12
+ initializer, etc:
13
+
14
+ # production.rb
15
+ ENV["WEBSOLR_URL"] = "http://index.websolr.com/solr/<api-key>"
16
+
17
+ # WEBSOLR_URL must already be defined.
18
+ require "websolr-sunspot_rails"
19
+
20
+ == Semantic Versioning
21
+
22
+ This library obeys the definition of "Semantic Versioning" at http://semver.org/. YMMV with its dependencies.
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2009 Kyle Maxwell. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "websolr-sunspot_rails"
8
+ gem.summary = %Q{websolr to sunspot_rails shim}
9
+ gem.description = %Q{websolr to sunspot_rails shim}
10
+ gem.email = "kyle@kylemaxwell.com"
11
+ gem.homepage = "http://github.com/fizx/websolr-sunspot_rails"
12
+ gem.authors = ["Kyle Maxwell"]
13
+ gem.add_dependency "plain_option_parser", ">= 0"
14
+ gem.add_dependency "sunspot", "=0.10.8"
15
+ gem.add_dependency "sunspot_rails", "=0.11.5"
16
+ gem.add_dependency "rest-client"
17
+ gem.add_development_dependency "rspec", ">= 0"
18
+ end
19
+ Jeweler::GemcutterTasks.new
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/test_*.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/test_*.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "websolr-sunspot_rails #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,97 @@
1
+ require "rubygems"
2
+ gem "sunspot", :version => "0.10.8"
3
+ gem "sunspot_rails", :version => "0.11.5"
4
+
5
+ # Post-require hooks and sunspot if WEBSOLR_URL is defined.
6
+ if ENV["WEBSOLR_URL"]
7
+
8
+ CLIENT_KEY = "sunspot-0.10"
9
+
10
+ require "rest_client"
11
+ require "uri"
12
+ require "sunspot/rails"
13
+ require "sunspot/rails/configuration"
14
+ require "sunspot/rails/searchable"
15
+ require "sunspot/rails/request_lifecycle"
16
+
17
+ api_key = ENV["WEBSOLR_URL"][/[0-9a-f]{11}/] or raise "Invalid WEBSOLR_URL: bad or no api key"
18
+ print "Setting schema to #{CLIENT_KEY}..."
19
+ STDOUT.flush
20
+ RestClient.post("http://www.websolr.com/schema/#{api_key}", :client => CLIENT_KEY)
21
+ puts "done"
22
+
23
+ module Sunspot #:nodoc:
24
+ module Rails #:nodoc:
25
+ class Configuration
26
+ def hostname
27
+ URI.parse(ENV["WEBSOLR_URL"]).host
28
+ end
29
+ def port
30
+ URI.parse(ENV["WEBSOLR_URL"]).port
31
+ end
32
+ def path
33
+ URI.parse(ENV["WEBSOLR_URL"]).path
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ module Sunspot #:nodoc:
40
+ module Rails #:nodoc:
41
+ #
42
+ # This module adds an after_filter to ActionController::Base that commits
43
+ # the Sunspot session if any documents have been added, changed, or removed
44
+ # in the course of the request.
45
+ #
46
+ module RequestLifecycle
47
+ class <<self
48
+ def included(base) #:nodoc:
49
+ base.after_filter do
50
+ begin
51
+ # Sunspot moved the location of the commit_if_dirty method around.
52
+ # Let's support multiple versions for now.
53
+ session = Sunspot::Rails.respond_to?(:master_session) ?
54
+ Sunspot::Rails.master_session :
55
+ Sunspot
56
+
57
+ if Sunspot::Rails.configuration.auto_commit_after_request?
58
+ session.commit_if_dirty
59
+ elsif Sunspot::Rails.configuration.auto_commit_after_delete_request?
60
+ session.commit_if_delete_dirty
61
+ end
62
+ rescue Exception => e
63
+ ActionController::Base.logger.error e.message
64
+ ActionController::Base.logger.error e.backtrace.join("\n")
65
+ false
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+
75
+ module Sunspot
76
+ module Rails
77
+ module Searchable
78
+ module InstanceMethods
79
+ %w[index index! remove_from_index remove_from_index!].each do |method|
80
+ new_name = method =~ /!/ ? method.gsub("!", "") + "_with_caught_errors!" : "#{method}_with_caught_errors"
81
+ old_name = new_name.sub("_with_", "_without_")
82
+ define_method(new_name) do
83
+ begin
84
+ send(old_name)
85
+ rescue Exception => e
86
+ logger.error e.message
87
+ logger.error e.backtrace.join("\n")
88
+ false
89
+ end
90
+ end
91
+ alias_method_chain method, :caught_errors
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{websolr-sunspot_rails}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kyle Maxwell"]
12
+ s.date = %q{2010-01-26}
13
+ s.description = %q{websolr to sunspot_rails shim}
14
+ s.email = %q{kyle@kylemaxwell.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/websolr-sunspot_rails.rb",
27
+ "websolr-sunspot_rails.gemspec"
28
+ ]
29
+ s.homepage = %q{http://github.com/fizx/websolr-sunspot_rails}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{websolr to sunspot_rails shim}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_runtime_dependency(%q<plain_option_parser>, [">= 0"])
41
+ s.add_runtime_dependency(%q<sunspot>, ["= 0.10.8"])
42
+ s.add_runtime_dependency(%q<sunspot_rails>, ["= 0.11.5"])
43
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
44
+ s.add_development_dependency(%q<rspec>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<plain_option_parser>, [">= 0"])
47
+ s.add_dependency(%q<sunspot>, ["= 0.10.8"])
48
+ s.add_dependency(%q<sunspot_rails>, ["= 0.11.5"])
49
+ s.add_dependency(%q<rest-client>, [">= 0"])
50
+ s.add_dependency(%q<rspec>, [">= 0"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<plain_option_parser>, [">= 0"])
54
+ s.add_dependency(%q<sunspot>, ["= 0.10.8"])
55
+ s.add_dependency(%q<sunspot_rails>, ["= 0.11.5"])
56
+ s.add_dependency(%q<rest-client>, [">= 0"])
57
+ s.add_dependency(%q<rspec>, [">= 0"])
58
+ end
59
+ end
60
+
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: websolr-sunspot_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kyle Maxwell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-26 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: plain_option_parser
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sunspot
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.8
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sunspot_rails
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.11.5
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rest-client
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ description: websolr to sunspot_rails shim
66
+ email: kyle@kylemaxwell.com
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files:
72
+ - LICENSE
73
+ - README.rdoc
74
+ files:
75
+ - .document
76
+ - .gitignore
77
+ - LICENSE
78
+ - README.rdoc
79
+ - Rakefile
80
+ - VERSION
81
+ - lib/websolr-sunspot_rails.rb
82
+ - websolr-sunspot_rails.gemspec
83
+ has_rdoc: true
84
+ homepage: http://github.com/fizx/websolr-sunspot_rails
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --charset=UTF-8
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0"
103
+ version:
104
+ requirements: []
105
+
106
+ rubyforge_project:
107
+ rubygems_version: 1.3.5
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: websolr to sunspot_rails shim
111
+ test_files: []
112
+