[BioRuby-cvs] bioruby/lib/bio command.rb,1.15,1.16
Katayama Toshiaki
k at dev.open-bio.org
Thu Mar 29 12:14:48 UTC 2007
Update of /home/repository/bioruby/bioruby/lib/bio
In directory dev.open-bio.org:/tmp/cvs-serv10963/lib/bio
Modified Files:
command.rb
Log Message:
* routine for generating CGI arguments is separated from post_form to make_cgi_params
Index: command.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/command.rb,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** command.rb 28 Mar 2007 16:54:11 -0000 1.15
--- command.rb 29 Mar 2007 12:14:46 -0000 1.16
***************
*** 277,292 ****
end
! data = ""
case params
when Hash
data = params.map do |key, val|
! "#{URI.escape(key.to_s)}=#{URI.escape(val.to_s)}"
end.join('&')
when Array
case params.first
! when Hash, Array
data = params.map do |key, val|
! "#{URI.escape(key.to_s)}=#{URI.escape(val.to_s)}"
end.join('&')
when String
--- 277,311 ----
end
! data = make_cgi_params(params)
!
! hash = {
! 'Content-Type' => 'application/x-www-form-urlencoded',
! 'Content-Length' => data.length.to_s
! }
! hash.update(header)
!
! start_http(uri.host, uri.port) do |http|
! http.post(uri.path, data, hash)
! end
! end
+ def make_cgi_params(params)
+ data = ""
case params
when Hash
data = params.map do |key, val|
! make_cgi_params_key_value(key, val)
end.join('&')
when Array
case params.first
! when Hash
! data = params.map do |hash|
! hash.map do |key, val|
! make_cgi_params_key_value(key, val)
! end
! end.join('&')
! when Array
data = params.map do |key, val|
! make_cgi_params_key_value(key, val)
end.join('&')
when String
***************
*** 298,311 ****
data = URI.escape(params.strip)
end
! hash = {
! 'Content-Type' => 'application/x-www-form-urlencoded',
! 'Content-Length' => data.length.to_s
! }
! hash.update(header)
!
! start_http(uri.host, uri.port) do |http|
! http.post(uri.path, data, hash)
end
end
--- 317,334 ----
data = URI.escape(params.strip)
end
+ return data
+ end
! def make_cgi_params_key_value(key, value)
! result = []
! case value
! when Array
! value.each do |val|
! result << [key, val].map {|x| URI.escape(x.to_s) }.join('=')
! end
! else
! result << [key, value].map {|x| URI.escape(x.to_s) }.join('=')
end
+ return result
end
More information about the bioruby-cvs
mailing list