Module: Abqari::Importers

Defined in:
lib/abqari/importers.rb,
lib/abqari/importers/cli.rb,
lib/abqari/importers/base.rb,
lib/abqari/importers/ghost.rb,
lib/abqari/importers/jekyll.rb,
lib/abqari/importers/substack.rb,
lib/abqari/importers/support/report.rb,
lib/abqari/importers/support/slug_normalizer.rb,
lib/abqari/importers/support/html_to_markdown.rb,
lib/abqari/importers/support/image_downloader.rb

Overview

Content importers — bin/import <platform> <source>.

Loaded lazily: the registry below maps platform names to file paths so a normal site build never pays the cost of pulling reverse_markdown + the per-platform parsers into memory. The CLI handler resolves the requested platform and requires only its file.

Adding a new importer:

1. Create `lib/abqari/importers/<name>.rb` with class
 `Abqari::Importers::<Name>` < `Base`.
2. Register it in `REGISTRY` below with its short name.
3. Add a one-line description for the `--help` text.

Each importer implements each_post yielding Base::ImportedPost records. The base class handles the rest: HTML→Markdown, image download, slug collisions, frontmatter assembly, idempotent writes, and the run report.

Defined Under Namespace

Modules: Support Classes: Base, CLI, Ghost, Jekyll, Substack

Constant Summary collapse

REGISTRY =
{
  'substack' => {
    file:        'abqari/importers/substack',
    class_name:  'Abqari::Importers::Substack',
    description: 'Import a Substack export zip (or unzipped directory)'
  },
  'ghost' => {
    file:        'abqari/importers/ghost',
    class_name:  'Abqari::Importers::Ghost',
    description: 'Import a Ghost JSON export'
  },
  'jekyll' => {
    file:        'abqari/importers/jekyll',
    class_name:  'Abqari::Importers::Jekyll',
    description: 'Import a Jekyll site directory (_posts/ + assets)'
  }
}.freeze

Class Method Summary collapse

Class Method Details

.lookup(platform) ⇒ Object

Resolve a platform name to an importer class, lazy-loading the file on first use. Returns nil for unknown platforms.



43
44
45
46
47
48
49
# File 'lib/abqari/importers.rb', line 43

def self.lookup(platform)
  entry = REGISTRY[platform.to_s]
  return nil unless entry

  require entry[:file]
  Object.const_get(entry[:class_name])
end

.platformsObject



51
52
53
# File 'lib/abqari/importers.rb', line 51

def self.platforms
  REGISTRY.keys
end