Here is an weird situation, hope you can help me with a reason:
require "open-uri"
class TraceParser
def starttorip
url = 'http://yahoo.com'
proxy_addr = 'http://my proxy server:'
proxy_port = 1010
begin
open(url, :proxy => (proxy_addr + proxy_port.to_s)) do |source|
source.each_line do |x|
puts x
end
end
end
end
varb = TraceParser.new
varb.starttorip
end
Above code works like a charm, and everything is rosy. But, when I change the proxy definition to something like this:
require "open-uri"
class TraceParser
def starttorip
url = 'http://yahoo.com'
begin
open (url, :proxy => 'http://my proxy server:1010') do |source|
source.each_line do |x|
puts x
end
end
end
end
varb = TraceParser.new
varb.starttorip
end
Everything breaks loose:
/tracerparser.rb:6: syntax error, unexpected ',', expecting ')' (SyntaxError)
open (url, :proxy => "my proxy server...
From what I understand, the first one is splitting proxy defn into two strings and appending to the open gem. Thanks for sharing your inputs.
The problem is the space after the
open, it has nothing to do with the proxy map entry.