Permalink
Browse files

merged in RB-0.4.4

git-svn-id: svn+ssh://rubyforge.org/var/svn/mechanize/trunk@103 f1cf478b-080f-0410-abad-959bfeec9ea8
  • Loading branch information...
1 parent d8f7e63 commit 2cf22ce71cf1d10b06616d9c5e4b720abb3fda7d aaronp committed May 13, 2006
Showing with 47 additions and 12 deletions.
  1. +6 −0 CHANGELOG
  2. +9 −0 NOTES
  3. +3 −0 README
  4. +1 −2 Rakefile
  5. +3 −1 lib/mechanize.rb
  6. +1 −1 lib/mechanize/cookie.rb
  7. +7 −3 lib/mechanize/form.rb
  8. +16 −4 lib/mechanize/form_elements.rb
  9. +1 −1 lib/mechanize/mech_version.rb
View
@@ -1,3 +1,9 @@
+== 0.4.4
+
+* Fixed error in method signature, basic_authetication is now basic_auth
+* Fixed bug with encoding names in file uploads (Big thanks to Alex Young)
+* Added options to the select list
+
== 0.4.3
* Added syntactic sugar for finding things
View
@@ -1,5 +1,14 @@
= Mechanize Release Notes
+== 0.4.4
+
+This release of mechanize comes with a new "Option" object that can be
+accessed from select fields on forms. That means that you can figure out
+what option to set based on the text in the select field. For example:
+
+selectlist = form.fields.name('selectlist').first
+selectlist.value = selectlist.options.find { |o| o.text == 'foo'}.value
+
== 0.4.3
The new syntax for finding things like forms, fields, frames, etcetera looks
View
@@ -24,6 +24,9 @@ Copyright (c) 2005 by Michael Neumann (mneumann@ntecs.de)
New Code:
Copyright (c) 2006 by Aaron Patterson (aaronp@rubyforge.org)
+This library comes with a shameless plug for employing me (Aaron) programming
+Ruby, my favorite language!
+
== License
This library is distributed under the GPL. Please see the LICENSE file.
View
@@ -11,7 +11,7 @@ end
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = 'mechanize'
-PKG_VERSION = '0.4.3' + PKG_BUILD
+PKG_VERSION = '0.4.4' + PKG_BUILD
PKG_FILES = FileList["{doc,lib,test}/**/*"].exclude("rdoc").to_a
spec = Gem::Specification.new do |s|
@@ -24,7 +24,6 @@ spec = Gem::Specification.new do |s|
s.summary = "Mechanize provides automated web-browsing"
s.files = Dir.glob("{bin,test,lib,doc}/**/*").delete_if {|item| item.include?(".svn") }
s.require_path = "lib"
- s.autorequire = "mechanize"
s.has_rdoc = true
s.extra_rdoc_files = ["README", "EXAMPLES", "CHANGELOG", "LICENSE", "NOTES"]
s.rdoc_options << "--main" << 'README' << "--title" << "'WWW::Mechanize RDoc'"
View
@@ -102,11 +102,13 @@ def cookies
cookies
end
- def basic_authetication(user, password)
+ def basic_auth(user, password)
@user = user
@password = password
end
+ alias :basic_authetication :basic_auth
+
def get(url)
cur_page = current_page() || Page.new
@@ -16,7 +16,7 @@ def Cookie::parse(uri, raw_cookie, &block)
esc.split(/,/).each do |cookie_text|
cookie_values = Hash.new
cookie = Hash.new
- cookie_text.split(/; /).each do |data|
+ cookie_text.split(/; ?/).each do |data|
name, value = data.split('=', 2)
next unless name
cookie[name] = value ? URI::unescape(value) : nil
View
@@ -148,16 +148,20 @@ def rand_string(len = 10)
string
end
+ def mime_value_quote(str)
+ str.gsub(/(["\r\\])/){|s| '\\' + s}
+ end
+
def param_to_multipart(name, value)
return "Content-Disposition: form-data; name=\"" +
- "#{WEBrick::HTTPUtils.escape_form(name)}\"\r\n" +
+ "#{mime_value_quote(name)}\"\r\n" +
"\r\n#{value}\r\n"
end
def file_to_multipart(file)
body = "Content-Disposition: form-data; name=\"" +
- "#{WEBrick::HTTPUtils.escape_form(file.name)}\"; " +
- "filename=\"#{file.file_name}\"\r\n" +
+ "#{mime_value_quote(file.name)}\"; " +
+ "filename=\"#{mime_value_quote(file.file_name)}\"\r\n" +
"Content-Transfer-Encoding: binary\r\n"
if file.mime_type != nil
body << "Content-Type: #{file.mime_type}\r\n"
@@ -96,12 +96,24 @@ def initialize(name, node)
# parse
node.each_recursive {|n|
if n.name.downcase == 'option'
- value = n.attributes['value']
- @options << value
- @value = value if n.attributes['selected']
+ option = Option.new(n)
+ @options << option
+ @value = option.value if option.selected
end
}
- @value = @options.first if @value == nil
+ @value = @options.first.value if @value == nil
+ end
+ end
+
+ class Option
+ attr_reader :value, :selected, :text
+
+ alias :to_s :value
+
+ def initialize(node)
+ @text = node.all_text
+ @value = node.attributes['value']
+ @selected = node.attributes['selected'] ? true : false
end
end
end
@@ -1,5 +1,5 @@
# DO NOT EDIT
# This file is auto-generated by build scripts
module WWW
- MechVersion = '0.4.3'
+ MechVersion = '0.4.4'
end

0 comments on commit 2cf22ce

Please sign in to comment.