No description provided.
Set ruby 2.0.0 in `Gemfile`
Add 'active_support' gem for parameterize query
Add `geocoder` gem for calculate distance between points
Add ParseDatas Class
This class permit to store cities files in an array for future search. All cities where population < ParseDatas::MAX_POPULATIONS are excluded
cities = ParseDatas.get_datas_from_csv(file_path)
Add Suggestion class
This class filter cities according parameters
`Suggestion.new(cities, params).results` return results sorted by name
Add score by length to `Suggestion`.
Here, We comparing the length of the query with the length of the city.
London/London = 1
Londo/London = 0.83
Londo/Londonderry = 0.41
Change sorting of cities by score descending and by name ascending
Add score by distance to `Suggestion`
Here we use `geocoder` gem for calculate distance (using Haversine formula) and transposed to a score between 0 and 1 with:
`1 - distance / (Math::PI*Geocoder::Calculations::EARTH_RADIUS)`
Add score by populations to `Suggestion`
Most of the time, users search big cities so cities with most populations had a better score than small cities
Add `redis` gem
Add limit parameter to `Suggestion`
@jeromelefeuvre Seems I can't run the specs locally, any idea why I might be getting this error after running the following commands?
bundle exec rspec
$ bundle exec rspec
/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:409:in `rescue in _parse_driver': Cannot load driver "hiredis" (RuntimeError)
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:405:in `_parse_driver'
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:376:in `_parse_options'
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis/client.rb:67:in `initialize'
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis.rb:31:in `new'
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/redis-3.0.7/lib/redis.rb:31:in `initialize'
from /jerome-lefeuvre/coding-challenge-backend-b/app.rb:19:in `new'
from /jerome-lefeuvre/coding-challenge-backend-b/app.rb:19:in `block in <class:App>'
from /.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1393:in `configure'
oh you right, seems I forgot to run tests after configured Redis. My next commit fix that, sorry !
Use `fakeredis` gem for [:development, :test]