defmodule Processor.Source do # [upgrade] use Saxy.parse_stream, and file i/o streams. def read(glob, parser) do glob |> Path.wildcard() |> Enum.map(&File.read!/1) |> map_xml(parser) end # [upgrade] use Saxy.parse_stream, and file i/o streams. # sources: an enumerable of xml strings # parser: a Saxy.XML parser def map_xml(sources, parser) do sources |> Enum.map(fn source -> Task.async(fn -> {:ok, refs} = source |> Saxy.parse_string(parser, []) refs |> Enum.reverse end) end) |> Task.await_many() end end