From c9f8cafa56b2445adebd7eab51ac4111c9e383e7 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Wed, 8 Mar 2017 17:47:58 -0500 Subject: [PATCH] 1.0.2 --- README.md | 4 ++-- lib/transformer.dart | 37 +++++++++++++++++++++---------------- pubspec.yaml | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 63bab4dd..b3c6163d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Angel Configuration -![version 1.0.1+8](https://img.shields.io/badge/version-1.0.1+8-red.svg) +![version 1.0.2](https://img.shields.io/badge/version-1.0.2-brightgreen.svg) ![build status](https://travis-ci.org/angel-dart/configuration.svg) Isomorphic YAML configuration loader for Angel. @@ -17,7 +17,7 @@ In `pubspec.yaml`: ```yaml dependencies: - angel_configuration: ^1.0.0-dev + angel_configuration: ^1.0.0 ``` # Usage diff --git a/lib/transformer.dart b/lib/transformer.dart index aa84f58e..0bc591e8 100644 --- a/lib/transformer.dart +++ b/lib/transformer.dart @@ -14,22 +14,27 @@ class ConfigurationTransformer extends Transformer { ConfigurationTransformer.asPlugin(this._settings) {} Future apply(Transform transform) async { - var app = new Angel(); + try { + var app = new Angel(); - await app.configure(loadConfigurationFile( - directoryPath: _settings.configuration["dir"] ?? "./config", - overrideEnvironmentName: _settings.configuration["env"])); + await app.configure(loadConfigurationFile( + directoryPath: _settings.configuration["dir"] ?? "./config", + overrideEnvironmentName: _settings.configuration["env"])); - var text = await transform.primaryInput.readAsString(); - var compilationUnit = parseCompilationUnit(text); - var visitor = new ConfigAstVisitor(app.properties); - visitor.visitCompilationUnit(compilationUnit); + var text = await transform.primaryInput.readAsString(); + var compilationUnit = parseCompilationUnit(text); + var visitor = new ConfigAstVisitor(app.properties); + visitor.visitCompilationUnit(compilationUnit); - await for (Map replaced in visitor.onReplaced) { + await for (Map replaced in visitor.onReplaced) { text = text.replaceAll(replaced["needle"], replaced["with"]); - } + } - transform.addOutput(new Asset.fromString(transform.primaryInput.id, text)); + transform + .addOutput(new Asset.fromString(transform.primaryInput.id, text)); + } catch (e) { + // Fail silently... + } } } @@ -51,15 +56,15 @@ class ConfigAstVisitor extends GeneralizingAstVisitor { for (int i = 0; i < split.length; i++) { if (parent != null && parent is Map) parent = parent[split[i]]; } - + return parent; } @override visitCompilationUnit(CompilationUnit ctx) { - var result = super.visitCompilationUnit(ctx); - _onReplaced.close(); - return result; + var result = super.visitCompilationUnit(ctx); + _onReplaced.close(); + return result; } @override @@ -70,7 +75,7 @@ class ConfigAstVisitor extends GeneralizingAstVisitor { _onReplaced.add({"needle": ctx.toString(), "with": ""}); if (ctx.asKeyword != null) { - _prefix = ctx.prefix.name; + _prefix = ctx.prefix.name; } } diff --git a/pubspec.yaml b/pubspec.yaml index 6798f541..f99cda59 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_configuration description: Isomorphic YAML configuration loader for Angel. -version: 1.0.1+8 +version: 1.0.2 author: Tobe O homepage: https://github.com/angel-dart/angel_configuration dependencies: