Commits

Anonymous committed 9a61215

Renamed from compo to recipe

  • Participants
  • Parent commits 810d2ad

Comments (0)

Files changed (10)

File dist/amd/compo.js

-
-define('compo', ['formatter'], function(formatter) {
-    
-    var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
-        reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
-        reSection = /\s*\[(\w+)\]/;
-    
-    function Recipe(opts) {
-        // if opts is a string, then map this to opts.text
-        if (typeof opts == 'string' || (opts instanceof String)) {
-            opts = {
-                text: opts
-            };
-        }
-    
-        // ensure the opts have been initialised
-        opts = opts || {};
-    
-        // define the sections
-        this.sections = opts.sections || {};
-        
-        // initialise requirements
-        this.requirements = [].concat(opts.requirements || []);
-        
-        // if we have text, then parse the text
-        if (opts.text) {
-            this.parse(opts.text, opts);
-        }
-    }
-    
-    Recipe.prototype = {
-        parse: function(text, opts) {
-            var match, downloadMatch,
-                activeSection,
-                lines = (text || '').split(/\n/),
-                line,
-                inSections = false,
-                ii, count;
-                
-            // iterate through the lines until we hit the first section
-            for (ii = 0; ii < lines.length; ii++) {
-                // get a reference to the line
-                line = lines[ii];
-                
-                // check to see if we are in the sections
-                inSections = inSections || reSection.test(line);
-                
-                // if we are not in the sections, then check for field matches
-                if (! inSections) {
-                    match = reField.exec(line);
-                    if (match) {
-                        this[match[1]] = match[2];
-                    }
-                }
-                else {
-                    match = reSection.exec(line);
-                    if (match) {
-                        // create the active section
-                        activeSection = this.sections[match[1]] = {};
-                    }
-                    else {
-                        // check for a download match
-                        downloadMatch = reDownload.exec(line);
-    
-                        // if we have a download match, then add it to the active section
-                        if (downloadMatch) {
-                            var fileType = downloadMatch[1] || 'js';
-    
-                            // if the active section is currently undefined, then create the core section
-                            if (! activeSection) {
-                                activeSection = this.sections.core = {};
-                            }
-    
-                            // if the file type is not in the active section then add it
-                            if (! activeSection[fileType]) {
-                                activeSection[fileType] = [];
-                            }
-    
-                            // add the download to the file types in the active section
-                            activeSection[fileType].push(formatter(downloadMatch[2])(this));
-                        }
-                    }
-                }
-            }
-        }
-    };
-    
-    // define a `req` property to deal with parsing the string requirements into an array
-    Object.defineProperty(Recipe.prototype, 'req', {
-        set: function(value) {
-            var recipe = this;
-            
-            // update the requirements
-            this.requirements = value.split(reCommaDelim);
-            
-            // iterate through the requirements and update to absolute paths if it they are local
-            this.requirements.forEach(function(req, index) {
-                if (reLocalFile.test(req)) {
-                    recipe.requirements[index] = path.resolve(recipe.basePath, req);
-                }
-            });
-        }
-    });
-    
-    // define a `req` property to deal with parsing the string requirements into an array
-    Object.defineProperty(Recipe.prototype, 'dsc', {
-        set: function(value) {
-            this.desc = value;
-        }
-    });
-    
-    // define a dep property as an alias to req
-    Object.defineProperty(Recipe.prototype, 'dep', {
-        set: function(value) {
-            this.requirements = value.split(reCommaDelim);
-        }
-    });
-    
-    
-    function compo() {
-    }
-    
-    // patch the recipe class into the cookbook
-    compo.Recipe = Recipe;
-    
-    return typeof compo != 'undefined' ? compo : undefined;
-});

File dist/amd/recipe.js

