YUKI Hiroshi
null+****@clear*****
Mon Sep 30 12:09:16 JST 2013
YUKI Hiroshi 2013-09-30 12:09:16 +0900 (Mon, 30 Sep 2013) New Revision: fd01444e4f8317a5d3732ee09950746eec40e2a3 https://github.com/droonga/fluent-plugin-droonga/commit/fd01444e4f8317a5d3732ee09950746eec40e2a3 Message: Resolve path to the catalog file by Catalog's instances themselves Modified files: lib/droonga/catalog.rb Modified: lib/droonga/catalog.rb (+9 -9) =================================================================== --- lib/droonga/catalog.rb 2013-09-30 11:14:21 +0900 (4c483bd) +++ lib/droonga/catalog.rb 2013-09-30 12:09:16 +0900 (6842158) @@ -21,21 +21,15 @@ require "zlib" module Droonga class << self def catalog - @catalog ||= Catalog.new(catalog_path) - end - - def catalog_path - return @catalog_path unless @catalog_path.nil? - catalog_path = ENV["DROONGA_CATALOG"] || Catalog::CATALOG_FILE_PATH - @catalog_path = File.expand_path(catalog_path) + @catalog ||= Catalog.new end end class Catalog CATALOG_FILE_PATH = "catalog.json" - def initialize(path) - @catalog_path = path + def initialize(path=nil) + @catalog_path = path || default_path open(@catalog_path) do |file| @catalog = JSON.parse(file.read) @@ -147,5 +141,11 @@ module Droonga end end end + + private + def default_path + path = ENV["DROONGA_CATALOG"] || Catalog::CATALOG_FILE_PATH + File.expand_path(path) + end end end -------------- next part -------------- HTML����������������������������...Download