opal-activesupport 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -0
- data/README.md +4 -1
- data/Rakefile +22 -6
- data/lib/opal/activesupport/version.rb +1 -1
- data/opal-activesupport.gemspec +1 -0
- data/opal/active_support/concern.rb +152 -0
- data/opal/active_support/core_ext/string.rb +1 -38
- data/opal/active_support/core_ext/string/filters.rb +146 -0
- data/opal/active_support/core_ext/string/inflections.rb +66 -4
- data/opal/active_support/inflections.rb +2 -0
- data/opal/active_support/inflector.rb +5 -2
- data/opal/active_support/inflector/inflections.rb +64 -66
- data/opal/active_support/inflector/methods.rb +198 -0
- data/test/abstract_unit.rb +22 -5
- data/test/concern_test.rb +144 -0
- data/test/constantize_test_cases.rb +121 -0
- data/test/core_ext/numeric_ext_test.rb +1 -1
- data/test/core_ext/string_ext_test.rb +675 -304
- data/test/inflector_test.rb +578 -0
- data/test/inflector_test_cases.rb +91 -31
- metadata +27 -4
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module InflectorTestCases
|
4
4
|
SingularToPlural = {
|
@@ -13,8 +13,8 @@ module InflectorTestCases
|
|
13
13
|
"wish" => "wishes",
|
14
14
|
"fish" => "fish",
|
15
15
|
"jeans" => "jeans",
|
16
|
-
"funky jeans" => "funky jeans",
|
17
|
-
# "my money" => "my money",
|
16
|
+
# "funky jeans" => "funky jeans",
|
17
|
+
# "my money" => "my money",
|
18
18
|
|
19
19
|
"category" => "categories",
|
20
20
|
"query" => "queries",
|
@@ -63,6 +63,7 @@ module InflectorTestCases
|
|
63
63
|
"news" => "news",
|
64
64
|
|
65
65
|
"series" => "series",
|
66
|
+
"miniseries" => "miniseries",
|
66
67
|
"species" => "species",
|
67
68
|
|
68
69
|
"quiz" => "quizzes",
|
@@ -105,7 +106,6 @@ module InflectorTestCases
|
|
105
106
|
"prize" => "prizes",
|
106
107
|
"edge" => "edges",
|
107
108
|
|
108
|
-
"cow" => "cows",
|
109
109
|
"database" => "databases",
|
110
110
|
|
111
111
|
# regression tests against improper inflection regexes
|
@@ -130,10 +130,10 @@ module InflectorTestCases
|
|
130
130
|
}
|
131
131
|
|
132
132
|
SymbolToLowerCamel = {
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
133
|
+
product: "product",
|
134
|
+
special_guest: "specialGuest",
|
135
|
+
application_controller: "applicationController",
|
136
|
+
area51_controller: "area51Controller"
|
137
137
|
}
|
138
138
|
|
139
139
|
CamelToUnderscoreWithoutReverse = {
|
@@ -141,6 +141,7 @@ module InflectorTestCases
|
|
141
141
|
"HTMLTidyGenerator" => "html_tidy_generator",
|
142
142
|
"FreeBSD" => "free_bsd",
|
143
143
|
"HTML" => "html",
|
144
|
+
"ForceXMLController" => "force_xml_controller",
|
144
145
|
}
|
145
146
|
|
146
147
|
CamelWithModuleToUnderscoreWithSlash = {
|
@@ -172,7 +173,18 @@ module InflectorTestCases
|
|
172
173
|
"!@#Leading bad characters" => "leading-bad-characters",
|
173
174
|
"Squeeze separators" => "squeeze-separators",
|
174
175
|
"Test with + sign" => "test-with-sign",
|
175
|
-
"Test with malformed utf8 \251" => "test-with-malformed-utf8"
|
176
|
+
# "Test with malformed utf8 \251" => "test-with-malformed-utf8"
|
177
|
+
}
|
178
|
+
|
179
|
+
StringToParameterizedPreserveCase = {
|
180
|
+
"Donald E. Knuth" => "Donald-E-Knuth",
|
181
|
+
"Random text with *(bad)* characters" => "Random-text-with-bad-characters",
|
182
|
+
"Allow_Under_Scores" => "Allow_Under_Scores",
|
183
|
+
"Trailing bad characters!@#" => "Trailing-bad-characters",
|
184
|
+
"!@#Leading bad characters" => "Leading-bad-characters",
|
185
|
+
"Squeeze separators" => "Squeeze-separators",
|
186
|
+
"Test with + sign" => "Test-with-sign",
|
187
|
+
# "Test with malformed utf8 \xA9" => "Test-with-malformed-utf8"
|
176
188
|
}
|
177
189
|
|
178
190
|
StringToParameterizeWithNoSeparator = {
|
@@ -183,7 +195,18 @@ module InflectorTestCases
|
|
183
195
|
"!@#Leading bad characters" => "leadingbadcharacters",
|
184
196
|
"Squeeze separators" => "squeezeseparators",
|
185
197
|
"Test with + sign" => "testwithsign",
|
186
|
-
"Test with malformed utf8 \251" => "testwithmalformedutf8"
|
198
|
+
# "Test with malformed utf8 \251" => "testwithmalformedutf8"
|
199
|
+
}
|
200
|
+
|
201
|
+
StringToParameterizePreserveCaseWithNoSeparator = {
|
202
|
+
"Donald E. Knuth" => "DonaldEKnuth",
|
203
|
+
"With-some-dashes" => "With-some-dashes",
|
204
|
+
"Random text with *(bad)* characters" => "Randomtextwithbadcharacters",
|
205
|
+
"Trailing bad characters!@#" => "Trailingbadcharacters",
|
206
|
+
"!@#Leading bad characters" => "Leadingbadcharacters",
|
207
|
+
"Squeeze separators" => "Squeezeseparators",
|
208
|
+
"Test with + sign" => "Testwithsign",
|
209
|
+
# "Test with malformed utf8 \xA9" => "Testwithmalformedutf8"
|
187
210
|
}
|
188
211
|
|
189
212
|
StringToParameterizeWithUnderscore = {
|
@@ -195,41 +218,78 @@ module InflectorTestCases
|
|
195
218
|
"!@#Leading bad characters" => "leading_bad_characters",
|
196
219
|
"Squeeze separators" => "squeeze_separators",
|
197
220
|
"Test with + sign" => "test_with_sign",
|
198
|
-
"Test with malformed utf8 \251" => "test_with_malformed_utf8"
|
221
|
+
# "Test with malformed utf8 \251" => "test_with_malformed_utf8"
|
222
|
+
}
|
223
|
+
|
224
|
+
StringToParameterizePreserveCaseWithUnderscore = {
|
225
|
+
"Donald E. Knuth" => "Donald_E_Knuth",
|
226
|
+
"Random text with *(bad)* characters" => "Random_text_with_bad_characters",
|
227
|
+
"With-some-dashes" => "With-some-dashes",
|
228
|
+
"Allow_Under_Scores" => "Allow_Under_Scores",
|
229
|
+
"Trailing bad characters!@#" => "Trailing_bad_characters",
|
230
|
+
"!@#Leading bad characters" => "Leading_bad_characters",
|
231
|
+
"Squeeze separators" => "Squeeze_separators",
|
232
|
+
"Test with + sign" => "Test_with_sign",
|
233
|
+
# "Test with malformed utf8 \xA9" => "Test_with_malformed_utf8"
|
199
234
|
}
|
200
235
|
|
201
236
|
StringToParameterizedAndNormalized = {
|
202
237
|
"Malmö" => "malmo",
|
203
238
|
"Garçons" => "garcons",
|
204
|
-
"Ops\331" => "opsu",
|
239
|
+
# "Ops\331" => "opsu",
|
205
240
|
"Ærøskøbing" => "aeroskobing",
|
206
241
|
"Aßlar" => "asslar",
|
207
|
-
"Japanese: 日本語"
|
242
|
+
"Japanese: 日本語" => "japanese"
|
208
243
|
}
|
209
244
|
|
210
245
|
UnderscoreToHuman = {
|
211
246
|
"employee_salary" => "Employee salary",
|
212
247
|
"employee_id" => "Employee",
|
213
|
-
"underground" => "Underground"
|
248
|
+
"underground" => "Underground",
|
249
|
+
"_id" => "Id",
|
250
|
+
"_external_id" => "External"
|
251
|
+
}
|
252
|
+
|
253
|
+
UnderscoreToHumanWithKeepIdSuffix = {
|
254
|
+
"this_is_a_string_ending_with_id" => "This is a string ending with id",
|
255
|
+
"employee_id" => "Employee id",
|
256
|
+
"employee_id_something_else" => "Employee id something else",
|
257
|
+
"underground" => "Underground",
|
258
|
+
"_id" => "Id",
|
259
|
+
"_external_id" => "External id"
|
260
|
+
}
|
261
|
+
|
262
|
+
UnderscoreToHumanWithoutCapitalize = {
|
263
|
+
"employee_salary" => "employee salary",
|
264
|
+
"employee_id" => "employee",
|
265
|
+
"underground" => "underground"
|
266
|
+
}
|
267
|
+
|
268
|
+
MixtureToTitleCaseWithKeepIdSuffix = {
|
269
|
+
"this_is_a_string_ending_with_id" => "This Is A String Ending With Id",
|
270
|
+
"EmployeeId" => "Employee Id",
|
271
|
+
"Author Id" => "Author Id"
|
214
272
|
}
|
215
273
|
|
216
274
|
MixtureToTitleCase = {
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
275
|
+
"active_record" => "Active Record",
|
276
|
+
"ActiveRecord" => "Active Record",
|
277
|
+
"action web service" => "Action Web Service",
|
278
|
+
"Action Web Service" => "Action Web Service",
|
279
|
+
"Action web service" => "Action Web Service",
|
280
|
+
"actionwebservice" => "Actionwebservice",
|
281
|
+
"Actionwebservice" => "Actionwebservice",
|
224
282
|
"david's code" => "David's Code",
|
225
283
|
"David's code" => "David's Code",
|
226
284
|
"david's Code" => "David's Code",
|
227
285
|
"sgt. pepper's" => "Sgt. Pepper's",
|
228
286
|
"i've just seen a face" => "I've Just Seen A Face",
|
229
287
|
"maybe you'll be there" => "Maybe You'll Be There",
|
230
|
-
"¿por qué?" =>
|
288
|
+
"¿por qué?" => "¿Por Qué?",
|
231
289
|
"Fred’s" => "Fred’s",
|
232
|
-
"Fred`s" => "Fred`s"
|
290
|
+
"Fred`s" => "Fred`s",
|
291
|
+
# "this was 'fake news'" => "This Was 'Fake News'",
|
292
|
+
# ActiveSupport::SafeBuffer.new("confirmation num") => "Confirmation Num"
|
233
293
|
}
|
234
294
|
|
235
295
|
OrdinalNumbers = {
|
@@ -303,13 +363,13 @@ module InflectorTestCases
|
|
303
363
|
}
|
304
364
|
|
305
365
|
Irregularities = {
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
366
|
+
"person" => "people",
|
367
|
+
"man" => "men",
|
368
|
+
"child" => "children",
|
369
|
+
"sex" => "sexes",
|
370
|
+
"move" => "moves",
|
371
|
+
"cow" => "kine", # Test inflections with different starting letters
|
372
|
+
"zombie" => "zombies",
|
373
|
+
"genus" => "genera"
|
314
374
|
}
|
315
375
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: opal-sprockets
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: rake
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,6 +81,7 @@ extra_rdoc_files: []
|
|
67
81
|
files:
|
68
82
|
- ".gitignore"
|
69
83
|
- ".travis.yml"
|
84
|
+
- CHANGELOG.md
|
70
85
|
- Gemfile
|
71
86
|
- LICENSE.txt
|
72
87
|
- README.md
|
@@ -76,6 +91,7 @@ files:
|
|
76
91
|
- lib/opal/activesupport/version.rb
|
77
92
|
- opal-activesupport.gemspec
|
78
93
|
- opal/active_support.rb
|
94
|
+
- opal/active_support/concern.rb
|
79
95
|
- opal/active_support/core_ext.rb
|
80
96
|
- opal/active_support/core_ext/array.rb
|
81
97
|
- opal/active_support/core_ext/array/extract_options.rb
|
@@ -102,14 +118,18 @@ files:
|
|
102
118
|
- opal/active_support/core_ext/object/json.rb
|
103
119
|
- opal/active_support/core_ext/object/try.rb
|
104
120
|
- opal/active_support/core_ext/string.rb
|
121
|
+
- opal/active_support/core_ext/string/filters.rb
|
105
122
|
- opal/active_support/core_ext/string/inflections.rb
|
106
123
|
- opal/active_support/hash_with_indifferent_access.rb
|
107
124
|
- opal/active_support/inflections.rb
|
108
125
|
- opal/active_support/inflector.rb
|
109
126
|
- opal/active_support/inflector/inflections.rb
|
127
|
+
- opal/active_support/inflector/methods.rb
|
110
128
|
- opal/active_support/time.rb
|
111
129
|
- opal/opal-activesupport.rb
|
112
130
|
- test/abstract_unit.rb
|
131
|
+
- test/concern_test.rb
|
132
|
+
- test/constantize_test_cases.rb
|
113
133
|
- test/core_ext/array_ext_test.rb
|
114
134
|
- test/core_ext/blank_test.rb
|
115
135
|
- test/core_ext/class/attribute_test.rb
|
@@ -120,6 +140,7 @@ files:
|
|
120
140
|
- test/core_ext/object_and_class_ext_test.rb
|
121
141
|
- test/core_ext/string_ext_test.rb
|
122
142
|
- test/empty_bool.rb
|
143
|
+
- test/inflector_test.rb
|
123
144
|
- test/inflector_test_cases.rb
|
124
145
|
- test/minitest/autorun.rb
|
125
146
|
homepage: http://opalrb.org
|
@@ -145,13 +166,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
166
|
- !ruby/object:Gem::Version
|
146
167
|
version: '0'
|
147
168
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.7.4
|
169
|
+
rubygems_version: 3.0.3
|
150
170
|
signing_key:
|
151
171
|
specification_version: 4
|
152
172
|
summary: The port of the glorious ActiveSupport for Opal
|
153
173
|
test_files:
|
154
174
|
- test/abstract_unit.rb
|
175
|
+
- test/concern_test.rb
|
176
|
+
- test/constantize_test_cases.rb
|
155
177
|
- test/core_ext/array_ext_test.rb
|
156
178
|
- test/core_ext/blank_test.rb
|
157
179
|
- test/core_ext/class/attribute_test.rb
|
@@ -162,5 +184,6 @@ test_files:
|
|
162
184
|
- test/core_ext/object_and_class_ext_test.rb
|
163
185
|
- test/core_ext/string_ext_test.rb
|
164
186
|
- test/empty_bool.rb
|
187
|
+
- test/inflector_test.rb
|
165
188
|
- test/inflector_test_cases.rb
|
166
189
|
- test/minitest/autorun.rb
|