2.0.0 bump
This commit is contained in:
parent
3e157caa6c
commit
48e294f5c2
4 changed files with 24 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
# 2.0.0
|
||||||
|
* Dart/Angel 2 update.
|
||||||
|
* Remove `package:dart2_constant`
|
||||||
|
* Update `package:file` to `^5.0.0`.
|
||||||
|
|
||||||
# 1.1.2
|
# 1.1.2
|
||||||
* Added tests, because tests.
|
* Added tests, because tests.
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
import 'package:dart2_constant/convert.dart';
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:pool/pool.dart';
|
import 'package:pool/pool.dart';
|
||||||
|
|
||||||
/// Persists in-memory changes to a file on disk.
|
/// Persists in-memory changes to a file on disk.
|
||||||
class JsonFileService extends Service {
|
class JsonFileService extends Service<String, Map<String, dynamic>> {
|
||||||
FileStat _lastStat;
|
FileStat _lastStat;
|
||||||
final Pool _mutex = new Pool(1);
|
final Pool _mutex = new Pool(1);
|
||||||
MapService _store;
|
MapService _store;
|
||||||
|
@ -58,15 +58,17 @@ class JsonFileService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List> index([Map params]) async =>
|
Future<List<Map<String, dynamic>>> index(
|
||||||
|
[Map<String, dynamic> params]) async =>
|
||||||
_load().then((_) => _store.index(params));
|
_load().then((_) => _store.index(params));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map> read(id, [Map params]) =>
|
Future<Map<String, dynamic>> read(id, [Map<String, dynamic> params]) =>
|
||||||
_load().then((_) => _store.read(id, params));
|
_load().then((_) => _store.read(id, params));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map> create(data, [Map params]) async {
|
Future<Map<String, dynamic>> create(data,
|
||||||
|
[Map<String, dynamic> params]) async {
|
||||||
await _load();
|
await _load();
|
||||||
var created = await _store.create(data, params);
|
var created = await _store.create(data, params);
|
||||||
await _save();
|
await _save();
|
||||||
|
@ -74,7 +76,7 @@ class JsonFileService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map> remove(id, [Map params]) async {
|
Future<Map<String, dynamic>> remove(id, [Map<String, dynamic> params]) async {
|
||||||
await _load();
|
await _load();
|
||||||
var r = await _store.remove(id, params);
|
var r = await _store.remove(id, params);
|
||||||
await _save();
|
await _save();
|
||||||
|
@ -82,7 +84,8 @@ class JsonFileService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map> update(id, data, [Map params]) async {
|
Future<Map<String, dynamic>> update(id, data,
|
||||||
|
[Map<String, dynamic> params]) async {
|
||||||
await _load();
|
await _load();
|
||||||
var r = await _store.update(id, data, params);
|
var r = await _store.update(id, data, params);
|
||||||
await _save();
|
await _save();
|
||||||
|
@ -90,7 +93,8 @@ class JsonFileService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Map> modify(id, data, [Map params]) async {
|
Future<Map<String, dynamic>> modify(id, data,
|
||||||
|
[Map<String, dynamic> params]) async {
|
||||||
await _load();
|
await _load();
|
||||||
var r = await _store.update(id, data, params);
|
var r = await _store.update(id, data, params);
|
||||||
await _save();
|
await _save();
|
||||||
|
@ -117,7 +121,8 @@ Map _jsonify(Map map) {
|
||||||
|
|
||||||
dynamic _revive(x) {
|
dynamic _revive(x) {
|
||||||
if (x is Map) {
|
if (x is Map) {
|
||||||
return x.keys.fold<Map>({}, (out, k) => out..[k] = _revive(x[k]));
|
return x.keys.fold<Map<String, dynamic>>(
|
||||||
|
{}, (out, k) => out..[k.toString()] = _revive(x[k]));
|
||||||
} else if (x is Iterable)
|
} else if (x is Iterable)
|
||||||
return x.map(_revive).toList();
|
return x.map(_revive).toList();
|
||||||
else if (x is String) {
|
else if (x is String) {
|
||||||
|
|
11
pubspec.yaml
11
pubspec.yaml
|
@ -1,14 +1,13 @@
|
||||||
name: angel_file_service
|
name: angel_file_service
|
||||||
version: 1.1.2
|
version: 2.0.0
|
||||||
description: Angel service that persists data to a file on disk.
|
description: Angel service that persists data to a file on disk.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/file_service
|
homepage: https://github.com/angel-dart/file_service
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=1.8.0 <3.0.0"
|
sdk: ">=2.0.0-dev <3.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: ^1.1.0-alpha
|
angel_framework: ^2.0.0-alpha
|
||||||
dart2_constant: ^1.0.0
|
file: ^5.0.0
|
||||||
file: ^2.0.0
|
|
||||||
pool: ^1.0.0
|
pool: ^1.0.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test:
|
test: ^1.0.0
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:angel_file_service/angel_file_service.dart';
|
import 'package:angel_file_service/angel_file_service.dart';
|
||||||
import 'package:angel_framework/angel_framework.dart';
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
Loading…
Reference in a new issue