Skip to content

Commit

Permalink
Merge pull request #16530 from rwjblue/make-string-real-named-exports
Browse files Browse the repository at this point in the history
Migrate Ember.String to @ember/string.
  • Loading branch information
rwjblue authored Apr 17, 2018
2 parents 73fc532 + 8499693 commit 376d08b
Show file tree
Hide file tree
Showing 30 changed files with 507 additions and 533 deletions.
25 changes: 13 additions & 12 deletions packages/@ember/application/globals-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import { dictionary } from 'ember-utils';
import { get, findNamespace } from 'ember-metal';
import { assert, info } from 'ember-debug';
import { String as StringUtils, Object as EmberObject } from 'ember-runtime';
import { capitalize, classify, dasherize, decamelize } from '@ember/string';
import { Object as EmberObject } from 'ember-runtime';
import validateType from './lib/validate-type';
import { getTemplate } from 'ember-glimmer';
import { DEBUG } from '@glimmer/env';
Expand Down Expand Up @@ -191,7 +192,7 @@ const DefaultResolver = EmberObject.extend({
if (type !== 'template' && lastSlashIndex !== -1) {
let parts = name.split('/');
name = parts[parts.length - 1];
let namespaceName = StringUtils.capitalize(parts.slice(0, -1).join('.'));
let namespaceName = capitalize(parts.slice(0, -1).join('.'));
root = findNamespace(namespaceName);

assert(
Expand All @@ -200,7 +201,7 @@ const DefaultResolver = EmberObject.extend({
);
}

let resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : StringUtils.classify(type);
let resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : classify(type);

if (!(name && type)) {
throw new TypeError(`Invalid fullName: \`${fullName}\`, must be of the form \`type:name\` `);
Expand Down Expand Up @@ -235,10 +236,10 @@ const DefaultResolver = EmberObject.extend({
return `template at ${parsedName.fullNameWithoutType.replace(/\./g, '/')}`;
}

description = `${parsedName.root}.${StringUtils.classify(parsedName.name).replace(/\./g, '')}`;
description = `${parsedName.root}.${classify(parsedName.name).replace(/\./g, '')}`;

if (parsedName.type !== 'model') {
description += StringUtils.classify(parsedName.type);
description += classify(parsedName.type);
}

return description;
Expand Down Expand Up @@ -275,7 +276,7 @@ const DefaultResolver = EmberObject.extend({
resolveTemplate(parsedName) {
let templateName = parsedName.fullNameWithoutType.replace(/\./g, '/');

return getTemplate(templateName) || getTemplate(StringUtils.decamelize(templateName));
return getTemplate(templateName) || getTemplate(decamelize(templateName));
},

/**
Expand Down Expand Up @@ -325,7 +326,7 @@ const DefaultResolver = EmberObject.extend({
@protected
*/
resolveModel(parsedName) {
let className = StringUtils.classify(parsedName.name);
let className = classify(parsedName.name);
let factory = get(parsedName.root, className);

return factory;
Expand All @@ -352,13 +353,13 @@ const DefaultResolver = EmberObject.extend({
@protected
*/
resolveOther(parsedName) {
let className = StringUtils.classify(parsedName.name) + StringUtils.classify(parsedName.type);
let className = classify(parsedName.name) + classify(parsedName.type);
let factory = get(parsedName.root, className);
return factory;
},

resolveMain(parsedName) {
let className = StringUtils.classify(parsedName.type);
let className = classify(parsedName.type);
return get(parsedName.root, className);
},

Expand All @@ -371,7 +372,7 @@ const DefaultResolver = EmberObject.extend({
*/
knownForType(type) {
let namespace = get(this, 'namespace');
let suffix = StringUtils.classify(type);
let suffix = classify(type);
let typeRegexp = new RegExp(`${suffix}$`);

let known = dictionary(null);
Expand Down Expand Up @@ -403,9 +404,9 @@ const DefaultResolver = EmberObject.extend({
@private
*/
translateToContainerFullname(type, name) {
let suffix = StringUtils.classify(type);
let suffix = classify(type);
let namePrefix = name.slice(0, suffix.length * -1);
let dasherizedName = StringUtils.dasherize(namePrefix);
let dasherizedName = dasherize(namePrefix);

return `${type}:${dasherizedName}`;
},
Expand Down
2 changes: 2 additions & 0 deletions packages/@ember/string/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function dasherize(s: string): string;
export function loc(s: string, ...args: string[]): string;
Loading

0 comments on commit 376d08b

Please sign in to comment.