Sha256: 03e7401b1f5939fcd43bc3d4109fe80b3c8c4e139c8fc41da1c59457c6bb0cb6

Contents?: true

Size: 764 Bytes

Versions: 2

Compression:

Stored size: 764 Bytes

Contents

require_relative 'post'

module Contentful
  module Exporter
    module Wordpress
      class PostAuthor < Post
        attr_reader :post, :xml, :settings

        def initialize(xml, post, settings)
          @xml = xml
          @post = post
          @settings = settings
        end

        def author_extractor
          output_logger.info 'Extracting post author...'
          { id: author_id }
        end

        private

        def author_id
          "author_#{author_id_by_login(author_login)}"
        end

        def author_id_by_login(login)
          xml.xpath("//wp:author[wp:author_login=\"#{login}\"]/wp:author_id").text
        end

        def author_login
          post.at_xpath('dc:creator').text
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wordpress-exporter-0.2.0 lib/wordpress/post_author.rb
wordpress-exporter-0.1.0 lib/wordpress/post_author.rb