gares 1.1.0 → 1.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 +4 -1
- data/lib/gares/version.rb +1 -1
- data/spec/gares/search_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37c2b4d26cf3ffa144fb673445cca829225fab7b
|
4
|
+
data.tar.gz: dbb3e6740437f1dab018ee9da896123192e84ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffffb7fe4abf9d9dd92cb16d5e416b67b4d950004dfebf6ed1e457b431f85d3ee4786dfef5acaca6784770b186f1ba08f74dbd06a17f4ef8e0b75c98704bcdd9
|
7
|
+
data.tar.gz: 914ebb3686e8539e739e4ae009825104df72ddaccb28f657abe6a128461ae3b18db5602b75f6856603ce8b8c844aacafd540fb3df0eb194b02659d49c14986d2
|
data/lib/gares/search.rb
CHANGED
@@ -6,6 +6,8 @@ module Gares
|
|
6
6
|
# This is a file containing minimal information (name and slug) of all stations of gares-en-mouvement.com
|
7
7
|
GARES_LIST_URL = "https://www.kimonolabs.com/api/7jys32dy?apikey=lsOO4tNm78cH9JxqWg9gAk9l4nYaou9j&kimmodify=1"
|
8
8
|
|
9
|
+
# List of keywords to ignore while searching
|
10
|
+
IGNORE_KEYWORDS = ["ST"]
|
9
11
|
# Initialize a new Station search with the specified query
|
10
12
|
#
|
11
13
|
# search = Gares::Search.new("Aix")
|
@@ -30,8 +32,9 @@ module Gares
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def result
|
35
|
+
keywords = @query.split(" ").select { |keyword| !IGNORE_KEYWORDS.include?(keyword) }
|
33
36
|
@result ||= document.results.collection1.map(&:station).select do |station|
|
34
|
-
station.name.to_ascii =~ /#{
|
37
|
+
station.name.to_ascii =~ /#{keywords.join(".*")}/i
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
data/lib/gares/version.rb
CHANGED
data/spec/gares/search_spec.rb
CHANGED
@@ -51,5 +51,12 @@ describe Gares::Search do
|
|
51
51
|
@search = Gares::Search.new('CULMONT CHALINDREY')
|
52
52
|
expect(@search.stations.first.slug).to eql('frccy')
|
53
53
|
end
|
54
|
+
|
55
|
+
context 'with a "st" searching for "saint"' do
|
56
|
+
it 'should return the gare slug correctly' do
|
57
|
+
@search = Gares::Search.new('ST ETIENNE CHATEAUCREUX')
|
58
|
+
expect(@search.stations.first.slug).to eql('frhhd')
|
59
|
+
end
|
60
|
+
end
|
54
61
|
end
|
55
62
|
end
|