Skip to content

Commit

Permalink
Add load
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Nov 25, 2012
1 parent aa41a9a commit b194074
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/groonga/command/load.rb
@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "groonga/command/base"

module Groonga
module Command
class Load < Base
Command.register("load", self)

class << self
def parameter_names
[
:values,
:table,
:columns,
:ifexists,
:input_type,
:each,
]
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/groonga/command/parser.rb
Expand Up @@ -21,6 +21,7 @@

require "groonga/command/base"
require "groonga/command/select"
require "groonga/command/load"
require "groonga/command/table-create"
require "groonga/command/table-remove"
require "groonga/command/table-rename"
Expand Down
49 changes: 49 additions & 0 deletions test/command/test-load.rb
@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

class LoadCommandTest < Test::Unit::TestCase
class CommandLineTest < self
include GroongaCommandTestUtils::CommandLineCommandParser

def test_ordered_arguments
values = "[[\"Alice\"], [\"Bob\"]]"
table = "Users"
columns = "_key"
ifexists = "_key == \"Alice\""
input_type = "json"
each = "strlen(_key)"

command = parse(values, table, columns, ifexists, input_type, each)
assert_instance_of(Groonga::Command::Load, command)
assert_equal({
:values => values,
:table => table,
:columns => columns,
:ifexists => ifexists,
:input_type => input_type,
:each => each,
},
command.arguments)
end

private
def parse(*arguments)
super("load", arguments, :output_type => false)
end
end
end

0 comments on commit b194074

Please sign in to comment.