2018-03-08 00:57:38 +00:00
|
|
|
defmodule RDF.Serialization do
|
|
|
|
@moduledoc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Functions for working with RDF serializations generically.
|
|
|
|
|
|
|
|
Besides some reflection functions regarding available serialization formats,
|
|
|
|
this module includes the full serialization reader and writer API from the
|
|
|
|
serialization format modules.
|
|
|
|
As opposed to calling the reader and writer functions statically on the
|
|
|
|
serialization format module, they can be used more dynamically on this module
|
|
|
|
either by providing the format by name or media type with the `:format` option
|
|
|
|
or in the case of the read and write function on files by relying on detection
|
|
|
|
of the format by file extension.
|
2018-03-08 00:57:38 +00:00
|
|
|
"""
|
|
|
|
|
2020-03-10 00:37:53 +00:00
|
|
|
alias RDF.{Dataset, Graph}
|
|
|
|
|
|
|
|
@type format :: module
|
|
|
|
|
2018-03-08 00:57:38 +00:00
|
|
|
@formats [
|
|
|
|
RDF.Turtle,
|
|
|
|
JSON.LD,
|
|
|
|
RDF.NTriples,
|
2020-11-05 21:06:10 +00:00
|
|
|
RDF.NQuads,
|
|
|
|
RDF.XML
|
2018-03-08 00:57:38 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
The list of all known `RDF.Serialization.Format`s in the RDF.ex eco-system.
|
|
|
|
|
|
|
|
Note: Not all known formats might be available to an application, see `available_formats/0`.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
iex> RDF.Serialization.formats
|
2020-11-03 12:01:47 +00:00
|
|
|
#{inspect(@formats)}
|
2018-03-08 00:57:38 +00:00
|
|
|
|
|
|
|
"""
|
2020-03-10 00:37:53 +00:00
|
|
|
@spec formats :: [format]
|
2018-03-08 00:57:38 +00:00
|
|
|
def formats, do: @formats
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
The list of all available `RDF.Serialization.Format`s in an application.
|
|
|
|
|
|
|
|
A known format might not be available in an application, when the format is
|
|
|
|
implemented in an external library and this not specified as a Mix dependency
|
|
|
|
of this application.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
iex> RDF.Serialization.available_formats
|
|
|
|
[RDF.Turtle, RDF.NTriples, RDF.NQuads]
|
|
|
|
|
|
|
|
"""
|
2020-03-10 00:37:53 +00:00
|
|
|
@spec available_formats :: [format]
|
2018-03-08 00:57:38 +00:00
|
|
|
def available_formats do
|
2020-06-29 08:37:42 +00:00
|
|
|
Enum.filter(@formats, &Code.ensure_loaded?/1)
|
2018-03-08 00:57:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Returns the `RDF.Serialization.Format` with the given name, if available.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
iex> RDF.Serialization.format(:turtle)
|
|
|
|
RDF.Turtle
|
|
|
|
iex> RDF.Serialization.format("turtle")
|
|
|
|
RDF.Turtle
|
|
|
|
iex> RDF.Serialization.format(:jsonld)
|
|
|
|
nil # unless json_ld is defined as a dependency of the application
|
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec format(String.t() | atom) :: format | nil
|
2018-03-08 00:57:38 +00:00
|
|
|
def format(name)
|
|
|
|
|
|
|
|
def format(name) when is_binary(name) do
|
2018-05-15 23:59:46 +00:00
|
|
|
name
|
2020-06-29 08:37:42 +00:00
|
|
|
|> String.to_existing_atom()
|
2018-05-15 23:59:46 +00:00
|
|
|
|> format()
|
|
|
|
rescue
|
|
|
|
ArgumentError -> nil
|
2018-03-08 00:57:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def format(name) do
|
|
|
|
format_where(fn format -> format.name == name end)
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Returns the `RDF.Serialization.Format` with the given media type, if available.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2018-03-08 01:14:49 +00:00
|
|
|
iex> RDF.Serialization.format_by_media_type("text/turtle")
|
2018-03-08 00:57:38 +00:00
|
|
|
RDF.Turtle
|
2018-03-08 01:14:49 +00:00
|
|
|
iex> RDF.Serialization.format_by_media_type("application/ld+json")
|
2018-03-08 00:57:38 +00:00
|
|
|
nil # unless json_ld is defined as a dependency of the application
|
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec format_by_media_type(String.t()) :: format | nil
|
2018-03-08 01:14:49 +00:00
|
|
|
def format_by_media_type(media_type) do
|
|
|
|
format_where(fn format -> format.media_type == media_type end)
|
2018-03-08 00:57:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Returns the proper `RDF.Serialization.Format` for the given file extension, if available.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
iex> RDF.Serialization.format_by_extension("ttl")
|
|
|
|
RDF.Turtle
|
2018-03-09 20:15:43 +00:00
|
|
|
iex> RDF.Serialization.format_by_extension(".ttl")
|
|
|
|
RDF.Turtle
|
2018-03-08 00:57:38 +00:00
|
|
|
iex> RDF.Serialization.format_by_extension("jsonld")
|
|
|
|
nil # unless json_ld is defined as a dependency of the application
|
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec format_by_extension(String.t()) :: format | nil
|
2018-03-09 20:15:43 +00:00
|
|
|
def format_by_extension(extension)
|
|
|
|
|
|
|
|
def format_by_extension("." <> extension), do: format_by_extension(extension)
|
|
|
|
|
2018-03-08 00:57:38 +00:00
|
|
|
def format_by_extension(extension) do
|
|
|
|
format_where(fn format -> format.extension == extension end)
|
|
|
|
end
|
|
|
|
|
|
|
|
defp format_where(fun) do
|
|
|
|
@formats
|
|
|
|
|> Stream.filter(&Code.ensure_loaded?/1)
|
|
|
|
|> Enum.find(fun)
|
|
|
|
end
|
2018-03-09 20:15:43 +00:00
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Deserializes a graph or dataset from a string.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
|
|
|
It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
|
|
|
|
dataset, or `{:error, reason}` if an error occurs.
|
2020-11-03 12:01:47 +00:00
|
|
|
|
|
|
|
The format must be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec read_string(String.t(), keyword) :: {:ok, Graph.t() | Dataset.t()} | {:error, any}
|
2018-03-09 20:15:43 +00:00
|
|
|
def read_string(content, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.read_string(content, opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Deserializes a graph or dataset from a string.
|
|
|
|
|
|
|
|
As opposed to `read_string/2`, it raises an exception if an error occurs.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
The format must be specified with the `format` option and a format name or the
|
2018-03-09 20:15:43 +00:00
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec read_string!(String.t(), keyword) :: Graph.t() | Dataset.t()
|
2018-03-09 20:15:43 +00:00
|
|
|
def read_string!(content, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.read_string!(content, opts)
|
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-04 11:18:04 +00:00
|
|
|
@doc """
|
|
|
|
Deserializes a graph or dataset from a stream.
|
|
|
|
|
2020-11-06 12:03:01 +00:00
|
|
|
It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
|
|
|
|
dataset, or `{:error, reason}` if an error occurs.
|
|
|
|
|
2020-11-04 11:18:04 +00:00
|
|
|
The format must be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
|
|
|
"""
|
2020-11-06 12:03:01 +00:00
|
|
|
@spec read_stream(Enumerable.t(), keyword) :: {:ok, Graph.t() | Dataset.t()} | {:error, any}
|
2020-11-04 11:18:04 +00:00
|
|
|
def read_stream(stream, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.read_stream(stream, opts)
|
2020-11-06 12:03:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
Deserializes a graph or dataset from a stream.
|
|
|
|
|
|
|
|
As opposed to `read_stream/2`, it raises an exception if an error occurs.
|
|
|
|
|
|
|
|
The format must be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
|
|
|
"""
|
|
|
|
@spec read_stream!(Enumerable.t(), keyword) :: Graph.t() | Dataset.t()
|
|
|
|
def read_stream!(stream, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.read_stream!(stream, opts)
|
2020-11-04 11:18:04 +00:00
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-09 20:15:43 +00:00
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Deserializes a graph or dataset from a file.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
It returns an `{:ok, data}` tuple, with `data` being the deserialized graph or
|
|
|
|
dataset, or `{:error, reason}` if an error occurs.
|
|
|
|
|
2020-11-05 16:23:59 +00:00
|
|
|
## Options
|
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
The format can be specified with the `format` option and a format name or the
|
2018-03-09 20:15:43 +00:00
|
|
|
`media_type` option and the media type of the format. If none of these are
|
|
|
|
given, the format gets inferred from the extension of the given file name.
|
|
|
|
|
2020-11-05 16:23:59 +00:00
|
|
|
Other available serialization-independent options:
|
|
|
|
|
2020-11-05 21:06:10 +00:00
|
|
|
- `:stream`: Allows to enable reading the data from a file directly via a
|
|
|
|
stream (default: `false` on this function, `true` on the bang version)
|
2020-11-05 16:23:59 +00:00
|
|
|
- `:gzip`: Allows to read directly from a gzipped file (default: `false`)
|
|
|
|
- `:file_mode`: A list with the Elixir `File.open` modes to be used for reading
|
|
|
|
(default: `[:read, :utf8]`)
|
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec read_file(Path.t(), keyword) :: {:ok, Graph.t() | Dataset.t()} | {:error, any}
|
2018-03-09 20:15:43 +00:00
|
|
|
def read_file(file, opts \\ []) do
|
|
|
|
with {:ok, format} <- file_format(file, opts) do
|
|
|
|
format.read_file(file, opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Deserializes a graph or dataset from a file.
|
|
|
|
|
2020-11-05 21:06:10 +00:00
|
|
|
As opposed to `read_file/2`, it raises an exception if an error occurs and
|
|
|
|
defaults to `stream: true`.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
|
|
|
The format can be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format. If none of these are
|
|
|
|
given, the format gets inferred from the extension of the given file name.
|
|
|
|
|
2020-11-05 21:06:10 +00:00
|
|
|
See `read_file/3` for the available format-independent options.
|
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the decoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-06-29 08:37:42 +00:00
|
|
|
@spec read_file!(Path.t(), keyword) :: Graph.t() | Dataset.t()
|
2018-03-09 20:15:43 +00:00
|
|
|
def read_file!(file, opts \\ []) do
|
|
|
|
with {:ok, format} <- file_format(file, opts) do
|
|
|
|
format.read_file!(file, opts)
|
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Serializes a RDF data structure to a string.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
|
|
|
It returns an `{:ok, string}` tuple, with `string` being the serialized graph or
|
|
|
|
dataset, or `{:error, reason}` if an error occurs.
|
2020-11-03 12:01:47 +00:00
|
|
|
|
|
|
|
The format must be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
|
|
|
Please refer to the documentation of the encoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-11-03 10:39:38 +00:00
|
|
|
@spec write_string(RDF.Data.t(), keyword) :: {:ok, String.t()} | {:error, any}
|
2018-03-09 20:15:43 +00:00
|
|
|
def write_string(data, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.write_string(data, opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Serializes a RDF data structure to a string.
|
|
|
|
|
|
|
|
As opposed to `write_string/2`, it raises an exception if an error occurs.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
The format must be specified with the `format` option and a format name or the
|
2018-03-09 20:15:43 +00:00
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the encoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-11-03 10:39:38 +00:00
|
|
|
@spec write_string!(RDF.Data.t(), keyword) :: String.t()
|
2018-03-09 20:15:43 +00:00
|
|
|
def write_string!(data, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.write_string!(data, opts)
|
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-04 09:26:30 +00:00
|
|
|
@doc """
|
|
|
|
Serializes a RDF data structure to a stream.
|
|
|
|
|
|
|
|
The format must be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format.
|
|
|
|
|
|
|
|
Please refer to the documentation of the encoder of a RDF serialization format
|
|
|
|
for format-specific options and what the stream emits.
|
|
|
|
"""
|
|
|
|
@spec write_stream(RDF.Data.t(), keyword) :: Enumerable.t()
|
|
|
|
def write_stream(data, opts) do
|
|
|
|
with {:ok, format} <- string_format(opts) do
|
|
|
|
format.write_stream(data, opts)
|
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-09 20:15:43 +00:00
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Serializes a RDF data structure to a file.
|
|
|
|
|
|
|
|
It returns `:ok` if successful or `{:error, reason}` if an error occurs.
|
|
|
|
|
|
|
|
## Options
|
2018-03-09 20:15:43 +00:00
|
|
|
|
|
|
|
The format can be specified with the `format` option and a format name or the
|
|
|
|
`media_type` option and the media type of the format. If none of these are
|
|
|
|
given, the format gets inferred from the extension of the given file name.
|
|
|
|
|
|
|
|
Other available serialization-independent options:
|
|
|
|
|
2020-11-05 21:06:10 +00:00
|
|
|
- `:stream`: Allows to enable writing the serialized data to the file directly
|
|
|
|
via a stream. Possible values: `:string` or `:iodata` for writing to the file
|
|
|
|
with a stream of strings respective IO lists, `true` if you want to use streams,
|
|
|
|
but don't care for the exact method or `false` for not writing with
|
|
|
|
a stream (default: `false` on this function, `:iodata` on the bang version)
|
2020-11-05 16:23:59 +00:00
|
|
|
- `:gzip`: Allows to write directly to a gzipped file (default: `false`)
|
|
|
|
- `:force`: If not set to `true`, an error is raised when the given file
|
2018-03-09 20:15:43 +00:00
|
|
|
already exists (default: `false`)
|
2020-11-05 16:23:59 +00:00
|
|
|
- `:file_mode`: A list with the Elixir `File.open` modes to be used for writing
|
2020-11-03 12:01:47 +00:00
|
|
|
(default: `[:write, :exclusive]`)
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the encoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-11-03 10:39:38 +00:00
|
|
|
@spec write_file(RDF.Data.t(), Path.t(), keyword) :: :ok | {:error, any}
|
2018-03-09 20:15:43 +00:00
|
|
|
def write_file(data, path, opts \\ []) do
|
|
|
|
with {:ok, format} <- file_format(path, opts) do
|
|
|
|
format.write_file(data, path, opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
2020-11-03 12:01:47 +00:00
|
|
|
Serializes a RDF data structure to a file.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
As opposed to `write_file/3`, it raises an exception if an error occurs.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
See `write_file/3` for the available format-independent options.
|
2018-03-09 20:15:43 +00:00
|
|
|
|
2020-11-03 12:01:47 +00:00
|
|
|
Please refer to the documentation of the encoder of a RDF serialization format
|
|
|
|
for format-specific options.
|
2018-03-09 20:15:43 +00:00
|
|
|
"""
|
2020-11-03 10:39:38 +00:00
|
|
|
@spec write_file!(RDF.Data.t(), Path.t(), keyword) :: :ok
|
2018-03-09 20:15:43 +00:00
|
|
|
def write_file!(data, path, opts \\ []) do
|
|
|
|
with {:ok, format} <- file_format(path, opts) do
|
|
|
|
format.write_file!(data, path, opts)
|
|
|
|
else
|
|
|
|
{:error, error} -> raise error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
defp string_format(opts) do
|
|
|
|
if format =
|
2020-06-29 08:37:42 +00:00
|
|
|
opts |> Keyword.get(:format) |> format() ||
|
|
|
|
opts |> Keyword.get(:media_type) |> format_by_media_type() do
|
2018-03-09 20:15:43 +00:00
|
|
|
{:ok, format}
|
|
|
|
else
|
|
|
|
{:error, "unable to detect serialization format"}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
defp file_format(filename, opts) do
|
|
|
|
case string_format(opts) do
|
|
|
|
{:ok, format} -> {:ok, format}
|
2020-06-29 08:37:42 +00:00
|
|
|
_ -> format_by_file_name(filename)
|
2018-03-09 20:15:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
defp format_by_file_name(filename) do
|
|
|
|
if format = filename |> Path.extname() |> format_by_extension() do
|
|
|
|
{:ok, format}
|
|
|
|
else
|
|
|
|
{:error, "unable to detect serialization format"}
|
|
|
|
end
|
|
|
|
end
|
2020-11-05 12:36:08 +00:00
|
|
|
|
|
|
|
@doc false
|
|
|
|
def use_file_streaming(mod, opts) do
|
|
|
|
case Keyword.get(opts, :stream) do
|
2020-11-05 21:06:10 +00:00
|
|
|
nil ->
|
|
|
|
false
|
|
|
|
|
|
|
|
false ->
|
|
|
|
false
|
|
|
|
|
|
|
|
stream_mode ->
|
2020-11-05 12:36:08 +00:00
|
|
|
if mod.stream_support?() do
|
2020-11-05 21:06:10 +00:00
|
|
|
stream_mode
|
2020-11-05 12:36:08 +00:00
|
|
|
else
|
|
|
|
raise "#{inspect(mod)} does not support streams"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc false
|
|
|
|
def use_file_streaming!(mod, opts) do
|
|
|
|
case Keyword.get(opts, :stream) do
|
|
|
|
nil ->
|
|
|
|
mod.stream_support?()
|
|
|
|
|
2020-11-05 21:06:10 +00:00
|
|
|
false ->
|
|
|
|
false
|
|
|
|
|
|
|
|
stream_mode ->
|
2020-11-05 12:36:08 +00:00
|
|
|
if mod.stream_support?() do
|
2020-11-05 21:06:10 +00:00
|
|
|
stream_mode
|
2020-11-05 12:36:08 +00:00
|
|
|
else
|
|
|
|
raise "#{inspect(mod)} does not support streams"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-08 00:57:38 +00:00
|
|
|
end
|