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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a7346ed6637e992bd4ce2dc1be20d8b1e44fcf8
4
- data.tar.gz: 2d681f7d329983887a33aed98d6399fde4097c85
3
+ metadata.gz: 37c2b4d26cf3ffa144fb673445cca829225fab7b
4
+ data.tar.gz: dbb3e6740437f1dab018ee9da896123192e84ef4
5
5
  SHA512:
6
- metadata.gz: ca67937fb6fdfc242aefebb4661e67f456fde6512463ee367cab41bf33a06d0be452b21e8e5a1002ad75c28b22f0f044209cab6b899560295917303feaedf34d
7
- data.tar.gz: 58958615ac14299dbae8ee968e8ef22ce9e9eeaf71bfddcc5664412c214a118f480bba287e38df92ad20353e9c44684c96e8e578c643f580e315c1df0c04852b
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 =~ /#{@query.split(" ").join(".*")}/i
37
+ station.name.to_ascii =~ /#{keywords.join(".*")}/i
35
38
  end
36
39
  end
37
40
 
data/lib/gares/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gares
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gares
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud