Module: Octospy::Configurable
- Included in:
- Octospy
- Defined in:
- lib/octospy/configurable.rb
Constant Summary collapse
- OPTIONS_KEYS =
i( channels server port ssl password nick 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
22 23 24 |
# File 'lib/octospy/configurable.rb', line 22 def keys @keys ||= OPTIONS_KEYS end |
Instance Method Details
#cinch_config_block(&block) ⇒ Object
31 32 33 |
# File 'lib/octospy/configurable.rb', line 31 def cinch_config_block(&block) @cinch_config_block = block end |
#configure {|_self| ... } ⇒ Object
27 28 29 |
# File 'lib/octospy/configurable.rb', line 27 def configure yield self end |
#options ⇒ Object
35 36 37 38 39 |
# File 'lib/octospy/configurable.rb', line 35 def Hash[Octospy::Configurable.keys.map{ |key| [key, instance_variable_get(:"@#{key}")] }] end |
#setup ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/octospy/configurable.rb', line 41 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'] @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 @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 |