From 7259d2b73a921425bd59e3bfcd21d257ea09cd36 Mon Sep 17 00:00:00 2001 From: regiostech Date: Mon, 2 May 2016 19:35:21 -0400 Subject: [PATCH] 1.0.0 --- lib/angel_configuration.dart | 12 ++++++------ pubspec.yaml | 2 +- test/all_tests.dart | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/angel_configuration.dart b/lib/angel_configuration.dart index 88bae83e..a685b920 100644 --- a/lib/angel_configuration.dart +++ b/lib/angel_configuration.dart @@ -4,9 +4,9 @@ import 'dart:io'; import 'package:angel_framework/angel_framework.dart'; import 'package:yaml/yaml.dart'; -_loadYamlFile(Angel app, File yamlFile) { - if (yamlFile.existsSync()) { - Map config = loadYaml(yamlFile.readAsStringSync()); +_loadYamlFile(Angel app, File yamlFile) async { + if (await yamlFile.exists()) { + Map config = loadYaml(await yamlFile.readAsString()); for (String key in config.keys) { app.properties[key] = config[key]; } @@ -15,7 +15,7 @@ _loadYamlFile(Angel app, File yamlFile) { loadConfigurationFile( {String directoryPath: "./config", String overrideEnvironmentName}) { - return (Angel app) { + return (Angel app) async { Directory sourceDirectory = new Directory(directoryPath); String environmentName = Platform.environment['ANGEL_ENV'] ?? 'development'; @@ -25,12 +25,12 @@ loadConfigurationFile( File defaultYaml = new File.fromUri( sourceDirectory.absolute.uri.resolve("default.yaml")); - _loadYamlFile(app, defaultYaml); + await _loadYamlFile(app, defaultYaml); String configFilePath = "$environmentName.yaml"; File configFile = new File.fromUri( sourceDirectory.absolute.uri.resolve(configFilePath)); - _loadYamlFile(app, configFile); + await _loadYamlFile(app, configFile); }; } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 40cb217d..d02de4fa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_configuration description: YAML configuration loader for Angel. -version: 1.0.0-dev +version: 1.0.0 author: thosakwe homepage: https://github.com/angel-dart/angel_configuration dependencies: diff --git a/test/all_tests.dart b/test/all_tests.dart index 9fb2aadf..e76497de 100644 --- a/test/all_tests.dart +++ b/test/all_tests.dart @@ -2,13 +2,14 @@ import 'package:angel_framework/angel_framework.dart'; import 'package:angel_configuration/angel_configuration.dart'; import 'package:test/test.dart'; -main() { +main() async { // Note: Set ANGEL_ENV to 'development' Angel angel = new Angel(); + await angel.configure( + loadConfigurationFile(directoryPath: './test/config')); - test('can load based on ANGEL_ENV', () { - angel.configure(loadConfigurationFile(directoryPath: './test/config')); + test('can load based on ANGEL_ENV', () async { expect(angel.properties['hello'], equals('world')); expect(angel.properties['foo']['version'], equals('bar')); }); @@ -18,8 +19,8 @@ main() { }); - test('can override ANGEL_ENV', () { - angel.configure(loadConfigurationFile( + test('can override ANGEL_ENV', () async { + await angel.configure(loadConfigurationFile( directoryPath: './test/config', overrideEnvironmentName: 'override')); expect(angel.properties['hello'], equals('goodbye')); expect(angel.properties['foo']['version'], equals('baz'));