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

Commit

Permalink
Merge pull request #27 from lrhn/remove-upper-case-constants
Browse files Browse the repository at this point in the history
Remove usage of deprecated Dart 1 upper-case constants
  • Loading branch information
lrhn authored May 22, 2018
2 parents ba1765d + 14e7648 commit 15e4a10
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ language: dart

dart:
- dev
- stable

dart_task:
- test
- dartanalyzer
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.8

* Updated SDK version to 2.0.0-dev.17.0

## 2.0.7

* When a `Client` is closed before a request completes, the error sent to that
Expand Down
8 changes: 4 additions & 4 deletions lib/src/parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ class Parameter extends Parameters {
/// parameter is represented by that name in quotes.
String get _path {
if (_parent is! Parameter) {
return _key is int ? (_key + 1).toString() : JSON.encode(_key);
return _key is int ? (_key + 1).toString() : jsonEncode(_key);
}

quoteKey(key) {
if (key.contains(new RegExp(r'[^a-zA-Z0-9_-]'))) return JSON.encode(key);
if (key.contains(new RegExp(r'[^a-zA-Z0-9_-]'))) return jsonEncode(key);
return key;
}

Expand Down Expand Up @@ -267,7 +267,7 @@ class Parameter extends Parameters {
_getTyped(String type, bool test(value)) {
if (test(value)) return value;
throw new RpcException.invalidParams('Parameter $_path for method '
'"$method" must be $type, but was ${JSON.encode(value)}.');
'"$method" must be $type, but was ${jsonEncode(value)}.');
}

_getParsed(String description, parse(String value)) {
Expand All @@ -287,7 +287,7 @@ class Parameter extends Parameters {

throw new RpcException.invalidParams('Parameter $_path for method '
'"$method" must be a valid $description, but was '
'${JSON.encode(string)}.$message');
'${jsonEncode(string)}.$message');
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class Server {
throw new RpcException(
error_code.INVALID_REQUEST,
'Invalid JSON-RPC '
'version ${JSON.encode(request['jsonrpc'])}, expected "2.0".');
'version ${jsonEncode(request['jsonrpc'])}, expected "2.0".');
}

if (!request.containsKey('method')) {
Expand All @@ -224,23 +224,23 @@ class Server {
throw new RpcException(
error_code.INVALID_REQUEST,
'Request method must '
'be a string, but was ${JSON.encode(method)}.');
'be a string, but was ${jsonEncode(method)}.');
}

var params = request['params'];
if (request.containsKey('params') && params is! List && params is! Map) {
throw new RpcException(
error_code.INVALID_REQUEST,
'Request params must '
'be an Array or an Object, but was ${JSON.encode(params)}.');
'be an Array or an Object, but was ${jsonEncode(params)}.');
}

var id = request['id'];
if (id != null && id is! String && id is! num) {
throw new RpcException(
error_code.INVALID_REQUEST,
'Request id must be a '
'string, number, or null, but was ${JSON.encode(id)}.');
'string, number, or null, but was ${jsonEncode(id)}.');
}
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: json_rpc_2
version: 2.0.7
version: 2.0.8
author: Dart Team <misc@dartlang.org>
description: An implementation of the JSON-RPC 2.0 spec.
homepage: http://github.com/dart-lang/json_rpc_2
Expand All @@ -9,4 +9,4 @@ dependencies:
dev_dependencies:
test: "^0.12.28"
environment:
sdk: ">=1.8.0 <2.0.0"
sdk: ">=2.0.0-dev.17.0 <2.0.0"
6 changes: 3 additions & 3 deletions test/client/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ class ClientController {
void expectRequest(callback(request)) {
expect(
_requestController.stream.first.then((request) {
return callback(JSON.decode(request));
return callback(jsonDecode(request));
}).then((response) {
if (response == null) return;
if (response is! String) response = JSON.encode(response);
if (response is! String) response = jsonEncode(response);
_responseController.add(response);
}),
completes);
}

/// Sends [response], a decoded response, to [client].
void sendResponse(response) {
sendJsonResponse(JSON.encode(response));
sendJsonResponse(jsonEncode(response));
}

/// Sends [response], a JSON-encoded response, to [client].
Expand Down
2 changes: 1 addition & 1 deletion test/peer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void main() {
new StreamChannel(incomingController.stream, outgoingController));

expect(
outgoingController.stream.first.then(JSON.decode),
outgoingController.stream.first.then(jsonDecode),
completion({
"jsonrpc": "2.0",
"error": {
Expand Down
2 changes: 1 addition & 1 deletion test/server/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void main() {

test("a JSON parse error is rejected", () {
return controller.handleJsonRequest('invalid json {').then((result) {
expect(JSON.decode(result), {
expect(jsonDecode(result), {
'jsonrpc': '2.0',
'error': {
'code': error_code.PARSE_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion test/server/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ServerController {
/// Passes [request], a decoded request, to [server] and returns its decoded
/// response.
Future handleRequest(request) =>
handleJsonRequest(JSON.encode(request)).then(JSON.decode);
handleJsonRequest(jsonEncode(request)).then(jsonDecode);

/// Passes [request], a JSON-encoded request, to [server] and returns its
/// encoded response.
Expand Down

0 comments on commit 15e4a10

Please sign in to comment.