Class: WP2Middleman::Migrator
- Inherits:
-
Object
- Object
- WP2Middleman::Migrator
- Defined in:
- lib/wp2middleman/migrator.rb
Instance Attribute Summary collapse
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
Instance Method Summary collapse
- #ensure_export_directory ⇒ Object
-
#initialize(wp_xml_export_file, body_to_markdown: false, include_fields: []) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate ⇒ Object
- #output_path ⇒ Object
Constructor Details
#initialize(wp_xml_export_file, body_to_markdown: false, include_fields: []) ⇒ Migrator
Returns a new instance of Migrator.
7 8 9 10 11 12 |
# File 'lib/wp2middleman/migrator.rb', line 7 def initialize(wp_xml_export_file, body_to_markdown: false, include_fields: []) @posts = WP2Middleman::PostCollection.from_file(wp_xml_export_file) . .only_valid .to_middleman(body_to_markdown: body_to_markdown, include_fields: include_fields) end |
Instance Attribute Details
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
5 6 7 |
# File 'lib/wp2middleman/migrator.rb', line 5 def posts @posts end |
Instance Method Details
#ensure_export_directory ⇒ Object
26 27 28 29 30 |
# File 'lib/wp2middleman/migrator.rb', line 26 def ensure_export_directory unless File.directory? output_path FileUtils.mkdir_p output_path end end |
#migrate ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/wp2middleman/migrator.rb', line 14 def migrate ensure_export_directory posts.each do |post| File.write(post.full_filename(output_path), post.file_content) end end |
#output_path ⇒ Object
22 23 24 |
# File 'lib/wp2middleman/migrator.rb', line 22 def output_path "#{Dir.pwd}/export/" end |