diff --git a/.gitignore b/.gitignore index f703189..ec6ca6d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ pkg/* checksums/* *.gem spec/artefacts/test.json -.rspec_status \ No newline at end of file +.rspec_status diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8eaa30c..44e75a4 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,3 +2,4 @@ * David Rice [@davidjrice](https://github.com/davidjrice) * Thomas Buckley-Houston [@tombh](https://github.com/tombh) +* Martin Sidaway [@martinjos](https://github.com/martinjos) \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 2e98d87..4e9b849 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - atco (1.0.5) + atco (1.0.6) GEM remote: https://rubygems.org/ diff --git a/lib/atco.rb b/lib/atco.rb index 62b6560..dcec975 100644 --- a/lib/atco.rb +++ b/lib/atco.rb @@ -38,7 +38,7 @@ def parse(file) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, unparsed = [] data.each_with_index do |line, line_number| # rubocop:disable Metrics/BlockLength - if line == data.first + if line_number.zero? header = parse_header(line) next end @@ -52,13 +52,13 @@ def parse(file) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, object = send("parse_#{method}", line) next unless object[:record_identity] && object[:record_identity] == identifier - current_journey = object if object[:record_identity] && object[:record_identity] == METHODS[:journey_header] - if object[:record_identity] && (object[:record_identity] == METHODS[:location] || object[:record_identity] == METHODS[:additional_location_info]) # rubocop:disable Layout/LineLength - if object[:record_identity] == METHODS[:location] - current_location = object - else - locations << Location.new(current_location, object) - end + case method + when :journey_header + current_journey = object + when :location + current_location = object + when :additional_location_info + locations << Location.new(current_location, object) end if current_journey @@ -73,6 +73,7 @@ def parse(file) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, unparsed << { line: line, line_number: line_number } next end + objects << object end { header: header, locations: locations, journeys: journeys, unparsed: unparsed } end diff --git a/lib/atco/version.rb b/lib/atco/version.rb index f20b359..8d2ee61 100644 --- a/lib/atco/version.rb +++ b/lib/atco/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Atco - VERSION = "1.0.5" + VERSION = "1.0.6" end