YamlEnvironmentParser class

Environment parser for YAML configuration files.

This parser extends YAML parsing capabilities with profile support. Profile names are extracted from file names following these patterns:

  • application.yaml -> "default"
  • application-dev.yaml -> "dev"
  • application_dev.yaml -> "dev"
  • config-prod.yml -> "prod"

Example Usage

final parser = YamlEnvironmentParser();
final asset = Asset.fromFile('application-dev.yaml');

if (parser.canParse(asset)) {
  final (profile, properties) = parser.parse(asset);
  print('Profile: $profile'); // "dev"
  print('Properties: $properties');
}
Inheritance
Implemented types

Constructors

YamlEnvironmentParser()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canParse(Asset asset) bool
Returns true if this parser can handle the given asset.
override
extractProfileFromFileName(String fileName) String
Extracts profile name from a file name.
override
load(Asset asset) → ParsedEnvironmentSource
Parses the asset and returns environment data.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String source) Map<String, dynamic>
Parses the given source string into a Map<String, dynamic>.
inherited
parseAs(Asset asset) Object
Parses the given Asset and returns it as a generic Object.
inherited
parseAsset(Asset asset) Map<String, dynamic>
Parses a Jetleaf Asset into a Map<String, dynamic>.
inherited
parseFile(String path) Map<String, dynamic>
Optionally parses configuration directly from a file located at path.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited