lib/wordpress/blog.rb in wordpress-exporter-0.0.2 vs lib/wordpress/blog.rb in wordpress-exporter-0.1.0

- old
+ new

@@ -15,14 +15,20 @@ def blog_extractor create_directory(settings.data_dir) extract_blog end - def link_entry(entries) - entries.each do |entry| + def link_entry(entry_or_entries) + link = ->(entry) { entry.keep_if { |key, _v| key if key == :id } entry.merge!(type: 'Entry') + } + + if entry_or_entries.is_a? Array + entry_or_entries.each(&link) + else + link.call(entry_or_entries) end end def link_asset(asset) asset.keep_if { |key, _v| key if key == :id } @@ -54,13 +60,18 @@ def extracted_data { id: 'blog_id', title: title, + authors: link_entry(authors), posts: link_entry(posts), categories: link_entry(categories), tags: link_entry(tags) } + end + + def authors + Author.new(xml, settings).author_extractor end def posts Post.new(xml, settings).post_extractor end