rdfobjects 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,12 +1,13 @@
1
1
  RDFObjects are intended to simplify working with RDF data by providing a (more) Ruby-like interface to resources (thanks to OpenStruct).
2
2
 
3
3
  Installation:
4
- sudo gem install rsinger-rdfobjects
4
+ The gem is currently hosted at http://gemcutter.org/gems/rdfobjects so you'll either need the gemcutter gem (and run "gem tumble") or add gemcutter.org to your sources manually (gem sources -a http://gemcutter.org)
5
+
6
+ $ sudo gem install rdfobjects
5
7
 
6
8
  Requirements:
7
9
  * Nokogiri (the idea is for more options in the future)
8
10
  * rsinger-curies
9
- * Builder (although, ideally, this will be deprecated)
10
11
  * json (or json_pure)
11
12
 
12
13
  Usage:
@@ -82,6 +83,16 @@ Usage:
82
83
 
83
84
  => {"http://ex.org/ex/1234"=>#<RDFObject::Resource uri="http://ex.org/ex/1234">}
84
85
 
86
+ To override this behavior (i.e. to create another object with the same URI), pass the :force argument:
87
+
88
+ >> r2 = Resource.new('http://ex.org/ex/1234', :force)
89
+
90
+ => #<RDFObject::Resource uri="http://ex.org/ex/1234">
91
+
92
+ >> r2.object_id
93
+
94
+ => 8996310
95
+
85
96
  You can delete a single resource:
86
97
 
87
98
  >> Resource.remove(r1)
@@ -93,7 +104,7 @@ Usage:
93
104
 
94
105
  >> Resource.reset!
95
106
 
96
- There are also very crude parsers for ntriples and rdf/xml
107
+ There are also parsers for ntriples, rdf/xml, RSS 1.0, RDFa, and JSON.
97
108
 
98
109
  >> resources = Parser.parse(open('lcsh.nt').read)
99
110
 
@@ -137,9 +137,9 @@ class XMLParser
137
137
  #
138
138
  def self.parse(doc)
139
139
  namespaces = doc.namespaces
140
- if namespaces.index("http://purl.org/rss/1.0/")
141
- collection = parse_rss10(doc)
142
- elsif namespaces.index("http://www.w3.org/2005/sparql-results#")
140
+ #if namespaces.index("http://purl.org/rss/1.0/")
141
+ # collection = parse_rss10(doc)
142
+ if namespaces.index("http://www.w3.org/2005/sparql-results#")
143
143
  raise "Sorry, SPARQL not yet supported"
144
144
  else
145
145
  collection = parse_rdfxml(doc)
@@ -195,13 +195,13 @@ class XMLParser
195
195
  collection
196
196
  end
197
197
 
198
- def self.parse_rss10(doc)
199
- collection = []
200
- doc.root.xpath("./rss:item","rss"=>"http://purl.org/rss/1.0/").each do | resource_node |
201
- parse_resource_node(resource_node, collection)
202
- end
203
- collection
204
- end
198
+ #def self.parse_rss10(doc)
199
+ # collection = []
200
+ # doc.root.xpath("./rss:item","rss"=>"http://purl.org/rss/1.0/").each do | resource_node |
201
+ # parse_resource_node(resource_node, collection)
202
+ # end
203
+ # collection
204
+ #end
205
205
  end
206
206
 
207
207
  class RDFAParser
@@ -122,12 +122,14 @@ module RDFObject
122
122
  return true
123
123
  end
124
124
 
125
- def self.new(uri)
125
+ def self.new(uri, *opts)
126
126
  #if self.exists?(uri)
127
127
  # return self.instances[uri]
128
128
  #end
129
129
  if exists = self.instances[uri]
130
- return exists
130
+ unless opts.index(:force)
131
+ return exists
132
+ end
131
133
  end
132
134
  super(uri)
133
135
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdfobjects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Singer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-07 00:00:00 -04:00
12
+ date: 2009-10-08 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency