From f5913f8a37f28c3b5ea8426098894a9b1e542fa5 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 11 Jul 2017 16:41:32 -0400 Subject: [PATCH 1/6] Initial commit --- .gitignore | 12 ++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4d2a4d6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.packages +.pub/ +build/ +# If you're building an application, you may want to check-in your pubspec.lock +pubspec.lock + +# Directory created by dartdoc +# If you don't generate documentation locally you can remove this line. +doc/api/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..3de28325 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Tobe O + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..5aeb82bd --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# angel_model +Angel's basic data model class, no longer with the added weight of the whole framework. From 980e0408a055a8c9b99735a358e0b84923da5d7a Mon Sep 17 00:00:00 2001 From: thosakwe Date: Tue, 11 Jul 2017 16:46:12 -0400 Subject: [PATCH 2/6] 1.0.0 --- README.md | 10 ++++++++++ lib/angel_model.dart | 8 ++++++++ pubspec.yaml | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 lib/angel_model.dart create mode 100644 pubspec.yaml diff --git a/README.md b/README.md index 5aeb82bd..80a2b5c8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ # angel_model Angel's basic data model class, no longer with the added weight of the whole framework. + +```dart +// Old: import 'package:angel_framework/common.dart' show Model; + +// The new way!!! +import 'package:angel_model/angel_model.dart'; +``` + +This package was created to prevent dependency collisions with third-party packages. +`framework/common` will continue to export this class. \ No newline at end of file diff --git a/lib/angel_model.dart b/lib/angel_model.dart new file mode 100644 index 00000000..c07e0596 --- /dev/null +++ b/lib/angel_model.dart @@ -0,0 +1,8 @@ +/// Represents arbitrary data, with an associated ID and timestamps. +class Model { + String id; + DateTime createdAt; + DateTime updatedAt; + + Model({this.id, this.createdAt, this.updatedAt}); +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 00000000..fad57ab2 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,5 @@ +name: angel_model +version: 1.0.0 +description: Angel's basic data model class, no longer with the added weight of the whole framework. +author: Tobe O +homepage: https://github.com/angel-dart/model \ No newline at end of file From 7658217d05926735966f9bd8db74448a456c05e8 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 19 Aug 2018 10:55:18 -0400 Subject: [PATCH 3/6] Dart2 --- CHANGELOG.md | 2 ++ pubspec.yaml | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..d710edf3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# 1.0.0+1 +* Update constraint to work with Dart 2. diff --git a/pubspec.yaml b/pubspec.yaml index fad57ab2..20539a24 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,7 @@ name: angel_model -version: 1.0.0 +version: 1.0.0+1 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O -homepage: https://github.com/angel-dart/model \ No newline at end of file +homepage: https://github.com/angel-dart/model +environment: + sdk: ">=1.8.0 <3.0.0" From eb1c5f7df228ec79f3f33de8124b30e782acb38f Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 30 Dec 2018 19:30:23 -0500 Subject: [PATCH 4/6] 1.0.1 --- CHANGELOG.md | 3 +++ README.md | 6 +----- example/main.dart | 20 ++++++++++++++++++++ lib/angel_model.dart | 10 +++++++++- pubspec.yaml | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 example/main.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index d710edf3..ad7c5bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ +# 1.0.1 +* Add `idAsInt`. + # 1.0.0+1 * Update constraint to work with Dart 2. diff --git a/README.md b/README.md index 80a2b5c8..fdb704c9 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ Angel's basic data model class, no longer with the added weight of the whole framework. ```dart -// Old: import 'package:angel_framework/common.dart' show Model; - -// The new way!!! import 'package:angel_model/angel_model.dart'; ``` -This package was created to prevent dependency collisions with third-party packages. -`framework/common` will continue to export this class. \ No newline at end of file +This package was created to prevent dependency collisions with third-party packages. \ No newline at end of file diff --git a/example/main.dart b/example/main.dart new file mode 100644 index 00000000..f6c5caef --- /dev/null +++ b/example/main.dart @@ -0,0 +1,20 @@ +import 'package:angel_model/angel_model.dart'; + +void main() { + var todo = Todo(id: '34', isComplete: false); + print(todo.idAsInt == 34); +} + +class Todo extends Model { + String text; + + bool isComplete; + + Todo( + {String id, + this.text, + this.isComplete, + DateTime createdAt, + DateTime updatedAt}) + : super(id: id, createdAt: createdAt, updatedAt: updatedAt); +} diff --git a/lib/angel_model.dart b/lib/angel_model.dart index c07e0596..c3290602 100644 --- a/lib/angel_model.dart +++ b/lib/angel_model.dart @@ -1,8 +1,16 @@ /// Represents arbitrary data, with an associated ID and timestamps. class Model { + /// A unique identifier corresponding to this item. String id; + + /// The time at which this item was created. DateTime createdAt; + + /// The last time at which this item was updated. DateTime updatedAt; Model({this.id, this.createdAt, this.updatedAt}); -} \ No newline at end of file + + /// Returns the [id], parsed as an [int]. + int get idAsInt => int.parse(id); +} diff --git a/pubspec.yaml b/pubspec.yaml index 20539a24..bfa889ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_model -version: 1.0.0+1 +version: 1.0.1 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O homepage: https://github.com/angel-dart/model From d663c99582ef26e633b7a209f98fddb1f27207cc Mon Sep 17 00:00:00 2001 From: Tobe O Date: Thu, 28 Mar 2019 20:51:02 -0400 Subject: [PATCH 5/6] 1.0.2 --- CHANGELOG.md | 3 +++ analysis_options.yaml | 4 ++++ lib/angel_model.dart | 2 +- pubspec.yaml | 4 +++- 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 analysis_options.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7c5bc1..e28d4188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.0.2 +* `idAsInt` now uses `int.tryParse`. + # 1.0.1 * Add `idAsInt`. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..c230cee7 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:pedantic/analysis_options.yaml +analyzer: + strong-mode: + implicit-casts: false \ No newline at end of file diff --git a/lib/angel_model.dart b/lib/angel_model.dart index c3290602..0694c33a 100644 --- a/lib/angel_model.dart +++ b/lib/angel_model.dart @@ -12,5 +12,5 @@ class Model { Model({this.id, this.createdAt, this.updatedAt}); /// Returns the [id], parsed as an [int]. - int get idAsInt => int.parse(id); + int get idAsInt => int.tryParse(id); } diff --git a/pubspec.yaml b/pubspec.yaml index bfa889ee..e751fa00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,9 @@ name: angel_model -version: 1.0.1 +version: 1.0.2 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O homepage: https://github.com/angel-dart/model environment: sdk: ">=1.8.0 <3.0.0" +dev_dependencies: + pedantic: ^1.0.0 From 308cd94c783dcf884d88c1e6660bc86510616387 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 26 Apr 2019 09:50:07 -0400 Subject: [PATCH 6/6] 1.0.3 --- CHANGELOG.md | 3 +++ lib/angel_model.dart | 2 +- pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e28d4188..f1c86f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.0.3 +* `idAsInt` returns `null` when `id` is `null`. + # 1.0.2 * `idAsInt` now uses `int.tryParse`. diff --git a/lib/angel_model.dart b/lib/angel_model.dart index 0694c33a..d179fa54 100644 --- a/lib/angel_model.dart +++ b/lib/angel_model.dart @@ -12,5 +12,5 @@ class Model { Model({this.id, this.createdAt, this.updatedAt}); /// Returns the [id], parsed as an [int]. - int get idAsInt => int.tryParse(id); + int get idAsInt => id == null ? null : int.tryParse(id); } diff --git a/pubspec.yaml b/pubspec.yaml index e751fa00..22040435 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_model -version: 1.0.2 +version: 1.0.3 description: Angel's basic data model class, no longer with the added weight of the whole framework. author: Tobe O homepage: https://github.com/angel-dart/model