rdfobjects 0.10.4 → 0.10.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -77,14 +77,16 @@ module RDFObject
77
77
  end
78
78
  else
79
79
  # Check to see if it is a URI being passed
80
- begin
81
- uri = URI.parse(rdf)
82
- if uri.is_a?(URI::HTTP)
83
- response = HTTPClient.fetch(rdf)
84
- rdf = response[:content]
85
- options[:base_uri] = response[:uri]
80
+ if rdf.is_a?(String)
81
+ begin
82
+ uri = Addressable::URI.parse(rdf)
83
+ if uri.ip_based?
84
+ response = HTTPClient.fetch(rdf)
85
+ rdf = response[:content]
86
+ options[:base_uri] = response[:uri]
87
+ end
88
+ rescue URI::InvalidURIError
86
89
  end
87
- rescue URI::InvalidURIError
88
90
  end
89
91
  # Check if the format is XML or RDFa
90
92
  doc = XMLTestDocument.new
@@ -141,7 +143,7 @@ module RDFObject
141
143
  if uri.is_a?(URI)
142
144
  @base_uri = uri
143
145
  else
144
- @base_uri = URI.parse(uri)
146
+ @base_uri = Addressable::URI.parse(uri).normalize
145
147
  end
146
148
  end
147
149
 
@@ -151,7 +153,7 @@ module RDFObject
151
153
  # Return if there's nothing to sanitize with
152
154
  return uri unless self.base_uri
153
155
  begin
154
- u = URI.parse(uri)
156
+ u = Addressable::URI.parse(uri).normalize
155
157
  return uri if u.host
156
158
  fq_uri = self.base_uri+u
157
159
  fq_uri.to_s
@@ -365,7 +367,7 @@ module RDFObject
365
367
  layer[:datatype] = attributes["http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype"] if attributes["http://www.w3.org/1999/02/22-rdf-syntax-ns#datatype"]
366
368
  layer[:language] = attributes["http://www.w3.org/XML/1998/namespace/lang"] if attributes["http://www.w3.org/XML/1998/namespace/lang"]
367
369
  end
368
- layer[:base_uri] = URI.parse(attributes["http://www.w3.org/XML/1998/namespace/base"]) if attributes["http://www.w3.org/XML/1998/namespace/base"]
370
+ layer[:base_uri] = Addressable::URI.parse(attributes["http://www.w3.org/XML/1998/namespace/base"]).normalize if attributes["http://www.w3.org/XML/1998/namespace/base"]
369
371
  @hierarchy << layer
370
372
  attributes_as_assertions(attributes)
371
373
  end
@@ -279,8 +279,8 @@ module RDFObject
279
279
  str = Curie.parse str
280
280
  end
281
281
  begin
282
- uri = URI.parse(str)
283
- return true unless uri.scheme
282
+ uri = Addressable::URI.parse(str).normalize
283
+ return true if uri.scheme.nil? or !uri.scheme =~ /[A-z]/
284
284
  rescue URI::InvalidURIError
285
285
  return true
286
286
  end
data/lib/rdf_objects.rb CHANGED
@@ -2,6 +2,7 @@ module RDFObject
2
2
  require 'rubygems'
3
3
  require 'ostruct'
4
4
  require 'curies'
5
+ require 'addressable/uri'
5
6
  require File.dirname(__FILE__) + '/rdf_objects/parsers'
6
7
  require File.dirname(__FILE__) + '/rdf_objects/rdf_resource'
7
8
  require File.dirname(__FILE__) + '/rdf_objects/curies'
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdfobjects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 10
8
+ - 5
9
+ version: 0.10.5
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ross Singer
@@ -9,29 +14,45 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-08 00:00:00 -05:00
17
+ date: 2010-03-11 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: nokogiri
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  - !ruby/object:Gem::Dependency
26
33
  name: curies
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
27
42
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: addressable
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
30
48
  requirements:
31
49
  - - ">="
32
50
  - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
33
53
  version: "0"
34
- version:
54
+ type: :runtime
55
+ version_requirements: *id003
35
56
  description: RDFObjects are intended to simplify working with RDF data by providing a (more) Ruby-like interface to resources (thanks to OpenStruct).
36
57
  email: rossfsinger@gmail.com
37
58
  executables: []
@@ -68,18 +89,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
89
  requirements:
69
90
  - - ">="
70
91
  - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
71
94
  version: "0"
72
- version:
73
95
  required_rubygems_version: !ruby/object:Gem::Requirement
74
96
  requirements:
75
97
  - - ">="
76
98
  - !ruby/object:Gem::Version
99
+ segments:
100
+ - 0
77
101
  version: "0"
78
- version:
79
102
  requirements:
80
103
  - json, json_pure or json-ruby required for parsing RDF/JSON
81
104
  rubyforge_project:
82
- rubygems_version: 1.3.5
105
+ rubygems_version: 1.3.6
83
106
  signing_key:
84
107
  specification_version: 3
85
108
  summary: A DSL for working with RDF resources.