rsinger-rdfobjects 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. data/lib/rdf_objects/http_client.rb +40 -39
  2. metadata +2 -3
@@ -1,54 +1,55 @@
1
1
  require 'net/http'
2
2
  require 'uri'
3
3
  require 'cgi'
4
-
5
- class HTTPClient
6
- @@proxies = {}
7
- def self.fetch(uri)
8
- @@proxies.each do | key, proxy |
9
- if uri.match(key)
10
- uri = proxy.proxy_uri(uri, ['ntriples','rdf'])
4
+ module RDFObject
5
+ class HTTPClient
6
+ @@proxies = {}
7
+ def self.fetch(uri)
8
+ @@proxies.each do | key, proxy |
9
+ if uri.match(key)
10
+ uri = proxy.proxy_uri(uri, ['ntriples','rdf'])
11
+ end
11
12
  end
13
+ u = URI.parse(uri)
14
+ request = Net::HTTP::Get.new(u.request_uri)
15
+ request['accept'] = nil
16
+ request['accept'] = ['application/rdf+xml']
17
+ response = Net::HTTP.start(u.host, u.port) do | http |
18
+ http.request(request)
19
+ end
20
+ if response.code != "200"
21
+ raise response.message
22
+ end
23
+ response.body
12
24
  end
13
- u = URI.parse(uri)
14
- request = Net::HTTP::Get.new(u.request_uri)
15
- request['accept'] = nil
16
- request['accept'] = ['application/rdf+xml']
17
- response = Net::HTTP.start(u.host, u.port) do | http |
18
- http.request(request)
19
- end
20
- if response.code != "200"
21
- raise response.message
22
- end
23
- response.body
24
- end
25
25
 
26
- def self.register_proxy(uri,proxy)
27
- @@proxies[uri] = proxy
26
+ def self.register_proxy(uri,proxy)
27
+ @@proxies[uri] = proxy
28
+ end
28
29
  end
29
- end
30
30
 
31
31
 
32
- class TalisPlatformProxy
33
- attr_reader :store
34
- @@formats = ['rdf','ntriples','turtle','json']
35
- def initialize(store_name)
36
- @store = store_name
37
- end
32
+ class TalisPlatformProxy
33
+ attr_reader :store
34
+ @@formats = ['rdf','ntriples','turtle','json']
35
+ def initialize(store_name)
36
+ @store = store_name
37
+ end
38
38
 
39
- def proxy_uri(uri, format=['rdf'])
40
- idx = 0
41
- best_format = nil
42
- while !best_format
43
- @@formats.each do | fmt |
44
- if format[idx] == fmt
45
- best_format = fmt
46
- break
39
+ def proxy_uri(uri, format=['rdf'])
40
+ idx = 0
41
+ best_format = nil
42
+ while !best_format
43
+ @@formats.each do | fmt |
44
+ if format[idx] == fmt
45
+ best_format = fmt
46
+ break
47
+ end
47
48
  end
49
+ idx += 1
48
50
  end
49
- idx += 1
51
+ raise "No compatible response format!" if !best_format
52
+ "http://api.talis.com/stores/#{@store}/meta?about=#{CGI.escape(uri)}&output=#{best_format}"
50
53
  end
51
- raise "No compatible response format!" if !best_format
52
- "http://api.talis.com/stores/#{@store}/meta?about=#{CGI.escape(uri)}&output=#{best_format}"
53
54
  end
54
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsinger-rdfobjects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Singer
@@ -65,7 +65,6 @@ files:
65
65
  - lib/xsl/rdf2nt.xsl
66
66
  has_rdoc: false
67
67
  homepage: http://github.com/rsinger/RDFObjects/tree
68
- licenses:
69
68
  post_install_message:
70
69
  rdoc_options:
71
70
  - --charset=UTF-8
@@ -86,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
85
  requirements: []
87
86
 
88
87
  rubyforge_project:
89
- rubygems_version: 1.3.5
88
+ rubygems_version: 1.2.0
90
89
  signing_key:
91
90
  specification_version: 3
92
91
  summary: A DSL for working with RDF resources.