Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Ember.String to @ember/string. #16530

Merged
merged 2 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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