Class: JekyllRecker::Social::Twitter

Inherits:
Share
  • Object
show all
Defined in:
lib/jekyll_recker/social.rb

Overview

Twitter

Twitter social sharing backend

Constant Summary collapse

KEY =
'twitter'

Instance Attribute Summary

Attributes inherited from Share

#site

Instance Method Summary collapse

Methods inherited from Share

#config, #config_key, #dry?, #initialize, #latest, #latest_title, #post_body, share

Methods included from Logging

included, #info, #logger

Constructor Details

This class inherits a constructor from JekyllRecker::Social::Share

Instance Method Details

#configure!Object



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/jekyll_recker/social.rb', line 136

def configure!
  creds = extract_from_env || extract_from_config
  raise 'cannot find twitter credentials!' if creds.nil?

  @client = ::Twitter::REST::Client.new do |settings|
    settings.consumer_key = creds['consumer_api_key']
    settings.consumer_secret = creds['consumer_api_secret']
    settings.access_token = creds['access_token']
    settings.access_token_secret = creds['access_token_secret']
  end
end

#post!Object



148
149
150
151
152
153
154
155
# File 'lib/jekyll_recker/social.rb', line 148

def post!
  if dry?
    info('tweeting in dry mode, printing message')
    puts "BEGIN TWEET\n#{post_body}END TWEET"
  else
    @client.update(post_body)
  end
end