underscore_extensions 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile
CHANGED
@@ -3,4 +3,4 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in underscore_extensions.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git', :branch => '
|
6
|
+
gem 'jasmine', :git => 'https://github.com/pivotal/jasmine-gem.git', :branch => 'ddeb56597c3507f068f9dfca4fd22d48e5a68253'
|
@@ -63,10 +63,17 @@
|
|
63
63
|
}
|
64
64
|
});
|
65
65
|
|
66
|
-
if (this.
|
66
|
+
if (this.InflectionJS) {
|
67
67
|
_.mixin({
|
68
|
-
pluralize: function(obj, options) {
|
68
|
+
pluralize: function(obj, number, options) {
|
69
|
+
if (!_(number).isNumber()) {
|
70
|
+
options = number;
|
71
|
+
number = 0;
|
72
|
+
}
|
69
73
|
options = options || {};
|
74
|
+
if (number === 1) {
|
75
|
+
options.skip = obj;
|
76
|
+
}
|
70
77
|
options.skip = options.skip || '';
|
71
78
|
return InflectionJS.apply_rules(obj, InflectionJS.plural_rules, options.skip);
|
72
79
|
},
|
@@ -96,18 +96,31 @@ describe('_', function() {
|
|
96
96
|
expect(_('story').pluralize()).toEqual('stories');
|
97
97
|
});
|
98
98
|
|
99
|
-
it(
|
99
|
+
it('should pass the skip option', function() {
|
100
100
|
expect(_('foo').pluralize({skip: 'foo'})).toEqual('foo');
|
101
101
|
});
|
102
|
+
|
103
|
+
describe('when a number is provided', function() {
|
104
|
+
it('should not pluralize when the number is 1', function() {
|
105
|
+
expect(_('foo').pluralize(0)).toEqual('foos');
|
106
|
+
expect(_('foo').pluralize(1)).toEqual('foo');
|
107
|
+
expect(_('foo').pluralize(2)).toEqual('foos');
|
108
|
+
});
|
109
|
+
|
110
|
+
it('should pass the skip option', function() {
|
111
|
+
expect(_('foo').pluralize(2, {skip: 'bar'})).toEqual('foos');
|
112
|
+
expect(_('foo').pluralize(2, {skip: 'foo'})).toEqual('foo');
|
113
|
+
});
|
114
|
+
});
|
102
115
|
});
|
103
116
|
|
104
117
|
describe('#singularize', function() {
|
105
|
-
it(
|
118
|
+
it('should singularize a model name', function() {
|
106
119
|
expect(_('octopi').singularize()).toEqual('octopus');
|
107
120
|
expect(_('stories').singularize()).toEqual('story');
|
108
121
|
});
|
109
122
|
|
110
|
-
it(
|
123
|
+
it('should pass the skip option', function() {
|
111
124
|
expect(_('foos').singularize({skip: 'foos'})).toEqual('foos');
|
112
125
|
});
|
113
126
|
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: underscore_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fuubar
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project: underscore_extensions
|
156
|
-
rubygems_version: 1.8.
|
156
|
+
rubygems_version: 1.8.19
|
157
157
|
signing_key:
|
158
158
|
specification_version: 3
|
159
159
|
summary: Extensions to underscore javascript library as a rails engine
|