Skip to content

Commit

Permalink
Merge pull request #713 from CanalTP/add_object_codes_on_companies
Browse files Browse the repository at this point in the history
[feature] add object codes on companies
  • Loading branch information
patochectp authored Oct 28, 2020
2 parents ed158ca + 65487de commit edb7b4b
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Kisio Digital <[email protected]>", "Guillaume Pinot <[email protected]>"]
name = "transit_model"
version = "0.31.5"
version = "0.32.0"
license = "AGPL-3.0-only"
description = "Transit data management"
repository = "https://github.com/CanalTP/transit_model"
Expand Down
2 changes: 1 addition & 1 deletion gtfs2netexfr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../", features = ["proj"] }
transit_model = { version = "0.32", path = "../", features = ["proj"] }
2 changes: 1 addition & 1 deletion gtfs2ntfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../" }
transit_model = { version = "0.32", path = "../" }
2 changes: 1 addition & 1 deletion ntfs2gtfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../" }
transit_model = { version = "0.32", path = "../" }
2 changes: 1 addition & 1 deletion ntfs2netexfr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../", features = ["proj"] }
transit_model = { version = "0.32", path = "../", features = ["proj"] }
2 changes: 1 addition & 1 deletion ntfs2ntfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../" }
transit_model = { version = "0.32", path = "../" }
2 changes: 1 addition & 1 deletion restrict-validity-period/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ slog-scope = "4.1"
slog-stdlog = "4.0"
slog-term = "2.4"
structopt = "0.3"
transit_model = { version = "0.31", path = "../" }
transit_model = { version = "0.32", path = "../" }
1 change: 1 addition & 0 deletions src/gtfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl From<Agency> for objects::Company {
url: Some(agency.url),
mail: agency.email,
phone: agency.phone,
codes: BTreeSet::new(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod validity_period;
pub mod vptranslator;

/// Current version of the NTFS format
pub const NTFS_VERSION: &str = "0.11.2";
pub const NTFS_VERSION: &str = "0.11.4";

/// The max distance in meters to compute the transfer
pub const TRANSFER_MAX_DISTANCE: &str = "300";
Expand Down
4 changes: 3 additions & 1 deletion src/ntfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {
("feed_end_date".to_string(), "20180131".to_string()),
("feed_publisher_name".to_string(), "Nicaragua".to_string()),
("feed_start_date".to_string(), "20180130".to_string()),
("ntfs_version".to_string(), "0.11.2".to_string()),
("ntfs_version".to_string(), "0.11.4".to_string()),
("tartare_platform".to_string(), "dev".to_string()),
],
collections
Expand Down Expand Up @@ -458,6 +458,7 @@ mod tests {
url: Some("http://www.foo.fr/".to_string()),
mail: Some("[email protected]".to_string()),
phone: Some("0123456789".to_string()),
codes: BTreeSet::new(),
},
Company {
id: "OIF:102".to_string(),
Expand All @@ -466,6 +467,7 @@ mod tests {
url: None,
mail: None,
phone: None,
codes: BTreeSet::new(),
},
]);
}
Expand Down
1 change: 1 addition & 0 deletions src/ntfs/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ pub fn write_codes(path: &path::Path, collections: &Collections) -> Result<()> {
write_codes_from_collection_with_id(&mut wtr, &collections.lines, &path)?;
write_codes_from_collection_with_id(&mut wtr, &collections.routes, &path)?;
write_codes_from_collection_with_id(&mut wtr, &collections.vehicle_journeys, &path)?;
write_codes_from_collection_with_id(&mut wtr, &collections.companies, &path)?;

wtr.flush()
.with_context(|_| format!("Error reading {:?}", path))?;
Expand Down
12 changes: 12 additions & 0 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum ObjectType {
StopTime,
LineGroup,
Ticket,
Company,
}

pub trait GetObjectType {
Expand All @@ -61,6 +62,7 @@ impl ObjectType {
ObjectType::StopTime => "stop_time",
ObjectType::LineGroup => "line_group",
ObjectType::Ticket => "ticket",
ObjectType::Company => "company",
}
}
}
Expand Down Expand Up @@ -1308,9 +1310,13 @@ pub struct Company {
pub mail: Option<String>,
#[serde(rename = "company_phone")]
pub phone: Option<String>,
#[serde(skip)]
pub codes: KeysValues,
}

impl_id!(Company);
impl_codes!(Company);

impl Default for Company {
fn default() -> Company {
Company {
Expand All @@ -1320,6 +1326,7 @@ impl Default for Company {
url: None,
mail: None,
phone: None,
codes: BTreeSet::new(),
}
}
}
Expand All @@ -1328,6 +1335,11 @@ impl AddPrefix for Company {
self.id = prefix_conf.referential_prefix(self.id.as_str());
}
}
impl GetObjectType for Company {
fn get_object_type() -> ObjectType {
ObjectType::Company
}
}

impl_with_id!(Company);

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/gtfs2ntfs/full_output/feed_infos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ feed_license,DefaultDatasourceLicense
feed_license_url,http://www.default-datasource-website.com
feed_publisher_name,DefaultContributorName
feed_start_date,20180101
ntfs_version,0.11.2
ntfs_version,0.11.4
tartare_contributor_id,DefaultContributorId
tartare_platform,dev
2 changes: 1 addition & 1 deletion tests/fixtures/gtfs2ntfs/minimal/output/feed_infos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ feed_creation_time,17:19:00
feed_creation_datetime,2019-04-03T17:19:00+00:00
feed_end_date,20180106
feed_start_date,20180101
ntfs_version,0.11.2
ntfs_version,0.11.4
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ feed_creation_time,17:19:00
feed_creation_datetime,2019-04-03T17:19:00+00:00
feed_end_date,20180805
feed_start_date,20180501
ntfs_version,0.11.2
ntfs_version,0.11.4

0 comments on commit edb7b4b

Please sign in to comment.