Expose compiler to factory.

    :param compiler: the callable to expose
    :type compiler: callable
    :param spec: name of the spec
    :type spec: str

    It can be used as a decorator::

        @register(spec='my:first:spec')
        def my_compiler(schema, pointer, context):
            return Validator(schema)

    or as a function::

        def my_compiler(schema, pointer, context):
            return Validator(schema)

        register(my_compiler, 'my:second:spec')

def register(compiler=None, spec=None):
    """
    Expose compiler to factory.

    :param compiler: the callable to expose
    :type compiler: callable
    :param spec: name of the spec
    :type spec: str

    It can be used as a decorator::

        @register(spec='my:first:spec')
        def my_compiler(schema, pointer, context):
            return Validator(schema)

    or as a function::

        def my_compiler(schema, pointer, context):
            return Validator(schema)

        register(my_compiler, 'my:second:spec')

    """
    if not spec:
        raise CompilationError('Spec is required')
    if not compiler:
        return partial(register, spec=spec)
    return Factory.register(spec, compiler)