Skip to content

Commit

Permalink
Can't URI something that is already a URI in Ruby 1.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Apr 23, 2014
1 parent 14447e9 commit 7504567
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/lpxc.rb
Expand Up @@ -60,8 +60,8 @@ def initialize(opts={})
@batch_size = opts[:batch_size] || 300
@flush_interval = opts[:flush_interval] || 0.5
@user_agent = opts[:user_agent] || ENV["LPXC_USER_AGENT"] || "Lpxc (Ruby #{RUBY_VERSION})"
@logplex_url = URI(opts[:logplex_url] || ENV["LOGPLEX_URL"] ||
raise("Must set logplex url."))
@logplex_url = URI((opts[:logplex_url] || ENV["LOGPLEX_URL"] ||
raise("Must set logplex url.")).to_s)

#Keep track of the number of requests that the outlet
#is processing. This value is used by the wait function.
Expand All @@ -79,7 +79,7 @@ def initialize(opts={})
#and use it to send msg using the token from the URL.
def self.puts(msg, url, opts={})
@lock = Mutex.new
url = url.is_a?(URI) ? url : URI.parse(url)
url = url.is_a?(URI) ? url : URI(url)
server = [url.host, url.port, url.scheme]
@clients ||= {}
c = @lock.synchronize { @clients[server] ||= Lpxc.new(:logplex_url => url) }
Expand Down
2 changes: 1 addition & 1 deletion test.rb
Expand Up @@ -112,7 +112,7 @@ def test_flushing_the_client
def test_auto_multiplexing
ts2 = TestServer.new.start(5001)

Lpxc.puts("hello first", LOGPLEX_URL)
Lpxc.puts("hello first", LOGPLEX_URL.to_s)
Lpxc.puts("hello second", 'http://token:second@localhost:5001/logs')
Lpxc.puts("second again", 'http://token:second@localhost:5001/logs')
Lpxc.puts("hello third", 'http://token:third@localhost:5001/logs')
Expand Down

0 comments on commit 7504567

Please sign in to comment.