Monday, March 15, 2010

Woo Hoo! A Bug Report!

‹prev | My Chain | next›

I'm pretty excited. I received my first ever bug report on the couch_docs issue tracker. Obviously, I would prefer that my gem just work, but hey, bugs happen. Mostly I'm excited that someone else is trying it out and I definitely want to help out if I can.

First up, I need to stash my code generators work-in-progress:
cstrom@whitefall:~/repos/couch_docs$ git st
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: bin/couch-docs
# modified: lib/couch_docs/command_line.rb
# modified: spec/couch_docs_spec.rb
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# lib/couch_docs/generator.rb
# spec/command_line_spec.rb
# spec/generator_spec.rb
no changes added to commit (use "git add" and/or "git commit -a")
Rather than git stash stashing the work-in-progress, I will branch for 1.2. I am reasonably optimistic that I am on the right path. So:
cstrom@whitefall:~/repos/couch_docs$ git checkout -b 1.2
M bin/couch-docs
M lib/couch_docs/command_line.rb
M spec/couch_docs_spec.rb
Switched to a new branch '1.2'
cstrom@whitefall:~/repos/couch_docs$ git st
# On branch 1.2
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: bin/couch-docs
# modified: lib/couch_docs/command_line.rb
# modified: spec/couch_docs_spec.rb
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# lib/couch_docs/generator.rb
# spec/command_line_spec.rb
# spec/generator_spec.rb
no changes added to commit (use "git add" and/or "git commit -a")
cstrom@whitefall:~/repos/couch_docs$ git add lib/couch_docs/generator.rb spec/command_line_spec.rb spec/generator_spec.rb
cstrom@whitefall:~/repos/couch_docs$ git commit -m "Initial generator support" -a
[1.2 f80a85e] Initial generator support
6 files changed, 222 insertions(+), 109 deletions(-)
create mode 100644 lib/couch_docs/generator.rb
create mode 100644 spec/command_line_spec.rb
create mode 100644 spec/generator_spec.rb
With things checked into the 1.2 branch, I switch back to the master for fixing the issue:
cstrom@whitefall:~/repos/couch_docs$ git checkout master
Switched to branch 'master'
Thanks to a comment from Johannes Jörg Schmidt, it seems likely that the culprit is the version of RestClient that I coded against:
cstrom@whitefall:~/repos/couch_docs$ gem list | grep rest-client
rest-client (1.1.0)
Yup, that seems to be it—Glenn Rempe was using RestClient 1.4 while I coded against 1.1. To address, I bump up the version number on the gem and restrict the version number of the RestClient dependency:
#...
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rest-client>, ["~> 1.1.0"])
#...
The ~> in RubyGems specifies that I want greater than version 1.1.0, but not so much greater that a new minor version is reached (i.e. 1.1.10 is OK, but 1.2.0 is not).

With that I commit my changes:
cstrom@whitefall:~/repos/couch_docs$ git ci -m "Require rest-client version 1.1. closes #1" -a
[master fa542e0] Require rest-client version 1.1. closes #1
3 files changed, 5 insertions(+), 5 deletions(-)
I also update History.txt and the README file. Then I can update my gemspec:
cstrom@whitefall:~/repos/couch_docs$ rake gem:spec
(in /home/cstrom/repos/couch_docs)
Build my gem:
cstrom@whitefall:~/repos/couch_docs$ gem build couch_docs.gemspec
Successfully built RubyGem
Name: couch_docs
Version: 1.1.1
File: couch_docs-1.1.1.gem
And then I push to rubygems.org:
cstrom@whitefall:~/repos/couch_docs$ gem push couch_docs-1.1.1.gem
Pushing gem to Gemcutter...
Successfully registered gem: couch_docs (1.1.1)
Easy enough!

After pushing my changes to github, I test out the fix by uninstalling all of my couch_docs gems, and my RestClient 1.1 gem:
cstrom@whitefall:~/repos/couch_docs$ gem uninstall couch_docs

Select gem to uninstall:
1. couch_docs-1.1.0
2. couch_docs-1.1.1
3. All versions
> 3

#...

cstrom@whitefall:~/repos/couch_docs$ gem uninstall rest-client

Select gem to uninstall:
1. rest-client-1.1.0
2. rest-client-1.4.2
3. All versions
> 1

#...
A fresh install of couch_docs now installs version 1.1.1 of couch_docs, along with the older, locked version of RestClient:
cstrom@whitefall:~/repos/couch_docs$ gem install couch_docs
WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and
/var/lib/gems/1.8/bin aren't both writable.
Successfully installed rest-client-1.1.0
Successfully installed couch_docs-1.1.1
2 gems installed
And, just to be absolutely sure, I am still able to dump design documents from my development database with the freshly installed couch-docs script:
 cstrom@whitefall:~/tmp/dump$ couch-docs dump -d http://localhost:5984/eee
cstrom@whitefall:~/tmp/dump$ find _design/
_design/
_design/relax
_design/relax/lib
_design/relax/lib/super_textile.js
_design/relax/shows
_design/relax/shows/ingredients.js
_design/relax/shows/upload.js
_design/relax/shows/recipe.js
_design/relax/shows/test.js
...
Hopefully that really does resolve the issue. Time will tell!

Day #43

No comments:

Post a Comment