gares 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gares/search.rb +9 -3
- data/lib/gares/version.rb +1 -1
- data/spec/fixtures/bls.csv +21488 -21468
- data/spec/fixtures/stations.csv +21494 -21469
- metadata +38 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e52dec4e601a002f0e9cb42ed4e8518e4fb7b6d
|
4
|
+
data.tar.gz: 35051c6f87ec0c2a0d693cf62b94aa277d4a56be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
46
|
-
|
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