Sha256: c48ac42792a19939f24da361568bfb68a212f35385a9de0086c79b3666199418

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true
require 'dato/dump/dsl/root'
require 'dato/dump/operation/root'
require 'dato/dump/ssg_detector'

module Dato
  module Dump
    class Runner
      attr_reader :config_path, :api_token

      def initialize(config_path, api_token)
        @config_path = config_path
        @api_token = api_token
      end

      def run
        Dsl::Root.new(
          File.read(config_path),
          site.items_repo,
          operation
        )

        site.load
        operation.perform
      end

      def operation
        @operation ||= Operation::Root.new(Dir.pwd)
      end

      def site
        @site ||= Dato::Local::Site.new(client)
      end

      def client
        @client ||= Dato::Site::Client.new(
          api_token,
          extra_headers: {
            'X-Reason' => 'dump',
            'X-SSG' => generator
          }
        )
      end

      def generator
        SsgDetector.new(Dir.pwd).detect
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dato-0.1.13 lib/dato/dump/runner.rb