YUKI Hiroshi
null+****@clear*****
Fri Sep 27 18:56:31 JST 2013
YUKI Hiroshi 2013-09-27 18:56:31 +0900 (Fri, 27 Sep 2013) New Revision: b3179cf0ce70d57939c1b55abce82a83fddbf608 https://github.com/droonga/fluent-plugin-droonga/commit/b3179cf0ce70d57939c1b55abce82a83fddbf608 Message: Specify the path to the catalog file when I instanciate Catalog Modified files: lib/droonga/catalog.rb Modified: lib/droonga/catalog.rb (+12 -10) =================================================================== --- lib/droonga/catalog.rb 2013-09-27 18:07:47 +0900 (bd829cc) +++ lib/droonga/catalog.rb 2013-09-27 18:56:31 +0900 (d6a0359) @@ -21,15 +21,23 @@ require 'zlib' module Droonga class << self def catalog - @catalog ||= Catalog.new + @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) end end class Catalog CATALOG_FILE_PATH = 'catalog.json' - def initialize - open(catalog_path) do |file| + def initialize(path) + @catalog_path = path + + open(@catalog_path) do |file| @catalog = JSON.parse(file.read) end @catalog["datasets"].each do |name, dataset| @@ -51,14 +59,8 @@ module Droonga @options = @catalog["options"] || {} end - def catalog_path - return @catalog_path unless @catalog_path.nil? - catalog_path = ENV["DROONGA_CATALOG"] || CATALOG_FILE_PATH - @catalog_path = File.expand_path(catalog_path) - end - def base_path - @base_path ||= File.dirname(catalog_path) + @base_path ||= File.dirname(@catalog_path) end def option(name) -------------- next part -------------- HTML����������������������������...Download