Browse Source

Add models for connection, type and region

Add pipeline
master
Jonas Franz 2 years ago
parent
commit
6aeebf5483
Signed by: JonasFranzDEV
GPG Key ID: 7293A220B7C38080
  1. 11
      .drone.yml
  2. 54
      lib/models/connection.dart
  3. 83
      lib/models/connection.g.dart
  4. 10
      lib/models/connection_type.dart
  5. 51
      lib/models/region.dart
  6. 144
      pubspec.lock
  7. 9
      pubspec.yaml

11
.drone.yml

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
kind: pipeline
name: default
steps:
- name: test
image: google/dart:2
commands:
- pub get
- dartanalyzer --fatal-infos --fatal-warnings .
- dartfmt -n --set-exit-if-changed .
- pub run test

54
lib/models/connection.dart

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
import 'package:db_construction_site/models/region.dart';
import 'package:json_annotation/json_annotation.dart';
import 'connection_type.dart';
part 'connection.g.dart';
@JsonSerializable(createToJson: false)
class Connection {
final String id;
final String name;
@JsonKey(name: "von")
final String origin;
@JsonKey(name: "nach")
final String destination;
@JsonKey(name: "kbnr")
final String courseBookNumber;
@JsonKey(name: "verlauf")
final List<String> stops;
@JsonKey(name: "via")
final String via;
final DateTime timestamp;
@JsonKey(name: "verfall")
final DateTime expiryDate;
@JsonKey(name: "verbindung")
final ConnectionType type;
@JsonKey(name: "land")
final Region region;
final String url;
@JsonKey(name: "ics")
final String icsUrl;
@JsonKey(name: "doc")
final String documentUrl;
const Connection({
this.id,
this.name,
this.origin,
this.destination,
this.courseBookNumber,
this.stops,
this.via,
this.timestamp,
this.expiryDate,
this.type,
this.region,
this.url,
this.icsUrl,
this.documentUrl,
});
factory Connection.fromJson(Map<String, dynamic> json) =>
_$ConnectionFromJson(json);
}

83
lib/models/connection.g.dart

@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'connection.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Connection _$ConnectionFromJson(Map<String, dynamic> json) {
return Connection(
id: json['id'] as String,
name: json['name'] as String,
origin: json['von'] as String,
destination: json['nach'] as String,
courseBookNumber: json['kbnr'] as String,
stops: (json['verlauf'] as List)?.map((e) => e as String)?.toList(),
via: json['via'] as String,
timestamp: json['timestamp'] == null
? null
: DateTime.parse(json['timestamp'] as String),
expiryDate: json['verfall'] == null
? null
: DateTime.parse(json['verfall'] as String),
type: _$enumDecodeNullable(_$ConnectionTypeEnumMap, json['verbindung']),
region: _$enumDecodeNullable(_$RegionEnumMap, json['land']),
url: json['url'] as String,
icsUrl: json['ics'] as String,
documentUrl: json['doc'] as String,
);
}
T _$enumDecode<T>(
Map<T, dynamic> enumValues,
dynamic source, {
T unknownValue,
}) {
if (source == null) {
throw ArgumentError('A value must be provided. Supported values: '
'${enumValues.values.join(', ')}');
}
final value = enumValues.entries
.singleWhere((e) => e.value == source, orElse: () => null)
?.key;
if (value == null && unknownValue == null) {
throw ArgumentError('`$source` is not one of the supported values: '
'${enumValues.values.join(', ')}');
}
return value ?? unknownValue;
}
T _$enumDecodeNullable<T>(
Map<T, dynamic> enumValues,
dynamic source, {
T unknownValue,
}) {
if (source == null) {
return null;
}
return _$enumDecode<T>(enumValues, source, unknownValue: unknownValue);
}
const _$ConnectionTypeEnumMap = {
ConnectionType.longDistance: 'fern',
ConnectionType.regional: 'regional',
ConnectionType.sBahn: 'sbahn',
};
const _$RegionEnumMap = {
Region.lowerSaxonyBremen: 'niedersachen-bremen',
Region.north: 'norden',
Region.mecklenburgWesternPomerania: 'mvp',
Region.berlinBrandenburg: 'berlin-bb',
Region.saxonyAnhalt: 'sachsen-anhalt',
Region.saxony: 'sachsen',
Region.bavaria: 'bayern',
Region.thuringia: 'thueringen',
Region.badenWuerttemberg: 'baden-w',
Region.rhinelandPalatinate: 'rheinland-pfalz',
Region.hesse: 'hessen',
Region.northrhineWestphalia: 'nrw',
};

