2011-06-02 12:41:31 +00:00
|
|
|
module Refinery
|
|
|
|
module WordPress
|
|
|
|
class Author
|
|
|
|
attr_reader :author_node
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +00:00
|
|
|
def initialize(author_node)
|
|
|
|
@author_node = author_node
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +00:00
|
|
|
def login
|
|
|
|
author_node.xpath("wp:author_login").text
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +00:00
|
|
|
def email
|
|
|
|
author_node.xpath("wp:author_email").text
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +00:00
|
|
|
def ==(other)
|
|
|
|
login == other.login
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +00:00
|
|
|
def inspect
|
|
|
|
"WordPress::Author: #{login} <#{email}>"
|
|
|
|
end
|
2011-06-01 19:11:57 +00:00
|
|
|
|
2011-06-02 12:41:31 +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
|
|
|
|
user
|
2011-06-01 19:11:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|