atco 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: d9b77a9ff8bc2044b0985cdc1cf6b9f9f997e6884c72ce88e713cc807c04aa40
4
- data.tar.gz: 8c09fd9b592ce9c1c8eae5b2bf4b36e9b1f1e8a98aff075773285f4a2da28e92
3
+ metadata.gz: 15e9812933c6ca6dcc275bd1f262a30c4b916a12feedf824ce9c4f55f7d24825
4
+ data.tar.gz: 36e55b87cdaa72cdd1601f87ab10e9937f7ba4d6ea8fdcf174bb5f20603978c2
5
5
  SHA512:
6
- metadata.gz: 7962c7bd938e9ec5d406b72994148b01368651b49ae4b023088dda40e8317895999805f1d6d8e5cc58d23caf5eb7d05da71fc64251cab7e666c30ba38302929b
7
- data.tar.gz: 4b1469dce23b861431b42cbdc1aeaf0f731388c648fb5bd4951b72e1fe889ce567cf0ff451c633737c6879a6cf950752409f79675e83234dee47c60dc03494bf
6
+ metadata.gz: 72580053068ad316cf22e9d262dbc8d0013a80aa5cde5de3160270fc9727850332df69ef94503f04a913e5f704f381558e361ddb5db857f0e9ae2d373a3fdbe5
7
+ data.tar.gz: e8450ac692fc998e2a1a735f243666abf7a82701a667b6569c307fc13869b30fabfa7ade64988feed77f30381f52d8972534436fcedeb987f1357c1decb71b44
data/README.md CHANGED
@@ -5,34 +5,37 @@ ATCO-CIF is the format of choice for UK public transport authorities. This is a
5
5
  * ATCO (Association of Transport Coordinating Officers)
6
6
  * CIF (Common Interface File)
7
7
 
8
- * **Official spec:** [http://www.pti.org.uk/CIF/atco-cif-spec.pdf](http://www.pti.org.uk/CIF/atco-cif-spec.pdf)
8
+ * **Official spec:** ~~[http://www.pti.org.uk/CIF/atco-cif-spec.pdf](http://www.pti.org.uk/CIF/atco-cif-spec.pdf)~~
9
+ * **NOTE**: official spec is no-longer available from the above URL but can be found on archive.org
10
+ * A copy of the [atco-cif-spec.pdf](http://github.com/davidjrice/atco/blob/master/docs/atco-cif-spec.pdf) is included in the `docs` folder in this repo
9
11
 
10
12
  ### USAGE
11
13
 
12
- Currently this library is under-development and has several things left to do before it is perfect (see the [todo.md](http://github.com/davidjrice/atco/blob/master/TODO.md) list ).
14
+ Currently this library is under-development and has several things left to do before it is perfect (see the [TODO.md](http://github.com/davidjrice/atco/blob/master/TODO.md) list ).
13
15
 
14
- * clone this library
15
- * start an irb session
16
- * put the cif file in ./data (needs to change from being hardcoded)
16
+ * clone this library `git clone git@github.com:davidjrice/atco.git`
17
+ * or install the gem `gem install atco`
18
+ * start an irb session (with the helper console command) `bin/console`
17
19
 
18
20
  Code example, for more detailed internal api usage see the spec files.
19
21
 
20
22
 
21
23
  ```ruby
22
- gem install atco
23
- irb
24
+ require "rubygems"
25
+ require "atco"
24
26
 
25
-
26
- require 'rubygems'
27
- require 'atco'
28
-
29
- result = Atco.parse('filename.cif')
30
- result = Atco.parse('SVRTMAO009A-20091005.cif) # an example data file in the repo
27
+ result = Atco.parse("filename.cif")
28
+ result = Atco.parse("data/SVRTMAO009A-20091005.cif")
31
29
 
32
30
  => {
33
- header: {…},
34
- locations: […],
35
- journies: {…}
31
+ header: {…}, # Atco::Header
32
+ locations: […], # Atco::Location
33
+ journeys: {
34
+ "journey_identifier": {…} # Atco::Journey
35
+ },
36
+ unparsed: [
37
+ {line: "unparsed line", line_number:1234}
38
+ ]
36
39
  }
37
40
  ```
38
41
 
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.8"
4
+ VERSION = "1.0.9"
5
5
  end
data/lib/atco.rb CHANGED
@@ -30,7 +30,6 @@ module Atco # rubocop:disable Metrics/ModuleLength
30
30
  @path = File.expand_path(file)
31
31
  data = File.readlines(@path)
32
32
 
33
- objects = []
34
33
  current_journey = nil
35
34
  current_location = nil
36
35
  locations = []
@@ -69,12 +68,10 @@ module Atco # rubocop:disable Metrics/ModuleLength
69
68
  journeys[current_journey[:unique_journey_identifier]] = Journey.new(object)
70
69
  end
71
70
  end
72
- objects << object
73
71
  rescue UnidentifiedRecordError
74
72
  unparsed << { line: line, line_number: line_number }
75
73
  next
76
74
  end
77
- objects << object
78
75
  end
79
76
  { header: header, locations: locations, journeys: journeys, unparsed: unparsed }
80
77
  end
data/spec/atco_spec.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
4
-
5
3
  RSpec.describe Atco do # rubocop:disable Metrics/BlockLength
6
4
  it "has a version number" do
7
5
  expect(Atco::VERSION).not_to be nil
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "atco"
4
+ require "json"
4
5
 
5
6
  RSpec.configure do |config|
6
7
  # Enable flags like --only-failures and --next-failure
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.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rice