Permalink
Browse files

human readable open_index command

  • Loading branch information...
1 parent 73b4586 commit 1b56113b74cc751610ac63e81bd04cb738ee736b @igrigorik committed Jan 10, 2011
Showing with 37 additions and 14 deletions.
  1. +8 −3 lib/em-handlersocket/client.rb
  2. +29 −11 spec/client_spec.rb
@@ -18,12 +18,17 @@ def execute(*cmd, &blk)
add_deferrable(&blk)
end
+ def open_index(opts)
+ execute(['P', opts[:id], opts[:database], opts[:table], opts[:index_name], opts[:columns]])
+ end
+
+ # def query(*q)
+ # end
private
def send(data)
- p [:sending, data.join("\t")]
- send_data data.join("\t")+"\n"
+ send_data data.join("\t") + "\n"
end
def receive_line(line)
@@ -40,4 +45,4 @@ def add_deferrable(&blk)
end
end
-end
+end
View
@@ -20,22 +20,40 @@
}
end
- it "should open an index" do
+ it "should open an index via raw interface" do
EM.run {
c = EM::HandlerSocket.new
df = c.execute(['P', '0', 'widgets', 'user', 'PRIMARY', 'user_name,user_email,created'])
-
- df.callback {|data|
- p data
-
- df = c.execute(['0', '=', '1', '1'])
- df.callback { |data|
- p data
- EM.stop
- }
+ df.callback {|r|
+ r.should == ["0", "1"]
+ EM.stop
}
}
end
-end
+ it "should open an index" do
+ EM.run {
+ c = EM::HandlerSocket.new
+ d = c.open_index({
+ :id => 0,
+ :db => 'widgets',
+ :table => 'user',
+ :index_name => 'PRIMARY',
+ :columns => 'user_name,user_email,created'
+ })
+
+ d.callback do
+ EM.stop
+ end
+ }
+
+ # df = c.execute(['0', '=', '1', '1'])
+ # df.callback { |data|
+ # p data
+ # EM.stop
+ # }
+
+
+ end
+end

0 comments on commit 1b56113

Please sign in to comment.