Skip to content

Commit

Permalink
Merged in CHOUETTE-3258-use-ara-ruby-gem (pull request #1541)
Browse files Browse the repository at this point in the history
CHOUETTE-3258 use ara-ruby gem

Approved-by: Alban Peignier
  • Loading branch information
Renaud Vignery authored and albanpeignier committed Dec 11, 2023
2 parents 4910cc2 + ad51ee2 commit f7b15f5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ gem 'redis-actionpack', '>= 5.3.0'
gem 'gtfs', en_route: 'gtfs'
gem 'netex', en_route: 'netex'
gem 'rgeo-shapefile'
gem 'ara-file', '>= 0.1.2', en_route: 'ara-file'
gem 'ara', '>= 1.0.0', en_route: 'ara-ruby'
gem 'neptune', en_route: 'neptune'

# Monitoring
Expand Down
10 changes: 6 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
GIT
remote: https://bitbucket.org/enroute-mobi/ara-file.git
revision: 4e96971bfb52ea3208d3231ecc72dd0d070f59d0
remote: https://bitbucket.org/enroute-mobi/ara-ruby.git
revision: ac8cc50642bfad5e23f55b04020d87d5b3a5d808
specs:
ara-file (0.1.2)
ara (1.0.0)
faraday
json

GIT
remote: https://bitbucket.org/enroute-mobi/cuckoo.git
Expand Down Expand Up @@ -874,7 +876,7 @@ DEPENDENCIES
activerecord-postgis-adapter (~> 5.2.3)
acts_as_list
acts_as_tree
ara-file (>= 0.1.2)!
ara (>= 1.0.0)!
awesome_print
bcrypt_pbkdf
better_errors
Expand Down
13 changes: 7 additions & 6 deletions app/models/export/ara.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# Export a dataset into a Ara CSV file
require 'ara/file'
class Export::Ara < Export::Base
include LocalExportSupport

Expand Down Expand Up @@ -29,7 +30,7 @@ def export_file
end

def target
@target ||= ::Ara::File.new export_file
@target ||= ::Ara::File::Target.new export_file
end
attr_writer :target

Expand Down Expand Up @@ -354,7 +355,7 @@ def referent_uuid
end

def ara_model
Ara::StopArea.new ara_attributes
Ara::File::StopArea.new ara_attributes
end

# TODO: To be shared
Expand Down Expand Up @@ -430,7 +431,7 @@ def ara_attributes
end

def ara_model
Ara::StopVisit.new ara_attributes
Ara::File::StopVisit.new ara_attributes
end

def stop_area_id
Expand Down Expand Up @@ -545,7 +546,7 @@ def ara_attributes
end

def ara_model
Ara::Line.new ara_attributes
Ara::File::Line.new ara_attributes
end

# TODO: To be shared
Expand Down Expand Up @@ -594,7 +595,7 @@ def ara_attributes
end

def ara_model
Ara::Operator.new ara_attributes
Ara::File::Operator.new ara_attributes
end

# TODO: To be shared
Expand Down Expand Up @@ -648,7 +649,7 @@ def ara_attributes
end

def ara_model
Ara::VehicleJourney.new ara_attributes
Ara::File::VehicleJourney.new ara_attributes
end

# TODO: To be shared
Expand Down
52 changes: 40 additions & 12 deletions spec/models/export/ara_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@
it { is_expected.to be_successful }

describe 'file' do
# TODO: Use Ara::File to read the file
subject { export.file.read.split("\n") }
it { is_expected.to have_attributes(size: 48) }
subject(:source) { Ara::File::Source.new(export.file.path) }
describe 'stop_visits count ' do
subject { source.stop_visits.to_a.size }
it { is_expected.to eq(18) }
end
describe 'lines count' do
subject { source.lines.to_a.size }
it { is_expected.to eq(6) }
end
describe 'vehicle_journeys count' do
subject { source.vehicle_journeys.to_a.size }
it { is_expected.to eq(6) }
end
describe 'operators count' do
subject { source.operators.to_a.size }
it { is_expected.to eq(0) }
end
end
end

Expand All @@ -54,9 +68,23 @@
it { is_expected.to be_successful }

describe 'file' do
# TODO: Use Ara::File to read the file
subject { export.file.read.split("\n") }
it { is_expected.to have_attributes(size: 30) }
subject(:source) { Ara::File::Source.new(export.file.path) }
describe 'stop_visits count ' do
subject { source.stop_visits.to_a.size }
it { is_expected.to eq(0) }
end
describe 'lines count' do
subject { source.lines.to_a.size }
it { is_expected.to eq(6) }
end
describe 'vehicle_journeys count' do
subject { source.vehicle_journeys.to_a.size }
it { is_expected.to eq(6) }
end
describe 'operators count' do
subject { source.operators.to_a.size }
it { is_expected.to eq(0) }
end
end
end
end
Expand Down Expand Up @@ -184,7 +212,7 @@
subject do
part.export!
target end
it { is_expected.to match_array([an_instance_of(Ara::StopArea)] * 2) }
it { is_expected.to match_array([an_instance_of(Ara::File::StopArea)] * 2) }

context "when one of the Stop Area has a registration number 'dummy'" do
before { stop_area.update registration_number: 'dummy' }
Expand Down Expand Up @@ -241,7 +269,7 @@
subject do
part.export!
target end
it { is_expected.to match_array([an_instance_of(Ara::Line)] * 2) }
it { is_expected.to match_array([an_instance_of(Ara::File::Line)] * 2) }

it 'contains Line having a number' do
expect(subject.first).to respond_to(:number)
Expand Down Expand Up @@ -323,7 +351,7 @@
part.export!
target
end
it { is_expected.to match_array([an_instance_of(Ara::Operator)] * 2) }
it { is_expected.to match_array([an_instance_of(Ara::File::Operator)] * 2) }

context "when one of the Company has a registration number 'dummy'" do
before { company.update registration_number: 'dummy' }
Expand Down Expand Up @@ -377,7 +405,7 @@
end

describe 'the Ara File target' do
it { is_expected.to match_array([an_instance_of(Ara::VehicleJourney)]) }
it { is_expected.to match_array([an_instance_of(Ara::File::VehicleJourney)]) }

it 'contains a Vehicle journey having a direction_type' do
expect(subject.first).to respond_to(:direction_type)
Expand All @@ -397,7 +425,7 @@
end

describe 'the Ara File target' do
it { is_expected.to match_array([an_instance_of(Ara::VehicleJourney)] * 2) }
it { is_expected.to match_array([an_instance_of(Ara::File::VehicleJourney)] * 2) }

context "when one of the Vehicle Journey has a code 'test': 'dummy" do
before { vehicle_journey.codes.create!(code_space: code_space, value: 'dummy') }
Expand Down Expand Up @@ -581,7 +609,7 @@

let(:at_stops_count) { vehicle_journey.vehicle_journey_at_stops.count }

it { is_expected.to match_array([an_instance_of(Ara::StopVisit)] * at_stops_count) }
it { is_expected.to match_array([an_instance_of(Ara::File::StopVisit)] * at_stops_count) }

describe Export::Ara::StopVisits::Decorator do
context 'with the first stop_visit' do
Expand Down

0 comments on commit f7b15f5

Please sign in to comment.