class JekyllRecker::Social::Share

Backend

Backend base class for social sharing backends. @abstract

Attributes

site[R]

Public Class Methods

new(site, dry: false) click to toggle source
# File lib/jekyll_recker/social.rb, line 33
def initialize(site, dry: false)
  @site = Site.new(site)
  @dry = dry
end
share(site, dry: false) click to toggle source
# File lib/jekyll_recker/social.rb, line 24
def self.share(site, dry: false)
  backend = new(site, dry: dry)
  info "#{backend.name} - building configuration"
  backend.configure!

  info "#{backend.name} - sharing \"#{backend.latest_title}\""
  backend.post!
end

Public Instance Methods

config() click to toggle source
# File lib/jekyll_recker/social.rb, line 42
def config
  site.recker_config.fetch(config_key, {})
end
config_key() click to toggle source
# File lib/jekyll_recker/social.rb, line 46
def config_key
  self.class.const_get(:KEY)
end
Also aliased as: name
configure!() click to toggle source
# File lib/jekyll_recker/social.rb, line 67
def configure!
  raise NotImplementedError
end
dry?() click to toggle source
# File lib/jekyll_recker/social.rb, line 38
def dry?
  @dry
end
latest() click to toggle source
# File lib/jekyll_recker/social.rb, line 63
def latest
  site.latest
end
latest_title() click to toggle source
# File lib/jekyll_recker/social.rb, line 59
def latest_title
  latest.title
end
name()
Alias for: config_key
post!() click to toggle source
# File lib/jekyll_recker/social.rb, line 71
def post!
  raise NotImplementedError
end
post_body() click to toggle source
# File lib/jekyll_recker/social.rb, line 51
      def post_body
        <<~BODY
          #{latest.title}
          #{latest.subtitle}
          #{File.join site.url, latest.url}
        BODY
      end