Sha256: 3eb16254a876e2bc2c1ec0f01c398daf8145a2eeaf781ff340c509e1cfcdccf1

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

require 'yaml'

module WP2Middleman
  class Migrator
    attr_reader :posts

    def initialize(wp_xml_export_file, body_to_markdown: false, include_fields: [])
      @posts = WP2Middleman::PostCollection.from_file(wp_xml_export_file)
        .without_attachments
        .only_valid
        .to_middleman(body_to_markdown: body_to_markdown, include_fields: include_fields)
    end

    def migrate
      ensure_export_directory

      posts.each do |post|
        File.write(post.full_filename(output_path), post.file_content)
      end
    end

    def output_path
      "#{Dir.pwd}/export/"
    end

    def ensure_export_directory
      unless File.directory? output_path
        FileUtils.mkdir_p output_path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wp2middleman-0.0.3 lib/wp2middleman/migrator.rb
wp2middleman-0.0.2 lib/wp2middleman/migrator.rb