Class: MediumExport::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-medium_export/publisher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, shell:, api_client:) ⇒ Publisher

Returns a new instance of Publisher.


4
5
6
7
8
# File 'lib/middleman-medium_export/publisher.rb', line 4

def initialize(content:, shell:, api_client:)
  @content = content
  @shell = shell
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject (readonly)

Returns the value of attribute api_client.


2
3
4
# File 'lib/middleman-medium_export/publisher.rb', line 2

def api_client
  @api_client
end

#contentObject (readonly)

Returns the value of attribute content.


2
3
4
# File 'lib/middleman-medium_export/publisher.rb', line 2

def content
  @content
end

#shellObject (readonly)

Returns the value of attribute shell.


2
3
4
# File 'lib/middleman-medium_export/publisher.rb', line 2

def shell
  @shell
end

Instance Method Details

#callObject


10
11
12
13
14
15
16
17
# File 'lib/middleman-medium_export/publisher.rb', line 10

def call
  shell.say("Preparing to publish #{content.size} articles") if content.size > 1

  content.each do |article|
    publish(article)
    shell.say(%Q(Published: "#{article.title}"), :green)
  end
end