Module: CouchRest::Changes::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/couchrest/changes/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_nameObject



48
49
50
# File 'lib/couchrest/changes/config.rb', line 48

def app_name
  @app_name ||= Pathname.new($0).basename.to_s
end

#connectionObject

Returns the value of attribute connection.



9
10
11
# File 'lib/couchrest/changes/config.rb', line 9

def connection
  @connection
end

#flagsObject

Returns the value of attribute flags.



15
16
17
# File 'lib/couchrest/changes/config.rb', line 15

def flags
  @flags
end

#log_fileObject

Returns the value of attribute log_file.



11
12
13
# File 'lib/couchrest/changes/config.rb', line 11

def log_file
  @log_file
end

#log_level=(value) ⇒ Object

Sets the attribute log_level

Parameters:

  • value

    the value to set the attribute log_level to.



12
13
14
# File 'lib/couchrest/changes/config.rb', line 12

def log_level=(value)
  @log_level = value
end

#loggerObject

Returns the value of attribute logger.



13
14
15
# File 'lib/couchrest/changes/config.rb', line 13

def logger
  @logger
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/couchrest/changes/config.rb', line 14

def options
  @options
end

#seq_fileObject

Returns the value of attribute seq_file.



10
11
12
# File 'lib/couchrest/changes/config.rb', line 10

def seq_file
  @seq_file
end

Instance Method Details

#complete_db_name(db_name) ⇒ Object



41
42
43
44
45
46
# File 'lib/couchrest/changes/config.rb', line 41

def complete_db_name(db_name)
  [connection[:prefix], db_name, connection[:suffix]].
   compact.
   reject{|part| part == ""}.
   join('_')
end

#couch_host(conf = nil) ⇒ Object



30
31
32
33
34
35
# File 'lib/couchrest/changes/config.rb', line 30

def couch_host(conf = nil)
  conf ||= connection
  userinfo = [conf[:username], conf[:password]].compact.join(':')
  userinfo += '@' unless userinfo.empty?
  "#{conf[:protocol]}://#{userinfo}#{conf[:host]}:#{conf[:port]}"
end

#couch_host_without_passwordObject



37
38
39
# File 'lib/couchrest/changes/config.rb', line 37

def couch_host_without_password
  couch_host connection.merge({:password => nil})
end

#load(base_dir, *configs) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/couchrest/changes/config.rb', line 17

def load(base_dir, *configs)
  @base_dir = Pathname.new(base_dir)
  loaded = configs.collect do |file_path|
    file = find_file(file_path)
    load_config(file)
  end
  self.flags ||= []
  init_logger
  log_loaded_configs(loaded.compact)
  logger.info "Observing #{couch_host_without_password}"
  return self
end