[ https://issues.apache.org/jira/browse/COUCHDB-732?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14204076#comment-14204076 ]
Matt Lyon commented on COUCHDB-732: ----------------------------------- Cool deal, I don’t use Ruby or CouchDB anymore, and I sent this in four and a half years ago, so no worries. -- Matthew Lyon aka @mattly :: lyonheart.us On November 9, 2014 at 11:23:37 AM, Robert Kowalski (JIRA) (j...@apache.org) wrote: [ https://issues.apache.org/jira/browse/COUCHDB-732?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Robert Kowalski resolved COUCHDB-732. ------------------------------------- Resolution: Won't Fix Hi and sorry for the long delay. We don't include a queryserver in ruby, so for testing this we would have to include a ruby queryserver which is not planned currently. I would suggest to include the spec with your queryserver. -- This message was sent by Atlassian JIRA (v6.3.4#6332) > ruby versions of the query server spec functions > ------------------------------------------------ > > Key: COUCHDB-732 > URL: https://issues.apache.org/jira/browse/COUCHDB-732 > Project: CouchDB > Issue Type: Improvement > Components: Test Suite > Reporter: Matt Lyon > Assignee: Robert Kowalski > Priority: Trivial > > In the process of creating the a ruby version of the query server, I wrote > these to determine it was working correctly. Even though the repository for > the ruby query server contains its own test suite, I figure these might be > welcomed into the main query server specs. If not, no big deal. They assume > the ruby query server's repository is in the same parent directory as couchdb. > diff --git a/test/view_server/query_server_spec.rb > b/test/view_server/query_server_spec.rb > index 1de8e5b..c427e35 100644 > --- a/test/view_server/query_server_spec.rb > +++ b/test/view_server/query_server_spec.rb > @@ -117,7 +117,8 @@ class QueryServerRunner < OSProcessRunner > > COMMANDS = { > "js" => "#{COUCH_ROOT}/bin/couchjs_dev > #{COUCH_ROOT}/share/server/main.js", > - "erlang" => "#{COUCH_ROOT}/test/view_server/run_native_process.es" > + "erlang" => "#{COUCH_ROOT}/test/view_server/run_native_process.es", > + "ruby" => "/usr/bin/env ruby -- > #{COUCH_ROOT}/../couchdb-ruby-query-server/bin/couchdb_view_server --safe" > } > > def self.run_command > @@ -137,13 +138,14 @@ end > functions = { > "emit-twice" => { > "js" => %{function(doc){emit("foo",doc.a); emit("bar",doc.a)}}, > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun({Doc}) -> > A = proplists:get_value(<<"a">>, Doc, null), > Emit(<<"foo">>, A), > Emit(<<"bar">>, A) > end. > ERLANG > + "ruby" => "lambda{|doc| emit('foo',doc['a']); emit('bar',doc['a']) }" > }, > "emit-once" => { > "js" => <<-JS, > @@ -151,20 +153,39 @@ functions = { > emit("baz",doc.a) > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun({Doc}) -> > A = proplists:get_value(<<"a">>, Doc, null), > Emit(<<"baz">>, A) > end. > ERLANG > + "ruby" => <<-RUBY > + lambda {|doc| emit("baz", doc['a']) } > + RUBY > + }, > + "map-invalid-expression" => { > + "js" => %{function(doc {emit("foo", doc.a);}}, > + "erlang" => %|fun({Doc}|, > + "ruby" => "lambda{" > + }, > + "map-non-function-expression" => { > + "js" => "3", > + "erlang" => "3", > + "ruby" => "3" > + }, > + "map-logging" => { > + "js" => %{function(doc){ log(doc); emit("logged", doc.a);}}, > + "ruby" => %{lambda{|doc| log(doc); emit("logged", doc['a']) }} > }, > "reduce-values-length" => { > "js" => %{function(keys, values, rereduce) { return values.length; }}, > - "erlang" => %{fun(Keys, Values, ReReduce) -> length(Values) end.} > + "erlang" => %{fun(Keys, Values, ReReduce) -> length(Values) end.}, > + "ruby" => %{lambda{|keys, values, rereduce| values.size }} > }, > "reduce-values-sum" => { > "js" => %{function(keys, values, rereduce) { return sum(values); }}, > - "erlang" => %{fun(Keys, Values, ReReduce) -> lists:sum(Values) end.} > + "erlang" => %{fun(Keys, Values, ReReduce) -> lists:sum(Values) end.}, > + "ruby" => %{lambda{|keys, values, rereduce| values.inject(0){|sum, val| > sum += val} }} > }, > "validate-forbidden" => { > "js" => <<-JS, > @@ -173,7 +194,7 @@ functions = { > throw({forbidden:"bad doc"}); "foo bar"; > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun({NewDoc}, _OldDoc, _UserCtx) -> > case proplists:get_value(<<"bad">>, NewDoc) of > undefined -> 1; > @@ -181,6 +202,13 @@ functions = { > end > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|new_doc, old_doc, user_ctx| > + if (new_doc['bad']) > + throw(:forbidden, "bad doc") > + end > + } > + RUBY > }, > "show-simple" => { > "js" => <<-JS, > @@ -189,7 +217,7 @@ functions = { > return [doc.title, doc.body].join(' - '); > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun({Doc}, Req) -> > Title = proplists:get_value(<<"title">>, Doc), > Body = proplists:get_value(<<"body">>, Doc), > @@ -197,6 +225,9 @@ functions = { > {[{<<"body">>, Resp}]} > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|doc, req| [doc['title'], doc['body']].join(' - ') } > + RUBY > }, > "show-headers" => { > "js" => <<-JS, > @@ -206,7 +237,7 @@ functions = { > return resp; > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun({Doc}, Req) -> > Title = proplists:get_value(<<"title">>, Doc), > Body = proplists:get_value(<<"body">>, Doc), > @@ -218,6 +249,12 @@ functions = { > ]} > end. > ERLANG > + "ruby" => <<-RUBY > + lambda {|doc, req| > + resp = {"code" => 200, "headers" => {"X-Plankton" => "Rusty"}} > + resp.update("body" => [doc["title"], doc["body"]].join(" - ")) > + } > + RUBY > }, > "show-sends" => { > "js" => <<-JS, > @@ -228,7 +265,7 @@ functions = { > return "tail"; > }; > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun(Head, Req) -> > Resp = {[ > {<<"headers">>, {[{<<"Content-Type">>, <<"text/plain">>}]}} > @@ -239,6 +276,14 @@ functions = { > <<"tail">> > end. > ERLANG > + "ruby" => <<-RUBY > + lambda {|head, req| > + start({"headers" => {"Content-Type" => "text/plain"}}) > + send "first chunk" > + send 'second "chunk"' > + "tail" > + } > + RUBY > }, > "show-while-get-rows" => { > "js" => <<-JS, > @@ -265,6 +310,16 @@ functions = { > <<"tail">> > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|head, req| > + send "first chunk" > + send req['q'] > + while row = get_row do > + send row['key'] > + end > + "tail" > + } > + RUBY > }, > "show-while-get-rows-multi-send" => { > "js" => <<-JS, > @@ -291,6 +346,16 @@ functions = { > <<"tail">> > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|head, req| > + send "bacon" > + while row = get_row do > + send row["key"] > + send "eggs" > + end > + "tail" > + } > + RUBY > }, > "list-simple" => { > "js" => <<-JS, > @@ -316,6 +381,16 @@ functions = { > <<"early">> > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|head, req| > + send("first chunk") > + send(req['q']) > + while row = get_row do > + send(row['key']) > + end > + return "early" > + } > + RUBY > }, > "list-chunky" => { > "js" => <<-JS, > @@ -348,6 +423,14 @@ functions = { > Tail > end. > ERLANG > + "ruby" => <<-RUBY > + lambda {|head, req| > + send("first chunk") > + send(req['q']) > + 3.times { send get_row['key'] } > + "early tail" > + } > + RUBY > }, > "list-old-style" => { > "js" => <<-JS, > @@ -390,6 +473,13 @@ functions = { > Tail > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|head, req| > + send "bacon" > + 3.times { send get_row['key'] } > + "early" > + } > + RUBY > }, > "list-raw" => { > "js" => <<-JS, > @@ -417,6 +507,16 @@ functions = { > <<"tail">> > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|head, req| > + send "first chunk" > + send req["q"] > + while row = get_row do > + send row["key"] > + end > + return "tail" > + } > + RUBY > }, > "filter-basic" => { > "js" => <<-JS, > @@ -431,6 +531,9 @@ functions = { > proplists:get_value(<<"good">>, Doc) > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|doc, req| doc["good"] } > + RUBY > }, > "update-basic" => { > "js" => <<-JS, > @@ -446,6 +549,12 @@ functions = { > [{Doc2}, {[{<<"body">>, <<"hello doc">>}]}] > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|doc, req| > + doc["world"] = "hello" > + [doc, "hello doc"] > + } > + RUBY > }, > "error" => { > "js" => <<-JS, > @@ -453,11 +562,14 @@ functions = { > throw(["error","error_key","testing"]); > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun(A, B) -> > throw([<<"error">>,<<"error_key">>,<<"testing">>]) > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|doc, req| throw :error, "error_key", "testing" } > + RUBY > }, > "fatal" => { > "js" => <<-JS, > @@ -465,11 +577,14 @@ functions = { > throw(["fatal","error_key","testing"]); > } > JS > - "erlang" => <<-ERLANG > + "erlang" => <<-ERLANG, > fun(A, B) -> > throw([<<"fatal">>,<<"error_key">>,<<"testing">>]) > end. > ERLANG > + "ruby" => <<-RUBY > + lambda{|h,r| throw :fatal, ["error_key", "testing"] } > + RUBY > } > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)