Navigation Menu

Skip to content

Commit

Permalink
Remove a redundant method call.
Browse files Browse the repository at this point in the history
  • Loading branch information
daijiro committed Jun 23, 2013
2 parents 4720171 + 81c9c2c commit 2c19c56
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Gemfile
@@ -1,3 +1,23 @@
source 'https://rubygems.org'
# Copyright (C) 2013 droonga project
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

source "https://rubygems.org"

gemspec

local_rroonga_path = File.join(File.dirname(__FILE__), "..", "rroonga")
if File.exist?(local_rroonga_path)
gem "rroonga", :path => local_rroonga_path
end
5 changes: 5 additions & 0 deletions lib/droonga/plugin/handler_search.rb
Expand Up @@ -91,6 +91,7 @@ def initialize(context, query)
@context = context
@query = query
@result = nil
@condition = nil
@start_time = nil
end

Expand Down Expand Up @@ -201,6 +202,7 @@ def search_query(results)
expression.define_variable(:domain => source)
parseCondition(source, expression, @query["condition"])
@result = source.select(expression)
@condition = expression
end
if @query["groupBy"]
if @query["groupBy"].is_a? String
Expand Down Expand Up @@ -311,6 +313,9 @@ def normalize_target_attributes(attributes)
expression = Groonga::Expression.new(context: @context)
variable = expression.define_variable(domain: @result)
expression.parse(source, syntax: :script)
condition = expression.define_variable(name: "$condition",
reference: true)
condition.value = @condition
source = nil
end
{
Expand Down
41 changes: 41 additions & 0 deletions test/plugin/test_handler_search.rb
Expand Up @@ -387,6 +387,47 @@ def test_expression
}
assert_search(expected, request)
end

def test_snippet_html
expected = {
"sections-result" => {
"records" => [
{
"title" => "Groonga overview",
"snippet" => [
"<span class=\"keyword\">Groonga</span> overview",
],
},
],
},
}
request = {
"queries" => {
"sections-result" => {
"source" => "Sections",
"condition" => {
"query" => "Groonga",
"matchTo" => ["title"],
},
"output" => {
"elements" => [
"records",
],
"format" => "complex",
"limit" => 1,
"attributes" => [
"title",
{
"label" => "snippet",
"source" => "snippet_html(title)",
},
],
},
},
},
}
assert_search(expected, request)
end
end

class FormatTest < self
Expand Down

0 comments on commit 2c19c56

Please sign in to comment.