DataScienceTheater3000, refactor'd
Recently Nick Fine contributed heavily to DST3K by implementing the remaining APIs the Data Science Toolkit offers, adding tests with minitest, and DRYing up all the things. Check out the diff!
After you look through his awesome example of refactoring, fork the project and play. Here’s how
$ git clone git@github.com:rthbound/data_science_theater_3000.git
$ cd data_science_theater_3000
$ gem install bundler
$ bundle install
$ bundle exec rake test
$ bundle console
...then in console:
request = DataScienceTheater3000::Ip2Coordinates.new( '8.8.8.8' )
> #<datasciencetheater3000::ip2coordinates:0x000000019c7f60 ip=""8.8.8.8"">
request.result
> {"8.8.8.8"=>{"longitude"=>-122.057403564453, "country_name"=>"United States", "postal_code"=>"94043", "region"=>"CA", "locality"=>"Mountain View", "country_code"=>"US", "dma_code"=>807, "latitude"=>37.4192008972168, "country_code3"=>"USA", "area_code"=>650}}
This is also fun ... pass output from street2coordinates or ip2coordinates to coordinates2politics
locations_request = DataScienceTheater3000::Ip2Coordinates.new( ["8.8.8.8", "74.125.224.72"] )
> #<datasciencetheater3000::ip2coordinates:0x000000026b17f8 ip="">
locations = locations_request.result
> {"8.8.8.8"=>{ ... ... ... }, "74.125.224.72"=>{ ... ... ... }}
politics_request = DataScienceTheater3000::Coordinates2Politics.new( locations )
> #<datasciencetheater3000::coordinates2politics:0x00000002ba6470 coordinates=""[[\"37.4192008972168\",\"-122.057403564453\"],[\"37.4192008972168\",\"-122.057403564453\"]]"">
politics = politics_request.result
Have fun!