code4lib / ruby-oai

a Ruby library for building OAI-PMH clients and servers
MIT License
62 stars 43 forks source link

after upgrading to gem oai (0.1.0) #10

Closed atomotic closed 12 years ago

atomotic commented 12 years ago

after upgrading the gem to latest 0.1.0 i got this error for get_record() o list_records()

/Users/raffaele/.rvm/gems/ruby-1.9.2-p0/gems/oai-0.1.0/lib/oai/client.rb:294:in `gsub': invalid byte sequence in US-ASCII     (ArgumentError)
    from /Users/raffaele/.rvm/gems/ruby-1.9.2-p0/gems/oai-0.1.0/lib/oai/client.rb:294:in `strip_invalid_utf_8_chars'
    from /Users/raffaele/.rvm/gems/ruby-1.9.2-p0/gems/oai-0.1.0/lib/oai/client.rb:175:in `do_request'
from /Users/raffaele/.rvm/gems/ruby-1.9.2-p0/gems/oai-0.1.0/lib/oai/client.rb:144:in `get_record'
from ./get-record.rb:7:in `<main>'

a code example

#!/usr/bin/env ruby -W0
require 'rubygems'
require 'oai'
client = OAI::Client.new 'http://amsdottorato.cib.unibo.it/cgi/oai2', :parser => 'libxml' 
record = client.get_record :identifier => 'oai:amsdottorato.cib.unibo.it:4295'
puts record.record.metadata
cbeer commented 12 years ago

I tried your code example (under ruby 1.9.3, if it matters) and didn't have a problem. Can you help us reproduce the problem?

atomotic commented 12 years ago

i tried again with a fresh user and an empty ruby install from rvm, on osx 10.6, and fails. it works fine on linux

➜ gem env RubyGems Environment:

➜ gem list

* LOCAL GEMS *

builder (3.0.0) faraday (0.8.1) faraday_middleware (0.8.8) multipart-post (1.1.5) oai (0.1.0) rake (0.8.7)

cbeer commented 12 years ago

I tried your code snippet under ruby 1.9.2 and those gems and it still worked for me.

nabeta commented 12 years ago

@atomotic Did you install libxml-ruby gem? I had the same error, but after installing libxml-ruby it worked for me.

atomotic commented 12 years ago

@nabeta: yes, i tried also with and without libxml-ruby.

the problem i think is something in my ENV. if i set

    export LC_ALL=en_US.UTF-8
    export LC_CTYPE=en_US.UTF-8
    export LANG=C

the error returned:

/Users/void/.rvm/gems/ruby-1.9.2-p0@oai/gems/oai-0.1.0/lib/oai/client.rb:293:in `gsub': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (Encoding::CompatibilityError)
    from /Users/void/.rvm/gems/ruby-1.9.2-p0@oai/gems/oai-0.1.0/lib/oai/client.rb:293:in `strip_invalid_utf_8_chars'
    from /Users/void/.rvm/gems/ruby-1.9.2-p0@oai/gems/oai-0.1.0/lib/oai/client.rb:175:in `do_request'
    from /Users/void/.rvm/gems/ruby-1.9.2-p0@oai/gems/oai-0.1.0/lib/oai/client.rb:144:in `get_record'
    from ./get-record.rb:7:in `<main>'

under linux everything works.

atomotic commented 12 years ago

switching to 1.9.3 solved everything.