+
+define('recipe', ['formatter'], function(formatter) {
+    
+    var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
+        reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
+        reSection = /\s*\[(\w+)\]/;
+    
+    function Recipe(opts) {
+        // if opts is a string, then map this to opts.text
+        if (typeof opts == 'string' || (opts instanceof String)) {
+            opts = {
+                text: opts
+            };
+        }
+    
+        // ensure the opts have been initialised
+        opts = opts || {};
+    
+        // define the sections
+        this.sections = opts.sections || {};
+        
+        // initialise requirements
+        this.requirements = [].concat(opts.requirements || []);
+        
+        // if we have text, then parse the text
+        if (opts.text) {
+            this.parse(opts.text, opts);
+        }
+    }
+    
+    Recipe.prototype = {
+        parse: function(text, opts) {
+            var match, downloadMatch,
+                activeSection,
+                lines = (text || '').split(/\n/),
+                line,
+                inSections = false,
+                ii, count;
+                
+            // iterate through the lines until we hit the first section
+            for (ii = 0; ii < lines.length; ii++) {
+                // get a reference to the line
+                line = lines[ii];
+                
+                // check to see if we are in the sections
+                inSections = inSections || reSection.test(line);
+                
+                // if we are not in the sections, then check for field matches
+                if (! inSections) {
+                    match = reField.exec(line);
+                    if (match) {
+                        this[match[1]] = match[2];
+                    }
+                }
+                else {
+                    match = reSection.exec(line);
+                    if (match) {
+                        // create the active section
+                        activeSection = this.sections[match[1]] = {};
+                    }
+                    else {
+                        // check for a download match
+                        downloadMatch = reDownload.exec(line);
+    
+                        // if we have a download match, then add it to the active section
+                        if (downloadMatch) {
+                            var fileType = downloadMatch[1] || 'js';
+    
+                            // if the active section is currently undefined, then create the core section
+                            if (! activeSection) {
+                                activeSection = this.sections.core = {};
+                            }
+    
+                            // if the file type is not in the active section then add it
+                            if (! activeSection[fileType]) {
+                                activeSection[fileType] = [];
+                            }
+    
+                            // add the download to the file types in the active section
+                            activeSection[fileType].push(formatter(downloadMatch[2])(this));
+                        }
+                    }
+                }
+            }
+        }
+    };
+    
+    // define a `req` property to deal with parsing the string requirements into an array
+    Object.defineProperty(Recipe.prototype, 'req', {
+        set: function(value) {
+            var recipe = this;
+            
+            // update the requirements
+            this.requirements = value.split(reCommaDelim);
+            
+            // iterate through the requirements and update to absolute paths if it they are local
+            this.requirements.forEach(function(req, index) {
+                if (reLocalFile.test(req)) {
+                    recipe.requirements[index] = path.resolve(recipe.basePath, req);
+                }
+            });
+        }
+    });
+    
+    // define a `req` property to deal with parsing the string requirements into an array
+    Object.defineProperty(Recipe.prototype, 'dsc', {
+        set: function(value) {
+            this.desc = value;
+        }
+    });
+    
+    // define a dep property as an alias to req
+    Object.defineProperty(Recipe.prototype, 'dep', {
+        set: function(value) {
+            this.requirements = value.split(reCommaDelim);
+        }
+    });
+    
+    
+    exports.define = function(opts) {
+    	return new Recipe(opts);
+    };
+    
+    return typeof recipe != 'undefined' ? recipe : undefined;
+});

File dist/commonjs/compo.js

