Class: Migrator
- Inherits:
-
Object
- Object
- Migrator
- Defined in:
- lib/migrator.rb
Instance Attribute Summary collapse
-
#converter ⇒ Object
readonly
Returns the value of attribute converter.
-
#exporter ⇒ Object
readonly
Returns the value of attribute exporter.
-
#markup_converter ⇒ Object
readonly
Returns the value of attribute markup_converter.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(settings) ⇒ Migrator
constructor
A new instance of Migrator.
- #run(action, opts = {}) ⇒ Object
Constructor Details
#initialize(settings) ⇒ Migrator
Returns a new instance of Migrator.
9 10 11 12 13 14 |
# File 'lib/migrator.rb', line 9 def initialize(settings) @settings = Contentful::Configuration.new(settings) @exporter = Contentful::Exporter::Wordpress::Export.new(@settings) @converter = Contentful::Converter::ContentfulModelToJson.new(@settings) @markup_converter = Contentful::Converter::MarkupConverter.new(@settings) end |
Instance Attribute Details
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
7 8 9 |
# File 'lib/migrator.rb', line 7 def converter @converter end |
#exporter ⇒ Object (readonly)
Returns the value of attribute exporter.
7 8 9 |
# File 'lib/migrator.rb', line 7 def exporter @exporter end |
#markup_converter ⇒ Object (readonly)
Returns the value of attribute markup_converter.
7 8 9 |
# File 'lib/migrator.rb', line 7 def markup_converter @markup_converter end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
7 8 9 |
# File 'lib/migrator.rb', line 7 def settings @settings end |
Instance Method Details
#run(action, opts = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/migrator.rb', line 16 def run(action, opts = {}) case action.to_s when '--extract-to-json' exporter.export_blog omit_flag = opts[:omit_content_model].present? converter.create_content_type_json(omit_flag) unless omit_flag when '--convert-content-model-to-json' converter.convert_to_import_form when '--create-contentful-model-from-json' converter.create_content_type_json when '--convert-markup' markup_converter.convert_markup_to_markdown end end |