gares 2.0.0.pre.dev1 → 2.0.0.pre.dev2
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 +4 -4
- data/lib/gares/search.rb +2 -2
- data/lib/gares/version.rb +1 -1
- data/spec/gares/search_spec.rb +5 -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: 5a2068a77f7242decc42538c4b351e9f7310ae98
|
4
|
+
data.tar.gz: 75bea0e0b426c6bc6a690d15277b1c97dbb34e9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b23cdf24b6cf1c8479f677ebc209f16247fb4842d7cb4c992c6198e809cbda2729c791397e200b065d4136c42d985299b08f1ace78e4543ec54aebcc6724a8
|
7
|
+
data.tar.gz: 2222356832680a874edfaa2708ee832ecb6d3c04392a0262d55d4c0797e30827aca3639cf9c51209379079b336c1f1341c2f6409a2c833c08479de7e73d30ee1
|
data/lib/gares/search.rb
CHANGED
@@ -7,7 +7,7 @@ module Gares
|
|
7
7
|
GARES_LIST_URL = "https://raw.githubusercontent.com/capitainetrain/stations/master/stations.csv"
|
8
8
|
|
9
9
|
# List of keywords to ignore while searching
|
10
|
-
IGNORE_KEYWORDS = ["ST", "GARE", "SNCF"]
|
10
|
+
IGNORE_KEYWORDS = ["ST", "SAINT", "GARE", "SNCF"]
|
11
11
|
# Initialize a new Station search with the specified query
|
12
12
|
#
|
13
13
|
# search = Gares::Search.new("Aix")
|
@@ -33,7 +33,7 @@ module Gares
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def result
|
36
|
-
keywords = @query.split(
|
36
|
+
keywords = @query.split(/[ -]/).select { |keyword| !IGNORE_KEYWORDS.include?(keyword.upcase) }
|
37
37
|
@result ||= data.select do |station|
|
38
38
|
station.send(@by) && station.send(@by).to_ascii =~ /#{keywords.join(".*")}/i
|
39
39
|
end
|
data/lib/gares/version.rb
CHANGED
data/spec/gares/search_spec.rb
CHANGED
@@ -74,6 +74,11 @@ describe Gares::Search do
|
|
74
74
|
@stations = Gares::Station.search('MONTELIMAR GARE SNCF')
|
75
75
|
expect(@stations.first.sncf_id.downcase).to eql('frmtl')
|
76
76
|
end
|
77
|
+
|
78
|
+
it 'should return the gare sncf_id.downcase correctly' do
|
79
|
+
@stations = Gares::Station.search('MONTPELLIER SAINT-ROCH')
|
80
|
+
expect(@stations.first.sncf_id.downcase).to eql('frmpl')
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|