module Lita
The main namespace for Lita. Provides a global registry of adapters and handlers, as well as global configuration, logger, and Redis store.
Constants
Attributes
A mode that makes minor changes to the Lita runtime to improve testability. @return [Boolean] Whether or not test mode is active. @since 4.0.0
A mode that makes minor changes to the Lita runtime to improve testability. @return [Boolean] Whether or not test mode is active. @since 4.0.0
A special mode to ensure that tests written for Lita 3 plugins continue to work. @return [Boolean] Whether or not version 3 compatibility mode is active. @since 4.0.0
A special mode to ensure that tests written for Lita 3 plugins continue to work. @return [Boolean] Whether or not version 3 compatibility mode is active. @since 4.0.0
Public Class Methods
Sets I18n.locale, normalizing the provided locale name. @param new_locale [Symbol, String] The code of the locale to use. @return [void] @since 3.0.0
# File lib/lita/common.rb, line 19 def locale=(new_locale) I18n.locale = new_locale.to_s.tr("_", "-") end
The root Redis object. @return [Redis::Namespace] The root Redis object.
# File lib/lita.rb, line 48 def redis @redis ||= begin redis = Redis.new(config.redis) Redis::Namespace.new(REDIS_NAMESPACE, redis: redis).tap do |client| begin client.ping rescue Redis::BaseError => e if Lita.test_mode? raise RedisError, I18n.t("lita.redis.test_mode_exception", message: e.message) else Lita.logger.fatal I18n.t( "lita.redis.exception", message: e.message, backtrace: e.backtrace.join("\n") ) abort end end end end end
Loads user configuration and starts the robot. @param config_path [String] The path to the user configuration file. @return [void]
# File lib/lita.rb, line 73 def run(config_path = nil) hooks[:before_run].each { |hook| hook.call(config_path: config_path) } ConfigurationBuilder.load_user_config(config_path) ConfigurationBuilder.freeze_config(config) ConfigurationValidator.new(self).call hooks[:config_finalized].each { |hook| hook.call(config_path: config_path) } self.locale = config.robot.locale Robot.new.run end
The absolute path to Lita's templates directory. @return [String] The path. @since 3.0.0
# File lib/lita/common.rb, line 26 def template_root File.expand_path("../../../templates", __FILE__) end