Sha256: fbda51c26050b7dfa88a7a36569892d56df664c1daa0bfbd62b69ac9ddd0de00
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
module DingBot # Defines constants and methods related to configuration. module Configuration # An array of valid keys in the options hash when configuring a Sentry::API. VALID_OPTIONS_KEYS = [:endpoint, :access_token, :httparty].freeze # The user agent that will be sent to the API endpoint if none is set. DEFAULT_USER_AGENT = "DingBot Ruby Gem #{DingBot::VERSION}".freeze DEFAULT_ENDPOINT = "https://oapi.dingtalk.com/robot/send" # @private attr_accessor(*VALID_OPTIONS_KEYS) # Sets all configuration options to their default values # when this module is extended. def self.extended(base) base.reset end # Convenience method to allow configuration options to be set in a block. def configure yield self end # Creates a hash of options and their values. def options VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end # Resets all configuration options to the defaults. def reset self.endpoint = ENV['DINGTALK_ENDPOINT'] || DEFAULT_ENDPOINT self.access_token = ENV['DINGTALK_ACCESS_TOKEN'] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dingbot-0.2.3 | lib/dingbot/configuration.rb |
dingbot-0.2.2 | lib/dingbot/configuration.rb |
dingbot-0.2.1 | lib/dingbot/configuration.rb |
dingbot-0.2.0 | lib/dingbot/configuration.rb |