Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Add (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
goderbauer authored May 19, 2017
1 parent 0a85ce0 commit aba5b2b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
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

* Added `localeName`
* Bumped minimum Dart SDK version to 1.24.0-dev.0.0

### 2.0.0

* Added `stdinSupportsAnsi` and `stdinSupportsAnsi`
* Removed `ansiSupported`

Expand Down
3 changes: 3 additions & 0 deletions lib/src/interface/local_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ class LocalPlatform extends Platform {

@override
bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes;

@override
String get localeName => io.Platform.localeName;
}
4 changes: 4 additions & 0 deletions lib/src/interface/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ abstract class Platform {
/// When stdout is connected to a terminal, whether ANSI codes are supported.
bool get stdoutSupportsAnsi;

/// Get the name of the current locale.
String get localeName;

/// Returns a JSON-encoded representation of this platform.
String toJson() {
return const JsonEncoder.withIndent(' ').convert(<String, dynamic>{
Expand All @@ -137,6 +140,7 @@ abstract class Platform {
'version': version,
'stdinSupportsAnsi': stdinSupportsAnsi,
'stdoutSupportsAnsi': stdoutSupportsAnsi,
'localeName': localeName,
});
}
}
8 changes: 7 additions & 1 deletion lib/src/testing/fake_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class FakePlatform extends Platform {
this.version,
this.stdinSupportsAnsi,
this.stdoutSupportsAnsi,
this.localeName,
});

/// Creates a new [FakePlatform] with properties whose initial values mirror
Expand All @@ -46,7 +47,8 @@ class FakePlatform extends Platform {
packageConfig = platform.packageConfig,
version = platform.version,
stdinSupportsAnsi = platform.stdinSupportsAnsi,
stdoutSupportsAnsi = platform.stdoutSupportsAnsi;
stdoutSupportsAnsi = platform.stdoutSupportsAnsi,
localeName = platform.localeName;

/// Creates a new [FakePlatform] with properties extracted from the encoded
/// JSON string.
Expand All @@ -70,6 +72,7 @@ class FakePlatform extends Platform {
version: map['version'],
stdinSupportsAnsi: map['stdinSupportsAnsi'],
stdoutSupportsAnsi: map['stdoutSupportsAnsi'],
localeName: map['localeName'],
);
}

Expand Down Expand Up @@ -114,4 +117,7 @@ class FakePlatform extends Platform {

@override
bool stdoutSupportsAnsi;

@override
String localeName;
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: platform
version: 2.0.0
version: 2.1.0
authors:
- Todd Volkert <[email protected]>
description: A pluggable, mockable platform abstraction for Dart.
Expand All @@ -9,4 +9,4 @@ dev_dependencies:
test: ^0.12.10

environment:
sdk: '>=1.23.0-dev.10.0 <2.0.0'
sdk: '>=1.24.0-dev.0.0 <2.0.0'
2 changes: 2 additions & 0 deletions test/fake_platform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void _expectPlatformsEqual(Platform actual, Platform expected) {
expect(actual.packageRoot, expected.packageRoot);
expect(actual.packageConfig, expected.packageConfig);
expect(actual.version, expected.version);
expect(actual.localeName, expected.localeName);
}

void main() {
Expand Down Expand Up @@ -75,6 +76,7 @@ void main() {
expect(fake.packageRoot, null);
expect(fake.packageConfig, null);
expect(fake.version, '1.22.0');
expect(fake.localeName, 'de/de');
});

test('fromJsonToJson', () {
Expand Down
3 changes: 2 additions & 1 deletion test/platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
],
"packageRoot": null,
"packageConfig": null,
"version": "1.22.0"
"version": "1.22.0",
"localeName": "de/de"
}

0 comments on commit aba5b2b

Please sign in to comment.