[Groonga-commit] droonga/fluent-plugin-droonga at fdd24f1 [master] catalog: Check the version

Back to archive index

Yoji Shidara null+****@clear*****
Wed Feb 19 12:51:45 JST 2014


Yoji Shidara	2014-02-19 12:51:45 +0900 (Wed, 19 Feb 2014)

  New Revision: fdd24f1733ea195360c272d79766911e8e41e806
  https://github.com/droonga/fluent-plugin-droonga/commit/fdd24f1733ea195360c272d79766911e8e41e806

  Message:
    catalog: Check the version

  Modified files:
    lib/droonga/catalog_loader.rb
    test/command/config/default/catalog.json
    test/performance/watch/catalog.json

  Modified: lib/droonga/catalog_loader.rb (+14 -1)
===================================================================
--- lib/droonga/catalog_loader.rb    2014-02-19 12:14:52 +0900 (bfbb4f6)
+++ lib/droonga/catalog_loader.rb    2014-02-19 12:51:45 +0900 (fab0894)
@@ -34,7 +34,20 @@ module Droonga
       rescue JSON::ParserError => error
         raise Error.new("Syntax error in #{@path}:\n#{error.to_s}")
       end
-      Catalog::Version1.new(data, @path)
+
+      unless data.is_a?(Hash)
+        raise Error.new("Root element of catalog must be an object in #{@path}")
+      end
+
+      version = data["version"]
+      case version
+      when 1
+        Catalog::Version1.new(data, @path)
+      when nil
+        raise Error.new("Catalog version must be specified in #{@path}")
+      else
+        raise Error.new("Unsupported catalog version <#{version}> is specified in #{@path}")
+      end
     end
   end
 end

  Modified: test/command/config/default/catalog.json (+1 -0)
===================================================================
--- test/command/config/default/catalog.json    2014-02-19 12:14:52 +0900 (f5995c2)
+++ test/command/config/default/catalog.json    2014-02-19 12:51:45 +0900 (441018a)
@@ -1,4 +1,5 @@
 {
+  "version": 1,
   "effective_date": "2013-09-01T00:00:00Z",
   "zones": ["localhost:23003/droonga"],
   "farms": {

  Modified: test/performance/watch/catalog.json (+1 -0)
===================================================================
--- test/performance/watch/catalog.json    2014-02-19 12:14:52 +0900 (693246b)
+++ test/performance/watch/catalog.json    2014-02-19 12:51:45 +0900 (4f10d21)
@@ -1,4 +1,5 @@
 {
+  "versoin": 1,
   "effective_date": "2013-09-01T00:00:00Z",
   "zones": ["localhost:23003/droonga"],
   "farms": {
-------------- next part --------------
HTML����������������������������...
Download 



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