From 4a454917dd3f8f50bfb741adc521a807e3daa39f Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 29 Jun 2018 15:14:26 +0200 Subject: [PATCH] rename profile.journeyLeg to profile.trip :boom: --- docs/changelog.md | 1 + docs/migrating-to-3.md | 3 ++- docs/profile-boilerplate.js | 2 +- docs/writing-a-profile.md | 2 +- index.js | 2 +- lib/default-profile.js | 2 +- lib/validate-profile.js | 7 +++++++ p/db/index.js | 2 +- p/insa/index.js | 2 +- p/nahsh/index.js | 2 +- p/oebb/index.js | 2 +- p/vbb/index.js | 2 +- 12 files changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 9d35c17d..c42ce562 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -31,6 +31,7 @@ This version is not fully backwords-compatible. Check out [the migration guide]( - 8881d8a & b6fbaa5: change parsers signature to `parse…(profile, opt, data)` - cabe5fa: option to parse & expose `station.lines`, default off - c8ff217 rename `journeyLeg()` to `trip()` +- 8de4447 rename `profile.journeyLeg` to `profile.trip` ### bugfixes diff --git a/docs/migrating-to-3.md b/docs/migrating-to-3.md index 93f54b4c..eb2c7ba2 100644 --- a/docs/migrating-to-3.md +++ b/docs/migrating-to-3.md @@ -36,7 +36,8 @@ ## If you use `hafas-client` with a custom profile… -…write your profile in [the new format](writing-a-profile.md). Then, you can pass it into `hafas-client` just like before. #32/b7c1ee3 +- …write your profile in [the new format](writing-a-profile.md). Then, you can pass it into `hafas-client` just like before. #32/b7c1ee3 +- …rename the `profile.journeyLeg` flag to `profile.trip`. 8de4447 ## If you use `hafas-client` with custom parse functions… diff --git a/docs/profile-boilerplate.js b/docs/profile-boilerplate.js index 6b8ae7b0..97f7291c 100644 --- a/docs/profile-boilerplate.js +++ b/docs/profile-boilerplate.js @@ -37,7 +37,7 @@ const insaProfile = { products: products, - journeyLeg: false, + trip: false, radar: false } diff --git a/docs/writing-a-profile.md b/docs/writing-a-profile.md index ff5d1ccb..01bee324 100644 --- a/docs/writing-a-profile.md +++ b/docs/writing-a-profile.md @@ -140,7 +140,7 @@ We consider these improvements to be *optional*: - **Check if the endpoint supports the journey legs call.** - In the app, check if you can query details for the status of a single journey leg. It should load realtime delays and the current progress. - - If this feature is supported, add `journeyLeg: true` to the profile. + - If this feature is supported, add `trip: true` to the profile. - **Check if the endpoint supports the live map call.** Does the app have a "live map" showing all vehicles within an area? If so, add `radar: true` to the profile. - **Consider transforming station & line names** into the formats that's most suitable for *local users*. Some examples: - `M13 (Tram)` -> `M13`. With Berlin context, it is obvious that `M13` is a tram. diff --git a/index.js b/index.js index 97068587..752b2b6f 100644 --- a/index.js +++ b/index.js @@ -413,7 +413,7 @@ const createClient = (profile, request = _request) => { } const client = {departures, arrivals, journeys, locations, station, nearby} - if (profile.journeyLeg) client.trip = trip + if (profile.trip) client.trip = trip if (profile.radar) client.radar = radar Object.defineProperty(client, 'profile', {value: profile}) return client diff --git a/lib/default-profile.js b/lib/default-profile.js index 64bc34dd..c7c0f89b 100644 --- a/lib/default-profile.js +++ b/lib/default-profile.js @@ -66,7 +66,7 @@ const defaultProfile = { filters, journeysNumF: true, // `journeys()` method: support for `numF` field? - journeyLeg: false, + trip: false, radar: false } diff --git a/lib/validate-profile.js b/lib/validate-profile.js index 5f8dae6b..4c7f6374 100644 --- a/lib/validate-profile.js +++ b/lib/validate-profile.js @@ -71,6 +71,13 @@ const validateProfile = (profile) => { } } } + + if ('trip' in profile && 'boolean' !== typeof profile.trip) { + throw new Error('profile.trip must be a boolean.') + } + if ('journeyLeg' in profile) { + throw new Error('profile.journeyLeg has been removed. Use profile.trip.') + } } module.exports = validateProfile diff --git a/p/db/index.js b/p/db/index.js index 8747b6ca..345f94f6 100644 --- a/p/db/index.js +++ b/p/db/index.js @@ -102,7 +102,7 @@ const dbProfile = { formatStation, - journeyLeg: true // todo: #49 + trip: true // todo: #49 } module.exports = dbProfile diff --git a/p/insa/index.js b/p/insa/index.js index ed562dee..c02b3445 100644 --- a/p/insa/index.js +++ b/p/insa/index.js @@ -25,7 +25,7 @@ const insaProfile = { products: products, - journeyLeg: true, + trip: true, radar: true } diff --git a/p/nahsh/index.js b/p/nahsh/index.js index cab9da69..9a992266 100644 --- a/p/nahsh/index.js +++ b/p/nahsh/index.js @@ -103,7 +103,7 @@ const nahshProfile = { parseJourney: createParseJourney, parseMovement: createParseMovement, - journeyLeg: true, + trip: true, radar: true // todo: see #34 } diff --git a/p/oebb/index.js b/p/oebb/index.js index a78d88bc..c6fbb1e7 100644 --- a/p/oebb/index.js +++ b/p/oebb/index.js @@ -71,7 +71,7 @@ const oebbProfile = { parseLocation, parseMovement: createParseMovement, - journeyLeg: true, + trip: true, radar: true } diff --git a/p/vbb/index.js b/p/vbb/index.js index b58f1f19..cfb14373 100644 --- a/p/vbb/index.js +++ b/p/vbb/index.js @@ -142,7 +142,7 @@ const vbbProfile = { formatStation, journeysNumF: false, - journeyLeg: true, + trip: true, radar: true }