Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: fetep/kv
base: 18a8962d47
...
head fork: fetep/kv
compare: 1ce6ab3d5d
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
5 lib/kv.rb
@@ -2,6 +2,7 @@
require "fileutils"
require "json"
require "kv/backend/file"
+require "kv/backend/http"
require "kv/exception"
require "kv/node"
require "kv/util"
@@ -36,6 +37,10 @@ def self.new(opts)
raise KV::Error.new("missing :path argument to constructor")
end
+ if opts[:path][0..6] == "http://"
+ return KV::Backend::HTTP.new(opts)
+ end
+
return KV::Backend::File.new(opts)
end # def initialize
end # class KV
View
2  lib/kv/backend/base.rb
@@ -3,7 +3,7 @@
class KV
class Backend
class Base
- NOT_IMPL = "command not supported by backend #{self.type}"
+ NOT_IMPL = "command not supported by backend #{self.class}"
public
def node_path(node_name)
View
6 lib/kvd/indexer.rb
@@ -7,12 +7,10 @@ class Indexer
attr_reader :index
attr_reader :kv
- KVDB_NODE = "__kvdb_node"
-
public
def initialize(kv)
@kv = kv
- @index = Ferret::Index::Index.new(:key => KVDB_NODE)
+ @index = Ferret::Index::Index.new
initial_index
end
@@ -22,7 +20,7 @@ def initial_index
kv.nodes.each do |node_name|
node = kv.node(node_name)
doc = node.attrs.to_hash
- doc[KVDB_NODE] = node_name
+ doc[:id] = node_name
@index << doc
end
end # def initialize
View
9 lib/kvd/web.rb
@@ -31,11 +31,16 @@ def initialize(*a)
content_type "application/json"
res = []
- @@ferret_index.search_each(params[:q]) do |id, score|
- res << @@ferret_index[id]["__kvdb_node"]
+ @@ferret_index.search_each(params[:q], :limit => :all) do |id, score|
+ res << @@ferret_index[id][:id]
end
return res.to_json
end
+
+ get '/get' do
+ $stderr.puts params[:q].inspect
+ return @@ferret_index[params[:q]].load.to_json
+ end
end # class Web
end # class KVD

No commit comments for this range

Something went wrong with that request. Please try again.