From e94996400d72b7445399c148c8c1613ac7cd023d Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 11 Jul 2017 17:48:53 +0100 Subject: [PATCH 1/3] Deprecate Ember.Inflector, Ember.String.singularize and Ember.String.pluralize --- addon/index.js | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/addon/index.js b/addon/index.js index c017a0f..dcbab15 100644 --- a/addon/index.js +++ b/addon/index.js @@ -7,10 +7,39 @@ import { } from "./lib/system"; Inflector.defaultRules = defaultRules; -Ember.Inflector = Inflector; -Ember.String.pluralize = pluralize; -Ember.String.singularize = singularize; +Object.defineProperty(Ember, 'Inflector', { + get() { + Ember.deprecate(`Ember.Inflector is deprecated. Please explicitly: import Inflector from 'ember-inflector';`, false, { + id: 'ember-inflector.globals', + until: '3.0.0', + }); + + return Inflector; + }, +}); + +Object.defineProperty(Ember.String, 'singularize', { + get() { + Ember.deprecate(`Ember.String.singularize() is deprecated. Please explicitly: import { singularize } from 'ember-inflector';`, false, { + id: 'ember-inflector.globals', + until: '3.0.0', + }); + + return singularize; + }, +}); + +Object.defineProperty(Ember.String, 'pluralize', { + get() { + Ember.deprecate(`Ember.String.pluralize() is deprecated. Please explicitly: import { pluralize } from 'ember-inflector';`, false, { + id: 'ember-inflector.globals', + until: '3.0.0', + }); + + return pluralize; + }, +}); import "./lib/ext/string"; From e08944ef0c34a0ca79bd656dbc4dd1e31e2379e4 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 12 Jul 2017 11:03:18 +0100 Subject: [PATCH 2/3] Deprecate String.singularize and String.pluralize --- addon/lib/ext/string.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/addon/lib/ext/string.js b/addon/lib/ext/string.js index 5e69098..9382620 100644 --- a/addon/lib/ext/string.js +++ b/addon/lib/ext/string.js @@ -11,9 +11,18 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { @method pluralize @for String */ - String.prototype.pluralize = function() { - return pluralize(this); - }; + Object.defineProperty(String.prototype, 'pluralize', { + get() { + Ember.deprecate(`String.prototype.pluralize() is deprecated. Please explicitly: import { pluralize } from 'ember-inflector';`, false, { + id: 'ember-inflector.globals', + until: '3.0.0', + }); + + return function() { + return pluralize(this); + }; + }, + }); /** See {{#crossLink "Ember.String/singularize"}}{{/crossLink}} @@ -21,7 +30,16 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.String) { @method singularize @for String */ - String.prototype.singularize = function() { - return singularize(this); - }; + Object.defineProperty(String.prototype, 'singularize', { + get() { + Ember.deprecate(`String.prototype.singularize() is deprecated. Please explicitly: import { singularize } from 'ember-inflector';`, false, { + id: 'ember-inflector.globals', + until: '3.0.0', + }); + + return function() { + return singularize(this); + }; + }, + }); } From 84cebbef3bb64f67aa2c26f172c3d95be7ffaafd Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 23 Jul 2017 19:51:16 +0200 Subject: [PATCH 3/3] Update README --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 209ea52..d2609a7 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,17 @@ ember install ember-inflector ## Usage -All methods are always available from `Ember.Inflector`, but in Ember CLI, you can always `import` instead: +All methods are always available from the `ember-inflector` module: ```javascript import Inflector from 'ember-inflector'; -import {singularize, pluralize} from 'ember-inflector'; +import { singularize, pluralize } from 'ember-inflector'; Inflector.inflector.singularize("tacos"); // taco Inflector.inflector.pluralize("taco"); // tacos singularize("tacos"); // taco pluralize("taco"); // tacos - -// or if not using Ember CLI/ES6 -Ember.Inflector.inflector.pluralize("taco"); // tacos ``` ### Template Helpers