Skip to content

Instantly share code, notes, and snippets.

@wesleytodd
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wesleytodd/9b2d7bc52c427f460dff to your computer and use it in GitHub Desktop.
Save wesleytodd/9b2d7bc52c427f460dff to your computer and use it in GitHub Desktop.
Example of a very basic module
// Export for Angular
if (angular) {
angular.module('vube.video', [])
.factory([function() {
return VideoSingle;
}]);
}
// Requirements
var gulp = require('gulp'),
build = require('../../build'),
// Create the default config
var config = module.exports = build.DefaultModuleConfig(__dirname);
// The build prefix and suffix files
config.prefix = config.paths.r('prefix.js');
config.suffix = config.paths.r('suffix.js');
// The module files
config.addFiles([
config.paths.r('video-single.js'),
]);
// The module deps
config.addDependencies([
build.loadModuleShortcut('util'),
]);
// Set the default task
config.default = [
config.taskName('jshint'),
config.taskName('watch'),
'serve',
];
// Sets up the tasks for this module
build.setupModule(config.moduleName, config, ['karma', 'jsdoc', 'jshint', 'watch']);
window.vube = window.vube || {};
vube.VideoSingle = (function(angular, vube) {
// Export for vube namespace
return VideoSingle;
})(window.angular, window.vube);
/**
* @file Video Single Model
* @version 1.0
* @module video
*/
/* exports VideoSingle */
/**
* Video Single Model
*
* This represents the data and functionality for a single video instance
*
* @constructs module:video.VideoSingle
* @memberof module:video
* @extends module:util.EventEmitter
* @param {object} options - The video single options
*
* @requires module:vube.util.extend
* @requires module:vube.util.EventEmitter
*/
var VideoSingle = function(options) {
this.options = vube.util.extend({}, options, VideoSingle.defaultOptions);
};
util.extend(VideoSingle.prototype, vube.util.EventEmitter);
/**
* The default options for a `VideoSingle`
*
* @var defaultOptions
* @memberof module:video.VideoSingle
* @static
*/
VideoSingle.defaultOptions = {
singleApi: '/t-api/video/'
};
/**
* Gets a single video from the api
*
* @function get
* @memberof module:video.VideoSingle
* @instance
* @param {string} urlId - The url id to get form the api
* @returns {module:xhr.XHR} - The xhr instance
*/
VideoSingle.prototype.get = function(urlId) {
return vube.http({
url: this.options.singleApi + urlId
});
};
@wesleytodd
Copy link
Author

EDIT: The jshint ignore: start|end stuff was un-necessary because those files are not specified in the files array, so jshint should not be run on them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment