Class: GroongaDelta::Config

Inherits:
Object
  • Object
show all
Includes:
PathResolvable
Defined in:
lib/groonga-delta/config.rb

Direct Known Subclasses

ApplyConfig, ImportConfig

Defined Under Namespace

Modules: PathResolvable

Instance Method Summary collapse

Constructor Details

#initialize(name, dir) ⇒ Config

Returns a new instance of Config.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/groonga-delta/config.rb', line 40

def initialize(name, dir)
  @name = name
  @dir = dir
  @path = File.join(@dir, "config.yaml")
  if File.exist?(@path)
    @data = YAML.load(File.read(@path))
  else
    @data = {}
  end
  @secret_path = File.join(@dir, "secret.yaml")
  if File.exist?(@secret_path)
    @secret_data = YAML.load(File.read(@secret_path))
  else
    @secret_data = {}
  end
end

Instance Method Details

#log_ageObject



66
67
68
# File 'lib/groonga-delta/config.rb', line 66

def log_age
  @data["log_age"] || 100
end

#log_levelObject



78
79
80
# File 'lib/groonga-delta/config.rb', line 78

def log_level
  @data["log_level"] || "info"
end

#log_max_sizeObject



70
71
72
# File 'lib/groonga-delta/config.rb', line 70

def log_max_size
  @data["log_max_size"] || (1024 * 1024)
end

#log_pathObject



61
62
63
64
# File 'lib/groonga-delta/config.rb', line 61

def log_path
  resolve_path(File.join(@data["log_dir"] || "log",
                         "#{@name}.log"))
end

#log_period_suffixObject



74
75
76
# File 'lib/groonga-delta/config.rb', line 74

def log_period_suffix
  @data["log_period_suffix"] || "%Y-%m-%d"
end

#loggerObject



57
58
59
# File 'lib/groonga-delta/config.rb', line 57

def logger
  @logger ||= create_logger
end

#polling_intervalObject



82
83
84
# File 'lib/groonga-delta/config.rb', line 82

def polling_interval
  Float(@data["polling_interval"] || "60")
end