Started on attachment import
* created Attachment * created Dump#attachments * specs * replaced require with autoload
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
require 'nokogiri'
|
||||
require "wordpress/railtie"
|
||||
|
||||
module Refinery
|
||||
module WordPress
|
||||
autoload :Author, 'wordpress/author'
|
||||
autoload :Tag, 'wordpress/tag'
|
||||
autoload :Category, 'wordpress/category'
|
||||
autoload :Page, 'wordpress/page'
|
||||
autoload :Post, 'wordpress/post'
|
||||
autoload :Comment, 'wordpress/comment'
|
||||
autoload :Dump, 'wordpress/dump'
|
||||
autoload :Attachment, 'wordpress/attachment'
|
||||
end
|
||||
end
|
||||
|
||||
require 'nokogiri'
|
||||
require 'wordpress/author'
|
||||
require 'wordpress/tag'
|
||||
require 'wordpress/category'
|
||||
require 'wordpress/page'
|
||||
require 'wordpress/post'
|
||||
require 'wordpress/comment'
|
||||
require 'wordpress/dump'
|
||||
|
||||
require "wordpress/railtie"
|
||||
|
||||
27
lib/wordpress/attachment.rb
Normal file
27
lib/wordpress/attachment.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
module Refinery
|
||||
module WordPress
|
||||
class Attachment
|
||||
attr_reader :node
|
||||
|
||||
def initialize(node)
|
||||
@node = node
|
||||
end
|
||||
|
||||
def title
|
||||
node.xpath("title").text
|
||||
end
|
||||
|
||||
def description
|
||||
node.xpath("description").text
|
||||
end
|
||||
|
||||
def post_date
|
||||
DateTime.parse node.xpath("wp:post_date").text
|
||||
end
|
||||
|
||||
def url
|
||||
node.xpath("wp:attachment_url").text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,6 +47,12 @@ module Refinery
|
||||
Category.new(category.text)
|
||||
end
|
||||
end
|
||||
|
||||
def attachments
|
||||
doc.xpath("//item[wp:post_type = 'attachment']").collect do |attachment|
|
||||
Attachment.new(attachment)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user