SparqlTransmission 1 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,8 @@ Gem::Specification.new do |spec|
3
3
  spec.name = 'SparqlTransmission'
4
4
  spec.author = 'Michael Sokol'
5
5
  spec.email = 'mikaa123@gmail.com'
6
- spec.homepage = 'http://s139459221.onlinehome.fr/MichaelSokol/'
7
- spec.version = '1'
6
+ spec.homepage = 'http://github.com/mikaa123/SparqlTransmission'
7
+ spec.version = '1.1'
8
8
  spec.summary = 'SparqlTransmission handles SPARQL queries over distant
9
9
  end-point and format the results in a ruby hash'
10
10
  spec.files = %w[
@@ -14,8 +14,14 @@ Gem::Specification.new do |spec|
14
14
  lib/SparqlTransmission.rb
15
15
  tests/SparqlTransmissionTest.rb
16
16
  tests/sparql_response.xml
17
+ tests/sparql_foaf_response.xml
17
18
  examples/example.rb
18
19
  ]
20
+ spec.test_files = %w[
21
+ tests/SparqlTransmissionTest.rb
22
+ tests/sparql_response.xml
23
+ tests/sparql_foaf_response.xml
24
+ ]
19
25
 
20
26
 
21
27
  end
@@ -80,7 +80,15 @@ class SparqlTransmission
80
80
  unless req.is_a? String
81
81
  raise ArgumentError, "The response must be a String"
82
82
  end
83
- doc = REXML::Document.new(req)
83
+
84
+ begin
85
+ doc = REXML::Document.new(req)
86
+ rescue
87
+ # Handle illegal characters here, we are being more permissive over badly
88
+ # formatted XMLs
89
+ req.sub!("&", '')
90
+ retry
91
+ end
84
92
 
85
93
  # Getting the list of sparql variables
86
94
  res = {:variables => doc.elements.collect('sparql/head/variable') do |element|
@@ -27,6 +27,9 @@ class SparqlTransmission_Test < Test::Unit::TestCase
27
27
  assert_equal("subject", result[:variables][0], "Wrong requested variable")
28
28
  assert_equal("http://www.openlinksw.com/schemas/virtrdf#DefaultQuadMap-G", result[:results][0][:subject], "Wrong result")
29
29
  assert_raise(ArgumentError, "ArgumentError not raised") { sq.send(:parse_request, 1) }
30
+ res = String.new
31
+ File.open('tests/sparql_foaf_response.xml').each { |line| res += line }
32
+ result = sq.send(:parse_request, res)
30
33
  end
31
34
 
32
35
  def test_fail