Module: WordpressImport
- Defined in:
- lib/wordpress_import.rb,
lib/wordpress_import/tag.rb,
lib/wordpress_import/post.rb,
lib/wordpress_import/about.rb,
lib/wordpress_import/author.rb,
lib/wordpress_import/category.rb,
lib/wordpress_import/attachment.rb
Defined Under Namespace
Classes: About, Attachment, Author, Category, Post, Tag
Class Method Summary
collapse
Class Method Details
.authors ⇒ Object
19
20
21
|
# File 'lib/wordpress_import.rb', line 19
def authors
@doc.xpath('//wp:author').map { |author| Author.new(author) }
end
|
.categories ⇒ Object
23
24
25
|
# File 'lib/wordpress_import.rb', line 23
def categories
@doc.xpath('//wp:category').map { |category| Category.new(category) }
end
|
.items ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/wordpress_import.rb', line 31
def items
@doc.xpath('//item').map do |item|
case item.xpath('wp:post_type').first.content
when 'attachment'
Attachment.new(item)
when 'about'
About.new(item)
when 'post'
Post.new(item)
end
end
end
|
.new(content) ⇒ Object
13
14
15
16
17
|
# File 'lib/wordpress_import.rb', line 13
def new(content)
@doc = Nokogiri::XML(content)
puts @doc.errors
self
end
|
27
28
29
|
# File 'lib/wordpress_import.rb', line 27
def tags
@doc.xpath('//wp:tag').map { |tag| Tag.new(tag) }
end
|