Sha256: 9cc4adf4cae7bf8cf40f3535b65261604bb34fcf20b0b7f67d9c944e9df72eb2

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true
require 'agave/dump/dsl/root'
require 'agave/dump/operation/root'
require 'agave/dump/ssg_detector'
require 'agave/local/loader'

module Agave
  module Dump
    class Runner
      attr_reader :config_path, :client, :destination_path, :preview_mode

      def initialize(config_path, client, preview_mode, destination_path = Dir.pwd)
        @config_path = config_path
        @preview_mode = preview_mode
        @client = client
        @destination_path = destination_path
      end

      def run
        print 'Fetching content from AgaveCMS... '

        loader.load

        I18n.available_locales = loader.items_repo.available_locales
        I18n.locale = I18n.available_locales.first

        Dsl::Root.new(
          File.read(config_path),
          loader.items_repo,
          operation
        )

        operation.perform

        puts "\e[32m✓\e[0m Done!"
      end

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

      def loader
        @loader ||= Agave::Local::Loader.new(client, preview_mode)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
agave-client-0.1.3 lib/agave/dump/runner.rb
agave-client-0.1.2 lib/agave/dump/runner.rb
agave-client-0.1.1 lib/agave/dump/runner.rb
agave-client-0.1.0 lib/agave/dump/runner.rb