Sha256: 7d1c2b8bd89f72d140956f35b4e1ba6ba7b6358d44030c392010c335b72c23f5

Contents?: true

Size: 1.03 KB

Versions: 28

Compression:

Stored size: 1.03 KB

Contents

require 'securerandom'

module SPARQL; module Algebra
  class Operator
    ##
    # The SPARQL `uuid` function.
    #
    # @example
    #     (prefix ((: <http://example.org/>)
    #              (xsd: <http://www.w3.org/2001/XMLSchema#>))
    #       (project (?length)
    #         (extend ((?length (strlen ?uuid)))
    #           (filter (&& (isLiteral ?uuid) (regex ?uuid "^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$" "i"))
    #             (extend ((?uuid (struuid)))
    #               (bgp))))))
    #
    # @see http://www.w3.org/TR/sparql11-query/#func-struuid
    class StrUUID < Operator::Nullary
      include Evaluatable

      NAME = :struuid

      ##
      # Return a string that is the scheme specific part of UUID. That is, as a simple literal, the result of generating a UUID, converting to a simple literal and removing the initial urn:uuid:.
      #
      # @return [RDF::URI]
      def apply
        RDF::Literal(SecureRandom.uuid)
      end
    end # StrUUID
  end # Operator
end; end # SPARQL::Algebra

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sparql-3.1.0 lib/sparql/algebra/operator/struuid.rb
sparql-3.0.2 lib/sparql/algebra/operator/struuid.rb
sparql-3.0.1 lib/sparql/algebra/operator/struuid.rb
sparql-3.0.0 lib/sparql/algebra/operator/struuid.rb
sparql-2.2.2 lib/sparql/algebra/operator/struuid.rb
sparql-2.2.1 lib/sparql/algebra/operator/struuid.rb
sparql-2.2.0 lib/sparql/algebra/operator/struuid.rb
sparql-2.1.0 lib/sparql/algebra/operator/struuid.rb
sparql-2.0.0 lib/sparql/algebra/operator/struuid.rb
sparql-2.0.0.beta2 lib/sparql/algebra/operator/struuid.rb
sparql-1.99.1 lib/sparql/algebra/operator/struuid.rb
sparql-2.0.0.beta1 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.9.1 lib/sparql/algebra/operator/struuid.rb
sparql-1.99.0 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.9 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.8 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.7 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.6 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.5 lib/sparql/algebra/operator/struuid.rb
sparql-1.1.4 lib/sparql/algebra/operator/struuid.rb