Class: Jekyll::PandocExports::ExportRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-pandoc-exports/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, options) ⇒ ExportRunner

Returns a new instance of ExportRunner.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll-pandoc-exports/command.rb', line 29

def initialize(args, options)
  @args = args
  @options = options
  @format = (options['format'] || 'both').downcase
  @target = options['target']
  @dry_run = options['dry_run'] || false
  @validate = options['validate'] || false
  @output_dir = options['output']
  @source = options['source'] || '.'
  @config_file = options['config'] || '_config.yml'
end

Instance Method Details

#runObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/jekyll-pandoc-exports/command.rb', line 41

def run
  # Ensure logger shows info-level output for CLI feedback
  Jekyll.logger.adjust_verbosity(verbose: true)

  validate_format!
  validate_schema! if @validate

  config = load_site_config
  export_config = PandocExports.setup_configuration(mock_site(config))

  unless PandocExports.validate_dependencies
    Jekyll.logger.error "Export:", "Missing required dependencies."
    return
  end

  html_files = find_export_targets(config, export_config)

  if html_files.empty?
    Jekyll.logger.warn "Export:", "No export targets found. Run 'jekyll build' first, or check that pages have pdf/docx front matter."
    return
  end

  html_files.each do |target|
    export_file(target, config, export_config)
  end

  Jekyll.logger.info "Export:", "Complete."
end