lib/dato/dump/runner.rb in dato-0.1.12 vs lib/dato/dump/runner.rb in dato-0.1.13
- old
+ new
@@ -1,8 +1,9 @@
# 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
@@ -11,28 +12,39 @@
@config_path = config_path
@api_token = api_token
end
def run
- site.load
-
- root = Operation::Root.new(Dir.pwd)
-
Dsl::Root.new(
File.read(config_path),
site.items_repo,
- root
+ operation
)
- root.perform
+ 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)
+ @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