Skip to content

Commit

Permalink
chore: prepare 3.0.1 release (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcb authored Jan 13, 2025
1 parent 9cdfe1f commit 9589ffe
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 366 deletions.
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ linter:
# See this related issue: https://github.com/dart-lang/pedantic/issues/23
rules:
# Error rules
- avoid_returning_null_for_future
- avoid_slow_async_io
- cancel_subscriptions
- close_sinks
- comment_references
- control_flow_in_finally
- empty_statements
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- prefer_void_to_null
Expand All @@ -28,7 +25,6 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
Expand Down
2 changes: 1 addition & 1 deletion lib/humanizer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// A Dart library to convert values into human-friendly [String]s.
library humanizer;
library;

export 'src/transformations/approximate_time.dart';
export 'src/transformations/approximate_time_extensions.dart';
Expand Down
44 changes: 15 additions & 29 deletions lib/src/units_of_measurement/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:meta/meta.dart';
/// A unit of measurement representing a two-dimensional area.
class Area extends UnitOfMeasurement<AreaUnit, Area> {
/// Creates an [Area] given a [unit] and rational [value] for that unit.
Area.fromUnits(AreaUnit unit, Rational value) : super.fromUnits(unit, value);
Area.fromUnits(super.unit, super.value) : super.fromUnits();

/// Creates an [Area] representing the specified number of [squareNanometers].
factory Area.fromSquareNanometers(Rational squareNanometers) =>
Expand Down Expand Up @@ -422,12 +422,9 @@ extension AreaUnitExtensions on AreaUnit {
/// Represents a rate of change in [Area].
class AreaRate extends UnitOfMeasurementRate<Area> {
const AreaRate._({
required Area value,
required Duration period,
}) : super(
value: value,
period: period,
);
required super.value,
required super.period,
}) : super();

static final _defaultFormat = AreaRateFormat();

Expand Down Expand Up @@ -477,15 +474,12 @@ class AreaRate extends UnitOfMeasurementRate<Area> {
/// * [UnitOfMeasurementFormat]
class AreaFormat extends _BaseAreaFormat<Area> {
AreaFormat({
String pattern =
super.pattern =
'0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}',
Set<AreaUnit> permissibleValueUnits = AreaUnits.commonSi,
String? locale,
super.permissibleValueUnits = AreaUnits.commonSi,
super.locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: const <RateUnit>{},
locale: locale,
);

@override
Expand Down Expand Up @@ -522,17 +516,12 @@ class AreaFormat extends _BaseAreaFormat<Area> {
/// * [AreaFormat]
class AreaRateFormat extends _BaseAreaFormat<AreaRate> {
AreaRateFormat({
String pattern =
super.pattern =
"0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}'/'${UnitOfMeasurementFormat.rateUnitSymbolFormatSpecifier}",
Set<AreaUnit> permissibleValueUnits = AreaUnits.commonSi,
Set<RateUnit> permissibleRateUnits = RateUnits.hourOrLess,
String? locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: permissibleRateUnits,
locale: locale,
);
super.permissibleValueUnits = AreaUnits.commonSi,
super.permissibleRateUnits = RateUnits.hourOrLess,
super.locale,
}) : super._();

@override
AreaUnit getLargestUnit(AreaRate input) =>
Expand All @@ -556,14 +545,11 @@ class AreaRateFormat extends _BaseAreaFormat<AreaRate> {
abstract class _BaseAreaFormat<TInput>
extends UnitOfMeasurementFormat<TInput, AreaUnit> {
_BaseAreaFormat._({
required String pattern,
required super.pattern,
required this.permissibleValueUnits,
required this.permissibleRateUnits,
required String? locale,
}) : super(
pattern: pattern,
locale: locale,
);
required super.locale,
}) : super();

final Set<AreaUnit> permissibleValueUnits;
final Set<RateUnit> permissibleRateUnits;
Expand Down
45 changes: 15 additions & 30 deletions lib/src/units_of_measurement/information.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:meta/meta.dart';
class InformationSize
extends UnitOfMeasurement<InformationUnit, InformationSize> {
/// Creates an [InformationSize] given a [unit] and rational [value] for that unit.
InformationSize.fromUnits(InformationUnit unit, Rational value)
: super.fromUnits(unit, value);
InformationSize.fromUnits(super.unit, super.value) : super.fromUnits();

/// Creates an [InformationSize] representing the specified number of [bits].
factory InformationSize.fromBits(Rational bits) =>
Expand Down Expand Up @@ -756,12 +755,9 @@ extension InformationUnitExtensions on InformationUnit {
/// Represents a rate of transfer of [InformationSize].
class InformationRate extends UnitOfMeasurementRate<InformationSize> {
const InformationRate._({
required InformationSize value,
required Duration period,
}) : super(
value: value,
period: period,
);
required super.value,
required super.period,
}) : super();

static final _defaultFormat = InformationRateFormat();

Expand Down Expand Up @@ -835,15 +831,12 @@ class InformationRate extends UnitOfMeasurementRate<InformationSize> {
/// * [UnitOfMeasurementFormat]
class InformationSizeFormat extends _BaseInformationFormat<InformationSize> {
InformationSizeFormat({
String pattern =
super.pattern =
'0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}',
Set<InformationUnit> permissibleValueUnits = InformationUnits.iecBytes,
String? locale,
super.permissibleValueUnits = InformationUnits.iecBytes,
super.locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: const <RateUnit>{},
locale: locale,
);

@override
Expand Down Expand Up @@ -885,17 +878,12 @@ class InformationSizeFormat extends _BaseInformationFormat<InformationSize> {
/// * [InformationSizeFormat]
class InformationRateFormat extends _BaseInformationFormat<InformationRate> {
InformationRateFormat({
String pattern =
super.pattern =
"0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}'/'${UnitOfMeasurementFormat.rateUnitSymbolFormatSpecifier}",
Set<InformationUnit> permissibleValueUnits = InformationUnits.iecBytes,
Set<RateUnit> permissibleRateUnits = RateUnits.hourOrLess,
String? locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: permissibleRateUnits,
locale: locale,
);
super.permissibleValueUnits = InformationUnits.iecBytes,
super.permissibleRateUnits = RateUnits.hourOrLess,
super.locale,
}) : super._();

@override
InformationUnit getLargestUnit(InformationRate input) =>
Expand All @@ -919,14 +907,11 @@ class InformationRateFormat extends _BaseInformationFormat<InformationRate> {
abstract class _BaseInformationFormat<TInput>
extends UnitOfMeasurementFormat<TInput, InformationUnit> {
_BaseInformationFormat._({
required String pattern,
required super.pattern,
required this.permissibleValueUnits,
required this.permissibleRateUnits,
required String? locale,
}) : super(
pattern: pattern,
locale: locale,
);
required super.locale,
}) : super();

final Set<InformationUnit> permissibleValueUnits;
final Set<RateUnit> permissibleRateUnits;
Expand Down
45 changes: 15 additions & 30 deletions lib/src/units_of_measurement/length.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:meta/meta.dart';
/// A unit of measurement representing a one-dimensional length.
class Length extends UnitOfMeasurement<LengthUnit, Length> {
/// Creates a [Length] given a [unit] and rational [value] for that unit.
Length.fromUnits(LengthUnit unit, Rational value)
: super.fromUnits(unit, value);
Length.fromUnits(super.unit, super.value) : super.fromUnits();

/// Creates a [Length] representing the specified number of [nanometers].
factory Length.fromNanometers(Rational nanometers) =>
Expand Down Expand Up @@ -403,12 +402,9 @@ extension LengthUnitExtensions on LengthUnit {
/// Represents a rate of change in [Length] (a.k.a. a speed).
class LengthRate extends UnitOfMeasurementRate<Length> {
const LengthRate._({
required Length value,
required Duration period,
}) : super(
value: value,
period: period,
);
required super.value,
required super.period,
}) : super();

static final _defaultFormat = LengthRateFormat();

Expand Down Expand Up @@ -457,15 +453,12 @@ class LengthRate extends UnitOfMeasurementRate<Length> {
/// * [UnitOfMeasurementFormat]
class LengthFormat extends _BaseLengthFormat<Length> {
LengthFormat({
String pattern =
super.pattern =
'0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}',
Set<LengthUnit> permissibleValueUnits = LengthUnits.commonSi,
String? locale,
super.permissibleValueUnits = LengthUnits.commonSi,
super.locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: const <RateUnit>{},
locale: locale,
);

@override
Expand Down Expand Up @@ -506,17 +499,12 @@ class LengthFormat extends _BaseLengthFormat<Length> {
/// * [LengthFormat]
class LengthRateFormat extends _BaseLengthFormat<LengthRate> {
LengthRateFormat({
String pattern =
super.pattern =
"0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}'/'${UnitOfMeasurementFormat.rateUnitSymbolFormatSpecifier}",
Set<LengthUnit> permissibleValueUnits = LengthUnits.commonSi,
Set<RateUnit> permissibleRateUnits = RateUnits.hourOrLess,
String? locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: permissibleRateUnits,
locale: locale,
);
super.permissibleValueUnits = LengthUnits.commonSi,
super.permissibleRateUnits = RateUnits.hourOrLess,
super.locale,
}) : super._();

@override
LengthUnit getLargestUnit(LengthRate input) =>
Expand All @@ -540,14 +528,11 @@ class LengthRateFormat extends _BaseLengthFormat<LengthRate> {
abstract class _BaseLengthFormat<TInput>
extends UnitOfMeasurementFormat<TInput, LengthUnit> {
_BaseLengthFormat._({
required String pattern,
required super.pattern,
required this.permissibleValueUnits,
required this.permissibleRateUnits,
required String? locale,
}) : super(
pattern: pattern,
locale: locale,
);
required super.locale,
}) : super();

final Set<LengthUnit> permissibleValueUnits;
final Set<RateUnit> permissibleRateUnits;
Expand Down
45 changes: 15 additions & 30 deletions lib/src/units_of_measurement/quantity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:meta/meta.dart';
/// means it is a quantity that has no corresponding physical dimension associated with it.
class Quantity extends UnitOfMeasurement<QuantityUnit, Quantity> {
/// Creates a [Quantity] given a [unit] and rational [value] for that unit.
Quantity.fromUnits(QuantityUnit unit, Rational value)
: super.fromUnits(unit, value);
Quantity.fromUnits(super.unit, super.value) : super.fromUnits();

/// Creates a [Quantity] representing the specified number of [ones].
factory Quantity.fromOnes(Rational ones) =>
Expand Down Expand Up @@ -167,12 +166,9 @@ extension QuantityUnitExtensions on QuantityUnit {
/// Represents a rate of change in [Quantity].
class QuantityRate extends UnitOfMeasurementRate<Quantity> {
const QuantityRate._({
required Quantity value,
required Duration period,
}) : super(
value: value,
period: period,
);
required super.value,
required super.period,
}) : super();

static final _defaultFormat = QuantityRateFormat();

Expand Down Expand Up @@ -210,15 +206,12 @@ class QuantityRate extends UnitOfMeasurementRate<Quantity> {
/// * [UnitOfMeasurementFormat]
class QuantityFormat extends _BaseQuantityFormat<Quantity> {
QuantityFormat({
String pattern =
super.pattern =
'0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}',
Set<QuantityUnit> permissibleValueUnits = QuantityUnits.all,
String? locale,
super.permissibleValueUnits = QuantityUnits.all,
super.locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: const <RateUnit>{},
locale: locale,
);

@override
Expand Down Expand Up @@ -263,17 +256,12 @@ class QuantityFormat extends _BaseQuantityFormat<Quantity> {
/// * [QuantityFormat]
class QuantityRateFormat extends _BaseQuantityFormat<QuantityRate> {
QuantityRateFormat({
String pattern =
super.pattern =
"0.##${UnitOfMeasurementFormat.valueUnitSymbolFormatSpecifier}'/'${UnitOfMeasurementFormat.rateUnitSymbolFormatSpecifier}",
Set<QuantityUnit> permissibleValueUnits = QuantityUnits.all,
Set<RateUnit> permissibleRateUnits = RateUnits.hourOrLess,
String? locale,
}) : super._(
pattern: pattern,
permissibleValueUnits: permissibleValueUnits,
permissibleRateUnits: permissibleRateUnits,
locale: locale,
);
super.permissibleValueUnits = QuantityUnits.all,
super.permissibleRateUnits = RateUnits.hourOrLess,
super.locale,
}) : super._();

@override
QuantityUnit getLargestUnit(QuantityRate input) =>
Expand All @@ -297,14 +285,11 @@ class QuantityRateFormat extends _BaseQuantityFormat<QuantityRate> {
abstract class _BaseQuantityFormat<TInput>
extends UnitOfMeasurementFormat<TInput, QuantityUnit> {
_BaseQuantityFormat._({
required String pattern,
required super.pattern,
required this.permissibleValueUnits,
required this.permissibleRateUnits,
required String? locale,
}) : super(
pattern: pattern,
locale: locale,
);
required super.locale,
}) : super();

final Set<QuantityUnit> permissibleValueUnits;
final Set<RateUnit> permissibleRateUnits;
Expand Down
Loading

0 comments on commit 9589ffe

Please sign in to comment.