Module: Droonga::Path
- Defined in:
- lib/droonga/path.rb
Constant Summary collapse
- BASE_DIR_ENV_NAME =
"DROONGA_BASE_DIR"
Class Method Summary collapse
- .accidental_buffer ⇒ Object
- .base ⇒ Object
- .base=(new_base) ⇒ Object
- .catalog ⇒ Object
- .cluster_state ⇒ Object
- .config ⇒ Object
- .databases(base_path = nil) ⇒ Object
- .default_log_file ⇒ Object
- .intentional_buffer ⇒ Object
- .last_message_timestamp ⇒ Object
- .serf_command ⇒ Object
- .serf_event_handler_error_file ⇒ Object
- .serf_event_handler_errors ⇒ Object
- .serf_tags_file ⇒ Object
- .setup ⇒ Object
- .state ⇒ Object
- .unique_file_path(directory, basename, suffix) ⇒ Object
Class Method Details
.accidental_buffer ⇒ Object
68 69 70 |
# File 'lib/droonga/path.rb', line 68 def accidental_buffer state + "buffer" + "accidental" end |
.base ⇒ Object
28 29 30 |
# File 'lib/droonga/path.rb', line 28 def base @base ||= Pathname.new(ENV[BASE_DIR_ENV_NAME] || Dir.pwd). end |
.base=(new_base) ⇒ Object
32 33 34 35 |
# File 'lib/droonga/path.rb', line 32 def base=(new_base) @base = nil ENV[BASE_DIR_ENV_NAME] = new_base end |
.catalog ⇒ Object
59 60 61 62 |
# File 'lib/droonga/path.rb', line 59 def catalog base_file_name = ENV["DROONGA_CATALOG"] || "catalog.json" Pathname.new(base_file_name).(base) end |
.cluster_state ⇒ Object
47 48 49 |
# File 'lib/droonga/path.rb', line 47 def cluster_state state + "cluster-state.json" end |
.config ⇒ Object
51 52 53 |
# File 'lib/droonga/path.rb', line 51 def config base + "droonga-engine.yaml" end |
.databases(base_path = nil) ⇒ Object
37 38 39 40 41 |
# File 'lib/droonga/path.rb', line 37 def databases(base_path=nil) base_path ||= base path = Pathname(base_path) + "databases" path. end |
.default_log_file ⇒ Object
55 56 57 |
# File 'lib/droonga/path.rb', line 55 def default_log_file base + "droonga-engine.log" end |
.intentional_buffer ⇒ Object
72 73 74 |
# File 'lib/droonga/path.rb', line 72 def intentional_buffer state + "buffer" + "intentional" end |
.last_message_timestamp ⇒ Object
64 65 66 |
# File 'lib/droonga/path.rb', line 64 def base + "last-message-timestamp.txt" end |
.serf_command ⇒ Object
76 77 78 |
# File 'lib/droonga/path.rb', line 76 def serf_command base + "serf" end |
.serf_event_handler_error_file ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/droonga/path.rb', line 88 def serf_event_handler_error_file now = Time.now name = sprintf("%04d-%02d-%02d_%02d-%02d-%02d.%d.error", now.year, now.month, now.day, now.hour, now.min, now.sec, now.nsec) serf_event_handler_errors + name end |
.serf_event_handler_errors ⇒ Object
84 85 86 |
# File 'lib/droonga/path.rb', line 84 def serf_event_handler_errors state + "serf-event-handler-errors" end |
.serf_tags_file ⇒ Object
80 81 82 |
# File 'lib/droonga/path.rb', line 80 def state + "serf-tags.json" end |
.setup ⇒ Object
23 24 25 26 |
# File 'lib/droonga/path.rb', line 23 def setup base_dir = ENV[BASE_DIR_ENV_NAME] || Dir.pwd ENV[BASE_DIR_ENV_NAME] = File.(base_dir) end |
.state ⇒ Object
43 44 45 |
# File 'lib/droonga/path.rb', line 43 def state base + "state" end |
.unique_file_path(directory, basename, suffix) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/droonga/path.rb', line 96 def unique_file_path(directory, basename, suffix) directory = Pathname(directory) basename = basename.sub(/\.\z/, "") suffix = suffix.sub(/\A\./, "") uniqueness_count = 0 path = nil begin path = directory + "#{basename}.#{uniqueness_count}.#{suffix}" uniqueness_count += 1 end while path.exist? path end |