-
-var formatter = require('formatter');
-
-
-var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
-    reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
-    reSection = /\s*\[(\w+)\]/;
-
-function Recipe(opts) {
-    // if opts is a string, then map this to opts.text
-    if (typeof opts == 'string' || (opts instanceof String)) {
-        opts = {
-            text: opts
-        };
-    }
-
-    // ensure the opts have been initialised
-    opts = opts || {};
-
-    // define the sections
-    this.sections = opts.sections || {};
-    
-    // initialise requirements
-    this.requirements = [].concat(opts.requirements || []);
-    
-    // if we have text, then parse the text
-    if (opts.text) {
-        this.parse(opts.text, opts);
-    }
-}
-
-Recipe.prototype = {
-    parse: function(text, opts) {
-        var match, downloadMatch,
-            activeSection,
-            lines = (text || '').split(/\n/),
-            line,
-            inSections = false,
-            ii, count;
-            
-        // iterate through the lines until we hit the first section
-        for (ii = 0; ii < lines.length; ii++) {
-            // get a reference to the line
-            line = lines[ii];
-            
-            // check to see if we are in the sections
-            inSections = inSections || reSection.test(line);
-            
-            // if we are not in the sections, then check for field matches
-            if (! inSections) {
-                match = reField.exec(line);
-                if (match) {
-                    this[match[1]] = match[2];
-                }
-            }
-            else {
-                match = reSection.exec(line);
-                if (match) {
-                    // create the active section
-                    activeSection = this.sections[match[1]] = {};
-                }
-                else {
-                    // check for a download match
-                    downloadMatch = reDownload.exec(line);
-
-                    // if we have a download match, then add it to the active section
-                    if (downloadMatch) {
-                        var fileType = downloadMatch[1] || 'js';
-
-                        // if the active section is currently undefined, then create the core section
-                        if (! activeSection) {
-                            activeSection = this.sections.core = {};
-                        }
-
-                        // if the file type is not in the active section then add it
-                        if (! activeSection[fileType]) {
-                            activeSection[fileType] = [];
-                        }
-
-                        // add the download to the file types in the active section
-                        activeSection[fileType].push(formatter(downloadMatch[2])(this));
-                    }
-                }
-            }
-        }
-    }
-};
-
-// define a `req` property to deal with parsing the string requirements into an array
-Object.defineProperty(Recipe.prototype, 'req', {
-    set: function(value) {
-        var recipe = this;
-        
-        // update the requirements
-        this.requirements = value.split(reCommaDelim);
-        
-        // iterate through the requirements and update to absolute paths if it they are local
-        this.requirements.forEach(function(req, index) {
-            if (reLocalFile.test(req)) {
-                recipe.requirements[index] = path.resolve(recipe.basePath, req);
-            }
-        });
-    }
-});
-
-// define a `req` property to deal with parsing the string requirements into an array
-Object.defineProperty(Recipe.prototype, 'dsc', {
-    set: function(value) {
-        this.desc = value;
-    }
-});
-
-// define a dep property as an alias to req
-Object.defineProperty(Recipe.prototype, 'dep', {
-    set: function(value) {
-        this.requirements = value.split(reCommaDelim);
-    }
-});
-Recipe.prototype.resolve = function(callback) {
-    
-};
-
-function compo() {
-}
-
-// patch the recipe class into the cookbook
-compo.Recipe = Recipe;
-
-if (typeof compo != 'undefined') {
-    module.exports = compo;
-}

File dist/commonjs/recipe.js

