pengwynn/octokit — pull request #245 by damian (2013-05-20 09:25:58+00:00)
Title: Ensure file content is properly Base64 encoded

When making a call to the `create_contents` method, the Base64-encoding is causing
Octokit to throw an `UnprocessableEntity` exception, complaining that the content
is not valid Base64.

See the error below:

```ruby
Octokit::UnprocessableEntity: PUT https://api.github.com/repos/Sage/sageone_help_uk/contents/_help/bbb.textile: 422: content is not valid Base64
from /usr/local/opt/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/octokit-50c53ea2579f/lib/faraday/response/raise_octokit_error.rb:22:in `on_complete'
```

It's because of this issue documented here:

http://stackoverflow.com/questions/2620975/strange-n-in-base64-encoded-string-in-ruby

Where the call to Base64 encoding is happening, I've added a small piece of logic
to mimic Ruby 1.9s `strict_encode64` functionality, ensuring we're backward compatible
to Ruby 1.8.7.