| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:collection/collection.dart'; |
| 7 import 'package:glob/glob.dart'; | 8 import 'package:glob/glob.dart'; |
| 8 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 9 import 'package:yaml/yaml.dart'; | 10 import 'package:yaml/yaml.dart'; |
| 10 | 11 |
| 11 /// Whether the package being tested uses the Polymer transforemrs at all. | 12 /// Whether the package being tested uses the Polymer transformers at all. |
| 12 /// | 13 /// |
| 13 /// This will be `null` until [_initialize] is called. | 14 /// This will be `null` until [_initialize] is called. |
| 14 bool _usesPolymer; | 15 bool _usesPolymer; |
| 15 | 16 |
| 16 /// The set of entry points passed in to the polymer transformer's config. | 17 /// The set of entry points passed in to the polymer transformer's config. |
| 17 /// | 18 /// |
| 18 /// This will be `null` if no entrypoints are declared, indicating that all | 19 /// This will be `null` if no entrypoints are declared, indicating that all |
| 19 /// entrypoints are supported. | 20 /// entrypoints are supported. |
| 20 Set<String> _entrypoints; | 21 Set<String> _entrypoints; |
| 21 | 22 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (transformer != "polymer") continue; | 74 if (transformer != "polymer") continue; |
| 74 _usesPolymer = true; | 75 _usesPolymer = true; |
| 75 return; | 76 return; |
| 76 } | 77 } |
| 77 | 78 |
| 78 if (transformer.keys.single != "polymer") continue; | 79 if (transformer.keys.single != "polymer") continue; |
| 79 _usesPolymer = true; | 80 _usesPolymer = true; |
| 80 | 81 |
| 81 var configuration = transformer.values.single; | 82 var configuration = transformer.values.single; |
| 82 | 83 |
| 83 var entrypoints = configuration["entry_points"]; | 84 var entrypoints = configuration["entry_points"] as List; |
| 84 if (entrypoints != null) _entrypoints = entrypoints.toSet(); | 85 if (entrypoints != null) { |
| 86 _entrypoints = DelegatingSet.typed(entrypoints.toSet()); |
| 87 } |
| 85 | 88 |
| 86 _includes = _parseGlobField(configuration, r"$includes"); | 89 _includes = _parseGlobField(configuration, r"$includes"); |
| 87 _excludes = _parseGlobField(configuration, r"$excludes"); | 90 _excludes = _parseGlobField(configuration, r"$excludes"); |
| 88 return; | 91 return; |
| 89 } | 92 } |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 | 95 |
| 93 /// Parses a glob field (either `$include` or `$exclude`). | 96 /// Parses a glob field (either `$include` or `$exclude`). |
| 94 Set<Glob> _parseGlobField(YamlMap configuration, String name) { | 97 Set<Glob> _parseGlobField(YamlMap configuration, String name) { |
| 95 if (!configuration.containsKey(name)) return null; | 98 if (!configuration.containsKey(name)) return null; |
| 96 var field = configuration[name]; | 99 var field = configuration[name]; |
| 97 | 100 |
| 98 if (field is String) { | 101 if (field is String) { |
| 99 return new Set.from([new Glob(field, context: p.url, recursive: true)]); | 102 return new Set.from([new Glob(field, context: p.url, recursive: true)]); |
| 100 } | 103 } |
| 101 | 104 |
| 102 return new Set.from(field.map((node) { | 105 return new Set.from(field.map((node) { |
| 103 return new Glob(node, context: p.url, recursive: true); | 106 return new Glob(node, context: p.url, recursive: true); |
| 104 })); | 107 })); |
| 105 } | 108 } |
| OLD | NEW |