2014-03-04 22:47:53 +00:00
|
|
|
module WordPressImport
|
|
|
|
class Author
|
|
|
|
attr_reader :author_node
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
def initialize(author_node)
|
|
|
|
@author_node = author_node
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
def login
|
|
|
|
author_node.xpath("wp:author_login").text
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
def email
|
|
|
|
author_node.xpath("wp:author_email").text
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
def ==(other)
|
|
|
|
login == other.login
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2014-03-04 22:47:53 +00:00
|
|
|
def inspect
|
|
|
|
"WordPress::Author: #{login} <#{email}>"
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
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
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
2014-03-04 22:47:53 +00:00
|
|
|
user
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
end
|
2014-03-04 22:47:53 +00:00
|
|
|
end
|