floere/picky — pull request #69 by rogerbraun (2012-01-25 15:12:28+00:00)
Title: Workaround for Yajl encoding problems

I don't really know what triggers this, but with Picky integrated in my Rails app, I get this error when dumping the index:

```ruby
ruby-1.9.3-p0 :006 > BookIndex.dump
Encoding::UndefinedConversionError: "\xE5" from ASCII-8BIT to UTF-8
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72:in `write'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72:in `encode'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/yajl-ruby-1.1.0/lib/yajl.rb:72:in `encode'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/backends/memory/json.rb:35:in `block in dump_json'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/backends/memory/json.rb:34:in `open'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/backends/memory/json.rb:34:in `dump_json'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/backends/memory/json.rb:27:in `dump'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/bundle_indexing.rb:34:in `dump'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/category.rb:80:in `dump'
from (__DELEGATION__):2:in `block in dump'
from (__DELEGATION__):2:in `each'
from (__DELEGATION__):2:in `dump'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/picky-4.1.0/lib/picky/index.rb:92:in `dump'
from (irb):4
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands/console.rb:45:in `start'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands/console.rb:8:in `start'
from /home/roger/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.1/lib/rails/commands.rb:40:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'ruby-1.9.3-p0 :005 >
```

This seems to be an error in Yajl, as changing the way the file is written makes it work. This is a workaround for this problem.