Add name to RDF.Serialization formats

This commit is contained in:
Marcel Otto 2018-03-07 10:16:00 +01:00
parent 6832176904
commit 7753d0d6f7
5 changed files with 23 additions and 0 deletions

View file

@ -5,6 +5,17 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
[Keep a CHANGELOG](http://keepachangelog.com).
## Unreleased
### Added
- `RDF.Serialization`s define an atom name
[Compare v0.3.1...HEAD](https://github.com/marcelotto/rdf-ex/compare/v0.3.1...HEAD)
## 0.3.1 - 2018-01-19
### Added

View file

@ -31,6 +31,11 @@ defmodule RDF.Serialization do
"""
@callback id :: RDF.IRI.t
@doc """
An name atom of the serialization format.
"""
@callback name :: atom
@doc """
The usual file extension for the serialization format.
"""
@ -99,6 +104,10 @@ defmodule RDF.Serialization do
Module.get_attribute(__MODULE__, :id) do
def id, do: @id
end
if !Module.defines?(__MODULE__, {:name, 0}) &&
Module.get_attribute(__MODULE__, :name) do
def name, do: @name
end
if !Module.defines?(__MODULE__, {:extension, 0}) &&
Module.get_attribute(__MODULE__, :extension) do
def extension, do: @extension

View file

@ -18,6 +18,7 @@ defmodule RDF.NQuads do
import RDF.Sigils
@id ~I<http://www.w3.org/ns/formats/N-Quads>
@name :nquads
@extension "nq"
@content_type "application/n-quads"

View file

@ -20,6 +20,7 @@ defmodule RDF.NTriples do
import RDF.Sigils
@id ~I<http://www.w3.org/ns/formats/N-Triples>
@name :ntriples
@extension "nt"
@content_type "application/n-triples"

View file

@ -11,6 +11,7 @@ defmodule RDF.Turtle do
import RDF.Sigils
@id ~I<http://www.w3.org/ns/formats/Turtle>
@name :turtle
@extension "ttl"
@content_type "text/turtle"