Module: Slacked

Defined in:
lib/slacked/version.rb,
lib/slacked/slack_post.rb,
lib/generators/slacked/install/install_generator.rb

Defined Under Namespace

Modules: Generators

Constant Summary collapse

VERSION =
"0.8.0"
SLACK_PROFILE_IMAGE =
':robot_face:'
SLACK_WEBHOOK_URL_KEY =
'SLACK_WEBHOOK'
SLACK_DEFAULT_MESSAGE_KEY =
'SLACK_DEFAULT_MESSAGE'
SLACK_CONFIG =
{
    icon_emoji: SLACK_PROFILE_IMAGE
}

Class Method Summary collapse

Class Method Details

.post(message = ENV[SLACK_DEFAULT_MESSAGE_KEY]) ⇒ Object



10
11
12
13
14
# File 'lib/slacked/slack_post.rb', line 10

def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY]
  return false if message.nil? || message.empty?
  notifier = slack_notifier
  notifier.ping message, SLACK_CONFIG
end

.post_async(message) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/slacked/slack_post.rb', line 16

def post_async message
  Thread.start do
    result = post(message)
    defined?(ActiveRecord) ? ActiveRecord::Base.connection.close : nil
    result
  end
end