+
+var formatter = require('formatter');
+
+
+var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
+    reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
+    reSection = /\s*\[(\w+)\]/;
+
+function Recipe(opts) {
+    // if opts is a string, then map this to opts.text
+    if (typeof opts == 'string' || (opts instanceof String)) {
+        opts = {
+            text: opts
+        };
+    }
+
+    // ensure the opts have been initialised
+    opts = opts || {};
+
+    // define the sections
+    this.sections = opts.sections || {};
+    
+    // initialise requirements
+    this.requirements = [].concat(opts.requirements || []);
+    
+    // if we have text, then parse the text
+    if (opts.text) {
+        this.parse(opts.text, opts);
+    }
+}
+
+Recipe.prototype = {
+    parse: function(text, opts) {
+        var match, downloadMatch,
+            activeSection,
+            lines = (text || '').split(/\n/),
+            line,
+            inSections = false,
+            ii, count;
+            
+        // iterate through the lines until we hit the first section
+        for (ii = 0; ii < lines.length; ii++) {
+            // get a reference to the line
+            line = lines[ii];
+            
+            // check to see if we are in the sections
+            inSections = inSections || reSection.test(line);
+            
+            // if we are not in the sections, then check for field matches
+            if (! inSections) {
+                match = reField.exec(line);
+                if (match) {
+                    this[match[1]] = match[2];
+                }
+            }
+            else {
+                match = reSection.exec(line);
+                if (match) {
+                    // create the active section
+                    activeSection = this.sections[match[1]] = {};
+                }
+                else {
+                    // check for a download match
+                    downloadMatch = reDownload.exec(line);
+
+                    // if we have a download match, then add it to the active section
+                    if (downloadMatch) {
+                        var fileType = downloadMatch[1] || 'js';
+
+                        // if the active section is currently undefined, then create the core section
+                        if (! activeSection) {
+                            activeSection = this.sections.core = {};
+                        }
+
+                        // if the file type is not in the active section then add it
+                        if (! activeSection[fileType]) {
+                            activeSection[fileType] = [];
+                        }
+
+                        // add the download to the file types in the active section
+                        activeSection[fileType].push(formatter(downloadMatch[2])(this));
+                    }
+                }
+            }
+        }
+    }
+};
+
+// define a `req` property to deal with parsing the string requirements into an array
+Object.defineProperty(Recipe.prototype, 'req', {
+    set: function(value) {
+        var recipe = this;
+        
+        // update the requirements
+        this.requirements = value.split(reCommaDelim);
+        
+        // iterate through the requirements and update to absolute paths if it they are local
+        this.requirements.forEach(function(req, index) {
+            if (reLocalFile.test(req)) {
+                recipe.requirements[index] = path.resolve(recipe.basePath, req);
+            }
+        });
+    }
+});
+
+// define a `req` property to deal with parsing the string requirements into an array
+Object.defineProperty(Recipe.prototype, 'dsc', {
+    set: function(value) {
+        this.desc = value;
+    }
+});
+
+// define a dep property as an alias to req
+Object.defineProperty(Recipe.prototype, 'dep', {
+    set: function(value) {
+        this.requirements = value.split(reCommaDelim);
+    }
+});
+Recipe.prototype.resolve = function(callback) {
+    
+};
+
+exports.define = function(opts) {
+	return new Recipe(opts);
+};
+
+if (typeof recipe != 'undefined') {
+    module.exports = recipe;
+}

File dist/glob/compo.js

-
-// req: formatter
-(function(glob) {
-    
-    var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
-        reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
-        reSection = /\s*\[(\w+)\]/;
-    
-    function Recipe(opts) {
-        // if opts is a string, then map this to opts.text
-        if (typeof opts == 'string' || (opts instanceof String)) {
-            opts = {
-                text: opts
-            };
-        }
-    
-        // ensure the opts have been initialised
-        opts = opts || {};
-    
-        // define the sections
-        this.sections = opts.sections || {};
-        
-        // initialise requirements
-        this.requirements = [].concat(opts.requirements || []);
-        
-        // if we have text, then parse the text
-        if (opts.text) {
-            this.parse(opts.text, opts);
-        }
-    }
-    
-    Recipe.prototype = {
-        parse: function(text, opts) {
-            var match, downloadMatch,
-                activeSection,
-                lines = (text || '').split(/\n/),
-                line,
-                inSections = false,
-                ii, count;
-                
-            // iterate through the lines until we hit the first section
-            for (ii = 0; ii < lines.length; ii++) {
-                // get a reference to the line
-                line = lines[ii];
-                
-                // check to see if we are in the sections
-                inSections = inSections || reSection.test(line);
-                
-                // if we are not in the sections, then check for field matches
-                if (! inSections) {
-                    match = reField.exec(line);
-                    if (match) {
-                        this[match[1]] = match[2];
-                    }
-                }
-                else {
-                    match = reSection.exec(line);
-                    if (match) {
-                        // create the active section
-                        activeSection = this.sections[match[1]] = {};
-                    }
-                    else {
-                        // check for a download match
-                        downloadMatch = reDownload.exec(line);
-    
-                        // if we have a download match, then add it to the active section
-                        if (downloadMatch) {
-                            var fileType = downloadMatch[1] || 'js';
-    
-                            // if the active section is currently undefined, then create the core section
-                            if (! activeSection) {
-                                activeSection = this.sections.core = {};
-                            }
-    
-                            // if the file type is not in the active section then add it
-                            if (! activeSection[fileType]) {
-                                activeSection[fileType] = [];
-                            }
-    
-                            // add the download to the file types in the active section
-                            activeSection[fileType].push(formatter(downloadMatch[2])(this));
-                        }
-                    }
-                }
-            }
-        }
-    };
-    
-    // define a `req` property to deal with parsing the string requirements into an array
-    Object.defineProperty(Recipe.prototype, 'req', {
-        set: function(value) {
-            var recipe = this;
-            
-            // update the requirements
-            this.requirements = value.split(reCommaDelim);
-            
-            // iterate through the requirements and update to absolute paths if it they are local
-            this.requirements.forEach(function(req, index) {
-                if (reLocalFile.test(req)) {
-                    recipe.requirements[index] = path.resolve(recipe.basePath, req);
-                }
-            });
-        }
-    });
-    
-    // define a `req` property to deal with parsing the string requirements into an array
-    Object.defineProperty(Recipe.prototype, 'dsc', {
-        set: function(value) {
-            this.desc = value;
-        }
-    });
-    
-    // define a dep property as an alias to req
-    Object.defineProperty(Recipe.prototype, 'dep', {
-        set: function(value) {
-            this.requirements = value.split(reCommaDelim);
-        }
-    });
-    
-    
-    function compo() {
-    }
-    
-    // patch the recipe class into the cookbook
-    compo.Recipe = Recipe;
-    
-    if (typeof compo != 'undefined') {
-        glob.compo = compo;
-    }
-}(this));

