Kouhei Sutou
null+****@clear*****
Thu Apr 10 16:51:50 JST 2014
Kouhei Sutou 2014-04-10 16:51:50 +0900 (Thu, 10 Apr 2014) New Revision: 1d7d7221716284e9a8bff339f5cb79a3c9e9159a https://github.com/droonga/fluent-plugin-droonga/commit/1d7d7221716284e9a8bff339f5cb79a3c9e9159a Message: Use droonga-message-pack-packer gem Removed files: lib/droonga/message_pack_packer.rb lib/droonga/time_formatter.rb test/unit/test_message_pack_packer.rb test/unit/test_time_formatter.rb Modified files: fluent-plugin-droonga.gemspec lib/droonga/fluent_message_sender.rb lib/droonga/searcher.rb Modified: fluent-plugin-droonga.gemspec (+1 -0) =================================================================== --- fluent-plugin-droonga.gemspec 2014-04-09 10:06:59 +0900 (4dde975) +++ fluent-plugin-droonga.gemspec 2014-04-10 16:51:50 +0900 (d0ee31b) @@ -36,6 +36,7 @@ Gem::Specification.new do |gem| gem.add_dependency "rroonga", ">= 3.1.0" gem.add_dependency "groonga-command-parser" gem.add_dependency "serverengine" + gem.add_dependency "droonga-message-pack-packer" gem.add_development_dependency "rake" gem.add_development_dependency "bundler" gem.add_development_dependency "droonga-client" Modified: lib/droonga/fluent_message_sender.rb (+2 -1) =================================================================== --- lib/droonga/fluent_message_sender.rb 2014-04-09 10:06:59 +0900 (6b26618) +++ lib/droonga/fluent_message_sender.rb 2014-04-10 16:51:50 +0900 (7f94ecb) @@ -19,8 +19,9 @@ require "thread" require "cool.io" +require "droonga/message-pack-packer" + require "droonga/loggable" -require "droonga/message_pack_packer" module Droonga class FluentMessageSender Deleted: lib/droonga/message_pack_packer.rb (+0 -62) 100644 =================================================================== --- lib/droonga/message_pack_packer.rb 2014-04-09 10:06:59 +0900 (3c15f0d) +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 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 - -require "msgpack" - -require "droonga/time_formatter" - -module Droonga - class MessagePackPacker - class << self - def pack(object) - packer = new - packer.pack(object) - packer.to_s - end - end - - MICRO_SECONDS_DECIMAL_PLACE = 6 - - def initialize - @packer = MessagePack::Packer.new - end - - def pack(object) - case object - when Array - @packer.write_array_header(object.size) - object.each do |element| - pack(element) - end - when Hash - @packer.write_map_header(object.size) - object.each do |key, value| - pack(key) - pack(value) - end - when Time - @packer.write(TimeFormatter.format(object)) - else - @packer.write(object) - end - end - - def to_s - @packer.to_s - end - end -end Modified: lib/droonga/searcher.rb (+1 -2) =================================================================== --- lib/droonga/searcher.rb 2014-04-09 10:06:59 +0900 (28c918d) +++ lib/droonga/searcher.rb 2014-04-10 16:51:50 +0900 (4cd8b6d) @@ -18,7 +18,6 @@ require "tsort" require "groonga" require "droonga/loggable" -require "droonga/time_formatter" require "droonga/error_messages" module Droonga @@ -697,7 +696,7 @@ module Droonga end def format_start_time - TimeFormatter.format(@result.start_time) + @result.start_time end def format_elapsed_time Deleted: lib/droonga/time_formatter.rb (+0 -37) 100644 =================================================================== --- lib/droonga/time_formatter.rb 2014-04-09 10:06:59 +0900 (0d6325d) +++ /dev/null @@ -1,37 +0,0 @@ -# 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 - -require "time" - -module Droonga - class TimeFormatter - class << self - def format(object) - formatter = new(object) - formatter.format - end - end - - MICRO_SECONDS_DECIMAL_PLACE = 6 - - def initialize(time) - @time = time - end - - def format - @time.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE) - end - end -end Deleted: test/unit/test_message_pack_packer.rb (+0 -51) 100644 =================================================================== --- test/unit/test_message_pack_packer.rb 2014-04-09 10:06:59 +0900 (aba2210) +++ /dev/null @@ -1,51 +0,0 @@ -# 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 - -require "droonga/message_pack_packer" - -class MessagePackPackerTest < Test::Unit::TestCase - def test_integer - assert_equal(29, unpack(pack(29))) - end - - def test_string - assert_equal("Droonga", unpack(pack("Droonga"))) - end - - def test_time - w3c_dtf_time = "2013-11-29T08:00:00.000000Z" - time = Time.parse(w3c_dtf_time) - assert_equal(w3c_dtf_time, unpack(pack(time))) - end - - def test_hash - hash = {"key" => "value"} - assert_equal(hash, unpack(pack(hash))) - end - - def test_array - array = ["Groonga", "Rroonga", "Droonga"] - assert_equal(array, unpack(pack(array))) - end - - private - def pack(object) - Droonga::MessagePackPacker.pack(object) - end - - def unpack(msgpack) - MessagePack.unpack(msgpack) - end -end Deleted: test/unit/test_time_formatter.rb (+0 -29) 100644 =================================================================== --- test/unit/test_time_formatter.rb 2014-04-09 10:06:59 +0900 (f2cef00) +++ /dev/null @@ -1,29 +0,0 @@ -# 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 - -require "droonga/time_formatter" - -class TimeFormatterTest < Test::Unit::TestCase - def test_fraction - w3c_dtf_time = "2013-11-29T08:00:00.292929Z" - time = Time.parse(w3c_dtf_time) - assert_equal(w3c_dtf_time, format(time)) - end - - private - def format(time) - Droonga::TimeFormatter.format(time) - end -end -------------- next part -------------- HTML����������������������������...Download