Class: Confluence::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/confluence/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file = "#{home()}/config.yml") ⇒ Config

Returns a new instance of Config.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/confluence/config.rb', line 4

def initialize(config_file = "#{home()}/config.yml")
  init_home_dir()
  config = YAML.load_file(config_file)
  
  @config = {}
  @config[:server_url] = config['server_url']
  @config[:server_url].concat("/rpc/xmlrpc") unless @config[:server_url][-11..-1] == "/rpc/xmlrpc"
  @config[:ldap_url] = config['ldap_url']
  @config[:username] = config['username'].to_s
  @config[:password] = config['password'].to_s
  @config[:user_default_password] = config['user_default_password'].to_s
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/confluence/config.rb', line 17

def [](key)
  @config[key.to_sym]
end

#homeObject



21
22
23
# File 'lib/confluence/config.rb', line 21

def home()
  "#{ENV['HOME']}/.ucb_confluence"
end

#init_home_dirObject



25
26
27
28
# File 'lib/confluence/config.rb', line 25

def init_home_dir()
  FileUtils.mkdir(home()) unless File.exists?(home())
  FileUtils.mkdir("#{home()}/log") unless File.exists?("#{home()}/log")
end