NUBIC/surveyor — pull request #381 by rsutphin (2012-11-25 17:36:43+00:00)
Title: response_set_methods.rb has unconditional require of fastercsv

`lib/surveyor/models/response_set_methods.rb` includes an unconditional require of `fastercsv`. While the code itself seems to correctly use `FasterCSV` or `CSV` based on context, the fact that `fastercsv` is required at all can interfere with other `CSV`-using code in the same application which hosts Surveyor.

This is possible because both `CSV` and `FasterCSV` define some of the same methods on common classes. For example, both define `Array#to_csv`. In the usual ruby way, the last code to define this method wins. Since Surveyor requires `fastercsv` first, it seems like `CSV` would always win. However, if other code in the host application requires `csv` before `surveyor/models/response_set_methods` is loaded, `fastercsv` will be the last code to define `Array#to_csv`. When this happens, a call to `CSV::Row#to_csv` will throw the following incongruous exception:

```
NotImplementedError:
Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine.
# /Users/rsutphin/.rvm/gems/ruby-1.9.3-p194/gems/fastercsv-1.5.5/lib/faster_csv.rb:13:in `const_missing'
# /Users/rsutphin/.rvm/gems/ruby-1.9.3-p194/gems/fastercsv-1.5.5/lib/faster_csv.rb:19:in `method_missing'
# /Users/rsutphin/.rvm/gems/ruby-1.9.3-p194/gems/fastercsv-1.5.5/lib/faster_csv.rb:2016:in `to_csv'
# /Users/rsutphin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/csv.rb:496:in `to_csv'
```

Surveyor should not require `fastercsv` at all if it is running on Ruby 1.9 or later.