public
Description: Mechanize is a ruby library that makes automated web interaction easy.
Homepage: http://mechanize.rubyforge.org/
Clone URL: git://github.com/aaronp/mechanize.git
Search Repo:
adding history added callback
aaronp (author)
Fri May 09 11:32:51 -0700 2008
commit  119ef6a6cd3cd880c2024cd8dc8cadd18876739c
tree    e5307e04a47d050c9c553146b614f9b35568215d
parent  edd885ecbd8117b1465efdb230a1566a9eaf96ab
...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18
19
...
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -2,18 +2,22 @@
0
 
0
 == 0.7.6
0
 
0
-* Added support for reading Mozilla cookie jars. Thanks Chris Riddoch!
0
-* Ignoring scheme case
0
- http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470642
0
-* Moving text, password, hidden, int to default. Thanks Tim Harper!
0
-* Not encoding tildes in uris. Thanks Bruno. [#19380]
0
-* Resetting request bodys when retrying form posts. Thanks Bruno. [#19379]
0
-* Throwing away keep alive connections on EPIPE and ECONNRESET.
0
-* Duplicating request headers when retrying a 401. Thanks Hiroshi Ichikawa.
0
-* Simulating an EOF error when a response length is bad. Thanks Tobias Gruetzmacher.
0
- http://rubyforge.org/tracker/index.php?func=detail&aid=19178&group_id=1453&atid=5711
0
-* Defaulting option tags to the inner text.
0
- http://rubyforge.org/tracker/index.php?func=detail&aid=19976&group_id=1453&atid=5709
0
+* New Features:
0
+ * Added support for reading Mozilla cookie jars. Thanks Chris Riddoch!
0
+ * Moving text, password, hidden, int to default. Thanks Tim Harper!
0
+ * Mechanize#history_added callback for page loads. Thanks Tobi Reif!
0
+
0
+* Bug Fixes:
0
+ * Ignoring scheme case
0
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470642
0
+ * Not encoding tildes in uris. Thanks Bruno. [#19380]
0
+ * Resetting request bodys when retrying form posts. Thanks Bruno. [#19379]
0
+ * Throwing away keep alive connections on EPIPE and ECONNRESET.
0
+ * Duplicating request headers when retrying a 401. Thanks Hiroshi Ichikawa.
0
+ * Simulating an EOF error when a response length is bad. Thanks Tobias Gruetzmacher.
0
+ http://rubyforge.org/tracker/index.php?func=detail&aid=19178&group_id=1453&atid=5711
0
+ * Defaulting option tags to the inner text.
0
+ http://rubyforge.org/tracker/index.php?func=detail&aid=19976&group_id=1453&atid=5709
0
 
0
 == 0.7.5
0
 
...
70
71
72
 
73
74
75
...
87
88
89
 
90
91
92
...
126
127
128
129
 
130
131
132
...
676
677
678
 
679
680
681
...
70
71
72
73
74
75
76
...
88
89
90
91
92
93
94
...
128
129
130
 
131
132
133
134
...
678
679
680
681
682
683
684
0
@@ -70,6 +70,7 @@
0
     attr_accessor :conditional_requests
0
     attr_accessor :follow_meta_refresh
0
     attr_accessor :verify_callback
0
+ attr_accessor :history_added
0
   
0
     attr_reader :history
0
     attr_reader :pluggable_parser
0
@@ -87,6 +88,7 @@
0
       @read_timeout = nil
0
       @user_agent = AGENT_ALIASES['Mechanize']
0
       @watch_for_set = nil
0
+ @history_added = nil
0
       @ca_file = nil # OpenSSL server certificate file
0
 
0
       # callback for OpenSSL errors while verifying the server certificate
0
@@ -126,7 +128,7 @@
0
   
0
       yield self if block_given?
0
     end
0
-
0
+
0
     def max_history=(length); @history.max_size = length; end
0
     def max_history; @history.max_size; end
0
   
0
@@ -676,6 +678,7 @@
0
   
0
     def add_to_history(page)
0
       @history.push(page, to_absolute_uri(page.uri))
0
+ history_added.call(page) if history_added
0
     end
0
   end
0
 end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1 +1,17 @@
0
+require File.dirname(__FILE__) + "/helper"
0
+
0
+class HistoryAddedTest < Test::Unit::TestCase
0
+ def setup
0
+ @agent = WWW::Mechanize.new
0
+ end
0
+
0
+ def test_history_added_gets_called
0
+ onload = 0
0
+ @agent.history_added = lambda { |page|
0
+ onload += 1
0
+ }
0
+ page = @agent.get('http://localhost/tc_blank_form.html')
0
+ assert_equal(1, onload)
0
+ end
0
+end

Comments

    No one has commented yet.