diff --git a/dist/ember-resolver-spade.js b/dist/ember-resolver-spade.js index f2756a80..0566ef21 100644 --- a/dist/ember-resolver-spade.js +++ b/dist/ember-resolver-spade.js @@ -6,4 +6,4 @@ // ========================================================================== -minispade.register('ember-resolver/container-debug-adapter', "(function() {/*globals define registry requirejs */\n\ndefine(\"ember/container-debug-adapter\",\n [],\n function() {\n \"use strict\";\n\n // Support Ember < 1.5-beta.4\n // TODO: Remove this after 1.5.0 is released\n if (typeof Ember.ContainerDebugAdapter === 'undefined') {\n return null;\n }\n /*\n * This module defines a subclass of Ember.ContainerDebugAdapter that adds two\n * important features:\n *\n * 1) is able provide injections to classes that implement `extend`\n * (as is typical with Ember).\n */\n\n var ContainerDebugAdapter = Ember.ContainerDebugAdapter.extend({\n /**\n The container of the application being debugged.\n This property will be injected\n on creation.\n\n @property container\n @default null\n */\n // container: null, LIVES IN PARENT\n\n /**\n The resolver instance of the application\n being debugged. This property will be injected\n on creation.\n\n @property resolver\n @default null\n */\n // resolver: null, LIVES IN PARENT\n /**\n Returns true if it is possible to catalog a list of available\n classes in the resolver for a given type.\n\n @method canCatalogEntriesByType\n @param {string} type The type. e.g. \"model\", \"controller\", \"route\"\n @return {boolean} whether a list is available for this type.\n */\n canCatalogEntriesByType: function(type) {\n return true;\n },\n\n /**\n * Get all defined modules.\n *\n * @method _getEntries\n * @return {Array} the list of registered modules.\n * @private\n */\n _getEntries: function() {\n return requirejs.entries;\n },\n\n /**\n Returns the available classes a given type.\n\n @method catalogEntriesByType\n @param {string} type The type. e.g. \"model\", \"controller\", \"route\"\n @return {Array} An array of classes.\n */\n catalogEntriesByType: function(type) {\n var entries = this._getEntries(),\n module,\n types = Ember.A();\n\n var makeToString = function(){\n return this.shortname;\n };\n\n var prefix = this.namespace.modulePrefix;\n\n for(var key in entries) {\n if(entries.hasOwnProperty(key) && key.indexOf(type) !== -1) {\n // Check if it's a pod module\n var name = getPod(type, key, this.namespace.podModulePrefix || prefix);\n if (!name) {\n // Not pod\n name = key.split(type + 's/').pop();\n\n // Support for different prefix (such as ember-cli addons).\n // Uncomment the code below when\n // https://github.com/ember-cli/ember-resolver/pull/80 is merged.\n\n //var match = key.match('^/?(.+)/' + type);\n //if (match && match[1] !== prefix) {\n // Different prefix such as an addon\n //name = match[1] + '@' + name;\n //}\n }\n types.addObject(name);\n }\n }\n return types;\n }\n });\n\n function getPod(type, key, prefix) {\n var match = key.match(new RegExp('^/?' + prefix + '/(.+)/' + type + '$'));\n if (match) {\n return match[1];\n }\n }\n\n ContainerDebugAdapter['default'] = ContainerDebugAdapter;\n return ContainerDebugAdapter;\n});\n\n})();\n//@ sourceURL=ember-resolver/container-debug-adapter");minispade.register('ember-resolver/core', "(function() {/*globals define registry requirejs */\n\ndefine(\"ember/resolver\",\n [],\n function() {\n \"use strict\";\n\n if (typeof requirejs.entries === 'undefined') {\n requirejs.entries = requirejs._eak_seen;\n }\n\n /*\n * This module defines a subclass of Ember.DefaultResolver that adds two\n * important features:\n *\n * 1) The resolver makes the container aware of es6 modules via the AMD\n * output. The loader's _moduleEntries is consulted so that classes can be\n * resolved directly via the module loader, without needing a manual\n * `import`.\n * 2) is able to provide injections to classes that implement `extend`\n * (as is typical with Ember).\n */\n\n function classFactory(klass) {\n return {\n create: function (injections) {\n if (typeof klass.extend === 'function') {\n return klass.extend(injections);\n } else {\n return klass;\n }\n }\n };\n }\n\n if (!(Object.create && !Object.create(null).hasOwnProperty)) {\n throw new Error(\"This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg\");\n }\n\n function makeDictionary() {\n var cache = Object.create(null);\n cache['_dict'] = null;\n delete cache['_dict'];\n return cache;\n }\n\n var underscore = Ember.String.underscore;\n var classify = Ember.String.classify;\n var get = Ember.get;\n\n function parseName(fullName) {\n /*jshint validthis:true */\n\n if (fullName.parsedName === true) { return fullName; }\n\n var prefixParts = fullName.split('@');\n var prefix;\n\n if (prefixParts.length === 2) {\n if (prefixParts[0].split(':')[0] === 'view') {\n prefixParts[0] = prefixParts[0].split(':')[1];\n prefixParts[1] = 'view:' + prefixParts[1];\n }\n\n prefix = prefixParts[0];\n }\n\n var nameParts = prefixParts[prefixParts.length - 1].split(\":\");\n var type = nameParts[0], fullNameWithoutType = nameParts[1];\n var name = fullNameWithoutType;\n var namespace = get(this, 'namespace');\n var root = namespace;\n\n return {\n parsedName: true,\n fullName: fullName,\n prefix: prefix || this.prefix({type: type}),\n type: type,\n fullNameWithoutType: fullNameWithoutType,\n name: name,\n root: root,\n resolveMethodName: \"resolve\" + classify(type)\n };\n }\n\n function resolveOther(parsedName) {\n /*jshint validthis:true */\n\n Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix);\n\n var normalizedModuleName = this.findModuleName(parsedName);\n\n if (normalizedModuleName) {\n var module = require(normalizedModuleName, null, null, true /* force sync */);\n\n if (module && module['default']) { module = module['default']; }\n\n if (module === undefined) {\n throw new Error(\" Expected to find: '\" + parsedName.fullName + \"' within '\" + normalizedModuleName + \"' but got 'undefined'. Did you forget to `export default` within '\" + normalizedModuleName + \"'?\");\n }\n\n if (this.shouldWrapInClassFactory(module, parsedName)) {\n module = classFactory(module);\n }\n\n return module;\n } else {\n return this._super(parsedName);\n }\n }\n // Ember.DefaultResolver docs:\n // https://github.com/emberjs/ember.js/blob/master/packages/ember-application/lib/system/resolver.js\n var Resolver = Ember.DefaultResolver.extend({\n resolveOther: resolveOther,\n resolveTemplate: resolveOther,\n pluralizedTypes: null,\n\n makeToString: function(factory, fullName) {\n return '' + this.namespace.modulePrefix + '@' + fullName + ':';\n },\n parseName: parseName,\n shouldWrapInClassFactory: function(module, parsedName){\n return false;\n },\n init: function() {\n this._super();\n this.moduleBasedResolver = true;\n this._normalizeCache = makeDictionary();\n\n this.pluralizedTypes = this.pluralizedTypes || makeDictionary();\n\n if (!this.pluralizedTypes.config) {\n this.pluralizedTypes.config = 'config';\n }\n \n var podModulePrefix = this.namespace.podModulePrefix || '';\n var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1);\n Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+\n 'from future versions of ember-cli. Please move existing pods from '+\n '\\'app/' + podPath + '/\\' to \\'app/\\'.', !this.namespace.podModulePrefix);\n\n },\n normalize: function(fullName) {\n return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName));\n },\n _normalize: function(fullName) {\n // replace `.` with `/` in order to make nested controllers work in the following cases\n // 1. `needs: ['posts/post']`\n // 2. `{{render \"posts/post\"}}`\n // 3. `this.render('posts/post')` from Route\n var split = fullName.split(':');\n if (split.length > 1) {\n return split[0] + ':' + Ember.String.dasherize(split[1].replace(/\\./g, '/'));\n } else {\n return fullName;\n }\n },\n\n pluralize: function(type) {\n return this.pluralizedTypes[type] || (this.pluralizedTypes[type] = type + 's');\n },\n\n podBasedLookupWithPrefix: function(podPrefix, parsedName) {\n var fullNameWithoutType = parsedName.fullNameWithoutType;\n\n if (parsedName.type === 'template') {\n fullNameWithoutType = fullNameWithoutType.replace(/^components\\//, '');\n }\n\n return podPrefix + '/' + fullNameWithoutType + '/' + parsedName.type;\n },\n\n podBasedModuleName: function(parsedName) {\n var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;\n\n return this.podBasedLookupWithPrefix(podPrefix, parsedName);\n },\n\n podBasedComponentsInSubdir: function(parsedName) {\n var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;\n podPrefix = podPrefix + '/components';\n\n if (parsedName.type === 'component' || parsedName.fullNameWithoutType.match(/^components/)) {\n return this.podBasedLookupWithPrefix(podPrefix, parsedName);\n }\n },\n\n mainModuleName: function(parsedName) {\n // if router:main or adapter:main look for a module with just the type first\n var tmpModuleName = parsedName.prefix + '/' + parsedName.type;\n\n if (parsedName.fullNameWithoutType === 'main') {\n return tmpModuleName;\n }\n },\n\n defaultModuleName: function(parsedName) {\n return parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/' + parsedName.fullNameWithoutType;\n },\n\n prefix: function(parsedName) {\n var tmpPrefix = this.namespace.modulePrefix;\n\n if (this.namespace[parsedName.type + 'Prefix']) {\n tmpPrefix = this.namespace[parsedName.type + 'Prefix'];\n }\n\n return tmpPrefix;\n },\n\n /**\n\n A listing of functions to test for moduleName's based on the provided\n `parsedName`. This allows easy customization of additional module based\n lookup patterns.\n\n @property moduleNameLookupPatterns\n @returns {Ember.Array}\n */\n moduleNameLookupPatterns: Ember.computed(function(){\n return Ember.A([\n this.podBasedModuleName,\n this.podBasedComponentsInSubdir,\n this.mainModuleName,\n this.defaultModuleName\n ]);\n }),\n\n findModuleName: function(parsedName, loggingDisabled){\n var self = this;\n var moduleName;\n\n this.get('moduleNameLookupPatterns').find(function(item) {\n var moduleEntries = requirejs.entries;\n var tmpModuleName = item.call(self, parsedName);\n\n // allow treat all dashed and all underscored as the same thing\n // supports components with dashes and other stuff with underscores.\n if (tmpModuleName) {\n tmpModuleName = self.chooseModuleName(moduleEntries, tmpModuleName);\n }\n\n if (tmpModuleName && moduleEntries[tmpModuleName]) {\n if (!loggingDisabled) {\n self._logLookup(true, parsedName, tmpModuleName);\n }\n\n moduleName = tmpModuleName;\n }\n\n if (!loggingDisabled) {\n self._logLookup(moduleName, parsedName, tmpModuleName);\n }\n\n return moduleName;\n });\n\n return moduleName;\n },\n\n chooseModuleName: function(moduleEntries, moduleName) {\n var underscoredModuleName = Ember.String.underscore(moduleName);\n\n if (moduleName !== underscoredModuleName && moduleEntries[moduleName] && moduleEntries[underscoredModuleName]) {\n throw new TypeError(\"Ambiguous module names: `\" + moduleName + \"` and `\" + underscoredModuleName + \"`\");\n }\n\n if (moduleEntries[moduleName]) {\n return moduleName;\n } else if (moduleEntries[underscoredModuleName]) {\n return underscoredModuleName;\n } else {\n // workaround for dasherized partials:\n // something/something/-something => something/something/_something\n var partializedModuleName = moduleName.replace(/\\/-([^\\/]*)$/, '/_$1');\n\n if (moduleEntries[partializedModuleName]) {\n Ember.deprecate('Modules should not contain underscores. ' +\n 'Attempted to lookup \"'+moduleName+'\" which ' +\n 'was not found. Please rename \"'+partializedModuleName+'\" '+\n 'to \"'+moduleName+'\" instead.', false);\n\n return partializedModuleName;\n } else {\n return moduleName;\n }\n }\n },\n\n // used by Ember.DefaultResolver.prototype._logLookup\n lookupDescription: function(fullName) {\n var parsedName = this.parseName(fullName);\n\n var moduleName = this.findModuleName(parsedName, true);\n\n return moduleName;\n },\n\n // only needed until 1.6.0-beta.2 can be required\n _logLookup: function(found, parsedName, description) {\n if (!Ember.ENV.LOG_MODULE_RESOLVER && !parsedName.root.LOG_RESOLVER) {\n return;\n }\n\n var symbol, padding;\n\n if (found) { symbol = '[✓]'; }\n else { symbol = '[ ]'; }\n\n if (parsedName.fullName.length > 60) {\n padding = '.';\n } else {\n padding = new Array(60 - parsedName.fullName.length).join('.');\n }\n\n if (!description) {\n description = this.lookupDescription(parsedName);\n }\n\n Ember.Logger.info(symbol, parsedName.fullName, padding, description);\n }\n });\n\n Resolver.moduleBasedResolver = true;\n Resolver['default'] = Resolver;\n return Resolver;\n});\n\ndefine(\"resolver\",\n [\"ember/resolver\"],\n function (Resolver) {\n Ember.deprecate('Importing/requiring Ember Resolver as \"resolver\" is deprecated, please use \"ember/resolver\" instead');\n return Resolver;\n });\n\n})();\n//@ sourceURL=ember-resolver/core");minispade.register('ember-resolver/initializers', "(function() {(function() {\n \"use strict\";\n\n Ember.Application.initializer({\n name: 'container-debug-adapter',\n\n initialize: function(container, app) {\n var ContainerDebugAdapter = require('ember/container-debug-adapter');\n var Resolver = require('ember/resolver');\n\n container.register('container-debug-adapter:main', ContainerDebugAdapter);\n app.inject('container-debug-adapter:main', 'namespace', 'application:main');\n }\n });\n}());\n\n})();\n//@ sourceURL=ember-resolver/initializers");minispade.register('ember-resolver', "(function() {minispade.require('ember-resolver/core');\nminispade.require('ember-resolver/container-debug-adapter');\nminispade.require('ember-resolver/initializers');\n\n})();\n//@ sourceURL=ember-resolver"); \ No newline at end of file +minispade.register('ember-resolver/container-debug-adapter', "(function() {/*globals define registry requirejs */\n\ndefine(\"ember/container-debug-adapter\",\n [],\n function() {\n \"use strict\";\n\n // Support Ember < 1.5-beta.4\n // TODO: Remove this after 1.5.0 is released\n if (typeof Ember.ContainerDebugAdapter === 'undefined') {\n return null;\n }\n /*\n * This module defines a subclass of Ember.ContainerDebugAdapter that adds two\n * important features:\n *\n * 1) is able provide injections to classes that implement `extend`\n * (as is typical with Ember).\n */\n\n var ContainerDebugAdapter = Ember.ContainerDebugAdapter.extend({\n /**\n The container of the application being debugged.\n This property will be injected\n on creation.\n\n @property container\n @default null\n */\n // container: null, LIVES IN PARENT\n\n /**\n The resolver instance of the application\n being debugged. This property will be injected\n on creation.\n\n @property resolver\n @default null\n */\n // resolver: null, LIVES IN PARENT\n /**\n Returns true if it is possible to catalog a list of available\n classes in the resolver for a given type.\n\n @method canCatalogEntriesByType\n @param {string} type The type. e.g. \"model\", \"controller\", \"route\"\n @return {boolean} whether a list is available for this type.\n */\n canCatalogEntriesByType: function(type) {\n return true;\n },\n\n /**\n * Get all defined modules.\n *\n * @method _getEntries\n * @return {Array} the list of registered modules.\n * @private\n */\n _getEntries: function() {\n return requirejs.entries;\n },\n\n /**\n Returns the available classes a given type.\n\n @method catalogEntriesByType\n @param {string} type The type. e.g. \"model\", \"controller\", \"route\"\n @return {Array} An array of classes.\n */\n catalogEntriesByType: function(type) {\n var entries = this._getEntries(),\n module,\n types = Ember.A();\n\n var makeToString = function(){\n return this.shortname;\n };\n\n var prefix = this.namespace.modulePrefix;\n\n for(var key in entries) {\n if(entries.hasOwnProperty(key) && key.indexOf(type) !== -1) {\n // Check if it's a pod module\n var name = getPod(type, key, this.namespace.podModulePrefix || prefix);\n if (!name) {\n // Not pod\n name = key.split(type + 's/').pop();\n\n // Support for different prefix (such as ember-cli addons).\n // Uncomment the code below when\n // https://github.com/ember-cli/ember-resolver/pull/80 is merged.\n\n //var match = key.match('^/?(.+)/' + type);\n //if (match && match[1] !== prefix) {\n // Different prefix such as an addon\n //name = match[1] + '@' + name;\n //}\n }\n types.addObject(name);\n }\n }\n return types;\n }\n });\n\n function getPod(type, key, prefix) {\n var match = key.match(new RegExp('^/?' + prefix + '/(.+)/' + type + '$'));\n if (match) {\n return match[1];\n }\n }\n\n ContainerDebugAdapter['default'] = ContainerDebugAdapter;\n return ContainerDebugAdapter;\n});\n\n})();\n//@ sourceURL=ember-resolver/container-debug-adapter");minispade.register('ember-resolver/core', "(function() {/*globals define registry requirejs */\n\ndefine(\"ember/resolver\",\n [],\n function() {\n \"use strict\";\n\n if (typeof requirejs.entries === 'undefined') {\n requirejs.entries = requirejs._eak_seen;\n }\n\n /*\n * This module defines a subclass of Ember.DefaultResolver that adds two\n * important features:\n *\n * 1) The resolver makes the container aware of es6 modules via the AMD\n * output. The loader's _moduleEntries is consulted so that classes can be\n * resolved directly via the module loader, without needing a manual\n * `import`.\n * 2) is able to provide injections to classes that implement `extend`\n * (as is typical with Ember).\n */\n\n function classFactory(klass) {\n return {\n create: function (injections) {\n if (typeof klass.extend === 'function') {\n return klass.extend(injections);\n } else {\n return klass;\n }\n }\n };\n }\n\n if (!(Object.create && !Object.create(null).hasOwnProperty)) {\n throw new Error(\"This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg\");\n }\n\n function makeDictionary() {\n var cache = Object.create(null);\n cache['_dict'] = null;\n delete cache['_dict'];\n return cache;\n }\n\n var underscore = Ember.String.underscore;\n var classify = Ember.String.classify;\n var get = Ember.get;\n\n function parseName(fullName) {\n /*jshint validthis:true */\n\n if (fullName.parsedName === true) { return fullName; }\n\n var prefixParts = fullName.split('@');\n var prefix;\n\n if (prefixParts.length === 2) {\n if (prefixParts[0].split(':')[0] === 'view') {\n prefixParts[0] = prefixParts[0].split(':')[1];\n prefixParts[1] = 'view:' + prefixParts[1];\n }\n\n prefix = prefixParts[0];\n }\n\n var nameParts = prefixParts[prefixParts.length - 1].split(\":\");\n var type = nameParts[0], fullNameWithoutType = nameParts[1];\n var name = fullNameWithoutType;\n var namespace = get(this, 'namespace');\n var root = namespace;\n\n return {\n parsedName: true,\n fullName: fullName,\n prefix: prefix || this.prefix({type: type}),\n type: type,\n fullNameWithoutType: fullNameWithoutType,\n name: name,\n root: root,\n resolveMethodName: \"resolve\" + classify(type)\n };\n }\n\n function resolveOther(parsedName) {\n /*jshint validthis:true */\n\n if (!this._deprecatedPodModulePrefix) {\n var podModulePrefix = this.namespace.podModulePrefix || '';\n var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1);\n\n Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+\n 'from future versions of ember-cli. Please move existing pods from '+\n '\\'app/' + podPath + '/\\' to \\'app/\\'.', !this.namespace.podModulePrefix);\n\n this._deprecatedPodModulePrefix = true;\n }\n\n Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix);\n\n var normalizedModuleName = this.findModuleName(parsedName);\n\n if (normalizedModuleName) {\n var module = require(normalizedModuleName, null, null, true /* force sync */);\n\n if (module && module['default']) { module = module['default']; }\n\n if (module === undefined) {\n throw new Error(\" Expected to find: '\" + parsedName.fullName + \"' within '\" + normalizedModuleName + \"' but got 'undefined'. Did you forget to `export default` within '\" + normalizedModuleName + \"'?\");\n }\n\n if (this.shouldWrapInClassFactory(module, parsedName)) {\n module = classFactory(module);\n }\n\n return module;\n } else {\n return this._super(parsedName);\n }\n }\n // Ember.DefaultResolver docs:\n // https://github.com/emberjs/ember.js/blob/master/packages/ember-application/lib/system/resolver.js\n var Resolver = Ember.DefaultResolver.extend({\n resolveOther: resolveOther,\n resolveTemplate: resolveOther,\n pluralizedTypes: null,\n\n makeToString: function(factory, fullName) {\n return '' + this.namespace.modulePrefix + '@' + fullName + ':';\n },\n parseName: parseName,\n shouldWrapInClassFactory: function(module, parsedName){\n return false;\n },\n init: function() {\n this._super();\n this.moduleBasedResolver = true;\n this._normalizeCache = makeDictionary();\n\n this.pluralizedTypes = this.pluralizedTypes || makeDictionary();\n\n if (!this.pluralizedTypes.config) {\n this.pluralizedTypes.config = 'config';\n }\n\n this._deprecatedPodModulePrefix = false;\n },\n normalize: function(fullName) {\n return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName));\n },\n _normalize: function(fullName) {\n // replace `.` with `/` in order to make nested controllers work in the following cases\n // 1. `needs: ['posts/post']`\n // 2. `{{render \"posts/post\"}}`\n // 3. `this.render('posts/post')` from Route\n var split = fullName.split(':');\n if (split.length > 1) {\n return split[0] + ':' + Ember.String.dasherize(split[1].replace(/\\./g, '/'));\n } else {\n return fullName;\n }\n },\n\n pluralize: function(type) {\n return this.pluralizedTypes[type] || (this.pluralizedTypes[type] = type + 's');\n },\n\n podBasedLookupWithPrefix: function(podPrefix, parsedName) {\n var fullNameWithoutType = parsedName.fullNameWithoutType;\n\n if (parsedName.type === 'template') {\n fullNameWithoutType = fullNameWithoutType.replace(/^components\\//, '');\n }\n\n return podPrefix + '/' + fullNameWithoutType + '/' + parsedName.type;\n },\n\n podBasedModuleName: function(parsedName) {\n var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;\n\n return this.podBasedLookupWithPrefix(podPrefix, parsedName);\n },\n\n podBasedComponentsInSubdir: function(parsedName) {\n var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;\n podPrefix = podPrefix + '/components';\n\n if (parsedName.type === 'component' || parsedName.fullNameWithoutType.match(/^components/)) {\n return this.podBasedLookupWithPrefix(podPrefix, parsedName);\n }\n },\n\n mainModuleName: function(parsedName) {\n // if router:main or adapter:main look for a module with just the type first\n var tmpModuleName = parsedName.prefix + '/' + parsedName.type;\n\n if (parsedName.fullNameWithoutType === 'main') {\n return tmpModuleName;\n }\n },\n\n defaultModuleName: function(parsedName) {\n return parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/' + parsedName.fullNameWithoutType;\n },\n\n prefix: function(parsedName) {\n var tmpPrefix = this.namespace.modulePrefix;\n\n if (this.namespace[parsedName.type + 'Prefix']) {\n tmpPrefix = this.namespace[parsedName.type + 'Prefix'];\n }\n\n return tmpPrefix;\n },\n\n /**\n\n A listing of functions to test for moduleName's based on the provided\n `parsedName`. This allows easy customization of additional module based\n lookup patterns.\n\n @property moduleNameLookupPatterns\n @returns {Ember.Array}\n */\n moduleNameLookupPatterns: Ember.computed(function(){\n return Ember.A([\n this.podBasedModuleName,\n this.podBasedComponentsInSubdir,\n this.mainModuleName,\n this.defaultModuleName\n ]);\n }),\n\n findModuleName: function(parsedName, loggingDisabled){\n var self = this;\n var moduleName;\n\n this.get('moduleNameLookupPatterns').find(function(item) {\n var moduleEntries = requirejs.entries;\n var tmpModuleName = item.call(self, parsedName);\n\n // allow treat all dashed and all underscored as the same thing\n // supports components with dashes and other stuff with underscores.\n if (tmpModuleName) {\n tmpModuleName = self.chooseModuleName(moduleEntries, tmpModuleName);\n }\n\n if (tmpModuleName && moduleEntries[tmpModuleName]) {\n if (!loggingDisabled) {\n self._logLookup(true, parsedName, tmpModuleName);\n }\n\n moduleName = tmpModuleName;\n }\n\n if (!loggingDisabled) {\n self._logLookup(moduleName, parsedName, tmpModuleName);\n }\n\n return moduleName;\n });\n\n return moduleName;\n },\n\n chooseModuleName: function(moduleEntries, moduleName) {\n var underscoredModuleName = Ember.String.underscore(moduleName);\n\n if (moduleName !== underscoredModuleName && moduleEntries[moduleName] && moduleEntries[underscoredModuleName]) {\n throw new TypeError(\"Ambiguous module names: `\" + moduleName + \"` and `\" + underscoredModuleName + \"`\");\n }\n\n if (moduleEntries[moduleName]) {\n return moduleName;\n } else if (moduleEntries[underscoredModuleName]) {\n return underscoredModuleName;\n } else {\n // workaround for dasherized partials:\n // something/something/-something => something/something/_something\n var partializedModuleName = moduleName.replace(/\\/-([^\\/]*)$/, '/_$1');\n\n if (moduleEntries[partializedModuleName]) {\n Ember.deprecate('Modules should not contain underscores. ' +\n 'Attempted to lookup \"'+moduleName+'\" which ' +\n 'was not found. Please rename \"'+partializedModuleName+'\" '+\n 'to \"'+moduleName+'\" instead.', false);\n\n return partializedModuleName;\n } else {\n return moduleName;\n }\n }\n },\n\n // used by Ember.DefaultResolver.prototype._logLookup\n lookupDescription: function(fullName) {\n var parsedName = this.parseName(fullName);\n\n var moduleName = this.findModuleName(parsedName, true);\n\n return moduleName;\n },\n\n // only needed until 1.6.0-beta.2 can be required\n _logLookup: function(found, parsedName, description) {\n if (!Ember.ENV.LOG_MODULE_RESOLVER && !parsedName.root.LOG_RESOLVER) {\n return;\n }\n\n var symbol, padding;\n\n if (found) { symbol = '[✓]'; }\n else { symbol = '[ ]'; }\n\n if (parsedName.fullName.length > 60) {\n padding = '.';\n } else {\n padding = new Array(60 - parsedName.fullName.length).join('.');\n }\n\n if (!description) {\n description = this.lookupDescription(parsedName);\n }\n\n Ember.Logger.info(symbol, parsedName.fullName, padding, description);\n }\n });\n\n Resolver.moduleBasedResolver = true;\n Resolver['default'] = Resolver;\n return Resolver;\n});\n\ndefine(\"resolver\",\n [\"ember/resolver\"],\n function (Resolver) {\n Ember.deprecate('Importing/requiring Ember Resolver as \"resolver\" is deprecated, please use \"ember/resolver\" instead');\n return Resolver;\n });\n\n})();\n//@ sourceURL=ember-resolver/core");minispade.register('ember-resolver/initializers', "(function() {(function() {\n \"use strict\";\n\n Ember.Application.initializer({\n name: 'container-debug-adapter',\n\n initialize: function(container, app) {\n var ContainerDebugAdapter = require('ember/container-debug-adapter');\n var Resolver = require('ember/resolver');\n\n container.register('container-debug-adapter:main', ContainerDebugAdapter);\n app.inject('container-debug-adapter:main', 'namespace', 'application:main');\n }\n });\n}());\n\n})();\n//@ sourceURL=ember-resolver/initializers");minispade.register('ember-resolver', "(function() {minispade.require('ember-resolver/core');\nminispade.require('ember-resolver/container-debug-adapter');\nminispade.require('ember-resolver/initializers');\n\n})();\n//@ sourceURL=ember-resolver"); \ No newline at end of file diff --git a/dist/ember-resolver-tests.js b/dist/ember-resolver-tests.js index 06d9928a..bb33adf9 100644 --- a/dist/ember-resolver-tests.js +++ b/dist/ember-resolver-tests.js @@ -66,4 +66,4 @@ var JSHINTRC = { } ; -minispade.register('ember-resolver/~tests/container_debug_adapter_test', "(function() {/*globals define registry requirejs */\n\nvar resolver,\n containerDebugAdapter,\n App, get = Ember.get,\n set = Ember.set,\n Resolver = require('ember/resolver'),\n ContainerDebugAdapter = require('ember/container-debug-adapter'),\n Model = Ember.Object.extend();\n\n\nvar modules = {};\nfunction def(module) {\n modules[module] = {};\n}\nfunction undef(module) {\n if (module) {\n delete modules[module];\n } else {\n modules = {};\n }\n}\n\n\nmodule(\"Container Debug Adapter Tests\", {\n setup:function() {\n Ember.run(function() {\n App = Ember.Application.extend({\n init: function () {\n this._super.apply(this, arguments);\n this.deferReadiness();\n },\n toString: function() { return 'App'; },\n modulePrefix: 'appkit',\n Resolver: Resolver['default'],\n ContainerDebugAdapter: ContainerDebugAdapter['default']\n }).create();\n });\n Ember.run(function() {\n containerDebugAdapter = App.__container__.lookup('container-debug-adapter:main');\n containerDebugAdapter._getEntries = function() { return modules; };\n });\n },\n teardown: function() {\n Ember.run(function() {\n containerDebugAdapter.destroy();\n App.destroy();\n App = null;\n });\n undef();\n }\n});\n\ntest(\"can access Container Debug Adapter which can catalog typical entries by type\", function() {\n equal(containerDebugAdapter.canCatalogEntriesByType('model'), true, \"canCatalogEntriesByType should return false for model\");\n equal(containerDebugAdapter.canCatalogEntriesByType('template'), true, \"canCatalogEntriesByType should return false for template\");\n equal(containerDebugAdapter.canCatalogEntriesByType('controller'), true, \"canCatalogEntriesByType should return true for controller\");\n equal(containerDebugAdapter.canCatalogEntriesByType('route'), true, \"canCatalogEntriesByType should return true for route\");\n equal(containerDebugAdapter.canCatalogEntriesByType('view'), true, \"canCatalogEntriesByType should return true for view\");\n});\n\ntest(\"the default ContainerDebugAdapter catalogs controller entries\", function() {\n def('appkit/controllers/foo');\n def('appkit/controllers/users/foo');\n\n var controllers = containerDebugAdapter.catalogEntriesByType('controller');\n\n equal(controllers.length, 2, \"controllers discovered\");\n equal(controllers[0], 'foo', \"found the right class\");\n equal(controllers[1], 'users/foo', \"the name is correct\");\n});\n\ntest(\"Does not duplicate entries\", function() {\n def('appkit/models/foo');\n def('appkit/more/models/foo');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 1, \"Only one is returned\");\n equal(models[0], 'foo', \"the name is correct\");\n});\n\ntest(\"Pods support\", function() {\n def('appkit/user/model');\n def('appkit/post/model');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 2, \"All models are found\");\n equal(models[0], 'user', \"the name is correct\");\n equal(models[1], 'post', \"the name is correct\");\n});\n\ntest(\"Pods podModulePrefix support\", function() {\n App.podModulePrefix = 'my-prefix';\n\n def('my-prefix/user/model');\n def('my-prefix/users/user/model');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 2, \"models discovered\");\n equal(models[0], 'user', \"the name is correct\");\n equal(models[1], 'users/user', \"the name is correct\");\n});\n\n\n})();\n//@ sourceURL=ember-resolver/~tests/container_debug_adapter_test");minispade.register('ember-resolver/~tests/core_test', "(function() {/*globals define registry requirejs */\n\nvar Resolver, resolver, logCalls, originalLog;\n\nfunction lookupResolver() {\n return requirejs.entries['ember/resolver'];\n}\n\nfunction resetRegistry() {\n var keeper = lookupResolver();\n\n requirejs.clear();\n define('ember/resolver', keeper['deps'], keeper['callback']);\n}\n\nfunction setupResolver(options) {\n if (!options) {\n options = { namespace: { modulePrefix: 'appkit' } };\n }\n\n Resolver = require('ember/resolver')['default'];\n resolver = Resolver.create(options);\n}\n\nmodule(\"Resolver Tests\",{\n setup: function(){\n setupResolver();\n },\n\n teardown: function() {\n resetRegistry();\n Ember.TEMPLATES = {};\n }\n});\n\ntest(\"can access at deprecated 'resolver' module name\", function(){\n expect(2);\n\n expectDeprecation(/Importing\\/requiring Ember Resolver as \"resolver\" is deprecated, please use \"ember\\/resolver\" instead/);\n\n var ResolverAlias = require('resolver')['default'];\n\n equal(Resolver, ResolverAlias, \"both 'ember/resolver' and 'resolver' return the same Resolver\");\n});\n\ntest(\"can access Resolver\", function(){\n ok(resolver);\n});\n\ntest(\"can lookup something\", function(){\n expect(2);\n\n define('appkit/adapters/post', [], function(){\n ok(true, \"adapter was invoked properly\");\n\n return Ember.K;\n });\n\n var adapter = resolver.resolve('adapter:post');\n\n ok(adapter, 'adapter was returned');\n\n adapter();\n});\n\ntest(\"can lookup something in another namespace\", function(){\n expect(2);\n\n define('other/adapters/post', [], function(){\n ok(true, \"adapter was invoked properly\");\n\n return Ember.K;\n });\n\n var adapter = resolver.resolve('other@adapter:post');\n\n ok(adapter, 'adapter was returned');\n\n adapter();\n});\n\ntest(\"can lookup a view in another namespace\", function() {\n expect(2);\n\n define('other/views/post', [], function(){\n ok(true, \"view was invoked properly\");\n\n return Ember.K;\n });\n\n var view = resolver.resolve('view:other@post');\n\n ok(view, 'view was returned');\n\n view();\n});\n\ntest(\"can lookup a view\", function() {\n expect(2);\n\n define('appkit/views/queue-list', [], function(){\n ok(true, \"view was invoked properly\");\n\n return Ember.K;\n });\n\n var view = resolver.resolve('view:queue-list');\n\n ok(view, 'view was returned');\n\n view();\n});\n\ntest(\"will return the raw value if no 'default' is available\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is awesome';\n });\n\n equal(resolver.resolve('fruit:orange'), 'is awesome', 'adapter was returned');\n});\n\ntest(\"will unwrap the 'default' export automatically\", function(){\n define('appkit/fruits/orange', [], function(){\n return {default: 'is awesome'};\n });\n\n equal(resolver.resolve('fruit:orange'), 'is awesome', 'adapter was returned');\n});\n\ntest(\"router:main is hard-coded to prefix/router.js\", function() {\n expect(1);\n\n define('appkit/router', [], function(){\n ok(true, 'router:main was looked up');\n return 'whatever';\n });\n\n resolver.resolve('router:main');\n});\n\ntest(\"store:main is looked up as prefix/store\", function() {\n expect(1);\n\n define('appkit/store', [], function(){\n ok(true, 'store:main was looked up');\n return 'whatever';\n });\n\n resolver.resolve('store:main');\n});\n\ntest(\"store:posts as prefix/stores/post\", function() {\n expect(1);\n\n define('appkit/stores/post', [], function(){\n ok(true, 'store:post was looked up');\n return 'whatever';\n });\n\n resolver.resolve('store:post');\n});\n\ntest(\"will raise error if both dasherized and underscored modules exist\", function() {\n define('appkit/big-bands/steve-miller-band', [], function(){\n ok(true, 'dasherized version looked up');\n return 'whatever';\n });\n\n define('appkit/big_bands/steve_miller_band', [], function(){\n ok(false, 'underscored version looked up');\n return 'whatever';\n });\n\n try {\n resolver.resolve('big-band:steve-miller-band');\n } catch (e) {\n equal(e.message, 'Ambiguous module names: `appkit/big-bands/steve-miller-band` and `appkit/big_bands/steve_miller_band`', \"error with a descriptive value is thrown\");\n }\n});\n\ntest(\"will lookup an underscored version of the module name when the dasherized version is not found\", function() {\n expect(1);\n\n define('appkit/big_bands/steve_miller_band', [], function(){\n ok(true, 'underscored version looked up properly');\n return 'whatever';\n });\n\n resolver.resolve('big-band:steve-miller-band');\n});\n\ntest(\"can lookup templates with mixed naming moduleName\", function(){\n expectDeprecation('Modules should not contain underscores. Attempted to lookup \"appkit/bands/-steve-miller-band\" which was not found. Please rename \"appkit/bands/_steve-miller-band\" to \"appkit/bands/-steve-miller-band\" instead.');\n\n expect(2);\n\n define('appkit/bands/_steve-miller-band', [], function(){\n ok(true, 'underscored version looked up properly');\n return 'whatever';\n });\n\n resolver.resolve('band:-steve-miller-band');\n});\n\ntest(\"can lookup templates via Ember.TEMPLATES\", function() {\n Ember.TEMPLATES['application'] = function() {\n return '

