rdfobjects 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module RDFObject
7
7
  def self.fetch(uri)
8
8
  @@proxies.each do | key, proxy |
9
9
  if uri.match(key)
10
- uri = proxy.proxy_uri(uri, ['ntriples','rdf'])
10
+ uri = proxy.proxy_uri(uri, ['json', 'ntriples','rdf'])
11
11
  end
12
12
  end
13
13
  u = URI.parse(uri)
@@ -115,95 +115,7 @@ module RDFObject
115
115
  end
116
116
  return true
117
117
  end
118
-
119
- def to_xml
120
- doc = Builder::XmlMarkup.new
121
- xmlns = {}
122
- i = 1
123
- @namespaces.each do | ns |
124
- next if ns == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
125
- xmlns["xmlns:n#{i}"] = ns
126
- i += 1
127
- end
128
- doc.rdf :Description,xmlns.merge({:about=>uri}) do | rdf |
129
- self.instance_variables.each do | ivar |
130
- next unless ivar =~ /^@n[0-9]*_/
131
- prefix, tag = ivar.split('_',2)
132
- attrs = {}
133
- curr_attr = self.instance_variable_get("#{ivar}")
134
- prefix.sub!(/^@/,'')
135
- prefix = 'rdf' if prefix == 'n0'
136
- unless curr_attr.is_a?(Array)
137
- curr_attr = [curr_attr]
138
- end
139
- curr_attr.each do | val |
140
- if val.is_a?(RDFResource)
141
- attrs['rdf:resource'] = val.uri
142
- end
143
- if @modifiers[val.object_id]
144
- if @modifiers[val.object_id][:language]
145
- attrs['xml:lang'] = @modifiers[val.object_id][:language]
146
- end
147
- if @modifiers[val.object_id][:type]
148
- attrs['rdf:datatype'] = @modifiers[val.object_id][:type]
149
- end
150
- end
151
- unless attrs['rdf:resource']
152
- rdf.tag!("#{prefix}:#{tag}", attrs, val)
153
- else
154
- rdf.tag!("#{prefix}:#{tag}", attrs)
155
- end
156
- end
157
- end
158
- end
159
- doc.target!
160
- end
161
-
162
- def to_rss
163
- doc = Builder::XmlMarkup.new
164
- xmlns = {}
165
- i = 1
166
- @namespaces.each do | ns |
167
- next if ns == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
168
- xmlns["xmlns:n#{i}"] = ns
169
- i += 1
170
- end
171
- xmlns["xmlns:rss"] = "http://purl.org/rss/1.0/"
172
- doc.rdf :RDF, xmlns do | rdf |
173
- rdf.item :about=>uri do | item |
174
- self.instance_variables.each do | ivar |
175
- next unless ivar =~ /^@n[0-9]*_/
176
- prefix, tag = ivar.split('_',2)
177
- attrs = {}
178
- curr_attr = self.instance_variable_get("#{ivar}")
179
- prefix.sub!(/^@/,'')
180
- prefix = 'rdf' if prefix == 'n0'
181
- unless curr_attr.is_a?(Array)
182
- curr_attr = [curr_attr]
183
- end
184
- curr_attr.each do | val |
185
- if val.is_a?(RDFResource)
186
- attrs['rdf:resource'] = val.uri
187
- end
188
- if @modifiers[val.object_id]
189
- if @modifiers[val.object_id][:language]
190
- attrs['xml:lang'] = @modifiers[val.object_id][:language]
191
- end
192
- if @modifiers[val.object_id][:type]
193
- attrs['rdf:datatype'] = @modifiers[val.object_id][:type]
194
- end
195
- end
196
- unless attrs['rdf:resource']
197
- item.tag!("#{prefix}:#{tag}", attrs, val)
198
- else
199
- item.tag!("#{prefix}:#{tag}", attrs)
200
- end
201
- end
202
- end
203
- end
204
- end
205
- doc.target!
206
- end
118
+
207
119
  def self.new(uri)
208
120
  if self.exists?(uri)
209
121
  return self.instances[uri]
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Singer