gares 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b7f08cfd31cca43ba9a05d17d103d8a092a9d50
4
- data.tar.gz: 11d1b1eb72fff644d1f0fe67a59cc68edf273072
3
+ metadata.gz: 5e52dec4e601a002f0e9cb42ed4e8518e4fb7b6d
4
+ data.tar.gz: 35051c6f87ec0c2a0d693cf62b94aa277d4a56be
5
5
  SHA512:
6
- metadata.gz: 7c18477831fa2520b08ad6d1bd1fcbbf2f2271ed68cf21c23e7d3e0a9bd5b7f1317d2b24d7efede154875d772d43e73cb46c8221c705abd0398c50fe2c43cc0d
7
- data.tar.gz: a4fb97957f8c1aac0f7e9a8140148eff784c0f7fa9307178f89ee146d669b36d733bbec45efe6469edddcad020f414977d83898abe297b68d5664ff239a8aa6f
6
+ metadata.gz: d26b586ea621d7c2c887b7714473b4584c11e0feb22ddc19c04d7d455f5eba3a55249f12b75a65a9d2a0fb1052ee8c72100bff2b0a50c27586cdb8242632ef4e
7
+ data.tar.gz: 9f561f8e8d53927870c9caf9a8bd3265afa28580694656ff3c1f24d1edcec55e1530b86654a866cddf9b66599cf5520e50c77f8e2b3d1dac435d4904d7ff056d
data/lib/gares/search.rb CHANGED
@@ -42,14 +42,20 @@ module Gares
42
42
  query = self.class.simplify(@query)
43
43
  if @raw_results.nil?
44
44
  @raw_results = self.class.find(query).values
45
- # try first keyword if nothing found
46
- @raw_results = @raw_results.empty? ? self.class.find(query.split(" ").first).values : @raw_results
45
+ # try removing keywords one by one if nothing found
46
+ while @raw_results.empty? && !query.split(" ").empty?
47
+ query = query.split(" ")[0..-2].join(" ")
48
+ @raw_results = @raw_results.empty? ? self.class.find(query).values : @raw_results
49
+ end
50
+ end
51
+ @result ||= @raw_results.map do |raw_station|
52
+ Gares::Station.new(raw_station.select { |key| Gares::Station.properties.include?(key) })
47
53
  end
48
- @result ||= @raw_results.map { |raw_station| Gares::Station.new(raw_station) }
49
54
  end
50
55
 
51
56
  def self.simplify(str)
52
57
  str.to_ascii.downcase
58
+ .gsub(/\bgare\ssncf\b/, "")
53
59
  .gsub(/\bsaint\b/, "st")
54
60
  .gsub(/[^a-z]/, " ")
55
61
  .gsub(/\s+/, " ")
data/lib/gares/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gares
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end