Skip to content

Commit

Permalink
Release 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Portnov committed Aug 30, 2024
1 parent 76e4ef1 commit c4574ec
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dart:
- dev
dart_task:
- test: --platform vm
- test: --platform firefox -j 1
- test: --platform chrome
- dartanalyzer: --fatal-warnings --fatal-lints lib
branches:
only: [master]
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

## 2.1.0
Minimal Dart v.3.3 dependency

### Changed
- `TimeUuidGenerator.nodeId` is changed from `UnmodifiableUint8ListView` to read-only `Uint8List`

## 2.0.0
Stable null safety release

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2019 Denis Portnov <[email protected]
Copyright (c) 2024 Denis Portnov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ and supports generation, parsing and formatting of UUIDs.
Features:
* [x] Creates UUID from string and byte-array, as well as GUID and URN strings
* [x] Provides access to variant, version and byte data of UUID
* [x] Generates RFC4122 time-based v1, random-based v4, and namespace & name-based v5 UUIDs
* [x] Generates RFC4122 version 1, version 4, or version 5 UUIDs
* [x] Implements `Comparable` for UUID comparison and lexicographical sorting
* [x] Runs on Dart VM and in browser
* [x] Runs in web, server, and flutter

RFC 4122 Version support:
- [x] v1, based on timestamp and MAC address (RFC 4122)
RFC Version support:
- [x] v1, based on timestamp and MAC address
- [ ] v2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) **Not planned**
- [ ] v3, based on MD5 hashing (RFC 4122) **Not planned**
- [x] v4, based on random numbers (RFC 4122)
- [x] v5, based on SHA-1 hashing (RFC 4122)
- [ ] v3, based on MD5 hashing **Not planned**
- [x] v4, based on random numbers
- [x] v5, based on SHA-1 hashing
- [ ] v6, A re-ordering of UUID version 1 so it is sortable as an opaque sequence of bytes
- [ ] v7, An entirely new time-based UUID bit layout sourced from the widely implemented and well known Unix Epoch timestamp source
- [ ] v8, A free-form UUID format which has no explicit requirements except maintaining backward compatibility.

## Requirements
- Dart SDK >- 2.12.0
- Dart SDK >= 2.12.0
- `crypto` package

## Getting Started
Expand All @@ -31,7 +34,7 @@ RFC 4122 Version support:
1. Add an entry in your `pubspec.yaml` for `uuid_type`
```yaml
dependencies:
uuid_type: ^2.0.0
uuid_type: ^2.1.0
```
2. Run `pub get` (`flutter packages get` for Flutter)
3. Import
Expand Down Expand Up @@ -65,5 +68,4 @@ See [CHANGELOG](CHANGELOG.md)
## Features and Bugs
Please file bugs and feature requests at the [issue tracker][tracker].


[tracker]: https://github.com/denixport/dart-uuid/issues
81 changes: 8 additions & 73 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,78 +1,13 @@
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
errors:
dead_code: error
missing_required_param: error
missing_return: error
omit_local_variable_types: info
prefer_single_quotes: info
todo: ignore
unused_element: error
unused_import: error
unused_local_variable: error
language:
strict-casts: true
strict-inference: true
strict-raw-types: true

linter:
rules:
- always_declare_return_types
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_empty_else
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_return_types_on_setters
- avoid_shadowing_type_parameters
- avoid_types_as_parameter_names
- await_only_futures
- camel_case_extensions
- camel_case_types
- avoid_unused_constructor_parameters
- cancel_subscriptions
- comment_references
- control_flow_in_finally
- curly_braces_in_flow_control_structures
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- no_duplicate_case_values
- non_constant_identifier_names
- null_closures
- overridden_fields
- package_api_docs
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_contains
- prefer_equal_for_default_values
- prefer_final_fields
- prefer_for_elements_to_map_fromIterable
- prefer_generic_function_type_aliases
- prefer_if_null_operators
- prefer_is_empty
- prefer_is_not_empty
- prefer_iterable_whereType
- prefer_spread_collections
- public_member_api_docs
- recursive_getters
- slash_for_doc_comments
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unawaited_futures
- unnecessary_const
- unnecessary_new
- unnecessary_null_in_if_null_operators
- unnecessary_this
- unrelated_type_equality_checks
- use_function_type_syntax_for_parameters
- use_rethrow_when_possible
- valid_regexps
- package_api_docs
6 changes: 3 additions & 3 deletions lib/src/generators.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) 2018-2021, Denis Portnov. All rights reserved.
// Copyright (c) 2018-2024, Denis Portnov. All rights reserved.
// Released under MIT License that can be found in the LICENSE file.

library uuid_type.generators;

import 'dart:convert' show utf8;
import 'dart:math' show Random;
import 'dart:typed_data' show Uint8List, UnmodifiableUint8ListView;
import 'dart:typed_data' show Uint8List;

import 'package:crypto/crypto.dart' show sha1;

Expand Down Expand Up @@ -127,7 +127,7 @@ class TimeUuidGenerator {
int get clockSequence => _clockSeq;

/// Returns Node ID for this generator
UnmodifiableUint8ListView get nodeId => UnmodifiableUint8ListView(_nodeId);
Uint8List get nodeId => _nodeId.asUnmodifiableView();

/// Generates UUID for current time
Uuid generate() {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/util.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2021, Denis Portnov. All rights reserved.
// Copyright (c) 2018-2024, Denis Portnov. All rights reserved.
// Released under MIT License that can be found in the LICENSE file.

library uuid_type.util;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/uuid.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2021, Denis Portnov. All rights reserved.
// Copyright (c) 2018-2024, Denis Portnov. All rights reserved.
// Released under MIT License that can be found in the LICENSE file.

library uuid_type;
Expand Down
12 changes: 7 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: uuid_type
description: UUID type, parser and generators. Can generate v1, v4, and v5 UUIDs
version: 2.0.0
version: 2.1.0
uploader: Denis Portnov <[email protected]>
homepage: https://github.com/denixport/dart-uuid
repository: https://github.com/denixport/dart-uuid
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: ">=3.3.0 <4.0.0"
dependencies:
crypto: ^3.0.0
dev_dependencies:
test: ^1.16.8
pedantic: ^1.11.0
test: ^1.25.8
lints: ^4.0.0
topics:
- uuid
4 changes: 4 additions & 0 deletions test/generators_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ void main() {
gi %= gens.length;
}
});

test('Node ID is not modifiable', () {
expect(() => TimeUuidGenerator().nodeId[0] = 0, throwsA(TypeMatcher<UnsupportedError>()));
});
});

group('Random-based generator (v4)', () {
Expand Down
12 changes: 6 additions & 6 deletions test/uuid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ void main() {
group('Parsing', () {
test('Can be parsed from various formats', () {
final expected = validStrings[0];
validStrings.forEach((String source) {
for (var source in validStrings) {
expect((Uuid.parse(source)).toString(), expected);
});
}
});

test('Invalid string throws FormatException', () {
invalidStrings.forEach((String source) {
for (var source in invalidStrings) {
expect(() => Uuid.parse(source), throwsFormatException);
});
}
});

test('Nil strings are parsed to Nil UUID', () {
nilStrings.forEach((String source) {
for (var source in nilStrings) {
expect(identical(Uuid.parse(source), Uuid.nil), isTrue);
});
}
});
});

Expand Down

0 comments on commit c4574ec

Please sign in to comment.