10
lib/models/connection_type.dart

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
import 'package:json_annotation/json_annotation.dart';
enum ConnectionType {
@JsonValue("fern")
longDistance,
@JsonValue("regional")
regional,
@JsonValue("sbahn")
sBahn,
}

51
lib/models/region.dart

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
import 'package:json_annotation/json_annotation.dart';
enum Region {
/// Lower Saxony and Bremen
@JsonValue("niedersachen-bremen")
lowerSaxonyBremen,
/// Schleswig Holstein
@JsonValue("norden")
north,
/// Mecklenburg Western Pomerania
@JsonValue("mvp")
mecklenburgWesternPomerania,
/// Berlin and Brandenburg
@JsonValue("berlin-bb")
berlinBrandenburg,
/// Saxony-Anhalt
@JsonValue("sachsen-anhalt")
saxonyAnhalt,
/// Saxony
@JsonValue("sachsen")
saxony,
/// Bavaria
@JsonValue("bayern")
bavaria,
/// Thuringia
@JsonValue("thueringen")
thuringia,
/// Baden-Württemberg
@JsonValue("baden-w")
badenWuerttemberg,
/// Rhineland Palatinate
@JsonValue("rheinland-pfalz")
rhinelandPalatinate,
/// Hesse
@JsonValue("hessen")
hesse,
/// Northrhine-Westphalia
@JsonValue("nrw")
northrhineWestphalia
}

144
pubspec.lock

@ -14,7 +14,7 @@ packages: @@ -14,7 +14,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.15"
version: "0.39.14"
args:
dependency: transitive
description:
@ -36,6 +36,62 @@ packages: @@ -36,6 +36,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.10"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.1"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.0"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
charcode:
dependency: transitive
description:
@ -43,6 +99,13 @@ packages: @@ -43,6 +99,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
cli_util:
dependency: transitive
description:
@ -50,6 +113,13 @@ packages: @@ -50,6 +113,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.0"
collection:
dependency: transitive
description:
@ -85,6 +155,20 @@ packages: @@ -85,6 +155,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.2"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.6"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
glob:
dependency: transitive
description:
@ -92,6 +176,13 @@ packages: @@ -92,6 +176,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
html:
dependency: transitive
description:
@ -134,6 +225,20 @@ packages: @@ -134,6 +225,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.2"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
logging:
dependency: transitive
description:
@ -198,7 +303,7 @@ packages: @@ -198,7 +303,7 @@ packages:
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
@ -218,6 +323,20 @@ packages: @@ -218,6 +323,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.4"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
shelf:
dependency: transitive
description:
@ -246,6 +365,13 @@ packages: @@ -246,6 +365,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6"
source_map_stack_trace:
dependency: transitive
description:
@ -281,6 +407,13 @@ packages: @@ -281,6 +407,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
string_scanner:
dependency: transitive
description:
@ -316,6 +449,13 @@ packages: @@ -316,6 +449,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.11"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
typed_data:
dependency: transitive
description:

9
pubspec.yaml

@ -6,6 +6,13 @@ homepage: https://git.jfdev.de/JonasFranzDEV/db_construction_site @@ -6,6 +6,13 @@ homepage: https://git.jfdev.de/JonasFranzDEV/db_construction_site
dependencies:
http: ^0.12.2
json_annotation: ^3.0.1
dev_dependencies:
test: ^1.15.3
test: ^1.15.3
build_runner: ^1.10.1
json_serializable: ^3.3.0
pedantic: ^1.9.2
# enable linting rules
include: package:pedantic/analysis_options.yaml

Loading…
Cancel
Save