openlogic-rdf 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +3 -0
- data/CREDITS +9 -0
- data/README +361 -0
- data/UNLICENSE +24 -0
- data/VERSION +1 -0
- data/bin/rdf +18 -0
- data/etc/doap.nt +62 -0
- data/lib/df.rb +1 -0
- data/lib/rdf/cli.rb +200 -0
- data/lib/rdf/format.rb +383 -0
- data/lib/rdf/mixin/countable.rb +39 -0
- data/lib/rdf/mixin/durable.rb +31 -0
- data/lib/rdf/mixin/enumerable.rb +637 -0
- data/lib/rdf/mixin/indexable.rb +26 -0
- data/lib/rdf/mixin/inferable.rb +5 -0
- data/lib/rdf/mixin/mutable.rb +191 -0
- data/lib/rdf/mixin/queryable.rb +265 -0
- data/lib/rdf/mixin/readable.rb +15 -0
- data/lib/rdf/mixin/type_check.rb +21 -0
- data/lib/rdf/mixin/writable.rb +152 -0
- data/lib/rdf/model/graph.rb +263 -0
- data/lib/rdf/model/list.rb +731 -0
- data/lib/rdf/model/literal/boolean.rb +121 -0
- data/lib/rdf/model/literal/date.rb +73 -0
- data/lib/rdf/model/literal/datetime.rb +72 -0
- data/lib/rdf/model/literal/decimal.rb +86 -0
- data/lib/rdf/model/literal/double.rb +189 -0
- data/lib/rdf/model/literal/integer.rb +126 -0
- data/lib/rdf/model/literal/numeric.rb +184 -0
- data/lib/rdf/model/literal/time.rb +87 -0
- data/lib/rdf/model/literal/token.rb +47 -0
- data/lib/rdf/model/literal/xml.rb +39 -0
- data/lib/rdf/model/literal.rb +373 -0
- data/lib/rdf/model/node.rb +156 -0
- data/lib/rdf/model/resource.rb +28 -0
- data/lib/rdf/model/statement.rb +296 -0
- data/lib/rdf/model/term.rb +77 -0
- data/lib/rdf/model/uri.rb +570 -0
- data/lib/rdf/model/value.rb +133 -0
- data/lib/rdf/nquads.rb +152 -0
- data/lib/rdf/ntriples/format.rb +48 -0
- data/lib/rdf/ntriples/reader.rb +239 -0
- data/lib/rdf/ntriples/writer.rb +219 -0
- data/lib/rdf/ntriples.rb +104 -0
- data/lib/rdf/query/pattern.rb +329 -0
- data/lib/rdf/query/solution.rb +252 -0
- data/lib/rdf/query/solutions.rb +237 -0
- data/lib/rdf/query/variable.rb +221 -0
- data/lib/rdf/query.rb +404 -0
- data/lib/rdf/reader.rb +511 -0
- data/lib/rdf/repository.rb +389 -0
- data/lib/rdf/transaction.rb +161 -0
- data/lib/rdf/util/aliasing.rb +63 -0
- data/lib/rdf/util/cache.rb +139 -0
- data/lib/rdf/util/file.rb +38 -0
- data/lib/rdf/util/uuid.rb +36 -0
- data/lib/rdf/util.rb +6 -0
- data/lib/rdf/version.rb +19 -0
- data/lib/rdf/vocab/cc.rb +18 -0
- data/lib/rdf/vocab/cert.rb +13 -0
- data/lib/rdf/vocab/dc.rb +63 -0
- data/lib/rdf/vocab/dc11.rb +23 -0
- data/lib/rdf/vocab/doap.rb +45 -0
- data/lib/rdf/vocab/exif.rb +168 -0
- data/lib/rdf/vocab/foaf.rb +69 -0
- data/lib/rdf/vocab/geo.rb +13 -0
- data/lib/rdf/vocab/http.rb +26 -0
- data/lib/rdf/vocab/owl.rb +59 -0
- data/lib/rdf/vocab/rdfs.rb +17 -0
- data/lib/rdf/vocab/rsa.rb +12 -0
- data/lib/rdf/vocab/rss.rb +14 -0
- data/lib/rdf/vocab/sioc.rb +93 -0
- data/lib/rdf/vocab/skos.rb +36 -0
- data/lib/rdf/vocab/wot.rb +21 -0
- data/lib/rdf/vocab/xhtml.rb +9 -0
- data/lib/rdf/vocab/xsd.rb +58 -0
- data/lib/rdf/vocab.rb +215 -0
- data/lib/rdf/writer.rb +475 -0
- data/lib/rdf.rb +192 -0
- metadata +173 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Web Ontology Language (OWL) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/owl-overview/
|
6
|
+
class OWL < Vocabulary("http://www.w3.org/2002/07/owl#")
|
7
|
+
property :allValuesFrom
|
8
|
+
property :annotatedProperty
|
9
|
+
property :annotatedSource
|
10
|
+
property :annotatedTarget
|
11
|
+
property :assertionProperty
|
12
|
+
property :backwardCompatibleWith
|
13
|
+
property :bottomDataProperty
|
14
|
+
property :bottomObjectProperty
|
15
|
+
property :cardinality
|
16
|
+
property :complementOf
|
17
|
+
property :datatypeComplementOf
|
18
|
+
property :deprecated
|
19
|
+
property :differentFrom
|
20
|
+
property :disjointUnionOf
|
21
|
+
property :disjointWith
|
22
|
+
property :distinctMembers
|
23
|
+
property :equivalentClass
|
24
|
+
property :equivalentProperty
|
25
|
+
property :hasKey
|
26
|
+
property :hasSelf
|
27
|
+
property :hasValue
|
28
|
+
property :imports
|
29
|
+
property :incompatibleWith
|
30
|
+
property :intersectionOf
|
31
|
+
property :inverseOf
|
32
|
+
property :maxCardinality
|
33
|
+
property :maxQualifiedCardinality
|
34
|
+
property :members
|
35
|
+
property :minCardinality
|
36
|
+
property :minQualifiedCardinality
|
37
|
+
property :onClass
|
38
|
+
property :onDataRange
|
39
|
+
property :onDatatype
|
40
|
+
property :onProperties
|
41
|
+
property :onProperty
|
42
|
+
property :oneOf
|
43
|
+
property :priorVersion
|
44
|
+
property :propertyChainAxiom
|
45
|
+
property :propertyDisjointWith
|
46
|
+
property :qualifiedCardinality
|
47
|
+
property :sameAs
|
48
|
+
property :someValuesFrom
|
49
|
+
property :sourceIndividual
|
50
|
+
property :targetIndividual
|
51
|
+
property :targetValue
|
52
|
+
property :topDataProperty
|
53
|
+
property :topObjectProperty
|
54
|
+
property :unionOf
|
55
|
+
property :versionIRI
|
56
|
+
property :versionInfo
|
57
|
+
property :withRestrictions
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# RDF Schema (RDFS) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/rdf-schema/
|
6
|
+
class RDFS < Vocabulary("http://www.w3.org/2000/01/rdf-schema#")
|
7
|
+
property :comment
|
8
|
+
property :domain
|
9
|
+
property :isDefinedBy
|
10
|
+
property :label
|
11
|
+
property :member
|
12
|
+
property :range
|
13
|
+
property :seeAlso
|
14
|
+
property :subClassOf
|
15
|
+
property :subPropertyOf
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# W3 RSA Keys (RSA) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/ns/auth/rsa#
|
6
|
+
# @since 0.2.0
|
7
|
+
class RSA < Vocabulary("http://www.w3.org/ns/auth/rsa#")
|
8
|
+
property :modulus
|
9
|
+
property :private_exponent
|
10
|
+
property :public_exponent
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# RDF Site Summary (RSS) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://web.resource.org/rss/1.0/
|
6
|
+
class RSS < Vocabulary("http://purl.org/rss/1.0/")
|
7
|
+
property :description
|
8
|
+
property :items
|
9
|
+
property :link
|
10
|
+
property :name
|
11
|
+
property :title
|
12
|
+
property :url
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Semantically-Interlinked Online Communities (SIOC) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://rdfs.org/sioc/spec/
|
6
|
+
class SIOC < Vocabulary("http://rdfs.org/sioc/ns#")
|
7
|
+
property :about
|
8
|
+
property :account_of
|
9
|
+
property :administrator_of
|
10
|
+
property :attachment
|
11
|
+
property :avatar
|
12
|
+
property :container_of
|
13
|
+
property :content
|
14
|
+
property :content_encoded # @deprecated
|
15
|
+
property :created_at # @deprecated
|
16
|
+
property :creator_of
|
17
|
+
property :description # @deprecated
|
18
|
+
property :earlier_version
|
19
|
+
property :email
|
20
|
+
property :email_sha1
|
21
|
+
property :feed
|
22
|
+
property :first_name # @deprecated
|
23
|
+
property :follows
|
24
|
+
property :function_of
|
25
|
+
property :group_of # @deprecated
|
26
|
+
property :has_administrator
|
27
|
+
property :has_container
|
28
|
+
property :has_creator
|
29
|
+
property :has_discussion
|
30
|
+
property :has_function
|
31
|
+
property :has_group # @deprecated
|
32
|
+
property :has_host
|
33
|
+
property :has_member
|
34
|
+
property :has_moderator
|
35
|
+
property :has_modifier
|
36
|
+
property :has_owner
|
37
|
+
property :has_parent
|
38
|
+
property :has_part # @deprecated
|
39
|
+
property :has_reply
|
40
|
+
property :has_scope
|
41
|
+
property :has_space
|
42
|
+
property :has_subscriber
|
43
|
+
property :has_usergroup
|
44
|
+
property :host_of
|
45
|
+
property :id
|
46
|
+
property :ip_address
|
47
|
+
property :last_activity_date
|
48
|
+
property :last_item_date
|
49
|
+
property :last_name # @deprecated
|
50
|
+
property :last_reply_date
|
51
|
+
property :later_version
|
52
|
+
property :latest_version
|
53
|
+
property :link
|
54
|
+
property :links_to
|
55
|
+
property :member_of
|
56
|
+
property :moderator_of
|
57
|
+
property :modified_at # @deprecated
|
58
|
+
property :modifier_of
|
59
|
+
property :name
|
60
|
+
property :next_by_date
|
61
|
+
property :next_version
|
62
|
+
property :note
|
63
|
+
property :num_authors
|
64
|
+
property :num_items
|
65
|
+
property :num_replies
|
66
|
+
property :num_threads
|
67
|
+
property :num_views
|
68
|
+
property :owner_of
|
69
|
+
property :parent_of
|
70
|
+
property :part_of # @deprecated
|
71
|
+
property :previous_by_date
|
72
|
+
property :previous_version
|
73
|
+
property :reference # @deprecated
|
74
|
+
property :related_to
|
75
|
+
property :reply_of
|
76
|
+
property :scope_of
|
77
|
+
property :sibling
|
78
|
+
property :space_of
|
79
|
+
property :subject # @deprecated
|
80
|
+
property :subscriber_of
|
81
|
+
property :title # @deprecated
|
82
|
+
property :topic
|
83
|
+
property :usergroup_of
|
84
|
+
|
85
|
+
##
|
86
|
+
# Semantically-Interlinked Online Communities (SIOC) types vocabulary.
|
87
|
+
#
|
88
|
+
# @see http://rdfs.org/sioc/spec/#sec-modules
|
89
|
+
class Types < RDF::Vocabulary("http://rdfs.org/sioc/types#")
|
90
|
+
# TODO
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Simple Knowledge Organization System (SKOS) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/skos-reference/skos.html
|
6
|
+
class SKOS < Vocabulary("http://www.w3.org/2004/02/skos/core#")
|
7
|
+
property :altLabel
|
8
|
+
property :broadMatch
|
9
|
+
property :broader
|
10
|
+
property :broaderTransitive
|
11
|
+
property :changeNote
|
12
|
+
property :closeMatch
|
13
|
+
property :definition
|
14
|
+
property :editorialNote
|
15
|
+
property :exactMatch
|
16
|
+
property :example
|
17
|
+
property :hasTopConcept
|
18
|
+
property :hiddenLabel
|
19
|
+
property :historyNote
|
20
|
+
property :inScheme
|
21
|
+
property :mappingRelation
|
22
|
+
property :member
|
23
|
+
property :memberList
|
24
|
+
property :narrowMatch
|
25
|
+
property :narrower
|
26
|
+
property :narrowerTransitive
|
27
|
+
property :notation
|
28
|
+
property :note
|
29
|
+
property :prefLabel
|
30
|
+
property :related
|
31
|
+
property :relatedMatch
|
32
|
+
property :scopeNote
|
33
|
+
property :semanticRelation
|
34
|
+
property :topConceptOf
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# Web of Trust (WOT) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://xmlns.com/wot/0.1/
|
6
|
+
class WOT < Vocabulary("http://xmlns.com/wot/0.1/")
|
7
|
+
property :assurance
|
8
|
+
property :encryptedTo
|
9
|
+
property :encrypter
|
10
|
+
property :fingerprint
|
11
|
+
property :hasKey
|
12
|
+
property :hex_id
|
13
|
+
property :identity
|
14
|
+
property :length
|
15
|
+
property :pubkeyAddress
|
16
|
+
property :sigdate
|
17
|
+
property :signed
|
18
|
+
property :signer
|
19
|
+
property :sigtime
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# XML Schema (XSD) vocabulary.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/XML/Schema
|
6
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-datatypes
|
7
|
+
class XSD < Vocabulary("http://www.w3.org/2001/XMLSchema#")
|
8
|
+
# XML Schema built-in primitive types
|
9
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-primitive-datatypes
|
10
|
+
property :NOTATION
|
11
|
+
property :QName
|
12
|
+
property :anyURI
|
13
|
+
property :base64Binary
|
14
|
+
property :boolean
|
15
|
+
property :date
|
16
|
+
property :dateTime
|
17
|
+
property :decimal
|
18
|
+
property :double
|
19
|
+
property :duration
|
20
|
+
property :float
|
21
|
+
property :gDay
|
22
|
+
property :gMonth
|
23
|
+
property :gMonthDay
|
24
|
+
property :gYear
|
25
|
+
property :gYearMonth
|
26
|
+
property :hexBinary
|
27
|
+
property :string
|
28
|
+
property :time
|
29
|
+
|
30
|
+
# XML Schema built-in derived types
|
31
|
+
# @see http://www.w3.org/TR/xmlschema-2/#built-in-derived
|
32
|
+
property :ENTITIES
|
33
|
+
property :ENTITY
|
34
|
+
property :ID
|
35
|
+
property :IDREF
|
36
|
+
property :IDREFS
|
37
|
+
property :NCName
|
38
|
+
property :NMTOKEN
|
39
|
+
property :NMTOKENS
|
40
|
+
property :Name
|
41
|
+
property :byte
|
42
|
+
property :int
|
43
|
+
property :integer
|
44
|
+
property :language
|
45
|
+
property :long
|
46
|
+
property :negativeInteger
|
47
|
+
property :nonNegativeInteger
|
48
|
+
property :nonPositiveInteger
|
49
|
+
property :normalizedString
|
50
|
+
property :positiveInteger
|
51
|
+
property :short
|
52
|
+
property :token
|
53
|
+
property :unsignedByte
|
54
|
+
property :unsignedInt
|
55
|
+
property :unsignedLong
|
56
|
+
property :unsignedShort
|
57
|
+
end
|
58
|
+
end
|
data/lib/rdf/vocab.rb
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
module RDF
|
2
|
+
##
|
3
|
+
# A {Vocabulary} represents an RDFS or OWL vocabulary.
|
4
|
+
#
|
5
|
+
# ### Vocabularies:
|
6
|
+
#
|
7
|
+
# The following vocabularies are pre-defined for your convenience:
|
8
|
+
#
|
9
|
+
# * {RDF} - Resource Description Framework (RDF)
|
10
|
+
# * {RDF::CC} - Creative Commons (CC)
|
11
|
+
# * {RDF::CERT} - W3 Authentication Certificate (CERT)
|
12
|
+
# * {RDF::DC} - Dublin Core (DC)
|
13
|
+
# * {RDF::DC11} - Dublin Core 1.1 (DC11) _deprecated_
|
14
|
+
# * {RDF::DOAP} - Description of a Project (DOAP)
|
15
|
+
# * {RDF::EXIF} - Exchangeable Image File Format (EXIF)
|
16
|
+
# * {RDF::FOAF} - Friend of a Friend (FOAF)
|
17
|
+
# * {RDF::GEO} - WGS84 Geo Positioning (GEO)
|
18
|
+
# * {RDF::HTTP} - Hypertext Transfer Protocol (HTTP)
|
19
|
+
# * {RDF::OWL} - Web Ontology Language (OWL)
|
20
|
+
# * {RDF::RDFS} - RDF Schema (RDFS)
|
21
|
+
# * {RDF::RSA} - W3 RSA Keys (RSA)
|
22
|
+
# * {RDF::RSS} - RDF Site Summary (RSS)
|
23
|
+
# * {RDF::SIOC} - Semantically-Interlinked Online Communities (SIOC)
|
24
|
+
# * {RDF::SKOS} - Simple Knowledge Organization System (SKOS)
|
25
|
+
# * {RDF::WOT} - Web of Trust (WOT)
|
26
|
+
# * {RDF::XHTML} - Extensible HyperText Markup Language (XHTML)
|
27
|
+
# * {RDF::XSD} - XML Schema (XSD)
|
28
|
+
#
|
29
|
+
# @example Using pre-defined RDF vocabularies
|
30
|
+
# include RDF
|
31
|
+
#
|
32
|
+
# DC.title #=> RDF::URI("http://purl.org/dc/terms/title")
|
33
|
+
# FOAF.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
|
34
|
+
# RDF.type #=> RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
|
35
|
+
# RDFS.seeAlso #=> RDF::URI("http://www.w3.org/2000/01/rdf-schema#seeAlso")
|
36
|
+
# RSS.title #=> RDF::URI("http://purl.org/rss/1.0/title")
|
37
|
+
# OWL.sameAs #=> RDF::URI("http://www.w3.org/2002/07/owl#sameAs")
|
38
|
+
# XSD.dateTime #=> RDF::URI("http://www.w3.org/2001/XMLSchema#dateTime")
|
39
|
+
#
|
40
|
+
# @example Using ad-hoc RDF vocabularies
|
41
|
+
# foaf = RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/")
|
42
|
+
# foaf.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
|
43
|
+
# foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
|
44
|
+
# foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
|
45
|
+
#
|
46
|
+
# @see http://www.w3.org/TR/curie/
|
47
|
+
# @see http://en.wikipedia.org/wiki/QName
|
48
|
+
class Vocabulary
|
49
|
+
extend ::Enumerable
|
50
|
+
|
51
|
+
##
|
52
|
+
# Enumerates known RDF vocabulary classes.
|
53
|
+
#
|
54
|
+
# @yield [klass]
|
55
|
+
# @yieldparam [Class] klass
|
56
|
+
# @return [Enumerator]
|
57
|
+
def self.each(&block)
|
58
|
+
if self.equal?(Vocabulary)
|
59
|
+
# This is needed since all vocabulary classes are defined using
|
60
|
+
# Ruby's autoloading facility, meaning that `@@subclasses` will be
|
61
|
+
# empty until each subclass has been touched or require'd.
|
62
|
+
RDF::VOCABS.each { |v| require "rdf/vocab/#{v}" unless v == :rdf }
|
63
|
+
@@subclasses.each(&block)
|
64
|
+
else
|
65
|
+
# TODO: should enumerate vocabulary-specific defined properties.
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Defines a vocabulary term called `property`.
|
71
|
+
#
|
72
|
+
# @param [Symbol]
|
73
|
+
# @return [void]
|
74
|
+
def self.property(property)
|
75
|
+
metaclass = class << self; self; end
|
76
|
+
metaclass.send(:define_method, property) { self[property] } # class method
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Returns the URI for the term `property` in this vocabulary.
|
81
|
+
#
|
82
|
+
# @param [#to_s] property
|
83
|
+
# @return [RDF::URI]
|
84
|
+
def self.[](property)
|
85
|
+
RDF::URI.intern([to_s, property.to_s].join(''))
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Returns the base URI for this vocabulary class.
|
90
|
+
#
|
91
|
+
# @return [RDF::URI]
|
92
|
+
def self.to_uri
|
93
|
+
RDF::URI.intern(to_s)
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# Returns a string representation of this vocabulary class.
|
98
|
+
#
|
99
|
+
# @return [String]
|
100
|
+
def self.to_s
|
101
|
+
@@uris.has_key?(self) ? @@uris[self].to_s : super
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# Returns a developer-friendly representation of this vocabulary class.
|
106
|
+
#
|
107
|
+
# @return [String]
|
108
|
+
def self.inspect
|
109
|
+
if self == Vocabulary
|
110
|
+
self.to_s
|
111
|
+
else
|
112
|
+
sprintf("%s(%s)", superclass.to_s, to_s)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class << self
|
117
|
+
# Preserve the class name so that it can be obtained even for
|
118
|
+
# vocabularies that define a `name` property:
|
119
|
+
alias_method :__name__, :name
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Returns a suggested CURIE/QName prefix for this vocabulary class.
|
124
|
+
#
|
125
|
+
# @return [Symbol]
|
126
|
+
# @since 0.3.0
|
127
|
+
def self.__prefix__
|
128
|
+
self.__name__.split('::').last.downcase.to_sym
|
129
|
+
end
|
130
|
+
|
131
|
+
# Undefine all superfluous instance methods:
|
132
|
+
undef_method(*(instance_methods.map(&:to_sym) - [:__id__, :__send__, :__class__, :__eval__, :object_id, :instance_eval, :inspect, :class, :is_a?]))
|
133
|
+
|
134
|
+
##
|
135
|
+
# @param [RDF::URI, String, #to_s]
|
136
|
+
def initialize(uri)
|
137
|
+
@uri = case uri
|
138
|
+
when RDF::URI then uri.to_s
|
139
|
+
else RDF::URI.parse(uri.to_s) ? uri.to_s : nil
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Returns the URI for the term `property` in this vocabulary.
|
145
|
+
#
|
146
|
+
# @param [#to_s] property
|
147
|
+
# @return [URI]
|
148
|
+
def [](property)
|
149
|
+
RDF::URI.intern([to_s, property.to_s].join(''))
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Returns the base URI for this vocabulary.
|
154
|
+
#
|
155
|
+
# @return [URI]
|
156
|
+
def to_uri
|
157
|
+
RDF::URI.intern(to_s)
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Returns a string representation of this vocabulary.
|
162
|
+
#
|
163
|
+
# @return [String]
|
164
|
+
def to_s
|
165
|
+
@uri.to_s
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Returns a developer-friendly representation of this vocabulary.
|
170
|
+
#
|
171
|
+
# @return [String]
|
172
|
+
def inspect
|
173
|
+
sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, to_s)
|
174
|
+
end
|
175
|
+
|
176
|
+
protected
|
177
|
+
|
178
|
+
def self.create(uri) # @private
|
179
|
+
@@uri = uri
|
180
|
+
self
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.inherited(subclass) # @private
|
184
|
+
@@subclasses << subclass
|
185
|
+
unless @@uri.nil?
|
186
|
+
subclass.send(:private_class_method, :new)
|
187
|
+
@@uris[subclass] = @@uri
|
188
|
+
@@uri = nil
|
189
|
+
end
|
190
|
+
super
|
191
|
+
end
|
192
|
+
|
193
|
+
def self.method_missing(property, *args, &block)
|
194
|
+
if args.empty? && @@uris.has_key?(self)
|
195
|
+
self[property]
|
196
|
+
else
|
197
|
+
super
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def method_missing(property, *args, &block)
|
202
|
+
if args.empty?
|
203
|
+
self[property]
|
204
|
+
else
|
205
|
+
raise ArgumentError.new("wrong number of arguments (#{args.size} for 0)")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
private
|
210
|
+
|
211
|
+
@@subclasses = [::RDF] # @private
|
212
|
+
@@uris = {} # @private
|
213
|
+
@@uri = nil # @private
|
214
|
+
end # Vocabulary
|
215
|
+
end # RDF
|