Class: JekyllRecker::Social::Share Abstract
- Inherits:
-
Object
- Object
- JekyllRecker::Social::Share
- Includes:
- Mixins::Logging
- Defined in:
- lib/jekyll_recker/social.rb
Overview
This class is abstract.
Backend
Backend base class for social sharing backends.
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #config_key ⇒ Object (also: #name)
- #configure! ⇒ Object
- #dry? ⇒ Boolean
-
#initialize(site, dry: false) ⇒ Share
constructor
A new instance of Share.
- #latest ⇒ Object
- #latest_title ⇒ Object
- #post! ⇒ Object
- #post_body ⇒ Object
Methods included from Mixins::Logging
Constructor Details
#initialize(site, dry: false) ⇒ Share
Returns a new instance of Share.
30 31 32 33 |
# File 'lib/jekyll_recker/social.rb', line 30 def initialize(site, dry: false) @site = site @dry = dry end |
Class Method Details
.share(site, dry: false) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jekyll_recker/social.rb', line 21 def self.share(site, dry: false) backend = new(site, dry: dry) logger.info "#{backend.name} - building configuration" backend.configure! logger.info "#{backend.name} - sharing \"#{backend.latest_title}\"" backend.post! end |
Instance Method Details
#config ⇒ Object
39 40 41 |
# File 'lib/jekyll_recker/social.rb', line 39 def config @site.config.fetch('recker', {}).fetch(config_key, {}) end |
#config_key ⇒ Object Also known as: name
43 44 45 |
# File 'lib/jekyll_recker/social.rb', line 43 def config_key self.class.const_get(:KEY) end |
#configure! ⇒ Object
65 66 67 |
# File 'lib/jekyll_recker/social.rb', line 65 def configure! raise NotImplementedError end |
#dry? ⇒ Boolean
35 36 37 |
# File 'lib/jekyll_recker/social.rb', line 35 def dry? @dry end |
#latest ⇒ Object
57 58 59 |
# File 'lib/jekyll_recker/social.rb', line 57 def latest @latest ||= @site.posts.docs.last end |
#latest_title ⇒ Object
61 62 63 |
# File 'lib/jekyll_recker/social.rb', line 61 def latest_title latest.data['title'] end |
#post! ⇒ Object
69 70 71 |
# File 'lib/jekyll_recker/social.rb', line 69 def post! raise NotImplementedError end |
#post_body ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/jekyll_recker/social.rb', line 48 def post_body url = File.join @site.config['url'], latest.url <<~BODY #{latest.data['date'].strftime('%A, %B %-d %Y')} #{latest.data['title']} #{url} BODY end |