libgss 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/libgss/action_request.rb +15 -6
- data/lib/libgss/async_action_request.rb +2 -13
- data/lib/libgss/network.rb +1 -0
- data/lib/libgss/version.rb +1 -1
- data/spec/libgss/network_spec.rb +3 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd3ebf42ffbb2444212e81cedbe2612ce5c441d
|
4
|
+
data.tar.gz: 2044b93d9d1f33020093e5e6275687fc97724855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10d914ee9d3658a984be8519b4c5f1cfad52392560a356ffbdf03195380858d7e001284866aa6c285445bc2533b21381e7ed84864135be82f9927e69ccae2be
|
7
|
+
data.tar.gz: 0a5f7be36db3014e69908f70628134afb054c56acab954d69c3310c1bb8d72fa785c926d2b4056715ca65a33c312a1cb8c2e02810fccb970ea32739ff6d63f0a
|
data/Gemfile.lock
CHANGED
@@ -55,17 +55,26 @@ module Libgss
|
|
55
55
|
res = Libgss.with_retry("action_request") do
|
56
56
|
@httpclient.post(action_url, {"inputs" => @actions.map(&:to_hash)}.to_json, req_headers)
|
57
57
|
end
|
58
|
+
r = process_response(res, :async_request)
|
59
|
+
@outputs = Outputs.new(r["outputs"])
|
60
|
+
callback.call(@outputs) if callback
|
61
|
+
@outputs
|
62
|
+
end
|
63
|
+
|
64
|
+
def process_response(res, req_type)
|
58
65
|
case res.code.to_i
|
59
66
|
when 200..299 then # OK
|
60
67
|
else
|
61
|
-
raise Error, "failed to send
|
68
|
+
raise Error, "failed to send #{req_type}: [#{res.code}] #{res.content}"
|
69
|
+
end
|
70
|
+
begin
|
71
|
+
return JSON.parse(res.content)
|
72
|
+
rescue JSON::ParserError => e
|
73
|
+
$stderr.puts("\e[31m[#{e.class}] #{e.message}\e[0m\n#{res.content}")
|
74
|
+
raise e
|
62
75
|
end
|
63
|
-
r = JSON.parse(res.body)
|
64
|
-
# puts res.body
|
65
|
-
@outputs = Outputs.new(r["outputs"])
|
66
|
-
callback.call(@outputs) if callback
|
67
|
-
@outputs
|
68
76
|
end
|
77
|
+
private :process_response
|
69
78
|
|
70
79
|
# 条件に該当するデータを取得
|
71
80
|
# @param [String] name 対象となるコレクション名
|
@@ -22,13 +22,7 @@ module Libgss
|
|
22
22
|
# アクション群を実行するために実際にHTTPリクエストを送信します。
|
23
23
|
def send_request(&callback)
|
24
24
|
res = @httpclient.post(action_url, {"inputs" => @actions.map(&:to_hash)}.to_json, req_headers)
|
25
|
-
|
26
|
-
when 200..299 then # OK
|
27
|
-
else
|
28
|
-
raise Error, "failed to send action request: [#{res.code}] #{res.body}"
|
29
|
-
end
|
30
|
-
r = JSON.parse(res.body)
|
31
|
-
# puts res.body
|
25
|
+
r = process_response(res, :async_request)
|
32
26
|
@outputs = Outputs.new(r["outputs"])
|
33
27
|
callback.call(@outputs) if callback
|
34
28
|
|
@@ -43,12 +37,7 @@ module Libgss
|
|
43
37
|
raise Error, "failed to get response. please exec send_request before call." unless @ids
|
44
38
|
|
45
39
|
res = @httpclient.get(result_url, {input_ids: @ids.join(',')}, req_headers)
|
46
|
-
|
47
|
-
when 200..299 then # OK
|
48
|
-
else
|
49
|
-
raise Error, "failed to send action request: [#{res.code}] #{res.body}"
|
50
|
-
end
|
51
|
-
r = JSON.parse(res.body)
|
40
|
+
r = process_response(res, :aync_status)
|
52
41
|
end
|
53
42
|
end
|
54
43
|
end
|
data/lib/libgss/network.rb
CHANGED
data/lib/libgss/version.rb
CHANGED
data/spec/libgss/network_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
require 'uuid'
|
@@ -116,9 +117,10 @@ describe Libgss::Network do
|
|
116
117
|
|
117
118
|
context "JSON parse Error" do
|
118
119
|
before do
|
120
|
+
$stderr.stub(:puts).with(an_instance_of(String)) # $stderrにメッセージが出力されます
|
119
121
|
res = double(:reponse)
|
120
122
|
res.stub(:status).and_return(200)
|
121
|
-
res.should_receive(:content).and_return("invalid JSON format string")
|
123
|
+
res.should_receive(:content).twice.and_return("invalid JSON format string")
|
122
124
|
HTTPClient.any_instance.should_receive(:post).and_return(res)
|
123
125
|
end
|
124
126
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akima
|
@@ -209,3 +209,4 @@ test_files:
|
|
209
209
|
- spec/protected_assets/Icon.png
|
210
210
|
- spec/public_assets/Default.png
|
211
211
|
- spec/spec_helper.rb
|
212
|
+
has_rdoc:
|