Class: JekyllRecker::Social::Share Abstract

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

Overview

This class is abstract.

Backend

Backend base class for social sharing backends.

Direct Known Subclasses

Slack, Twitter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #info, #logger

Constructor Details

#initialize(site, dry: false) ⇒ Share

Returns a new instance of Share.



33
34
35
36
# File 'lib/jekyll_recker/social.rb', line 33

def initialize(site, dry: false)
  @site = Site.new(site)
  @dry = dry
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



22
23
24
# File 'lib/jekyll_recker/social.rb', line 22

def site
  @site
end

Class Method Details

.share(site, dry: false) ⇒ Object



24
25
26
27
28
29
30
31
# 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

Instance Method Details

#configObject



42
43
44
# File 'lib/jekyll_recker/social.rb', line 42

def config
  site.recker_config.fetch(config_key, {})
end

#config_keyObject Also known as: name



46
47
48
# File 'lib/jekyll_recker/social.rb', line 46

def config_key
  self.class.const_get(:KEY)
end

#configure!Object

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/jekyll_recker/social.rb', line 67

def configure!
  raise NotImplementedError
end

#dry?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/jekyll_recker/social.rb', line 38

def dry?
  @dry
end

#latestObject



63
64
65
# File 'lib/jekyll_recker/social.rb', line 63

def latest
  site.latest
end

#latest_titleObject



59
60
61
# File 'lib/jekyll_recker/social.rb', line 59

def latest_title
  latest.title
end

#post!Object

Raises:

  • (NotImplementedError)


71
72
73
# File 'lib/jekyll_recker/social.rb', line 71

def post!
  raise NotImplementedError
end

#post_bodyObject



51
52
53
54
55
56
57
# File 'lib/jekyll_recker/social.rb', line 51

def post_body
  <<~BODY
    #{latest.title}
    #{latest.subtitle}
    #{File.join site.url, latest.url}
  BODY
end