[Groonga-commit] groonga/groonga-command at 1f2f800 [fix-travis-ci-error] Add output_type getter

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jan 13 17:19:54 JST 2016


Kouhei Sutou	2013-05-23 17:38:10 +0900 (Thu, 23 May 2013)

  New Revision: 1f2f8001b9e5c5201a964b17b350330bab7a3a3b
  https://github.com/groonga/groonga-command/commit/1f2f8001b9e5c5201a964b17b350330bab7a3a3b

  Message:
    Add output_type getter

  Modified files:
    lib/groonga/command/base.rb
    test/command/test-base.rb

  Modified: lib/groonga/command/base.rb (+5 -1)
===================================================================
--- lib/groonga/command/base.rb    2013-04-11 17:35:53 +0900 (4cc62b8)
+++ lib/groonga/command/base.rb    2013-05-23 17:38:10 +0900 (6fc4e68)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2012  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2013  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
@@ -74,6 +74,10 @@ module Groonga
         @original_format == :command
       end
 
+      def output_type
+        (self[:output_type] || :json).to_sym
+      end
+
       def to_uri_format
         path = "/d/#{@name}"
         arguments =****@argum*****

  Modified: test/command/test-base.rb (+14 -1)
===================================================================
--- test/command/test-base.rb    2013-04-11 17:35:53 +0900 (52a7213)
+++ test/command/test-base.rb    2013-05-23 17:38:10 +0900 (9d316c7)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2011-2012  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2011-2013  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
@@ -111,4 +111,17 @@ class BaseCommandTest < Test::Unit::TestCase
       assert_true(@select.has_key?("table"))
     end
   end
+
+  sub_test_case("#output_type") do
+    def test_default
+      command = Groonga::Command::Base.new("table_list", {})
+      assert_equal(:json, command.output_type)
+    end
+
+    def test_specified
+      command = Groonga::Command::Base.new("table_list",
+                                           :output_type => "xml")
+      assert_equal(:xml, command.output_type)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index