UNPKG

1.39 kBJavaScriptView Raw
1/*
2 * Copyright 2013 Yahoo! Inc. All rights reserved.
3 * Copyrights licensed under the BSD License.
4 * See the accompanying LICENSE.txt file for terms.
5 */
6
7
8/*jslint nomen:true, node:true */
9"use strict";
10
11
12var libpath = require('path'),
13 DEFAULT_SELECTOR = '{}';
14
15
16/**
17 * The Locator walks the filesystem and gives semantic meaning to
18 * files in the application.
19 * @module ModownLocator
20 */
21
22
23/**
24 * @class Bundle
25 * @constructor
26 * @param {string} baseDirectory Directory in which a bundle is rooted.
27 * @param {object} options Options for how the configuration files are handled.
28 */
29function Bundle(baseDirectory, options) {
30 this.options = options || {};
31 this.name = libpath.basename(baseDirectory);
32 this.baseDirectory = baseDirectory;
33 this.type = undefined;
34 this.files = {};
35 this.resources = {};
36}
37
38
39Bundle.prototype = {
40
41
42 /**
43 * Returns resources that match the selector.
44 * @method getResources
45 * @param {object} options Options for returned resources
46 * @param {string} [selector] Selector for the returned resources.
47 * If none is given then the resources which have no selector will
48 * be returned.
49 * @return {object} The resources.
50 */
51 getResources: function (options, selector) {
52 selector = selector || DEFAULT_SELECTOR;
53 return this.resources[selector];
54 }
55
56
57};
58
59
60module.exports = Bundle;