Permalink
Browse files

Update the indexer to just inherit from the default CoveSearch::Client

Also remove any -journal files from the git tree
  • Loading branch information...
1 parent 5c99624 commit ce2f156b44821d6bc6e869be39b0b1d503f5af5b @rweald rweald committed Jun 4, 2011
Showing with 50 additions and 47 deletions.
  1. +1 −1 .gitignore
  2. +4 −3 Gemfile.lock
  3. +45 −43 lib/indexer.rb
View
@@ -1,5 +1,5 @@
.bundle
-db/*.sqlite3
+db/*.sqlite3*
db/schema.rb
log/*.log
log/notes/*
View
@@ -1,10 +1,11 @@
GIT
remote: git://github.com/rweald/cove_search
- revision: c046457da9a7e76155f84ab7f07733de2e02711f
+ revision: 8bdb8739823b8dbb8a4e3428027408132d954d15
specs:
cove_search (0.0.1)
redis
redis-namespace
+ rest-client
sinatra
vegas
yajl-ruby
@@ -191,7 +192,7 @@ GEM
redis-namespace (1.0.3)
redis (< 3.0.0)
resque (1.17.1)
- json (>= 1.4.6, < 1.6)
+ json (< 1.6, >= 1.4.6)
redis-namespace (~> 1.0.2)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
@@ -236,7 +237,7 @@ GEM
simple_form (1.4.0)
sinatra (1.2.6)
rack (~> 1.1)
- tilt (>= 1.2.2, < 2.0)
+ tilt (< 2.0, >= 1.2.2)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
View
@@ -1,50 +1,52 @@
require 'rest-client'
+require 'cove_search/client'
-class Indexer
- class << self
- attr_accessor :host
- end
+class Indexer < CoveSearch::Client
+
+ #class << self
+ #attr_accessor :host
+ #end
@host = "127.0.0.1:5678"
- def self.update_index(parameters)
- response = post("/update_index", parameters)
- raise "Index could not be updated" unless response["status"] =~ /success/
- end
-
- def self.search(parameters)
- response = get("/search", parameters)
- begin
- return response["results"]
- rescue
- raise "Search query could not be complete"
- end
- end
-
- def self.get(path, parameters)
- uri = "http://" + @host + path + format_query_string(parameters)
- response = RestClient.get uri
- JSON.parse(response)
- end
-
- def self.post(path, parameters)
- uri = "http://" + @host + path
- response = RestClient.post uri, parameters
- JSON.parse(response)
- end
-
- def self.format_query_string(parameters)
- index = 0
- query_string = ""
- parameters.each_pair do |key, value|
- if index == 0
- query_string << "?#{key}=#{value}"
- else
- query_string << "&#{key}=#{value}"
- end
- index += 1
- end
- return query_string
- end
+ #def self.update_index(parameters)
+ #response = post("/update_index", parameters)
+ #raise "Index could not be updated" unless response["status"] =~ /success/
+ #end
+
+ #def self.search(parameters)
+ #response = get("/search", parameters)
+ #begin
+ #return response["results"]
+ #rescue
+ #raise "Search query could not be complete"
+ #end
+ #end
+
+ #def self.get(path, parameters)
+ #uri = "http://" + @host + path + format_query_string(parameters)
+ #response = RestClient.get uri
+ #JSON.parse(response)
+ #end
+
+ #def self.post(path, parameters)
+ #uri = "http://" + @host + path
+ #response = RestClient.post uri, parameters
+ #JSON.parse(response)
+ #end
+
+ #def self.format_query_string(parameters)
+ #index = 0
+ #query_string = ""
+ #parameters.each_pair do |key, value|
+ #if index == 0
+ #query_string << "?#{key}=#{value}"
+ #else
+ #query_string << "&#{key}=#{value}"
+ #end
+ #index += 1
+ #end
+ #return query_string
+ #end
end

0 comments on commit ce2f156

Please sign in to comment.