herp

';\n };\n\n var template = resolver.resolve('template:application');\n ok(template, 'template should resolve');\n});\n\nmodule(\"Logging\", {\n setup: function() {\n originalLog = Ember.Logger.info;\n logCalls = [];\n Ember.Logger.info = function(arg) { logCalls.push(arg); };\n },\n\n teardown: function() {\n Ember.Logger.info = originalLog;\n }\n});\n\ntest(\"logs lookups when logging is enabled\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is logged';\n });\n\n Ember.ENV.LOG_MODULE_RESOLVER = true;\n\n resolver.resolve('fruit:orange');\n\n ok(logCalls.length, \"should log lookup\");\n});\n\ntest(\"doesn't log lookups if disabled\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is not logged';\n });\n\n Ember.ENV.LOG_MODULE_RESOLVER = false;\n\n resolver.resolve('fruit:orange');\n\n equal(logCalls.length, 0, \"should not log lookup\");\n});\n\nmodule(\"custom prefixes by type\", {\n teardown: resetRegistry\n});\n\ntest(\"will use the prefix specified for a given type if present\", function() {\n setupResolver({ namespace: {\n fruitPrefix: 'grovestand',\n modulePrefix: 'appkit'\n }});\n\n define('grovestand/fruits/orange', [], function(){\n ok(true, 'custom prefix used');\n return 'whatever';\n });\n\n resolver.resolve('fruit:orange');\n});\n\nmodule(\"pods lookup structure\", {\n setup: function() {\n setupResolver();\n },\n\n teardown: resetRegistry\n});\n\ntest(\"will lookup modulePrefix/name/type before prefix/type/name\", function() {\n define('appkit/controllers/foo', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(true, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo');\n});\n\ntest(\"will lookup names with slashes properly\", function() {\n define('appkit/controllers/foo/index', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/index/controller', [], function(){\n ok(true, 'appkit/foo/index/controller was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo/index');\n});\n\ntest(\"specifying a podModulePrefix overrides the general modulePrefix\", function() {\n expectDeprecation(function() {\n setupResolver({\n namespace: {\n modulePrefix: 'appkit',\n podModulePrefix: 'appkit/pods'\n }\n });\n }, \"`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'.\");\n\n define('appkit/controllers/foo', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(false, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n define('appkit/pods/foo/controller', [], function(){\n ok(true, 'appkit/pods/foo/controllers was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo');\n});\n\ntest(\"specifying a podModulePrefix is deprecated\", function() {\n expectDeprecation(function() {\n setupResolver({\n namespace: {\n modulePrefix: 'appkit',\n podModulePrefix: 'appkit/pods'\n }\n });\n }, \"`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'.\");\n});\n\ntest(\"will not use custom type prefix when using POD format\", function() {\n resolver.namespace['controllerPrefix'] = 'foobar';\n\n define('foobar/controllers/foo', [], function(){\n ok(false, 'foobar/controllers was used');\n return 'whatever';\n });\n\n define('foobar/foo/controller', [], function(){\n ok(false, 'foobar/foo/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(true, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo');\n});\n\ntest(\"will lookup a components template without being rooted in `components/`\", function() {\n define('appkit/components/foo-bar/template', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/foo-bar/template', [], function(){\n ok(true, 'appkit/foo-bar/template was used');\n return 'whatever';\n });\n\n resolver.resolve('template:components/foo-bar');\n});\n\ntest(\"will use pods format to lookup components in components/\", function() {\n expect(2);\n\n define('appkit/components/foo-bar/template', [], function(){\n ok(true, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/components/foo-bar/component', [], function(){\n ok(true, 'appkit/components was used');\n return 'whatever';\n });\n\n resolver.resolve('template:components/foo-bar');\n resolver.resolve('component:foo-bar');\n});\n\ntest(\"will not lookup routes in components/\", function() {\n expect(1);\n\n define('appkit/components/foo-bar/route', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/routes/foo-bar', [], function(){\n ok(true, 'appkit/routes was used');\n return 'whatever';\n });\n\n resolver.resolve('route:foo-bar');\n});\n\ntest(\"will not lookup non component templates in components/\", function() {\n expect(1);\n\n define('appkit/components/foo-bar/template', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/templates/foo-bar', [], function(){\n ok(true, 'appkit/templates was used');\n return 'whatever';\n });\n\n resolver.resolve('template:foo-bar');\n});\n\nmodule(\"custom pluralization\", {\n teardown: resetRegistry\n});\n\ntest(\"will use the pluralization specified for a given type\", function() {\n expect(1);\n\n setupResolver({\n namespace: {\n modulePrefix: 'appkit'\n },\n\n pluralizedTypes: {\n 'sheep': 'sheep',\n 'octipus': 'octipii'\n }\n });\n\n define('appkit/sheep/baaaaaa', [], function(){\n ok(true, 'custom pluralization used');\n return 'whatever';\n });\n\n resolver.resolve('sheep:baaaaaa');\n});\n\ntest(\"will pluralize 'config' as 'config' by default\", function() {\n expect(1);\n\n setupResolver();\n\n define('appkit/config/environment', [], function(){\n ok(true, 'config/environment is found');\n return 'whatever';\n });\n\n resolver.resolve('config:environment');\n});\n\ntest(\"'config' can be overridden\", function() {\n expect(1);\n\n setupResolver({\n namespace: {\n modulePrefix: 'appkit'\n },\n\n pluralizedTypes: {\n 'config': 'super-duper-config'\n }\n });\n\n define('appkit/super-duper-config/environment', [], function(){\n ok(true, 'super-duper-config/environment is found');\n return 'whatever';\n });\n\n resolver.resolve('config:environment');\n});\n\n})();\n//@ sourceURL=ember-resolver/~tests/core_test"); \ No newline at end of file +minispade.register('ember-resolver/~tests/container_debug_adapter_test', "(function() {/*globals define registry requirejs */\n\nvar resolver,\n containerDebugAdapter,\n App, get = Ember.get,\n set = Ember.set,\n Resolver = require('ember/resolver'),\n ContainerDebugAdapter = require('ember/container-debug-adapter'),\n Model = Ember.Object.extend();\n\n\nvar modules = {};\nfunction def(module) {\n modules[module] = {};\n}\nfunction undef(module) {\n if (module) {\n delete modules[module];\n } else {\n modules = {};\n }\n}\n\n\nmodule(\"Container Debug Adapter Tests\", {\n setup:function() {\n Ember.run(function() {\n App = Ember.Application.extend({\n init: function () {\n this._super.apply(this, arguments);\n this.deferReadiness();\n },\n toString: function() { return 'App'; },\n modulePrefix: 'appkit',\n Resolver: Resolver['default'],\n ContainerDebugAdapter: ContainerDebugAdapter['default']\n }).create();\n });\n Ember.run(function() {\n containerDebugAdapter = App.__container__.lookup('container-debug-adapter:main');\n containerDebugAdapter._getEntries = function() { return modules; };\n });\n },\n teardown: function() {\n Ember.run(function() {\n containerDebugAdapter.destroy();\n App.destroy();\n App = null;\n });\n undef();\n }\n});\n\ntest(\"can access Container Debug Adapter which can catalog typical entries by type\", function() {\n equal(containerDebugAdapter.canCatalogEntriesByType('model'), true, \"canCatalogEntriesByType should return false for model\");\n equal(containerDebugAdapter.canCatalogEntriesByType('template'), true, \"canCatalogEntriesByType should return false for template\");\n equal(containerDebugAdapter.canCatalogEntriesByType('controller'), true, \"canCatalogEntriesByType should return true for controller\");\n equal(containerDebugAdapter.canCatalogEntriesByType('route'), true, \"canCatalogEntriesByType should return true for route\");\n equal(containerDebugAdapter.canCatalogEntriesByType('view'), true, \"canCatalogEntriesByType should return true for view\");\n});\n\ntest(\"the default ContainerDebugAdapter catalogs controller entries\", function() {\n def('appkit/controllers/foo');\n def('appkit/controllers/users/foo');\n\n var controllers = containerDebugAdapter.catalogEntriesByType('controller');\n\n equal(controllers.length, 2, \"controllers discovered\");\n equal(controllers[0], 'foo', \"found the right class\");\n equal(controllers[1], 'users/foo', \"the name is correct\");\n});\n\ntest(\"Does not duplicate entries\", function() {\n def('appkit/models/foo');\n def('appkit/more/models/foo');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 1, \"Only one is returned\");\n equal(models[0], 'foo', \"the name is correct\");\n});\n\ntest(\"Pods support\", function() {\n def('appkit/user/model');\n def('appkit/post/model');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 2, \"All models are found\");\n equal(models[0], 'user', \"the name is correct\");\n equal(models[1], 'post', \"the name is correct\");\n});\n\ntest(\"Pods podModulePrefix support\", function() {\n App.podModulePrefix = 'my-prefix';\n\n def('my-prefix/user/model');\n def('my-prefix/users/user/model');\n\n var models = containerDebugAdapter.catalogEntriesByType('model');\n\n equal(models.length, 2, \"models discovered\");\n equal(models[0], 'user', \"the name is correct\");\n equal(models[1], 'users/user', \"the name is correct\");\n});\n\n\n})();\n//@ sourceURL=ember-resolver/~tests/container_debug_adapter_test");minispade.register('ember-resolver/~tests/core_test', "(function() {/*globals define registry requirejs */\n\nvar Resolver, resolver, logCalls, originalLog;\n\nfunction lookupResolver() {\n return requirejs.entries['ember/resolver'];\n}\n\nfunction resetRegistry() {\n var keeper = lookupResolver();\n\n requirejs.clear();\n define('ember/resolver', keeper['deps'], keeper['callback']);\n}\n\nfunction setupResolver(options) {\n if (!options) {\n options = { namespace: { modulePrefix: 'appkit' } };\n }\n\n Resolver = require('ember/resolver')['default'];\n resolver = Resolver.create(options);\n}\n\nmodule(\"Resolver Tests\",{\n setup: function(){\n setupResolver();\n },\n\n teardown: function() {\n resetRegistry();\n Ember.TEMPLATES = {};\n }\n});\n\ntest(\"can access at deprecated 'resolver' module name\", function(){\n expect(2);\n\n expectDeprecation(/Importing\\/requiring Ember Resolver as \"resolver\" is deprecated, please use \"ember\\/resolver\" instead/);\n\n var ResolverAlias = require('resolver')['default'];\n\n equal(Resolver, ResolverAlias, \"both 'ember/resolver' and 'resolver' return the same Resolver\");\n});\n\ntest(\"can access Resolver\", function(){\n ok(resolver);\n});\n\ntest('does not require `namespace` to exist at `init` time', function() {\n expect(0);\n\n resolver = Resolver.create();\n});\n\ntest(\"can lookup something\", function(){\n expect(2);\n\n define('appkit/adapters/post', [], function(){\n ok(true, \"adapter was invoked properly\");\n\n return Ember.K;\n });\n\n var adapter = resolver.resolve('adapter:post');\n\n ok(adapter, 'adapter was returned');\n\n adapter();\n});\n\ntest(\"can lookup something in another namespace\", function(){\n expect(2);\n\n define('other/adapters/post', [], function(){\n ok(true, \"adapter was invoked properly\");\n\n return Ember.K;\n });\n\n var adapter = resolver.resolve('other@adapter:post');\n\n ok(adapter, 'adapter was returned');\n\n adapter();\n});\n\ntest(\"can lookup a view in another namespace\", function() {\n expect(2);\n\n define('other/views/post', [], function(){\n ok(true, \"view was invoked properly\");\n\n return Ember.K;\n });\n\n var view = resolver.resolve('view:other@post');\n\n ok(view, 'view was returned');\n\n view();\n});\n\ntest(\"can lookup a view\", function() {\n expect(2);\n\n define('appkit/views/queue-list', [], function(){\n ok(true, \"view was invoked properly\");\n\n return Ember.K;\n });\n\n var view = resolver.resolve('view:queue-list');\n\n ok(view, 'view was returned');\n\n view();\n});\n\ntest(\"will return the raw value if no 'default' is available\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is awesome';\n });\n\n equal(resolver.resolve('fruit:orange'), 'is awesome', 'adapter was returned');\n});\n\ntest(\"will unwrap the 'default' export automatically\", function(){\n define('appkit/fruits/orange', [], function(){\n return {default: 'is awesome'};\n });\n\n equal(resolver.resolve('fruit:orange'), 'is awesome', 'adapter was returned');\n});\n\ntest(\"router:main is hard-coded to prefix/router.js\", function() {\n expect(1);\n\n define('appkit/router', [], function(){\n ok(true, 'router:main was looked up');\n return 'whatever';\n });\n\n resolver.resolve('router:main');\n});\n\ntest(\"store:main is looked up as prefix/store\", function() {\n expect(1);\n\n define('appkit/store', [], function(){\n ok(true, 'store:main was looked up');\n return 'whatever';\n });\n\n resolver.resolve('store:main');\n});\n\ntest(\"store:posts as prefix/stores/post\", function() {\n expect(1);\n\n define('appkit/stores/post', [], function(){\n ok(true, 'store:post was looked up');\n return 'whatever';\n });\n\n resolver.resolve('store:post');\n});\n\ntest(\"will raise error if both dasherized and underscored modules exist\", function() {\n define('appkit/big-bands/steve-miller-band', [], function(){\n ok(true, 'dasherized version looked up');\n return 'whatever';\n });\n\n define('appkit/big_bands/steve_miller_band', [], function(){\n ok(false, 'underscored version looked up');\n return 'whatever';\n });\n\n try {\n resolver.resolve('big-band:steve-miller-band');\n } catch (e) {\n equal(e.message, 'Ambiguous module names: `appkit/big-bands/steve-miller-band` and `appkit/big_bands/steve_miller_band`', \"error with a descriptive value is thrown\");\n }\n});\n\ntest(\"will lookup an underscored version of the module name when the dasherized version is not found\", function() {\n expect(1);\n\n define('appkit/big_bands/steve_miller_band', [], function(){\n ok(true, 'underscored version looked up properly');\n return 'whatever';\n });\n\n resolver.resolve('big-band:steve-miller-band');\n});\n\ntest(\"can lookup templates with mixed naming moduleName\", function(){\n expectDeprecation('Modules should not contain underscores. Attempted to lookup \"appkit/bands/-steve-miller-band\" which was not found. Please rename \"appkit/bands/_steve-miller-band\" to \"appkit/bands/-steve-miller-band\" instead.');\n\n expect(2);\n\n define('appkit/bands/_steve-miller-band', [], function(){\n ok(true, 'underscored version looked up properly');\n return 'whatever';\n });\n\n resolver.resolve('band:-steve-miller-band');\n});\n\ntest(\"can lookup templates via Ember.TEMPLATES\", function() {\n Ember.TEMPLATES['application'] = function() {\n return '

herp

';\n };\n\n var template = resolver.resolve('template:application');\n ok(template, 'template should resolve');\n});\n\nmodule(\"Logging\", {\n setup: function() {\n originalLog = Ember.Logger.info;\n logCalls = [];\n Ember.Logger.info = function(arg) { logCalls.push(arg); };\n },\n\n teardown: function() {\n Ember.Logger.info = originalLog;\n }\n});\n\ntest(\"logs lookups when logging is enabled\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is logged';\n });\n\n Ember.ENV.LOG_MODULE_RESOLVER = true;\n\n resolver.resolve('fruit:orange');\n\n ok(logCalls.length, \"should log lookup\");\n});\n\ntest(\"doesn't log lookups if disabled\", function() {\n define('appkit/fruits/orange', [], function(){\n return 'is not logged';\n });\n\n Ember.ENV.LOG_MODULE_RESOLVER = false;\n\n resolver.resolve('fruit:orange');\n\n equal(logCalls.length, 0, \"should not log lookup\");\n});\n\nmodule(\"custom prefixes by type\", {\n teardown: resetRegistry\n});\n\ntest(\"will use the prefix specified for a given type if present\", function() {\n setupResolver({ namespace: {\n fruitPrefix: 'grovestand',\n modulePrefix: 'appkit'\n }});\n\n define('grovestand/fruits/orange', [], function(){\n ok(true, 'custom prefix used');\n return 'whatever';\n });\n\n resolver.resolve('fruit:orange');\n});\n\nmodule(\"pods lookup structure\", {\n setup: function() {\n setupResolver();\n },\n\n teardown: resetRegistry\n});\n\ntest(\"will lookup modulePrefix/name/type before prefix/type/name\", function() {\n define('appkit/controllers/foo', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(true, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo');\n});\n\ntest(\"will lookup names with slashes properly\", function() {\n define('appkit/controllers/foo/index', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/index/controller', [], function(){\n ok(true, 'appkit/foo/index/controller was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo/index');\n});\n\ntest(\"specifying a podModulePrefix overrides the general modulePrefix\", function() {\n setupResolver({\n namespace: {\n modulePrefix: 'appkit',\n podModulePrefix: 'appkit/pods'\n }\n });\n\n define('appkit/controllers/foo', [], function(){\n ok(false, 'appkit/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(false, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n define('appkit/pods/foo/controller', [], function(){\n ok(true, 'appkit/pods/foo/controllers was used');\n return 'whatever';\n });\n\n expectDeprecation(function() {\n resolver.resolve('controller:foo');\n }, \"`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'.\");\n});\n\ntest(\"specifying a podModulePrefix is deprecated\", function() {\n setupResolver({\n namespace: {\n modulePrefix: 'appkit',\n podModulePrefix: 'appkit/pods'\n }\n });\n\n expectDeprecation(function() {\n resolver.resolve('foo:bar');\n }, \"`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'.\");\n\n expectNoDeprecation(function() {\n resolver.resolve('foo:bar');\n });\n});\n\ntest(\"will not use custom type prefix when using POD format\", function() {\n resolver.namespace['controllerPrefix'] = 'foobar';\n\n define('foobar/controllers/foo', [], function(){\n ok(false, 'foobar/controllers was used');\n return 'whatever';\n });\n\n define('foobar/foo/controller', [], function(){\n ok(false, 'foobar/foo/controllers was used');\n return 'whatever';\n });\n\n define('appkit/foo/controller', [], function(){\n ok(true, 'appkit/foo/controllers was used');\n return 'whatever';\n });\n\n resolver.resolve('controller:foo');\n});\n\ntest(\"will lookup a components template without being rooted in `components/`\", function() {\n define('appkit/components/foo-bar/template', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/foo-bar/template', [], function(){\n ok(true, 'appkit/foo-bar/template was used');\n return 'whatever';\n });\n\n resolver.resolve('template:components/foo-bar');\n});\n\ntest(\"will use pods format to lookup components in components/\", function() {\n expect(2);\n\n define('appkit/components/foo-bar/template', [], function(){\n ok(true, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/components/foo-bar/component', [], function(){\n ok(true, 'appkit/components was used');\n return 'whatever';\n });\n\n resolver.resolve('template:components/foo-bar');\n resolver.resolve('component:foo-bar');\n});\n\ntest(\"will not lookup routes in components/\", function() {\n expect(1);\n\n define('appkit/components/foo-bar/route', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/routes/foo-bar', [], function(){\n ok(true, 'appkit/routes was used');\n return 'whatever';\n });\n\n resolver.resolve('route:foo-bar');\n});\n\ntest(\"will not lookup non component templates in components/\", function() {\n expect(1);\n\n define('appkit/components/foo-bar/template', [], function(){\n ok(false, 'appkit/components was used');\n return 'whatever';\n });\n\n define('appkit/templates/foo-bar', [], function(){\n ok(true, 'appkit/templates was used');\n return 'whatever';\n });\n\n resolver.resolve('template:foo-bar');\n});\n\nmodule(\"custom pluralization\", {\n teardown: resetRegistry\n});\n\ntest(\"will use the pluralization specified for a given type\", function() {\n expect(1);\n\n setupResolver({\n namespace: {\n modulePrefix: 'appkit'\n },\n\n pluralizedTypes: {\n 'sheep': 'sheep',\n 'octipus': 'octipii'\n }\n });\n\n define('appkit/sheep/baaaaaa', [], function(){\n ok(true, 'custom pluralization used');\n return 'whatever';\n });\n\n resolver.resolve('sheep:baaaaaa');\n});\n\ntest(\"will pluralize 'config' as 'config' by default\", function() {\n expect(1);\n\n setupResolver();\n\n define('appkit/config/environment', [], function(){\n ok(true, 'config/environment is found');\n return 'whatever';\n });\n\n resolver.resolve('config:environment');\n});\n\ntest(\"'config' can be overridden\", function() {\n expect(1);\n\n setupResolver({\n namespace: {\n modulePrefix: 'appkit'\n },\n\n pluralizedTypes: {\n 'config': 'super-duper-config'\n }\n });\n\n define('appkit/super-duper-config/environment', [], function(){\n ok(true, 'super-duper-config/environment is found');\n return 'whatever';\n });\n\n resolver.resolve('config:environment');\n});\n\n})();\n//@ sourceURL=ember-resolver/~tests/core_test"); \ No newline at end of file diff --git a/dist/ember-resolver.js b/dist/ember-resolver.js index d5c6cb11..87102ea1 100644 --- a/dist/ember-resolver.js +++ b/dist/ember-resolver.js @@ -97,6 +97,17 @@ define("ember/resolver", function resolveOther(parsedName) { /*jshint validthis:true */ + if (!this._deprecatedPodModulePrefix) { + var podModulePrefix = this.namespace.podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + + Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ + 'from future versions of ember-cli. Please move existing pods from '+ + '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + + this._deprecatedPodModulePrefix = true; + } + Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix); var normalizedModuleName = this.findModuleName(parsedName); @@ -143,13 +154,8 @@ define("ember/resolver", if (!this.pluralizedTypes.config) { this.pluralizedTypes.config = 'config'; } - - var podModulePrefix = this.namespace.podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ - 'from future versions of ember-cli. Please move existing pods from '+ - '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + this._deprecatedPodModulePrefix = false; }, normalize: function(fullName) { return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName)); diff --git a/dist/ember-resolver.min.js b/dist/ember-resolver.min.js index 3b6837a8..022bbce4 100644 --- a/dist/ember-resolver.min.js +++ b/dist/ember-resolver.min.js @@ -9,4 +9,4 @@ // Version: 0.1.13 // Copyright: Copyright 2013 Stefan Penner and Ember App Kit Contributors -!function(){define("ember/resolver",[],function(){"use strict";function e(e){return{create:function(r){return"function"==typeof e.extend?e.extend(r):e}}}function r(){var e=Object.create(null);return e._dict=null,delete e._dict,e}function t(e){if(e.parsedName===!0)return e;var r,t=e.split("@");2===t.length&&("view"===t[0].split(":")[0]&&(t[0]=t[0].split(":")[1],t[1]="view:"+t[1]),r=t[0]);var n=t[t.length-1].split(":"),a=n[0],u=n[1],s=u,l=o(this,"namespace"),d=l;return{parsedName:!0,fullName:e,prefix:r||this.prefix({type:a}),type:a,fullNameWithoutType:u,name:s,root:d,resolveMethodName:"resolve"+i(a)}}function n(r){Ember.assert("`modulePrefix` must be defined",this.namespace.modulePrefix);var t=this.findModuleName(r);if(t){var n=require(t,null,null,!0);if(n&&n["default"]&&(n=n["default"]),void 0===n)throw new Error(" Expected to find: '"+r.fullName+"' within '"+t+"' but got 'undefined'. Did you forget to `export default` within '"+t+"'?");return this.shouldWrapInClassFactory(n,r)&&(n=e(n)),n}return this._super(r)}if("undefined"==typeof requirejs.entries&&(requirejs.entries=requirejs._eak_seen),!Object.create||Object.create(null).hasOwnProperty)throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg");var i=(Ember.String.underscore,Ember.String.classify),o=Ember.get,a=Ember.DefaultResolver.extend({resolveOther:n,resolveTemplate:n,pluralizedTypes:null,makeToString:function(e,r){return""+this.namespace.modulePrefix+"@"+r+":"},parseName:t,shouldWrapInClassFactory:function(){return!1},init:function(){this._super(),this.moduleBasedResolver=!0,this._normalizeCache=r(),this.pluralizedTypes=this.pluralizedTypes||r(),this.pluralizedTypes.config||(this.pluralizedTypes.config="config");var e=this.namespace.podModulePrefix||"",t=e.substr(e.lastIndexOf("/")+1);Ember.deprecate("`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/"+t+"/' to 'app/'.",!this.namespace.podModulePrefix)},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this._normalize(e))},_normalize:function(e){var r=e.split(":");return r.length>1?r[0]+":"+Ember.String.dasherize(r[1].replace(/\./g,"/")):e},pluralize:function(e){return this.pluralizedTypes[e]||(this.pluralizedTypes[e]=e+"s")},podBasedLookupWithPrefix:function(e,r){var t=r.fullNameWithoutType;return"template"===r.type&&(t=t.replace(/^components\//,"")),e+"/"+t+"/"+r.type},podBasedModuleName:function(e){var r=this.namespace.podModulePrefix||this.namespace.modulePrefix;return this.podBasedLookupWithPrefix(r,e)},podBasedComponentsInSubdir:function(e){var r=this.namespace.podModulePrefix||this.namespace.modulePrefix;return r+="/components","component"===e.type||e.fullNameWithoutType.match(/^components/)?this.podBasedLookupWithPrefix(r,e):void 0},mainModuleName:function(e){var r=e.prefix+"/"+e.type;return"main"===e.fullNameWithoutType?r:void 0},defaultModuleName:function(e){return e.prefix+"/"+this.pluralize(e.type)+"/"+e.fullNameWithoutType},prefix:function(e){var r=this.namespace.modulePrefix;return this.namespace[e.type+"Prefix"]&&(r=this.namespace[e.type+"Prefix"]),r},moduleNameLookupPatterns:Ember.computed(function(){return Ember.A([this.podBasedModuleName,this.podBasedComponentsInSubdir,this.mainModuleName,this.defaultModuleName])}),findModuleName:function(e,r){var t,n=this;return this.get("moduleNameLookupPatterns").find(function(i){var o=requirejs.entries,a=i.call(n,e);return a&&(a=n.chooseModuleName(o,a)),a&&o[a]&&(r||n._logLookup(!0,e,a),t=a),r||n._logLookup(t,e,a),t}),t},chooseModuleName:function(e,r){var t=Ember.String.underscore(r);if(r!==t&&e[r]&&e[t])throw new TypeError("Ambiguous module names: `"+r+"` and `"+t+"`");if(e[r])return r;if(e[t])return t;var n=r.replace(/\/-([^\/]*)$/,"/_$1");return e[n]?(Ember.deprecate('Modules should not contain underscores. Attempted to lookup "'+r+'" which was not found. Please rename "'+n+'" to "'+r+'" instead.',!1),n):r},lookupDescription:function(e){var r=this.parseName(e),t=this.findModuleName(r,!0);return t},_logLookup:function(e,r,t){if(Ember.ENV.LOG_MODULE_RESOLVER||r.root.LOG_RESOLVER){var n,i;n=e?"[\u2713]":"[ ]",i=r.fullName.length>60?".":new Array(60-r.fullName.length).join("."),t||(t=this.lookupDescription(r)),Ember.Logger.info(n,r.fullName,i,t)}}});return a.moduleBasedResolver=!0,a["default"]=a,a}),define("resolver",["ember/resolver"],function(e){return Ember.deprecate('Importing/requiring Ember Resolver as "resolver" is deprecated, please use "ember/resolver" instead'),e})}(),function(){define("ember/container-debug-adapter",[],function(){"use strict";function e(e,r,t){var n=r.match(new RegExp("^/?"+t+"/(.+)/"+e+"$"));return n?n[1]:void 0}if("undefined"==typeof Ember.ContainerDebugAdapter)return null;var r=Ember.ContainerDebugAdapter.extend({canCatalogEntriesByType:function(){return!0},_getEntries:function(){return requirejs.entries},catalogEntriesByType:function(r){var t=this._getEntries(),n=Ember.A(),i=this.namespace.modulePrefix;for(var o in t)if(t.hasOwnProperty(o)&&-1!==o.indexOf(r)){var a=e(r,o,this.namespace.podModulePrefix||i);a||(a=o.split(r+"s/").pop()),n.addObject(a)}return n}});return r["default"]=r,r})}(),function(){!function(){"use strict";Ember.Application.initializer({name:"container-debug-adapter",initialize:function(e,r){{var t=require("ember/container-debug-adapter");require("ember/resolver")}e.register("container-debug-adapter:main",t),r.inject("container-debug-adapter:main","namespace","application:main")}})}()}(),"undefined"==typeof location||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname||Ember.Logger.warn("You are running a production build of Ember on localhost and won't receive detailed error messages. If you want full error messages please use the non-minified build provided on the Ember website."); \ No newline at end of file +!function(){define("ember/resolver",[],function(){"use strict";function e(e){return{create:function(r){return"function"==typeof e.extend?e.extend(r):e}}}function r(){var e=Object.create(null);return e._dict=null,delete e._dict,e}function t(e){if(e.parsedName===!0)return e;var r,t=e.split("@");2===t.length&&("view"===t[0].split(":")[0]&&(t[0]=t[0].split(":")[1],t[1]="view:"+t[1]),r=t[0]);var n=t[t.length-1].split(":"),a=n[0],u=n[1],s=u,l=o(this,"namespace"),d=l;return{parsedName:!0,fullName:e,prefix:r||this.prefix({type:a}),type:a,fullNameWithoutType:u,name:s,root:d,resolveMethodName:"resolve"+i(a)}}function n(r){if(!this._deprecatedPodModulePrefix){var t=this.namespace.podModulePrefix||"",n=t.substr(t.lastIndexOf("/")+1);Ember.deprecate("`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/"+n+"/' to 'app/'.",!this.namespace.podModulePrefix),this._deprecatedPodModulePrefix=!0}Ember.assert("`modulePrefix` must be defined",this.namespace.modulePrefix);var i=this.findModuleName(r);if(i){var o=require(i,null,null,!0);if(o&&o["default"]&&(o=o["default"]),void 0===o)throw new Error(" Expected to find: '"+r.fullName+"' within '"+i+"' but got 'undefined'. Did you forget to `export default` within '"+i+"'?");return this.shouldWrapInClassFactory(o,r)&&(o=e(o)),o}return this._super(r)}if("undefined"==typeof requirejs.entries&&(requirejs.entries=requirejs._eak_seen),!Object.create||Object.create(null).hasOwnProperty)throw new Error("This browser does not support Object.create(null), please polyfil with es5-sham: http://git.io/yBU2rg");var i=(Ember.String.underscore,Ember.String.classify),o=Ember.get,a=Ember.DefaultResolver.extend({resolveOther:n,resolveTemplate:n,pluralizedTypes:null,makeToString:function(e,r){return""+this.namespace.modulePrefix+"@"+r+":"},parseName:t,shouldWrapInClassFactory:function(){return!1},init:function(){this._super(),this.moduleBasedResolver=!0,this._normalizeCache=r(),this.pluralizedTypes=this.pluralizedTypes||r(),this.pluralizedTypes.config||(this.pluralizedTypes.config="config"),this._deprecatedPodModulePrefix=!1},normalize:function(e){return this._normalizeCache[e]||(this._normalizeCache[e]=this._normalize(e))},_normalize:function(e){var r=e.split(":");return r.length>1?r[0]+":"+Ember.String.dasherize(r[1].replace(/\./g,"/")):e},pluralize:function(e){return this.pluralizedTypes[e]||(this.pluralizedTypes[e]=e+"s")},podBasedLookupWithPrefix:function(e,r){var t=r.fullNameWithoutType;return"template"===r.type&&(t=t.replace(/^components\//,"")),e+"/"+t+"/"+r.type},podBasedModuleName:function(e){var r=this.namespace.podModulePrefix||this.namespace.modulePrefix;return this.podBasedLookupWithPrefix(r,e)},podBasedComponentsInSubdir:function(e){var r=this.namespace.podModulePrefix||this.namespace.modulePrefix;return r+="/components","component"===e.type||e.fullNameWithoutType.match(/^components/)?this.podBasedLookupWithPrefix(r,e):void 0},mainModuleName:function(e){var r=e.prefix+"/"+e.type;return"main"===e.fullNameWithoutType?r:void 0},defaultModuleName:function(e){return e.prefix+"/"+this.pluralize(e.type)+"/"+e.fullNameWithoutType},prefix:function(e){var r=this.namespace.modulePrefix;return this.namespace[e.type+"Prefix"]&&(r=this.namespace[e.type+"Prefix"]),r},moduleNameLookupPatterns:Ember.computed(function(){return Ember.A([this.podBasedModuleName,this.podBasedComponentsInSubdir,this.mainModuleName,this.defaultModuleName])}),findModuleName:function(e,r){var t,n=this;return this.get("moduleNameLookupPatterns").find(function(i){var o=requirejs.entries,a=i.call(n,e);return a&&(a=n.chooseModuleName(o,a)),a&&o[a]&&(r||n._logLookup(!0,e,a),t=a),r||n._logLookup(t,e,a),t}),t},chooseModuleName:function(e,r){var t=Ember.String.underscore(r);if(r!==t&&e[r]&&e[t])throw new TypeError("Ambiguous module names: `"+r+"` and `"+t+"`");if(e[r])return r;if(e[t])return t;var n=r.replace(/\/-([^\/]*)$/,"/_$1");return e[n]?(Ember.deprecate('Modules should not contain underscores. Attempted to lookup "'+r+'" which was not found. Please rename "'+n+'" to "'+r+'" instead.',!1),n):r},lookupDescription:function(e){var r=this.parseName(e),t=this.findModuleName(r,!0);return t},_logLookup:function(e,r,t){if(Ember.ENV.LOG_MODULE_RESOLVER||r.root.LOG_RESOLVER){var n,i;n=e?"[\u2713]":"[ ]",i=r.fullName.length>60?".":new Array(60-r.fullName.length).join("."),t||(t=this.lookupDescription(r)),Ember.Logger.info(n,r.fullName,i,t)}}});return a.moduleBasedResolver=!0,a["default"]=a,a}),define("resolver",["ember/resolver"],function(e){return Ember.deprecate('Importing/requiring Ember Resolver as "resolver" is deprecated, please use "ember/resolver" instead'),e})}(),function(){define("ember/container-debug-adapter",[],function(){"use strict";function e(e,r,t){var n=r.match(new RegExp("^/?"+t+"/(.+)/"+e+"$"));return n?n[1]:void 0}if("undefined"==typeof Ember.ContainerDebugAdapter)return null;var r=Ember.ContainerDebugAdapter.extend({canCatalogEntriesByType:function(){return!0},_getEntries:function(){return requirejs.entries},catalogEntriesByType:function(r){var t=this._getEntries(),n=Ember.A(),i=this.namespace.modulePrefix;for(var o in t)if(t.hasOwnProperty(o)&&-1!==o.indexOf(r)){var a=e(r,o,this.namespace.podModulePrefix||i);a||(a=o.split(r+"s/").pop()),n.addObject(a)}return n}});return r["default"]=r,r})}(),function(){!function(){"use strict";Ember.Application.initializer({name:"container-debug-adapter",initialize:function(e,r){{var t=require("ember/container-debug-adapter");require("ember/resolver")}e.register("container-debug-adapter:main",t),r.inject("container-debug-adapter:main","namespace","application:main")}})}()}(),"undefined"==typeof location||"localhost"!==location.hostname&&"127.0.0.1"!==location.hostname||Ember.Logger.warn("You are running a production build of Ember on localhost and won't receive detailed error messages. If you want full error messages please use the non-minified build provided on the Ember website."); \ No newline at end of file diff --git a/dist/ember-resolver.prod.js b/dist/ember-resolver.prod.js index 81d96cc7..e5237bd3 100644 --- a/dist/ember-resolver.prod.js +++ b/dist/ember-resolver.prod.js @@ -97,6 +97,17 @@ define("ember/resolver", function resolveOther(parsedName) { /*jshint validthis:true */ + if (!this._deprecatedPodModulePrefix) { + var podModulePrefix = this.namespace.podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + + Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ + 'from future versions of ember-cli. Please move existing pods from '+ + '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + + this._deprecatedPodModulePrefix = true; + } + Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix); var normalizedModuleName = this.findModuleName(parsedName); @@ -143,13 +154,8 @@ define("ember/resolver", if (!this.pluralizedTypes.config) { this.pluralizedTypes.config = 'config'; } - - var podModulePrefix = this.namespace.podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ - 'from future versions of ember-cli. Please move existing pods from '+ - '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + this._deprecatedPodModulePrefix = false; }, normalize: function(fullName) { return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName)); diff --git a/dist/modules/ember-resolver-tests.js b/dist/modules/ember-resolver-tests.js index 079f22ea..4ecc4c12 100644 --- a/dist/modules/ember-resolver-tests.js +++ b/dist/modules/ember-resolver-tests.js @@ -158,6 +158,12 @@ test("can access Resolver", function(){ ok(resolver); }); +test('does not require `namespace` to exist at `init` time', function() { + expect(0); + + resolver = Resolver.create(); +}); + test("can lookup something", function(){ expect(2); @@ -413,14 +419,12 @@ test("will lookup names with slashes properly", function() { }); test("specifying a podModulePrefix overrides the general modulePrefix", function() { - expectDeprecation(function() { - setupResolver({ - namespace: { - modulePrefix: 'appkit', - podModulePrefix: 'appkit/pods' - } - }); - }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); + setupResolver({ + namespace: { + modulePrefix: 'appkit', + podModulePrefix: 'appkit/pods' + } + }); define('appkit/controllers/foo', [], function(){ ok(false, 'appkit/controllers was used'); @@ -437,18 +441,26 @@ test("specifying a podModulePrefix overrides the general modulePrefix", function return 'whatever'; }); - resolver.resolve('controller:foo'); + expectDeprecation(function() { + resolver.resolve('controller:foo'); + }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); }); test("specifying a podModulePrefix is deprecated", function() { + setupResolver({ + namespace: { + modulePrefix: 'appkit', + podModulePrefix: 'appkit/pods' + } + }); + expectDeprecation(function() { - setupResolver({ - namespace: { - modulePrefix: 'appkit', - podModulePrefix: 'appkit/pods' - } - }); + resolver.resolve('foo:bar'); }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); + + expectNoDeprecation(function() { + resolver.resolve('foo:bar'); + }); }); test("will not use custom type prefix when using POD format", function() { diff --git a/dist/modules/ember-resolver.js b/dist/modules/ember-resolver.js index 11945063..63bc79df 100644 --- a/dist/modules/ember-resolver.js +++ b/dist/modules/ember-resolver.js @@ -87,6 +87,17 @@ define("ember/resolver", function resolveOther(parsedName) { /*jshint validthis:true */ + if (!this._deprecatedPodModulePrefix) { + var podModulePrefix = this.namespace.podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + + Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ + 'from future versions of ember-cli. Please move existing pods from '+ + '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + + this._deprecatedPodModulePrefix = true; + } + Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix); var normalizedModuleName = this.findModuleName(parsedName); @@ -133,13 +144,8 @@ define("ember/resolver", if (!this.pluralizedTypes.config) { this.pluralizedTypes.config = 'config'; } - - var podModulePrefix = this.namespace.podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ - 'from future versions of ember-cli. Please move existing pods from '+ - '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + this._deprecatedPodModulePrefix = false; }, normalize: function(fullName) { return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName)); diff --git a/packages/ember-resolver/lib/core.js b/packages/ember-resolver/lib/core.js index b284ccb7..49525d56 100644 --- a/packages/ember-resolver/lib/core.js +++ b/packages/ember-resolver/lib/core.js @@ -86,6 +86,17 @@ define("ember/resolver", function resolveOther(parsedName) { /*jshint validthis:true */ + if (!this._deprecatedPodModulePrefix) { + var podModulePrefix = this.namespace.podModulePrefix || ''; + var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); + + Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ + 'from future versions of ember-cli. Please move existing pods from '+ + '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + + this._deprecatedPodModulePrefix = true; + } + Ember.assert('`modulePrefix` must be defined', this.namespace.modulePrefix); var normalizedModuleName = this.findModuleName(parsedName); @@ -132,13 +143,8 @@ define("ember/resolver", if (!this.pluralizedTypes.config) { this.pluralizedTypes.config = 'config'; } - - var podModulePrefix = this.namespace.podModulePrefix || ''; - var podPath = podModulePrefix.substr(podModulePrefix.lastIndexOf('/') + 1); - Ember.deprecate('`podModulePrefix` is deprecated and will be removed '+ - 'from future versions of ember-cli. Please move existing pods from '+ - '\'app/' + podPath + '/\' to \'app/\'.', !this.namespace.podModulePrefix); + this._deprecatedPodModulePrefix = false; }, normalize: function(fullName) { return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this._normalize(fullName)); diff --git a/packages/ember-resolver/tests/core_test.js b/packages/ember-resolver/tests/core_test.js index 09ba9c6c..99ed6d60 100644 --- a/packages/ember-resolver/tests/core_test.js +++ b/packages/ember-resolver/tests/core_test.js @@ -47,6 +47,12 @@ test("can access Resolver", function(){ ok(resolver); }); +test('does not require `namespace` to exist at `init` time', function() { + expect(0); + + resolver = Resolver.create(); +}); + test("can lookup something", function(){ expect(2); @@ -302,14 +308,12 @@ test("will lookup names with slashes properly", function() { }); test("specifying a podModulePrefix overrides the general modulePrefix", function() { - expectDeprecation(function() { - setupResolver({ - namespace: { - modulePrefix: 'appkit', - podModulePrefix: 'appkit/pods' - } - }); - }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); + setupResolver({ + namespace: { + modulePrefix: 'appkit', + podModulePrefix: 'appkit/pods' + } + }); define('appkit/controllers/foo', [], function(){ ok(false, 'appkit/controllers was used'); @@ -326,18 +330,26 @@ test("specifying a podModulePrefix overrides the general modulePrefix", function return 'whatever'; }); - resolver.resolve('controller:foo'); + expectDeprecation(function() { + resolver.resolve('controller:foo'); + }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); }); test("specifying a podModulePrefix is deprecated", function() { + setupResolver({ + namespace: { + modulePrefix: 'appkit', + podModulePrefix: 'appkit/pods' + } + }); + expectDeprecation(function() { - setupResolver({ - namespace: { - modulePrefix: 'appkit', - podModulePrefix: 'appkit/pods' - } - }); + resolver.resolve('foo:bar'); }, "`podModulePrefix` is deprecated and will be removed from future versions of ember-cli. Please move existing pods from 'app/pods/' to 'app/'."); + + expectNoDeprecation(function() { + resolver.resolve('foo:bar'); + }); }); test("will not use custom type prefix when using POD format", function() {