Module: Octospy::Configurable
- Included in:
- Octospy
- Defined in:
- lib/octospy/configurable.rb
Constant Summary collapse
- OPTIONS_KEYS =
i( channels server 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 github_login github_token ).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #cinch_config_block(&block) ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #options ⇒ Object
- #setup ⇒ Object
Class Method Details
.keys ⇒ Object
27 28 29 |
# File 'lib/octospy/configurable.rb', line 27 def keys @keys ||= OPTIONS_KEYS end |
Instance Method Details
#cinch_config_block(&block) ⇒ Object
36 37 38 |
# File 'lib/octospy/configurable.rb', line 36 def cinch_config_block(&block) @cinch_config_block = block end |
#configure {|_self| ... } ⇒ Object
32 33 34 |
# File 'lib/octospy/configurable.rb', line 32 def configure yield self end |
#options ⇒ Object
40 41 42 43 44 |
# File 'lib/octospy/configurable.rb', line 40 def Hash[Octospy::Configurable.keys.map{ |key| [key, instance_variable_get(:"@#{key}")] }] end |
#setup ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/octospy/configurable.rb', line 46 def setup @github_api_endpoint = ENV['GITHUB_API_ENDPOINT'] @github_web_endpoint = ENV['GITHUB_WEB_ENDPOINT'] @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'] # you can make up to 20 requests per minute. # http://developer.github.com/v3/search/#rate-limit @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 |