transilien_realtime 0.2.0 → 0.3.0

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: 404fb3f75160ea7fd8804c7b2385452fd8e163e9
4
- data.tar.gz: 8bdc706c837f498c9ad19be1a4e7077c55ce68cf
3
+ metadata.gz: 68916028ace3035309227b7bb2fac604e37497d9
4
+ data.tar.gz: 963924a58bc4476cd0a78d6a1bf96a2f0f7fe6e5
5
5
  SHA512:
6
- metadata.gz: 0cca2cc028bd601ac576c4dca8a6c8f83c4e972d83438b064e202196b52a0dc497657b50d4d8e4dbd9c96fdc1845a0924216a50f448d5add48bec950762ba17a
7
- data.tar.gz: 9370652aee9e70daf47b04afdcc921ae89f01e595bf4eccc8540e181ae48741285012b43857a5ec6836be34191231b1b66eff0e1599adc3c85ce8ff1027eb224
6
+ metadata.gz: c581c1271e4b311fd0ecfd91607d58e5c44507ee93551572cc07722065271149455581f64174e6e7b4930a7009e88cff264fbbea2f2adc77106b72689da25936
7
+ data.tar.gz: e4a23f26ae73195a6ba89cfe65f4fc67eb12d9372bf27799814f1b71f52e3362d72fef4c1a416d0f215d1b5a0c1a646f22eff102bfe4f166651cafed7191249a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- transilien_realtime (0.2.0)
4
+ transilien_realtime (0.3.0)
5
5
  http (~> 0.8.9)
6
6
  nokogiri (~> 1.6.6.2)
7
7
  oj (~> 2.12.7)
data/README.md CHANGED
@@ -41,6 +41,10 @@ tr.trains
41
41
  => [#<TransilienRealtime::Train:0x007f945dcc4770 @departure_at=2015-05-15 16:12:00 +0200, @mission="MOCA", @numero="136891", @terminus="87381509">]
42
42
  ```
43
43
 
44
+ Important note about Train#departure_at:
45
+
46
+ Since the API doesn't give a timezone and that Europe/Paris offset change according to DST, there's no way to provide a correct Time instance after parsing this partial Date. As a workaround, the time is parsed "as if" and forced into a fake DST, so you can easily shift the date into a timezone of your concern.
47
+
44
48
  ## Development
45
49
 
46
50
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -68,6 +68,7 @@ module TransilienRealtime
68
68
  end
69
69
 
70
70
  def fetch(request)
71
+ @trains = nil # destroy cache
71
72
  @response = HTTP.basic_auth(user: @user, pass: @pwd).headers(accept: ACCEPT_STRINGS[API_VERSION]).get(request)#.body
72
73
  @body = @response.body
73
74
  @content = @body.readpartial
@@ -1,4 +1,7 @@
1
1
  module TransilienRealtime
2
+ # Important note about attribute departure_at:
3
+ # Since it's not possible to have a Time instance w/o timezone, and Europe/Paris change its offset w/ DST,
4
+ # lie by forcing a false UTC hours
2
5
  class Train
3
6
  include Comparable
4
7
 
@@ -31,7 +34,7 @@ module TransilienRealtime
31
34
  def initialize(mission:, departure_at:, terminus:, numero:, mode:, state: nil)
32
35
  @mission = mission
33
36
  @numero = numero
34
- @departure_at = DateTime.strptime(departure_at, '%d/%m/%Y %H:%M').to_time
37
+ @departure_at = Time.strptime(departure_at + ' +0000', '%d/%m/%Y %H:%M %z')
35
38
  @terminus = terminus
36
39
  @mode = MODES[mode]
37
40
  @state = STATES[state]
@@ -1,3 +1,3 @@
1
1
  module TransilienRealtime
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transilien_realtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Lecavelier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-17 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http