class Workarea::Blog::Import::Wordpress::PageParser
Public Class Methods
new(doc)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 8 def initialize(doc) @pages = doc.xpath("//item[wp:post_type='page']") end
Public Instance Methods
parse()
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 12 def parse @pages.map do |page| { guid_path: guid_path(page), page_title: page_title(page), url: page_url(page), new_slug: File.basename(page_url(page)), content: content(page), published?: published?(page) } end end
Private Instance Methods
content(page)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 39 def content(page) page.xpath('./content:encoded').inner_html end
guid_path(page)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 27 def guid_path(page) URI.parse(page.xpath('./guid').text).query end
page_title(page)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 31 def page_title(page) page.xpath('./title').text end
page_url(page)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 35 def page_url(page) page.xpath('./link').text end
published?(page)
click to toggle source
# File lib/workarea/blog/import/wordpress/page_parser.rb, line 43 def published?(page) page.xpath('./wp:status').text == 'publish' end