class StandupMD::Config::Post
The configuration class for chat posting.
Constants
- CONFIG_ATTRIBUTES
-
Attributes copied into request-scoped config snapshots.
@return [Array<Symbol>]
- DEFAULTS
-
The default posting options.
@return [Hash]
Attributes
Non-secret adapter options.
@return [Hash]
Registered adapter classes or instances.
@return [Hash]
The adapter used when ‘standup –post` is called without a platform.
@return [Symbol]
Format string for posted entry titles.
This only affects messages sent through chat posting adapters. It does not change stored standup markdown files. Use ‘%s` as a placeholder for the normal entry title, such as the entry date. This is useful when chat clients post through workspace apps or bots with shared names like “StandupMD”, but the message should still identify whose standup it is.
@example Include the person’s name after the entry date
StandupMD.config.post.title = "%s - Evan Gray"
@return [String, nil]
Public Class Methods
Source
# File lib/standup_md/config/post.rb, line 60 def initialize reset end
Initializes the config with default values.
Public Instance Methods
Source
# File lib/standup_md/config/post.rb, line 132 def build_adapter(name = nil) adapter_name = (name || default_adapter).to_sym adapter = adapters.fetch(adapter_name) do raise StandupMD::Post::UnknownAdapter, "No post adapter registered for #{adapter_name}" end return adapter unless adapter.respond_to?(:new) return adapter.new if adapter.instance_method(:initialize).arity.zero? adapter.new(options_for(adapter_name)) end
Builds the adapter requested by name.
@param name [String, Symbol, nil]
@return [Object]
Source
# File lib/standup_md/config/post.rb, line 112 def configure_adapter(name, options = {}) options_for(name).merge!(symbolize_keys(options)) end
Configures non-secret adapter options.
@param name [String, Symbol] @param options [Hash]
@return [Hash]
Source
# File lib/standup_md/config/post.rb, line 82 def copy_from(config) CONFIG_ATTRIBUTES.each do |attribute| instance_variable_set("@#{attribute}", config.public_send(attribute)) end @adapters = config.adapters.dup @adapter_options = Hash.new { |hash, key| hash[key] = {} } config.adapter_options.each do |name, options| @adapter_options[name] = options.dup end self end
Copies values from another post config.
@param [StandupMD::Config::Post] config
@return [StandupMD::Config::Post]
Source
# File lib/standup_md/config/post.rb, line 122 def options_for(name) adapter_options[name.to_sym] end
Returns non-secret options for an adapter.
@param name [String, Symbol]
@return [Hash]
Source
# File lib/standup_md/config/post.rb, line 101 def register_adapter(name, adapter) adapters[name.to_sym] = adapter end
Registers a posting adapter.
@param name [String, Symbol] @param adapter [Class, Object]
@return [Class, Object]
Source
# File lib/standup_md/config/post.rb, line 68 def reset DEFAULTS.each { |k, v| instance_variable_set("@#{k}", v) } @adapters = {} @adapter_options = Hash.new { |hash, key| hash[key] = {} } register_adapter(:slack, StandupMD::Post::Adapters::Slack) DEFAULTS end
Sets all config values back to their defaults.
@return [Hash]