PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/specification.d

http://github.com/wilkie/djehuty
D | 61 lines | 35 code | 12 blank | 14 comment | 2 complexity | 6e42811440ceb03a8ec5280fcdb5a753 MD5 | raw file
 1/*
 2 * specification.d
 3 *
 4 * This module facilitates specifying the application.
 5 *
 6 * Originated: May 6th, 2010
 7 *
 8 */
 9
10module spec.specification;
11import spec.packagespecification;
12
13import djehuty;
14
15class Specification {
16static:
17
18	string name() {
19		return Djehuty.app.name; 
20	}
21
22	void add(PackageSpecification spec) {
23		_packages[spec.name] = spec;
24	}
25
26	PackageSpecification traverse(string name) {
27		if (!(name in _packages)) {
28			return null;
29		}
30		return _packages[name];
31	}
32
33	int opApply(int delegate(ref PackageSpecification) loopBody) {
34		foreach(pack; _packages.values.sort) {
35			if (loopBody(pack)) {
36				return 1;
37			}
38		}
39		return 1;
40	}
41
42	// Description: Print out the specification, which is documentation of
43	//   the application.
44	string toString() {
45		// Package
46		//   Module
47		//     Item should do this
48		//     Item should do that
49		string ret = "";
50
51		foreach(pack; _packages.values.sort) {
52			ret ~= pack.toString();
53		}
54
55		return ret;
56	}
57
58private:
59
60	PackageSpecification[string] _packages;
61}