atco 1.0.4 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5321b93f293661308b4e7ee41024d24f873e08115c14a0600a45ca50875ca7d
4
- data.tar.gz: d31652011de26eb9872d118366e47d07e578d2a1f1459e8b6079219b0e42aafb
3
+ metadata.gz: 4ddb4c619b9d60d92fa99bc37e0df7f1181e5f42d6e001757284077eadbc597b
4
+ data.tar.gz: d5c8ebaa0bcec7f07a447a78e20d77727926de121616b700103fb06719cd2c1f
5
5
  SHA512:
6
- metadata.gz: '09fb7d8d1948d46855e0a07cd9f3739360e85fc048235ef6994b15939ef3e54faabfc4f5399b4076dcb498df0f26528a403f7e10e3532cddf7f55aa13a0f5f44'
7
- data.tar.gz: 07f1ed552c5b5278975e309bce0f518efeab83c518ea16fbc88fecff35d6ff80c8650ac1ba1682ff0d53edf5b10a9ce33337fe7309ab8ce79cccc6b2289f4491
6
+ metadata.gz: bae3d2d4b0ace8e394497fba4457f76135940198b10fa05a630ff789efaec217d85cc87406dfca5e338c9aa1e16ee2dd4f62fd039c39066c9235c8b888e9368c
7
+ data.tar.gz: 44e57ff1c7f56a5b0e1930f2a1fbbd6ec22490fd25608d713f760194520639e509015d38d900587021854d8fbc9160233dbf852d0d1bb2df2d684b3915e18114
data/README.md CHANGED
@@ -35,3 +35,9 @@ result = Atco.parse('SVRTMAO009A-20091005.cif) # an example data file in the rep
35
35
  journies: {…}
36
36
  }
37
37
  ```
38
+
39
+ ### Author & Contributors
40
+
41
+ The `ATCO-CIF` Ruby library was originally authored by David Rice [@davidjrice](https://github.com/davidjrice) in response to an FOI request to [Translink](https://www.translink.co.uk) for there timetable data as part of an [OpenDataNI](https://admin.opendatani.gov.uk) initiative.
42
+
43
+ See [CONTRIBUTORS.md](http://github.com/davidjrice/atco/blob/master/CONTRIBUTORS.md)
data/lib/atco/stop.rb CHANGED
@@ -3,7 +3,12 @@
3
3
  module Atco
4
4
  # Atco::Stop is a class to abstract ATCO-CIF Origin, Intermediate and Destination (Stop) records.
5
5
  class Stop
6
- attr_accessor :bay_number, :location, :timing_point_indicator, :fare_stage_indicator, :published_departure_time,
6
+ attr_accessor :bay_number,
7
+ :location,
8
+ :timing_point_indicator,
9
+ :fare_stage_indicator,
10
+ :published_arrival_time,
11
+ :published_departure_time,
7
12
  :record_identity
8
13
 
9
14
  def origin?
@@ -23,6 +28,7 @@ module Atco
23
28
  @location = data[:location]
24
29
  @timing_point_indicator = data[:timing_point_indicator]
25
30
  @fare_stage_indicator = data[:fare_stage_indicator]
31
+ @published_arrival_time = data[:published_arrival_time]
26
32
  @published_departure_time = data[:published_departure_time]
27
33
  @record_identity = data[:record_identity]
28
34
  end
@@ -31,6 +37,7 @@ module Atco
31
37
  {
32
38
  record_identity: @record_identity,
33
39
  location: @location,
40
+ published_arrival_time: @published_arrival_time,
34
41
  published_departure_time: @published_departure_time,
35
42
  timing_point_indicator: @timing_point_indicator,
36
43
  fare_stage_indicator: @fare_stage_indicator,
data/lib/atco/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Atco
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.7"
5
5
  end
data/lib/atco.rb CHANGED
@@ -38,7 +38,7 @@ module Atco # rubocop:disable Metrics/ModuleLength
38
38
  unparsed = []
39
39
 
40
40
  data.each_with_index do |line, line_number| # rubocop:disable Metrics/BlockLength
41
- if line == data.first
41
+ if line_number.zero?
42
42
  header = parse_header(line)
43
43
  next
44
44
  end
@@ -52,13 +52,13 @@ module Atco # rubocop:disable Metrics/ModuleLength
52
52
  object = send("parse_#{method}", line)
53
53
  next unless object[:record_identity] && object[:record_identity] == identifier
54
54
 
55
- current_journey = object if object[:record_identity] && object[:record_identity] == METHODS[:journey_header]
56
- if object[:record_identity] && (object[:record_identity] == METHODS[:location] || object[:record_identity] == METHODS[:additional_location_info]) # rubocop:disable Layout/LineLength
57
- if object[:record_identity] == METHODS[:location]
58
- current_location = object
59
- else
60
- locations << Location.new(current_location, object)
61
- end
55
+ case method
56
+ when :journey_header
57
+ current_journey = object
58
+ when :location
59
+ current_location = object
60
+ when :additional_location_info
61
+ locations << Location.new(current_location, object)
62
62
  end
63
63
 
64
64
  if current_journey
@@ -73,6 +73,7 @@ module Atco # rubocop:disable Metrics/ModuleLength
73
73
  unparsed << { line: line, line_number: line_number }
74
74
  next
75
75
  end
76
+ objects << object
76
77
  end
77
78
  { header: header, locations: locations, journeys: journeys, unparsed: unparsed }
78
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atco
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rice