lib/octospy/configurable.rb in octospy-0.1.1 vs lib/octospy/configurable.rb in octospy-0.2.0
- old
+ new
@@ -6,10 +6,14 @@
port
ssl
password
nick
debug
+ daemonize
+ sync_log
+ pid_file
+ log_file
worker_interval
api_request_interval
cinch_config_block
github_api_endpoint
github_web_endpoint
@@ -45,18 +49,32 @@
@nick = ENV['NICK'] || 'octospy'
@server = ENV['SERVER']
@port = ENV['PORT']
@ssl = !!ENV['SSL']
@debug = !!ENV['DEBUG']
+ @daemonize = !!ENV['DAEMONIZE']
+ @sync_log = "#{ENV['SYNC_LOG'] || true}".to_boolean
+ @pid_file = ENV['PID_FILE'] || default_pid_file
+ @log_file = ENV['LOG_FILE'] || default_log_file
@password = ENV['PASSWORD']
- @worker_interval = ENV['WORKER_INTERVAL'] ? ENV['WORKER_INTERVAL'].to_i : 30 #sec
# you can make up to 20 requests per minute.
# http://developer.github.com/v3/search/#rate-limit
- @api_request_interval = ENV['API_REQUEST_INTERVAL'] ? ENV['API_REQUEST_INTERVAL'].to_i : 3 #sec
+ @api_request_interval = "#{ENV['API_REQUEST_INTERVAL'] || 3}".to_i
+ @worker_interval = "#{ENV['WORKER_INTERVAL'] || 30}".to_i
@github_login = ENV['GITHUB_LOGIN']
@github_token = ENV['GITHUB_TOKEN']
@channels = ENV['CHANNELS'] ? ENV['CHANNELS'].gsub(/\s|#/, '').split(',').
map { |ch| "##{ch}" } : nil
@cinch_config_block = nil
+ end
+
+ private
+
+ def default_pid_file
+ File.join(File.expand_path('../../../tmp/pids', __FILE__), "#{@nick}")
+ end
+
+ def default_log_file
+ File.join(File.expand_path('../../../log', __FILE__), "#{@nick}.log")
end
end
end