Sha256: 22cd5d00f2755b032b854ba36b3262d4bfa7d3aeba28f80edc05651f376229e1

Contents?: true

Size: 872 Bytes

Versions: 4

Compression:

Stored size: 872 Bytes

Contents

require 'pathname'

module Natour
  module_function

  def create_reports(dir, out_dir: nil, out_file: nil, overwrite: false,
                     track_formats: %i[gpx fit], create_map: true, map_layers: [], adoc_author: nil)
    out_dir = Pathname(out_dir || dir)
    out_file = Pathname(out_file || "#{Pathname(dir).realpath.basename}.adoc")
    reports = Report.load_directory(
      dir, track_formats: track_formats, create_map: create_map, overwrite_map: overwrite, map_layers: map_layers
    )
    reports.map.with_index(1) do |report, index|
      filename = if index < 2
                   out_dir.join(out_file)
                 else
                   out_dir.join("#{out_file.basename('.*')} (#{index})#{out_file.extname}")
                 end
      report.save_adoc(filename, overwrite: overwrite, author: adoc_author)
      filename.to_s
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
natour-0.11.0 lib/natour/create_reports.rb
natour-0.10.0 lib/natour/create_reports.rb
natour-0.9.0 lib/natour/create_reports.rb
natour-0.8.0 lib/natour/create_reports.rb