Remove some duplication

Just refactorings, and added a *.travis.yml* file. Warning: this pull breaks compatibility with Ruby 1.8. You may want to refuse it or pull to a branch if you care about that. Rails will drop 1.8 in the next minor release, so the time to pull the plug on 1.8 might have come.