Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with hashie 2.1.0+ #2

Open
p-originate opened this issue May 28, 2014 · 6 comments
Open

Does not work with hashie 2.1.0+ #2

p-originate opened this issue May 28, 2014 · 6 comments

Comments

@p-originate
Copy link

Running rake when hashie 2.1.1 is installed there are many failures which all look like this:

     Failure/Error: @response = Geoip2.country('62.219.147.28')
     TypeError:
       superclass mismatch for class Rash
     # ./lib/geoip2/client.rb:79:in `block in connection'
     # ./lib/geoip2/client.rb:74:in `connection'
     # ./lib/geoip2/client.rb:39:in `block in get'
     # ./lib/geoip2/client.rb:67:in `call'
     # ./lib/geoip2/client.rb:67:in `block in preform'
     # ./lib/geoip2/client.rb:66:in `preform'
     # ./lib/geoip2/client.rb:38:in `get'
     # ./lib/geoip2/api/country.rb:5:in `country'
     # ./lib/geoip2.rb:65:in `method_missing'
     # ./spec/api/country_spec.rb:7:in `block (4 levels) in '
     # ./spec/api/country_spec.rb:6:in `block (3 levels) in '

Hashie 2.1.1 defines Rash which is different from rash's Rash.

@vladshub
Copy link
Contributor

@p-originate Thanks I'll check it... didn't see it until now.

@vladshub
Copy link
Contributor

Looks like it's working please tell me if you still have an issue?

ruby-2.1.1/bin/ruby -S rspec ./spec/api/country_spec.rb ./spec/geoip2_spec.rb
[Coveralls] Set up the SimpleCov formatter.
[Coveralls] Using SimpleCov's default settings.
You are using WebMock 1.15.0. VCR is known to work with WebMock >= 1.8.0, < 1.14. It may not work with this version.
..........

Finished in 0.0358 seconds
10 examples, 0 failures

Randomized with seed 20449

@abrambailey
Copy link

Using hashie (3.3.1) + rash (0.2.0) + rails (4.1.4) + ruby (2.1.2p95)

Geoip2.country('70.112.225.219')
TypeError: superclass mismatch for class Rash
    from /home/funkdified/.rvm/gems/[email protected]/gems/rash-0.2.0/lib/rash.rb:5:in `<module:Hashie>'

@abrambailey
Copy link

Any update on this issue?

@abrambailey
Copy link

In the meantime I have a workaround for others

https://gist.github.com/funkdified/4a9ea5aada528489e60e

module GeoHelper

  def maxmind_locate

    uri = URI("https://geoip.maxmind.com/geoip/v2.1/city/#{request.remote_ip}?pretty")

    Net::HTTP.start(uri.host, uri.port,
      :use_ssl => uri.scheme == 'https', 
      :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|

      request = Net::HTTP::Get.new uri.request_uri

      #Key from https://www.maxmind.com/en/my_license_key
      request.basic_auth 'USER_ID', 'USER_KEY'

      response = http.request request # Net::HTTPResponse object

      if response.kind_of? Net::HTTPSuccess
        location_hash = JSON.parse(response.body)
      end
    end
  end
end

@vladshub
Copy link
Contributor

@p-originate, @abrambailey Sorry for the long response (didn't notice that there are updates here)
We don't use Rash in our gem... The Rash gem seems to be deprecated and have moved into the Hashie project. So if you will update hashie to a greater version you will not have this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants