nesstar-api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nesstar-api.rb CHANGED
@@ -115,10 +115,19 @@ module Nesstar
115
115
  ddi_uri = URI.parse(uri)
116
116
  ddi_uri.merge!("/obj/fStudy/" + dataset)
117
117
  ddi_uri.merge!('?http://www.nesstar.org/rdf/method=http://www.nesstar.org/rdf/Dataset/GetDDI')
118
- res = Net::HTTP.get(ddi_uri)
119
- gz = Zlib::GzipReader.new(StringIO.new(res))
120
- xml = gz.read
121
- return xml
118
+ req = Net::HTTP::Get.new(ddi_uri.path)
119
+ res = Net::HTTP.start(ddi_uri.host, ddi_uri.port) {|http| http.request(req) }
120
+ if res.code == "200"
121
+ if res['content-encoding'] == "gzip"
122
+ gz = Zlib::GzipReader.new(StringIO.new(res.body))
123
+ xml = gz.read
124
+ return xml
125
+ else
126
+ return res.body
127
+ end
128
+ else
129
+ raise 'There was a problem retrieving the document'
130
+ end
122
131
  end
123
132
 
124
133
  #return a catalog object with information inside it
@@ -1,5 +1,5 @@
1
1
  module Nesstar
2
2
  module Api
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nesstar-api
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease:
5
- version: 0.0.3
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
6
11
  platform: ruby
7
12
  authors:
8
13
  - Ian Dunlop
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-11 00:00:00 +00:00
18
+ date: 2011-10-05 00:00:00 +01:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,11 @@ dependencies:
21
26
  requirements:
22
27
  - - "="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 4
24
34
  version: 1.4.4
25
35
  type: :runtime
26
36
  version_requirements: *id001
@@ -32,6 +42,11 @@ dependencies:
32
42
  requirements:
33
43
  - - "="
34
44
  - !ruby/object:Gem::Version
45
+ hash: 61
46
+ segments:
47
+ - 0
48
+ - 8
49
+ - 1
35
50
  version: 0.8.1
36
51
  type: :runtime
37
52
  version_requirements: *id002
@@ -41,8 +56,13 @@ dependencies:
41
56
  requirement: &id003 !ruby/object:Gem::Requirement
42
57
  none: false
43
58
  requirements:
44
- - - "="
59
+ - - ">="
45
60
  - !ruby/object:Gem::Version
61
+ hash: 27
62
+ segments:
63
+ - 1
64
+ - 1
65
+ - 4
46
66
  version: 1.1.4
47
67
  type: :runtime
48
68
  version_requirements: *id003
@@ -79,17 +99,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
99
  requirements:
80
100
  - - ">="
81
101
  - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
82
105
  version: "0"
83
106
  required_rubygems_version: !ruby/object:Gem::Requirement
84
107
  none: false
85
108
  requirements:
86
109
  - - ">="
87
110
  - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
88
114
  version: "0"
89
115
  requirements: []
90
116
 
91
117
  rubyforge_project: nesstar-api
92
- rubygems_version: 1.5.2
118
+ rubygems_version: 1.6.2
93
119
  signing_key:
94
120
  specification_version: 3
95
121
  summary: Simple API for calling NESSTAR API and returning results