File dist/glob/recipe.js

+
+// req: formatter
+(function(glob) {
+    
+    var reDownload = /^([\w\.\-]*?)\s*<\=\s*(.*)$/,
+        reField = /^\s*\#\s*(\w+)\:\s*(.*)$/,
+        reSection = /\s*\[(\w+)\]/;
+    
+    function Recipe(opts) {
+        // if opts is a string, then map this to opts.text
+        if (typeof opts == 'string' || (opts instanceof String)) {
+            opts = {
+                text: opts
+            };
+        }
+    
+        // ensure the opts have been initialised
+        opts = opts || {};
+    
+        // define the sections
+        this.sections = opts.sections || {};
+        
+        // initialise requirements
+        this.requirements = [].concat(opts.requirements || []);
+        
+        // if we have text, then parse the text
+        if (opts.text) {
+            this.parse(opts.text, opts);
+        }
+    }
+    
+    Recipe.prototype = {
+        parse: function(text, opts) {
+            var match, downloadMatch,
+                activeSection,
+                lines = (text || '').split(/\n/),
+                line,
+                inSections = false,
+                ii, count;
+                
+            // iterate through the lines until we hit the first section
+            for (ii = 0; ii < lines.length; ii++) {
+                // get a reference to the line
+                line = lines[ii];
+                
+                // check to see if we are in the sections
+                inSections = inSections || reSection.test(line);
+                
+                // if we are not in the sections, then check for field matches
+                if (! inSections) {
+                    match = reField.exec(line);
+                    if (match) {
+                        this[match[1]] = match[2];
+                    }
+                }
+                else {
+                    match = reSection.exec(line);
+                    if (match) {
+                        // create the active section
+                        activeSection = this.sections[match[1]] = {};
+                    }
+                    else {
+                        // check for a download match
+                        downloadMatch = reDownload.exec(line);
+    
+                        // if we have a download match, then add it to the active section
+                        if (downloadMatch) {
+                            var fileType = downloadMatch[1] || 'js';
+    
+                            // if the active section is currently undefined, then create the core section
+                            if (! activeSection) {
+                                activeSection = this.sections.core = {};
+                            }
+    
+                            // if the file type is not in the active section then add it
+                            if (! activeSection[fileType]) {
+                                activeSection[fileType] = [];
+                            }
+    
+                            // add the download to the file types in the active section
+                            activeSection[fileType].push(formatter(downloadMatch[2])(this));
+                        }
+                    }
+                }
+            }
+        }
+    };
+    
+    // define a `req` property to deal with parsing the string requirements into an array
+    Object.defineProperty(Recipe.prototype, 'req', {
+        set: function(value) {
+            var recipe = this;
+            
+            // update the requirements
+            this.requirements = value.split(reCommaDelim);
+            
+            // iterate through the requirements and update to absolute paths if it they are local
+            this.requirements.forEach(function(req, index) {
+                if (reLocalFile.test(req)) {
+                    recipe.requirements[index] = path.resolve(recipe.basePath, req);
+                }
+            });
+        }
+    });
+    
+    // define a `req` property to deal with parsing the string requirements into an array
+    Object.defineProperty(Recipe.prototype, 'dsc', {
+        set: function(value) {
+            this.desc = value;
+        }
+    });
+    
+    // define a dep property as an alias to req
+    Object.defineProperty(Recipe.prototype, 'dep', {
+        set: function(value) {
+            this.requirements = value.split(reCommaDelim);
+        }
+    });
+    
+    
+    exports.define = function(opts) {
+    	return new Recipe(opts);
+    };
+    
+    if (typeof recipe != 'undefined') {
+        glob.recipe = recipe;
+    }
+}(this));

