Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: 2-1-starter/lib/server/piratesapi.dart

Issue 1056193003: Rename methods to better match new terminology and get rid of json data file. (Closed) Base URL: https://github.com/dart-lang/one-hour-codelab.git@server2
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 2-1-starter/lib/server/piratenames.json ('k') | 2-2-simple/lib/common/messages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: 2-1-starter/lib/server/piratesapi.dart
diff --git a/2-1-starter/lib/server/piratesapi.dart b/2-1-starter/lib/server/piratesapi.dart
index 8e95221e34104e1b7dfe79e1dc75a150a43a6a5a..bfce1c20dbf9a53e8847f6650996b6b1c79e9f62 100644
--- a/2-1-starter/lib/server/piratesapi.dart
+++ b/2-1-starter/lib/server/piratesapi.dart
@@ -4,27 +4,17 @@
library pirate.server;
-import 'dart:convert' show JSON;
-import 'dart:io';
import 'package:rpc/rpc.dart';
import '../common/messages.dart';
import '../common/utils.dart';
class PiratesApi {
- final Map<int, Pirate> _alivePirates = {};
- PirateShanghaier _shanghaier;
- Map<String, List<String>> _properPirates;
-
- PiratesApi() {
- var namesFile = new File(
- Platform.script.resolve('../lib/server/piratenames.json').toFilePath());
- _properPirates = JSON.decode(namesFile.readAsStringSync());
- _shanghaier = new PirateShanghaier(_properPirates);
- }
+ final Map<int, Pirate> _pirateCrew = {};
+ final PirateShanghaier _shanghaier = new PirateShanghaier(properPirateNames);
List<Pirate> listPirates() {
- return _alivePirates.values.toList();
+ return _pirateCrew.values.toList();
}
Pirate shanghaiAPirate() {
@@ -32,7 +22,7 @@ class PiratesApi {
if (pirate == null) {
throw new InternalServerError('Ran out of pirates!');
}
- _alivePirates[pirate.toString().hashCode] = pirate;
+ _pirateCrew[pirate.toString().hashCode] = pirate;
return pirate;
}
}
« no previous file with comments | « 2-1-starter/lib/server/piratenames.json ('k') | 2-2-simple/lib/common/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698