Question

I'm using the ruby-fedora gem to fetch information from my database

Fedora::Repository.instance.fetch_content

I'm positive my code works, because there were no problems before I updated to Ruby 2.1.1. When I execute the code to fetch data, the code from the gem itself (bundle/ruby/2.1.0/gems/ruby-fedora-1.0.5/lib/fedora/connection.rb) produces following error:

undefined method `use_ssl' for #<Net::HTTP 127.0.0.1:8080 open=false>
    bundle/ruby/2.1.0/gems/ruby-fedora-1.0.5/lib/fedora/connection.rb:191:in `http'
    bundle/ruby/2.1.0/gems/ruby-fedora-1.0.5/lib/fedora/connection.rb:152:in `request'

Anyone encountered something like this before? Could it be due to gem incompatibility?

EDIT: I edited the gem code and the line where the problem occurs is:

# Creates new Net::HTTP instance for communication with
# remote service and resources.
def http
  http             = Net::HTTP.new(@site.host, @site.port)
  http.use_ssl     = @site.is_a?(URI::HTTPS)
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl <--- THIS LINE
  http
end

When I replace the function with the following one, everything works fine (as I don't use HTTPS)

# Creates new Net::HTTP instance for communication with
# remote service and resources.
def http
  http             = Net::HTTP.new(@site.host, @site.port)
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @site.is_a?(URI::HTTPS)
  http
end
Était-ce utile?

La solution

It looks like the problem is that ruby-fedora is no longer actively maintained, it seems that the last release was in 2009. Now I'm sure your fix will work but if you require extra help going forward you'll need to hack everything yourself. They don't even appear to have a github page anymore!!

ActiveFedora seems to be an actively maintained project that should suit your needs. Here it is on ruby-gems, the last release was 7 days ago (which IMO beats 5 years ago!!).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top