GhostParser
A ruby plugin used to help evaluate the exported Ghost posts
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add ghost_parser
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem installghost_parser
Usage
To parse the export:
parser = GhostParser.new("path/to/export.json").parse
[
{
id: "id",
title: "title",
slug: "slug",
html: "html",
feature_image: "feature_image",
created_at: "created_at",
updated_at: "updated_at",
published_at: "published_at",
status: "status"
}, ......
]
Ghost export content will have their links modified like __GHOST_URL__/image.jpg
. If you want the content with active links provide your ghost url.
GhostParser.set_ghost_url("your ghost url")
Instead of getting all the fields we can define the necessary params with necessary keys
GhostParser.set_config({
new_id: "id",
name: "title",
new_slug: "slug"
})
parser = GhostParser.new("path/to/export.json").parse
[
{
new_id: "id",
name: "title",
new_slug: "slug"
}, ......
]
GhostParser.unset_config
Also supports the option of adding extra fields to parsed data
parser = GhostParser.new(file_path).parse do |t|
t[:user_id] = 12
end
[
{
id: "id",
title: "title",
slug: "slug",
html: "html",
feature_image: "feature_image",
created_at: "created_at",
updated_at: "updated_at",
published_at: "published_at",
status: "status",
user_id: 12
}, ......
]
parser = GhostParser.new(file_path).parse(
{param_key: "123"}
)
[
{
id: "id",
title: "title",
slug: "slug",
html: "html",
feature_image: "feature_image",
created_at: "created_at",
updated_at: "updated_at",
published_at: "published_at",
status: "status",
param_key: "123"
}, ......
]