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 +4 -4
- data/README.md +19 -16
- data/lib/atco/version.rb +1 -1
- data/lib/atco.rb +0 -3
- data/spec/atco_spec.rb +0 -2
- data/spec/spec_helper.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e9812933c6ca6dcc275bd1f262a30c4b916a12feedf824ce9c4f55f7d24825
|
4
|
+
data.tar.gz: 36e55b87cdaa72cdd1601f87ab10e9937f7ba4d6ea8fdcf174bb5f20603978c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 [
|
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
|
-
*
|
16
|
-
*
|
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
|
-
|
23
|
-
|
24
|
+
require "rubygems"
|
25
|
+
require "atco"
|
24
26
|
|
25
|
-
|
26
|
-
|
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
|
-
|
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
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
data/spec/spec_helper.rb
CHANGED