clickclient_scrap 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,4 +1,6 @@
1
-
1
+ 2012-05-02 0.1.1
2
+ * クリック証券デモトレードの仕様変更に対応
3
+
2
4
  2010-03-20 0.1.10
3
5
  * クリック証券デモ取引用jijiプラグインを実装
4
6
  * 建玉が6以上あると建玉一覧の取得、および約定が正しく行えない問題を修正
@@ -8,6 +8,7 @@ require 'mechanize'
8
8
  require 'date'
9
9
  require 'kconv'
10
10
  require 'set'
11
+ require 'logger'
11
12
 
12
13
  #
13
14
  #=== クリック証券アクセスクライアント
@@ -40,7 +41,7 @@ module ClickClientScrap
40
41
  class Client
41
42
  # ホスト名
42
43
  DEFAULT_HOST_NAME = "https://sec-sso.click-sec.com/mf/"
43
- DEFAULT_DEMO_HOST_NAME = "https://www.click-sec.com/m/demo/"
44
+ DEFAULT_DEMO_HOST_NAME = "https://fx-demo.click-sec.com/ygmo/servlet/login?FAGD=2"
44
45
 
45
46
  #
46
47
  #===コンストラクタ
@@ -59,6 +60,7 @@ module ClickClientScrap
59
60
  @client.keep_alive = false
60
61
  @client.max_history=0
61
62
  @client.user_agent_alias = 'Windows IE 7'
63
+ #@client.log = Logger.new("log.txt")
62
64
  @demo = demo
63
65
  @host_name = @demo ? DEFAULT_DEMO_HOST_NAME : DEFAULT_HOST_NAME
64
66
  end
@@ -78,7 +80,9 @@ module ClickClientScrap
78
80
  form = page.forms.first
79
81
  form.j_username = userid
80
82
  form.j_password = password
81
- result = @client.submit(form, form.buttons.first)
83
+ form.WIN_NAME = "CLICK_FX_HOME_TRADE" if @demo
84
+ result = @client.submit(form, form.buttons.first)
85
+
82
86
  # デモサイトではjsによるリダイレクトは不要。
83
87
  if !@demo
84
88
  if result.body.toutf8 =~ /<META HTTP-EQUIV="REFRESH" CONTENT="0;URL=([^"]*)">/
@@ -203,7 +207,7 @@ module ClickClientScrap
203
207
  #戻り値:: 通貨ペアをキーとするClickClientScrap::FX::Rateのハッシュ。
204
208
  def list_rates
205
209
  result = link_click( "1" )
206
- if !@last_update_time_of_swaps \
210
+ if !@last_update_time_of_swaps \
207
211
  || Time.now.to_i - @last_update_time_of_swaps > (@options[:swap_update_interval] || 60*60)
208
212
  @swaps = list_swaps
209
213
  @last_update_time_of_swaps = Time.now.to_i
@@ -211,7 +215,7 @@ module ClickClientScrap
211
215
  reg = />([A-Z]+\/[A-Z]+)<\/a>[^\-\.\d]*?([\d]+\.[\d]+)\-[^\-\.\d]*([\d\.]+)/
212
216
  tokens = result.body.toutf8.scan( reg )
213
217
  ClickClientScrap::Client.error( result ) if !tokens || tokens.empty?
214
- return tokens.inject({}) {|r,l|
218
+ return tokens.inject({}) {|r,l|
215
219
  pair = to_pair( l[0] )
216
220
  swap = @swaps[pair]
217
221
  rate = FxSession.convert_rate "#{l[1]}-#{l[2]}"
@@ -638,10 +642,13 @@ module ClickClientScrap
638
642
 
639
643
  # ログアウトします。
640
644
  def logout
641
- @client.click( @links.find {|i|
645
+ begin
646
+ @client.click( @links.find {|i|
642
647
  i.text == "\303\233\302\270\303\236\302\261\302\263\303\204" \
643
648
  || i.text == "ログアウト"
644
- })
649
+ })
650
+ rescue
651
+ end
645
652
  end
646
653
 
647
654
  private
data/spec/common.rb CHANGED
@@ -19,8 +19,8 @@ DEMO_PASS=auth["demo_pass"]
19
19
  # ベース
20
20
  module TestBase
21
21
  # 通常/デモのそれぞれのセッションでブロックを実行する。
22
- def do_test
23
- [#{:c=>ClickClientScrap::Client.new, :p=>PASS, :u=>USER },
22
+ def do_test
23
+ [{:c=>ClickClientScrap::Client.new, :p=>PASS, :u=>USER },
24
24
  {:c=>ClickClientScrap::Client.new(nil, true), :p=>DEMO_PASS, :u=>DEMO_USER }].each {|i|
25
25
  @s = i[:c].fx_session( i[:u], i[:p] )
26
26
  @rates = @s.list_rates
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clickclient_scrap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 11
10
- version: 0.1.11
9
+ - 12
10
+ version: 0.1.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Masaya Yamauchi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 00:00:00 +09:00
18
+ date: 2012-04-30 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  description:
38
- email: y-masaya@red.hot.co.jp
38
+ email: masaya.yamauchi@gmail.com
39
39
  executables: []
40
40
 
41
41
  extensions: []