Module: CouchRest::Changes::Config
Instance Attribute Summary collapse
- #app_name ⇒ Object
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#log_level ⇒ Object
writeonly
Sets the attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#options ⇒ Object
Returns the value of attribute options.
-
#seq_dir ⇒ Object
Returns the value of attribute seq_dir.
Instance Method Summary collapse
- #complete_db_name(db_name) ⇒ Object
- #couch_host(options = nil) ⇒ Object
- #couch_host_no_auth ⇒ Object
- #couch_host_without_password ⇒ Object
- #load(base_dir, *configs) ⇒ Object
Instance Attribute Details
#app_name ⇒ Object
59 60 61 |
# File 'lib/couchrest/changes/config.rb', line 59 def app_name @app_name ||= Pathname.new($0).basename.to_s end |
#connection ⇒ Object
Returns the value of attribute connection.
9 10 11 |
# File 'lib/couchrest/changes/config.rb', line 9 def connection @connection end |
#flags ⇒ Object
Returns the value of attribute flags.
15 16 17 |
# File 'lib/couchrest/changes/config.rb', line 15 def flags @flags end |
#log_file ⇒ Object
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
12 13 14 |
# File 'lib/couchrest/changes/config.rb', line 12 def log_level=(value) @log_level = value end |
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/couchrest/changes/config.rb', line 13 def logger @logger end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/couchrest/changes/config.rb', line 14 def end |
#seq_dir ⇒ Object
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( = nil) if conf = connection.merge() 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_auth ⇒ Object
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_password ⇒ Object
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 |