/spec/specification.d
http://github.com/wilkie/djehuty · D · 61 lines · 35 code · 12 blank · 14 comment · 2 complexity · 6e42811440ceb03a8ec5280fcdb5a753 MD5 · raw file
- /*
- * specification.d
- *
- * This module facilitates specifying the application.
- *
- * Originated: May 6th, 2010
- *
- */
- module spec.specification;
- import spec.packagespecification;
- import djehuty;
- class Specification {
- static:
- string name() {
- return Djehuty.app.name;
- }
- void add(PackageSpecification spec) {
- _packages[spec.name] = spec;
- }
- PackageSpecification traverse(string name) {
- if (!(name in _packages)) {
- return null;
- }
- return _packages[name];
- }
- int opApply(int delegate(ref PackageSpecification) loopBody) {
- foreach(pack; _packages.values.sort) {
- if (loopBody(pack)) {
- return 1;
- }
- }
- return 1;
- }
- // Description: Print out the specification, which is documentation of
- // the application.
- string toString() {
- // Package
- // Module
- // Item should do this
- // Item should do that
- string ret = "";
- foreach(pack; _packages.values.sort) {
- ret ~= pack.toString();
- }
- return ret;
- }
- private:
- PackageSpecification[string] _packages;
- }