philnash / bitly

🗜 A Ruby wrapper for the bit.ly API
https://rubygems.org/gems/bitly
MIT License
451 stars 139 forks source link

v3.rb file is causing some naming conflicts and load order problems #45

Closed halloffame closed 8 years ago

halloffame commented 11 years ago

I came across this problem because when gem 'version' was included after gem 'bitly', it would cause an error when I tried to run a rake task.

undefined method 'to_version' for "1.2.8":String

When I included gem 'version' first, it would run without problems.

So, I think what is happening is that the line $:.unshift File.dirname(__FILE__) is including all of the /lib/bitly files in the load path and causing naming conflicts. Is there a reason why that line is in there at all? I changed the file to look like this and it fixed the problem.

# /lib/bitly/v3.rb
require 'httparty'
require 'cgi'
require 'oauth2'

require 'bitly/v3/bitly'
require 'bitly/v3/client'
require 'bitly/v3/url'
require 'bitly/v3/referrer'
require 'bitly/v3/day'
require 'bitly/v3/country'
require 'bitly/v3/missing_url'
require 'bitly/v3/realtime_link'
require 'bitly/v3/oauth'
require 'bitly/v3/user'