Class: Adocsite::WpPost

Inherits:
Object
  • Object
show all
Defined in:
lib/adocsite/wp/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWpPost

Returns a new instance of WpPost.



5
6
7
8
9
# File 'lib/adocsite/wp/post.rb', line 5

def initialize
  @engine = Adocsite::Engine::new

  @wp = Rubypress::Client.new(Adocsite.wpconfig)
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def categories
  @categories
end

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def content
  @content
end

#excerptObject (readonly)

Returns the value of attribute excerpt.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def excerpt
  @excerpt
end

#img_srcsObject (readonly)

Returns the value of attribute img_srcs.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def img_srcs
  @img_srcs
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def name
  @name
end

#post_mediaObject (readonly)

Returns the value of attribute post_media.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def post_media
  @post_media
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/adocsite/wp/post.rb', line 3

def title
  @title
end

Instance Method Details

#process(article_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/adocsite/wp/post.rb', line 16

def process(article_name)
  @name = article_name
  context = Adocsite::Context::new(@engine, Adocsite::Request.new('article', @name))
  article = context.get_article
  if article.nil?
    abort "Can't find article."
  end

  @categories = article.categories
  @content = article.content
  @title = article.title
  @excerpt = article.abstract

  collect_images
  create_post
  upload_post_media
  replace_images(@post_media)
  update_post
end

#process_by_title(article_title) ⇒ Object



11
12
13
14
# File 'lib/adocsite/wp/post.rb', line 11

def process_by_title(article_title)
  article_name = Adocsite::Content::title_to_name(article_title)
  process(article_name)
end