View Source ROR.ID (ROR v0.1.0)

Functions for extracting and using Admin data from a ROR Organization record

IDs are simply a string

Summary

Functions

Extracts an ID string from the decoded JSON of a ROR Organization record

Takes any variant of the ROR ID and returns only the record ID fragment

Takes any ID variant and returns a full ID

Return a URL path for the ID

Returns true if the ID is valid, false otherwise

Functions

extract(data)

@spec extract(data :: map()) :: binary()

Extracts an ID string from the decoded JSON of a ROR Organization record

If you are retrieving records via the ROR module and the REST API you will not need to use this function yourself.

Example

iex> record = File.read!("test/support/static/example_org.json") |> Jason.decode!()
...> ROR.ID.extract(record)
"https://ror.org/00pjdza24"

minimize(id)

@spec minimize(id :: binary()) :: binary()

Takes any variant of the ROR ID and returns only the record ID fragment

iex> ID.minimize("https://ror.org/00pjdza24")
"00pjdza24"

normalize(id)

@spec normalize(id :: binary()) :: binary()

Takes any ID variant and returns a full ID

iex> ID.normalize("00pjdza24")
"https://ror.org/00pjdza24"

path(id)

@spec path(id :: binary()) :: binary()

Return a URL path for the ID

iex> ID.minimize("https://ror.org/00pjdza24")
"/00pjdza24"

valid?(id)

@spec valid?(id :: binary()) :: boolean()

Returns true if the ID is valid, false otherwise

iex> ID.valid?("https://ror.org/00pjdza24")
true