File package.json

 {
-  "name": "compo",
+  "name": "recipe",
   "description": "Web Component Recipe Helpers",
   "author": "Damon Oehlman <damon.oehlman@sidelab.com>",
   "tags": [
   "engines": {
     "node": ">= 0.6.x < 0.9.0"
   },
-  "main": "dist/commonjs/compo",
+  "main": "dist/commonjs/recipe",
   "dependencies": {
     "formatter": "0.1.x"
   },
   },
   "repository": {
     "type": "git",
-    "url": "git://github.com/DamonOehlman/compo.git"
+    "url": "git://github.com/buildjs/recipe.git"
   },
   "bugs": {
-    "url": "http://github.com/DamonOehlman/compo/issues"
+    "url": "http://github.com/buildjs/recipe/issues"
   },
   "scripts": {
     "test": "node_modules/mocha/bin/mocha --reporter spec"

File src/compo.js

-// req: formatter
-
-//= core/recipe
-//= core/{{ packageType }}/recipe-ext
-
-function compo() {
-}
-
-// patch the recipe class into the cookbook
-compo.Recipe = Recipe;

File src/recipe.js

+// req: formatter
+
+//= core/recipe
+//= core/{{ packageType }}/recipe-ext
+
+exports.define = function(opts) {
+	return new Recipe(opts);
+};

File test/metadata.js

-var compo = require('../dist/commonjs/compo'),
+var recipe = require('../dist/commonjs/recipe'),
     expect = require('expect.js'),
     samples = {
-        simple: '# dsc: small JS library for DOM class manipulation\n' + 
-                '# url: https://github.com/DamonOehlman/classtweak\n' + 
-                '# bug: https://github.com/DamonOehlman/classtweak/issues\n\n' + 
-                '[core]\n' + 
+        simple: '# dsc: small JS library for DOM class manipulation\n' +
+                '# url: https://github.com/DamonOehlman/classtweak\n' +
+                '# bug: https://github.com/DamonOehlman/classtweak/issues\n\n' +
+                '[core]\n' +
                 'js <= github://DamonOehlman/classtweak/classtweak.js'
     };
 
 describe('recipe metadata tests', function() {
     it('should be able to read metdata from a simple recipe definition', function() {
-        var recipe = new compo.Recipe(samples.simple);
+        var testRecipe = recipe.define(samples.simple);
         
-        expect(recipe.desc).to.equal('small JS library for DOM class manipulation');
-        expect(recipe.url).to.equal('https://github.com/DamonOehlman/classtweak');
+        expect(testRecipe.desc).to.equal('small JS library for DOM class manipulation');
+        expect(testRecipe.url).to.equal('https://github.com/DamonOehlman/classtweak');
     });
     
     it('should be able to find sections within a simple recipe', function() {
-        var recipe = new compo.Recipe(samples.simple);
+        var testRecipe = recipe.define(samples.simple);
         
-        expect(recipe.sections.core).to.be.ok();
+        expect(testRecipe.sections.core).to.be.ok();
     });
     
     it('should have contents for the section specified in the simple recipe', function() {
-        var recipe = new compo.Recipe(samples.simple),
-            core = recipe.sections.core;
+        var testRecipe = recipe.define(samples.simple),
+            core = testRecipe.sections.core;
         
         expect(core.js).to.be.ok();
         expect(core.js).to.contain('github://DamonOehlman/classtweak/classtweak.js');