[Groonga-commit] droonga/droonga-engine at 6764dd6 [master] Extract DROONGA_BASE_DIR reader

Back to archive index

Kouhei Sutou null+****@clear*****
Tue May 20 15:40:29 JST 2014


Kouhei Sutou	2014-05-20 15:40:29 +0900 (Tue, 20 May 2014)

  New Revision: 6764dd63ff2a431c1bb8f3bf11ffe7c7a189f832
  https://github.com/droonga/droonga-engine/commit/6764dd63ff2a431c1bb8f3bf11ffe7c7a189f832

  Message:
    Extract DROONGA_BASE_DIR reader

  Added files:
    lib/droonga/base_path.rb
  Modified files:
    lib/droonga/catalog_observer.rb
    lib/droonga/command/droonga_engine.rb
    lib/droonga/live_nodes_list_observer.rb

  Added: lib/droonga/base_path.rb (+26 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/base_path.rb    2014-05-20 15:40:29 +0900 (53efee9)
@@ -0,0 +1,26 @@
+# Copyright (C) 2014 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 "pathname"
+
+module Droonga
+  BASE_DIR_ENV_NAME = "DROONGA_BASE_DIR"
+
+  class << self
+    def base_path
+      @base_dir ||= Pathname.new(ENV[BASE_DIR_ENV_NAME] || Dir.pwd)
+    end
+  end
+end

  Modified: lib/droonga/catalog_observer.rb (+2 -5)
===================================================================
--- lib/droonga/catalog_observer.rb    2014-05-20 14:17:06 +0900 (83b36b7)
+++ lib/droonga/catalog_observer.rb    2014-05-20 15:40:29 +0900 (66d2b3d)
@@ -15,6 +15,7 @@
 # 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/base_path"
 require "droonga/loggable"
 require "droonga/catalog_loader"
 
@@ -58,13 +59,9 @@ module Droonga
       end
     end
 
-    def base_path
-      ENV["DROONGA_BASE_DIR"]
-    end
-
     def catalog_path
       path = ENV["DROONGA_CATALOG"] || DEFAULT_CATALOG_PATH
-      File.expand_path(path, base_path)
+      File.expand_path(path, Droonga.base_path)
     end
 
     def catalog_updated?

  Modified: lib/droonga/command/droonga_engine.rb (+2 -1)
===================================================================
--- lib/droonga/command/droonga_engine.rb    2014-05-20 14:17:06 +0900 (5ead608)
+++ lib/droonga/command/droonga_engine.rb    2014-05-20 15:40:29 +0900 (dac0fc9)
@@ -19,6 +19,7 @@ require "ipaddr"
 require "fileutils"
 require "pathname"
 
+require "droonga/base_path"
 require "droonga/engine"
 require "droonga/event_loop"
 require "droonga/fluent_message_receiver"
@@ -151,7 +152,7 @@ module Droonga
           @heartbeat_socket.bind(@configuration.host,
                                  @configuration.port)
 
-          ENV["DROONGA_BASE_DIR"] ||= Dir.pwd
+          ENV[Droonga::BASE_DIR_ENV_NAME] ||= Dir.pwd
 
           if****@confi*****?
             Process.daemon

  Modified: lib/droonga/live_nodes_list_observer.rb (+3 -5)
===================================================================
--- lib/droonga/live_nodes_list_observer.rb    2014-05-20 14:17:06 +0900 (0338298)
+++ lib/droonga/live_nodes_list_observer.rb    2014-05-20 15:40:29 +0900 (d0ee8eb)
@@ -15,6 +15,8 @@
 
 require "fileutils"
 require "listen"
+
+require "droonga/base_name"
 require "droonga/loggable"
 require "droonga/live_nodes_list_loader"
 
@@ -46,10 +48,6 @@ module Droonga
     OBSERVE_DIR_NAME = "live-nodes"
     DEFAULT_LIST_PATH = "#{OBSERVE_DIR_NAME}/#{LIST_FILE_NAME}"
 
-    def base_path
-      ENV["DROONGA_BASE_DIR"]
-    end
-
     def file_path
       @file_path ||= prepare_file_path
     end
@@ -69,7 +67,7 @@ module Droonga
     private
     def prepare_file_path
       path = ENV["DROONGA_LIVE_NODES_LIST"] || DEFAULT_LIST_PATH
-      File.expand_path(path, base_path)
+      File.expand_path(path, Droonga.base_path)
     end
 
     def log_tag
-------------- next part --------------
HTML����������������������������...
下载 



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