rsinger-rdfobjects 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/README +100 -0
- metadata +94 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2007 Ross Singer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
RDFObjects are intended to simplify working with RDF data by providing a (more) Ruby-like interface to resources (thanks to OpenStruct).
|
2
|
+
|
3
|
+
Requirements:
|
4
|
+
* Nokogiri (the idea is for more options in the future)
|
5
|
+
* Curies (see: http://github.com/pius/curies/tree/master - currently a manual install required)
|
6
|
+
* Builder (although, ideally, this will be deprecated)
|
7
|
+
* json (or json_pure)
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
>> require 'rdf_objects'
|
11
|
+
|
12
|
+
>> include RDFObject
|
13
|
+
|
14
|
+
>> Curie.add_prefixes! :skos=>"http://www.w3.org/2004/02/skos/core#"
|
15
|
+
|
16
|
+
>> resource = Resource.new('http://id.loc.gov/authorities/sh2002000569#concept')
|
17
|
+
>> resource.describe
|
18
|
+
>> resource.skos
|
19
|
+
|
20
|
+
=> {"inScheme"=>[#<RDFObject::Resource uri="http://id.loc.gov/authorities#topicalTerms">, #<RDFObject::Resource uri="http://id.loc.gov/authorities#conceptScheme">], "broader"=>[#<RDFObject::Resource skos={"prefLabel"=>"Semantic networks (Information theory)"}, uri="http://id.loc.gov/authorities/sh92004914#concept">, #<RDFObject::Resource skos={"prefLabel"=>"World Wide Web"}, uri="http://id.loc.gov/authorities/sh95000541#concept">, #<RDFObject::Resource skos={"prefLabel"=>"Semantic integration (Computer systems)"}, uri="http://id.loc.gov/authorities/sh2004000479#concept">], "closeMatch"=>#<RDFObject::Resource uri="http://stitch.cs.vu.nl/vocabularies/rameau/ark:/12148/cb14521343b">, "prefLabel"=>"Semantic Web"}
|
21
|
+
|
22
|
+
>> resource["[skos:prefLabel]"]
|
23
|
+
|
24
|
+
=> "Semantic Web"
|
25
|
+
|
26
|
+
>> resource.skos["prefLabel"]
|
27
|
+
|
28
|
+
=> "Semantic Web"
|
29
|
+
|
30
|
+
>> resource["http://www.w3.org/2004/02/skos/core#prefLabel"]
|
31
|
+
|
32
|
+
=> "Semantic Web"
|
33
|
+
(etc.)
|
34
|
+
|
35
|
+
>> resource.skos["broader"].first.skos["prefLabel"]
|
36
|
+
|
37
|
+
=> "Semantic networks (Information theory)"
|
38
|
+
|
39
|
+
Unnecessary, but helpful, way to define typed literals
|
40
|
+
>> source = Literal.new("Library of Congress Authorities", {:language=>"en"})
|
41
|
+
|
42
|
+
And assert them
|
43
|
+
|
44
|
+
>> resource.assert("http://purl.org/dc/terms/source", source)
|
45
|
+
|
46
|
+
=> ["Work cat.: 2002070545: The Semantic Web--ISWC 20002, 2002.", "ASTI on FirstSearch, May 6, 2002: in titles (semantic Web)", "Engr. index online, May 6, 2002 (identifier: Semantic Web)", "Library of Congress Authorities"]
|
47
|
+
|
48
|
+
>> resource["http://purl.org/dc/terms/source"].last.language
|
49
|
+
|
50
|
+
=> "en"
|
51
|
+
|
52
|
+
To relate a resource to another URI you can use #.resource - it will accept full uri strings, safe curies or other RDFObject::Resource objects
|
53
|
+
|
54
|
+
>> resource.relate("[skos:closeMatch]", "http://dbpedia.org/resource/Category:Semantic_Web")
|
55
|
+
|
56
|
+
=> [#<RDFObject::Resource uri="http://stitch.cs.vu.nl/vocabularies/rameau/ark:/12148/cb14521343b">, #<RDFObject::Resource uri="http://dbpedia.org/resource/Category:Semantic_Web">]
|
57
|
+
|
58
|
+
RDFObject::Resources sort of act as singletons
|
59
|
+
|
60
|
+
>> r1 = Resource.new('http://ex.org/ex/1234')
|
61
|
+
|
62
|
+
=> #<RDFObject::Resource uri="http://ex.org/ex/1234">
|
63
|
+
|
64
|
+
>> r1.object_id
|
65
|
+
|
66
|
+
=> 8996290
|
67
|
+
|
68
|
+
>> r2 = Resource.new('http://ex.org/ex/1234')
|
69
|
+
|
70
|
+
=> #<RDFObject::Resource uri="http://ex.org/ex/1234">
|
71
|
+
|
72
|
+
>> r2.object_id
|
73
|
+
|
74
|
+
=> 8996290
|
75
|
+
|
76
|
+
So relationships and assertions are always applied to the same object. These are managed in the RDFObject::Resource class:
|
77
|
+
|
78
|
+
>> Resource.instances
|
79
|
+
|
80
|
+
=> {"http://ex.org/ex/1234"=>#<RDFObject::Resource uri="http://ex.org/ex/1234">}
|
81
|
+
|
82
|
+
You can delete a single resource:
|
83
|
+
|
84
|
+
>> Resource.remove(r1)
|
85
|
+
|
86
|
+
>> Resource.instances
|
87
|
+
=> {}
|
88
|
+
|
89
|
+
Or clear the entire hash:
|
90
|
+
|
91
|
+
>> Resource.reset!
|
92
|
+
|
93
|
+
There are also very crude parsers for ntriples and rdf/xml
|
94
|
+
|
95
|
+
>> resources = Parser.parse(open('lcsh.nt').read)
|
96
|
+
|
97
|
+
>> resources.first
|
98
|
+
|
99
|
+
=> #<RDFObject::Resource n0={"altLabel"=>"Lichen ruber planus", "inScheme"=>[#<RDFObject::Resource uri="http://id.loc.gov/authorities#conceptScheme">, #<RDFObject::Resource uri="http://id.loc.gov/authorities#topicalTerms">], "prefLabel"=>"Lichen planus"}, n1={"sameAs"=>#<RDFObject::Resource uri="info:lc/authorities/sh85076767">}, uri="http://id.loc.gov/authorities/sh85076767#concept", n2={"modified"=>#<DateTime: 211644344801/86400,-1/6,2299161>}, rdf={"type"=>#<RDFObject::Resource uri="http://www.w3.org/2004/02/skos/core#Concept">}>
|
100
|
+
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsinger-rdfobjects
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ross Singer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-07 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: curies
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: builder
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description:
|
56
|
+
email: rossfsinger@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files: []
|
62
|
+
|
63
|
+
files:
|
64
|
+
- README
|
65
|
+
- LICENSE
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/rsinger/RDFObjects/tree
|
68
|
+
licenses:
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.8.6
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: RDFObjects are intended to simplify working with RDF data by providing a (more) Ruby-like interface to resources (thanks to OpenStruct).
|
93
|
+
test_files: []
|
94
|
+
|