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



59
60
61
# File 'lib/couchrest/changes/config.rb', line 59

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_dirObject

Returns the value of attribute seq_dir.



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

def seq_dir
  @seq_dir
end

Instance Method Details

#complete_db_name(db_name) ⇒ Object



52
53
54
55
56
57
# File 'lib/couchrest/changes/config.rb', line 52

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

#couch_host(options = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/couchrest/changes/config.rb', line 33

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

#couch_host_no_authObject



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

def couch_host_no_auth
  couch_host connection.merge({:password => nil, :username => nil})
end

#couch_host_without_passwordObject



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

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
29
30
31
# 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
  unless loaded.compact.any?
    raise ArgumentError.new("Could not find config file")
  end
  self.flags ||= []
  init_logger
  log_loaded_configs(loaded.compact)
  logger.info "Observing #{couch_host_without_password}"
  return self
end