class JekyllRecker::Social::Slack
Slack
social sharing backend
Constants
- KEY
Public Instance Methods
configure!()
click to toggle source
# File lib/jekyll_recker/social.rb, line 82 def configure! @creds = {} workspaces.each do |key, data| webhook = ENV["SLACK_#{key.upcase}_WEBHOOK"] || extract_from_config(data) raise "cannot find slack webhook for #{key} workspace!" if webhook.nil? @creds[key] = webhook end end
post(key, config)
click to toggle source
# File lib/jekyll_recker/social.rb, line 103 def post(key, config) ::Slack::Notifier.new( @creds[key].strip, channel: config.fetch('channel'), username: config.fetch('username'), icon_emoji: config.fetch('emoji') ).post(text: post_body) end
post!()
click to toggle source
# File lib/jekyll_recker/social.rb, line 92 def post! workspaces.each do |key, config| info "posting to #{key} workspace" if @dry puts "BEGIN MESSAGE\n#{post_body.strip}\nEND MESSAGE" else post(key, config) end end end
post_body()
click to toggle source
Calls superclass method
JekyllRecker::Social::Share#post_body
# File lib/jekyll_recker/social.rb, line 112 def post_body ::Slack::Notifier::Util::LinkFormatter.format(super) end
Private Instance Methods
extract_from_config(data)
click to toggle source
# File lib/jekyll_recker/social.rb, line 118 def extract_from_config(data) cmd = data['webhook_cmd'] return nil if cmd.nil? Shell.run(cmd) end
workspaces()
click to toggle source
# File lib/jekyll_recker/social.rb, line 125 def workspaces config.each end