sbiclient 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/jiji_plugin.rb +13 -1
  2. data/lib/sbiclient.rb +6 -0
  3. metadata +2 -2
data/lib/jiji_plugin.rb CHANGED
@@ -114,7 +114,19 @@ class SBISecuritiesPluginSession
114
114
  rescue
115
115
  # エラーになった場合はセッションを再作成する
116
116
  close
117
- raise $!
117
+
118
+ # セッションタイムアウトの場合1回だけリトライ
119
+ if $!.to_s == "session-time-out"
120
+ @logger.warn "session time out. retry..."
121
+ begin
122
+ session.send( name, *args )
123
+ rescue
124
+ close
125
+ raise $!
126
+ end
127
+ else
128
+ raise $!
129
+ end
118
130
  end
119
131
  }
120
132
  end
data/lib/sbiclient.rb CHANGED
@@ -6,6 +6,8 @@ require 'mechanize'
6
6
  require 'date'
7
7
  require 'kconv'
8
8
  require 'set'
9
+ require 'fileutils'
10
+ require 'uuidtools'
9
11
 
10
12
  #
11
13
  #=== SBI証券アクセスクライアント
@@ -668,6 +670,10 @@ module SBIClient
668
670
  map[pair] = Rate.new( pair, rate[0], rate[1], swap.sell_swap, swap.buy_swap )
669
671
  end
670
672
  }
673
+ if tokens.length <= 0
674
+ raise "session-time-out" if page.body.toutf8 =~ /ログアウト/
675
+ raise SBIClient::Client.error( page )
676
+ end
671
677
  end
672
678
  RATE_REGEX = /◇<A([^>]*)>([^<]*)<\/A>\s*<BR>\s*<CENTER>\s*<B>\s*([\d\-_\.]+)\s*<\/B>\s*<\/CENTER>/
673
679
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbiclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaya Yamauchi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-12 00:00:00 +09:00
12
+ date: 2010-01-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency