unageanu-jiji 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog
CHANGED
@@ -21,7 +21,7 @@ module JIJI
|
|
21
21
|
def input_infos
|
22
22
|
[ Input.new( :user, "Please input a user name of CLICK Securities DEMO Trade.", false, nil ),
|
23
23
|
Input.new( :password, "Please input a password of CLICK Securities DEMO Trade.", true, nil ),
|
24
|
-
Input.new( :proxy, "Please input a proxy. example:
|
24
|
+
Input.new( :proxy, "Please input a proxy. example: http://example.com:80 (default: nil )", false, nil )]
|
25
25
|
end
|
26
26
|
|
27
27
|
#プラグインを初期化します。
|
@@ -20,25 +20,30 @@ end
|
|
20
20
|
|
21
21
|
module JIJI
|
22
22
|
module Plugin
|
23
|
-
|
23
|
+
|
24
24
|
#
|
25
25
|
#==クリック証券へのアクセスを集約するためのサービス
|
26
26
|
#
|
27
27
|
class SingleClickClient
|
28
|
-
|
28
|
+
include HTTPClient::Timeout
|
29
|
+
|
29
30
|
def initialize( conf, logger )
|
30
31
|
@conf = conf
|
31
32
|
@logger = logger
|
32
33
|
@mutex = Mutex.new
|
33
34
|
end
|
34
|
-
|
35
|
+
|
35
36
|
#リクエストを送付する。
|
36
37
|
#ブロックの第1引数としてセッションが渡される。
|
37
38
|
def request( &block )
|
38
39
|
@mutex.synchronize {
|
39
40
|
begin
|
40
41
|
@session = create_session unless @session
|
41
|
-
@session.request
|
42
|
+
@session.request {|fx|
|
43
|
+
#timeout( conf[:timeout] || 60 ) {
|
44
|
+
yield fx
|
45
|
+
#}
|
46
|
+
}
|
42
47
|
rescue Exception
|
43
48
|
begin
|
44
49
|
# セッション切れの場合、再作成して再実行してみる。
|
@@ -60,7 +65,7 @@ module JIJI
|
|
60
65
|
end
|
61
66
|
}
|
62
67
|
end
|
63
|
-
|
68
|
+
|
64
69
|
#サービスを破棄する。
|
65
70
|
#不要になった場合、必ず実行すること。
|
66
71
|
def close
|
@@ -69,15 +74,19 @@ module JIJI
|
|
69
74
|
end
|
70
75
|
attr :conf, true
|
71
76
|
attr :logger, true
|
72
|
-
|
77
|
+
|
73
78
|
private
|
74
79
|
def create_session
|
75
80
|
return Session.new { |wait|
|
76
81
|
logger.info "start single click client."
|
77
82
|
begin
|
78
83
|
JIJI::Util.log_if_error_and_throw( @logger ) {
|
79
|
-
|
80
|
-
|
84
|
+
proxy = nil
|
85
|
+
if conf.key?(:proxy) && conf[:proxy] != nil && conf[:proxy].length > 0
|
86
|
+
proxy = conf[:proxy]
|
87
|
+
end
|
88
|
+
client = ClickClient::Client.new( proxy )
|
89
|
+
client.host_name = conf[:host] ? conf[:host] : "https://fx-demo.click-sec.com"
|
81
90
|
@logger.info "connect host=#{client.host_name}, user=#{conf[:user]}"
|
82
91
|
client.fx_session(conf[:user], conf[:password]){|fx|
|
83
92
|
wait.call( fx )
|
@@ -91,7 +100,7 @@ module JIJI
|
|
91
100
|
}
|
92
101
|
end
|
93
102
|
end
|
94
|
-
|
103
|
+
|
95
104
|
#接続エラー時に使用するセッション
|
96
105
|
#常にエラーをスローする。
|
97
106
|
class ErrorSession
|
@@ -102,6 +111,6 @@ module JIJI
|
|
102
111
|
raise @error
|
103
112
|
end
|
104
113
|
end
|
105
|
-
|
114
|
+
|
106
115
|
end
|
107
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unageanu-jiji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaya Yamauchi
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.5
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: highline
|