td-client 0.8.17 → 0.8.18
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/lib/td/client.rb +2 -2
- data/lib/td/client/api.rb +24 -17
- data/lib/td/client/model.rb +2 -2
- data/lib/td/client/version.rb +1 -1
- metadata +8 -8
data/ChangeLog
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
|
2
|
+
== 2012-06-26 version 0.8.18
|
3
|
+
|
4
|
+
* Client#result_each(&block) uses streaming raed not to read all data into memory
|
5
|
+
* Client#result_format(format, io=nil) supports second argument not to read
|
6
|
+
all data into memory
|
7
|
+
|
8
|
+
|
2
9
|
== 2012-06-11 version 0.8.17
|
3
10
|
|
4
11
|
* Client#jobs supports status option
|
data/lib/td/client.rb
CHANGED
@@ -136,8 +136,8 @@ class Client
|
|
136
136
|
end
|
137
137
|
|
138
138
|
# => result:String
|
139
|
-
def job_result_format(job_id, format)
|
140
|
-
@api.job_result_format(job_id, format)
|
139
|
+
def job_result_format(job_id, format, io=nil)
|
140
|
+
@api.job_result_format(job_id, format, io=nil)
|
141
141
|
end
|
142
142
|
|
143
143
|
# => nil
|
data/lib/td/client/api.rb
CHANGED
@@ -333,25 +333,32 @@ class API
|
|
333
333
|
return result
|
334
334
|
end
|
335
335
|
|
336
|
-
def job_result_format(job_id, format)
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
336
|
+
def job_result_format(job_id, format, io=nil)
|
337
|
+
code, body, res = get("/v3/job/result/#{e job_id}", {'format'=>format}) {|res|
|
338
|
+
if res.code != "200"
|
339
|
+
raise_error("Get job result failed", res)
|
340
|
+
end
|
341
|
+
if io
|
342
|
+
res.read_body {|fragment|
|
343
|
+
io.write(fragment)
|
344
|
+
}
|
345
|
+
end
|
346
|
+
}
|
347
|
+
unless io
|
348
|
+
return body
|
341
349
|
end
|
342
|
-
return body
|
343
350
|
end
|
344
351
|
|
345
352
|
def job_result_each(job_id, &block)
|
346
|
-
# TODO chunked encoding
|
347
353
|
require 'msgpack'
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
354
|
+
get("/v3/job/result/#{e job_id}", {'format'=>'msgpack'}) {|res|
|
355
|
+
if res.code != "200"
|
356
|
+
raise_error("Get job result failed", res)
|
357
|
+
end
|
358
|
+
u = MessagePack::Unpacker.new
|
359
|
+
res.read_body {|fragment|
|
360
|
+
u.feed_each(fragment, &block)
|
361
|
+
}
|
355
362
|
}
|
356
363
|
nil
|
357
364
|
end
|
@@ -857,8 +864,7 @@ class API
|
|
857
864
|
end
|
858
865
|
|
859
866
|
private
|
860
|
-
|
861
|
-
def get(url, params=nil)
|
867
|
+
def get(url, params=nil, &block)
|
862
868
|
http, header = new_http
|
863
869
|
|
864
870
|
path = @base_path + url
|
@@ -870,7 +876,8 @@ class API
|
|
870
876
|
|
871
877
|
request = Net::HTTP::Get.new(path, header)
|
872
878
|
|
873
|
-
response = http.request(request)
|
879
|
+
response = http.request(request, &block)
|
880
|
+
|
874
881
|
return [response.code, response.body, response]
|
875
882
|
end
|
876
883
|
|
data/lib/td/client/model.rb
CHANGED
@@ -239,9 +239,9 @@ class Job < Model
|
|
239
239
|
@result
|
240
240
|
end
|
241
241
|
|
242
|
-
def result_format(format)
|
242
|
+
def result_format(format, io=nil)
|
243
243
|
return nil unless finished?
|
244
|
-
@client.job_result_format(@job_id, format)
|
244
|
+
@client.job_result_format(@job_id, format, io)
|
245
245
|
end
|
246
246
|
|
247
247
|
def result_each(&block)
|
data/lib/td/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70231327028320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70231327028320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70231327027100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.4.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70231327027100
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70231327025120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70231327025120
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
executables: []
|