wordpress-import/lib/wordpress/author.rb

35 lines
671 B
Ruby
Raw Normal View History

2014-03-04 22:47:53 +00:00
module WordPressImport
class Author
attr_reader :author_node
2014-03-04 22:47:53 +00:00
def initialize(author_node)
@author_node = author_node
end
2014-03-04 22:47:53 +00:00
def login
author_node.xpath("wp:author_login").text
end
2014-03-04 22:47:53 +00:00
def email
author_node.xpath("wp:author_email").text
end
2014-03-04 22:47:53 +00:00
def ==(other)
login == other.login
end
2014-03-04 22:47:53 +00:00
def inspect
"WordPress::Author: #{login} <#{email}>"
end
2014-03-04 22:47:53 +00:00
def to_refinery
user = User.find_or_initialize_by_username_and_email(login, email)
unless user.persisted?
user.password = 'password'
user.password_confirmation = 'password'
user.save
end
2014-03-04 22:47:53 +00:00
user
end
end
2014-03-04 22:47:53 +00:00
end