iegrip 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/iegrip/version.rb +1 -1
  3. data/lib/iegrip.rb +25 -55
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a78290a723f60f0929a7e1d8b6e7d97b2bb566b
4
- data.tar.gz: b30e5c693a66a4ad3fb61db39fc91de3d2df02a9
3
+ metadata.gz: a55cb782794185c96981b40e9d8fb3dbc581c790
4
+ data.tar.gz: 53e9fcd29af463de2f01bf242b66eb6507c9c691
5
5
  SHA512:
6
- metadata.gz: 1c8952c817e112b7bb4bb795927f738063c424a9ca3dc06180e4ac2adcfa38649584a089e3e9d1594d6a6d0c66d640533e1091d0fe8ad11bfcb1c345d34d4387
7
- data.tar.gz: a11a97cd49eee04f2c31591ab3321bf53d15cad44707b7692b7e6aee1ad6ced7bf50950aa4333c53fc717050840f5da6762ad0c12ba9870ac8a96e245d05efc7
6
+ metadata.gz: 5e38a0226fa11e5407f714207501babe0f66aea10496e931cdc2aa7ad26912c7d007f6d49076470700a8d8c744f47b639039ddb75adc4936943fad78b3ea05d8
7
+ data.tar.gz: d1502bb2bc459d062624f1be74e936ca0beaf1792c389b92574135ef580e19ee1f05efd9e914d59a06138da74b3e589a25a2b015ea42d670c5024fdfbba2fbd4
@@ -1,3 +1,3 @@
1
1
  module IEgrip
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/iegrip.rb CHANGED
@@ -21,9 +21,8 @@ module IEgrip
21
21
  ver = fs.GetFileVersion(@raw_object.FullName)
22
22
  @majorVersion = ver.split(/\./)[0].to_i
23
23
  @urlDownloadToFile = Win32API.new('urlmon', 'URLDownloadToFileA', %w(l p p l l), 'l')
24
- #@event = WIN32OLE_EVENT.new(@raw_object,"DWebBrowserEvents2")
25
- @downloading = 0
26
- #setup_event()
24
+ @event = WIN32OLE_EVENT.new(@raw_object,"DWebBrowserEvents2")
25
+ setup_event()
27
26
  end
28
27
 
29
28
  def version
@@ -35,22 +34,23 @@ module IEgrip
35
34
  end
36
35
 
37
36
  def navigate(url)
37
+ before_wait()
38
38
  @raw_object.navigate(url)
39
- sleep 0.5
40
39
  wait_stable()
41
40
  end
42
41
 
42
+ def before_wait()
43
+ @location_url = nil
44
+ @complete_flag = nil
45
+ end
46
+
43
47
  COMPLETE_STATE = 4
44
- def wait_stable()
45
- stable_counter = 0
48
+ def wait_stable(timeout=30)
49
+ start_time = Time.now
46
50
  loop do
47
- break if stable_counter >= 3
48
- if (@raw_object.Busy != true) and (@raw_object.ReadyState == COMPLETE_STATE)
49
- stable_counter += 1
50
- else
51
- sleep 0.5
52
- stable_counter = 0
53
- end
51
+ break if @complete_flag
52
+ break if (Time.now - start_time) > timeout
53
+ WIN32OLE_EVENT.message_loop
54
54
  end
55
55
  end
56
56
 
@@ -61,52 +61,16 @@ module IEgrip
61
61
  private
62
62
 
63
63
  def setup_event()
64
- @event.on_event("BeforeNavigate2") {
65
- @downloading += 1
66
- #puts " BeforeNavigate2. @downloading=#{@downloading}"
64
+ @event.on_event("NavigateComplete2") {|param|
65
+ unless @location_url # Keep First location
66
+ @location_url = param.LocationURL
67
+ end
67
68
  }
68
- #@event.on_event("CommandStateChange") {
69
- # puts " CommandStateChange"
70
- #}
71
69
  @event.on_event("DocumentComplete") {|param|
72
- # a document is completely loaded and initialized.
73
- if param.LocationURL == @raw_object.LocationURL
74
- @downloading = 0
75
- #puts " DocumentComplete. LocationURL match! : #{param.LocationURL} @downloading=#{@downloading}"
76
- else
77
- @downloading -= 1 if @downloading > 0
78
- #puts " DocumentComplete. #{param.LocationURL} @downloading=#{@downloading}"
70
+ if @location_url == param.LocationURL
71
+ @complete_flag = true
79
72
  end
80
73
  }
81
- #@event.on_event("DownloadBegin") {
82
- # # a navigation operation begins.
83
- # puts " DownloadBegin. "
84
- #}
85
- #@event.on_event("DownloadComplete") {
86
- # # a navigation operation finishes, is halted, or fails.
87
- # puts " Download Complete."
88
- #}
89
- #@event.on_event("NavigateComplete2") {
90
- # # a navigation to a link is completed on a window element or a frameSet element.
91
- # puts " NavigateComplete2."
92
- #}
93
- #@event.on_event("NewProcess") {
94
- # puts " NewProcess"
95
- #}
96
- #@event.on_event("ProgressChange") {
97
- # puts " ProgressChange"
98
- #}
99
- #@event.on_event("PropertyChange") {
100
- # puts " PropertyChange"
101
- #}
102
- #@event.on_event("StatusTextChange") {
103
- # puts " StatusTextChange"
104
- #}
105
- #@event.on_event("UpdatePageStatus") {
106
- # puts " UpdatePageStatus"
107
- #}
108
-
109
-
110
74
  end
111
75
  end
112
76
 
@@ -213,6 +177,7 @@ module IEgrip
213
177
 
214
178
  def get_inner(tag)
215
179
  inner = [tag.tagName]
180
+
216
181
  outer = nil
217
182
  inner.push "id='#{tag.ID}'" if tag.ID != ""
218
183
  case tag.tagName
@@ -473,6 +438,7 @@ module IEgrip
473
438
  alias text value
474
439
 
475
440
  def click
441
+ @ie_obj.before_wait()
476
442
  if @ie_obj.version >= 10
477
443
  @raw_object.click(false)
478
444
  else
@@ -545,6 +511,10 @@ module IEgrip
545
511
  end
546
512
  end
547
513
 
514
+ def document
515
+ Document.new(@raw_object.document, @ie_obj)
516
+ end
517
+
548
518
  private
549
519
 
550
520
  def replace_cr_code(text)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iegrip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yac4423
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-21 00:00:00.000000000 Z
11
+ date: 2014-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler