hanami-utils 1.3.6 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -3
- data/hanami-utils.gemspec +19 -16
- data/lib/hanami-utils.rb +3 -1
- data/lib/hanami/interactor.rb +47 -21
- data/lib/hanami/logger.rb +6 -6
- data/lib/hanami/logger/colorizer.rb +10 -10
- data/lib/hanami/logger/filter.rb +77 -9
- data/lib/hanami/logger/formatter.rb +4 -4
- data/lib/hanami/utils.rb +8 -6
- data/lib/hanami/utils/basic_object.rb +2 -2
- data/lib/hanami/utils/blank.rb +3 -1
- data/lib/hanami/utils/callbacks.rb +5 -1
- data/lib/hanami/utils/class.rb +7 -7
- data/lib/hanami/utils/class_attribute.rb +4 -2
- data/lib/hanami/utils/deprecation.rb +3 -1
- data/lib/hanami/utils/duplicable.rb +2 -0
- data/lib/hanami/utils/escape.rb +271 -267
- data/lib/hanami/utils/file_list.rb +2 -0
- data/lib/hanami/utils/files.rb +4 -2
- data/lib/hanami/utils/hash.rb +11 -9
- data/lib/hanami/utils/inflector.rb +106 -107
- data/lib/hanami/utils/io.rb +2 -0
- data/lib/hanami/utils/json.rb +4 -2
- data/lib/hanami/utils/kernel.rb +19 -18
- data/lib/hanami/utils/load_paths.rb +4 -2
- data/lib/hanami/utils/path_prefix.rb +6 -4
- data/lib/hanami/utils/shell_color.rb +7 -7
- data/lib/hanami/utils/string.rb +27 -28
- data/lib/hanami/utils/version.rb +3 -1
- metadata +22 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Utils
|
3
5
|
# BasicObject
|
@@ -38,13 +40,11 @@ module Hanami
|
|
38
40
|
#
|
39
41
|
# @see http://ruby-doc.org/core/Object.html#method-i-inspect
|
40
42
|
#
|
41
|
-
# rubocop:disable Style/FormatString
|
42
43
|
# rubocop:disable Style/FormatStringToken
|
43
44
|
def inspect
|
44
45
|
"#<#{self.class}:#{'0x0000%x' % (__id__ << 1)}#{__inspect}>"
|
45
46
|
end
|
46
47
|
# rubocop:enable Style/FormatStringToken
|
47
|
-
# rubocop:enable Style/FormatString
|
48
48
|
|
49
49
|
# @!macro [attach] instance_of?(class)
|
50
50
|
#
|
data/lib/hanami/utils/blank.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Utils
|
3
5
|
# Checks for blank
|
@@ -29,7 +31,7 @@ module Hanami
|
|
29
31
|
#
|
30
32
|
# @since 0.8.0
|
31
33
|
# @api private
|
32
|
-
def self.blank?(object)
|
34
|
+
def self.blank?(object)
|
33
35
|
case object
|
34
36
|
when String, ::String
|
35
37
|
STRING_MATCHER === object # rubocop:disable Style/CaseEquality
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Utils
|
3
5
|
# Before and After callbacks
|
@@ -248,7 +250,9 @@ module Hanami
|
|
248
250
|
end
|
249
251
|
|
250
252
|
# Method callback
|
251
|
-
#
|
253
|
+
#
|
254
|
+
# It wraps a symbol or a string representing a method name that is
|
255
|
+
# implemented by the context within it will be called.
|
252
256
|
#
|
253
257
|
# @since 0.1.0
|
254
258
|
# @api private
|
data/lib/hanami/utils/class.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "hanami/utils/deprecation"
|
2
4
|
|
3
5
|
module Hanami
|
4
6
|
module Utils
|
@@ -110,7 +112,7 @@ module Hanami
|
|
110
112
|
# # with missing constant
|
111
113
|
# Hanami::Utils::Class.load_from_pattern!('Unknown') # => raises NameError
|
112
114
|
def self.load_from_pattern!(pattern, namespace = Object)
|
113
|
-
Deprecation.new(
|
115
|
+
Deprecation.new("Hanami::Utils::Class.load_from_pattern! is deprecated, please use Hanami::Utils::Class.load! instead") # rubocop:disable Layout/LineLength
|
114
116
|
|
115
117
|
tokenize(pattern) do |token|
|
116
118
|
begin
|
@@ -119,13 +121,12 @@ module Hanami
|
|
119
121
|
end
|
120
122
|
end
|
121
123
|
|
122
|
-
full_name = [(namespace == Object ? nil : namespace), pattern].compact.join(
|
124
|
+
full_name = [(namespace == Object ? nil : namespace), pattern].compact.join("::")
|
123
125
|
raise NameError.new("uninitialized constant #{full_name}")
|
124
126
|
end
|
125
127
|
|
126
|
-
# rubocop:disable Metrics/MethodLength
|
127
128
|
def self.tokenize(pattern)
|
128
|
-
if match = TOKENIZE_REGEXP.match(pattern)
|
129
|
+
if match = TOKENIZE_REGEXP.match(pattern)
|
129
130
|
pre = match.pre_match
|
130
131
|
post = match.post_match
|
131
132
|
tokens = match[1].split(TOKENIZE_SEPARATOR)
|
@@ -138,7 +139,6 @@ module Hanami
|
|
138
139
|
|
139
140
|
nil
|
140
141
|
end
|
141
|
-
# rubocop:enable Metrics/MethodLength
|
142
142
|
|
143
143
|
# Regexp for .tokenize
|
144
144
|
#
|
@@ -150,7 +150,7 @@ module Hanami
|
|
150
150
|
#
|
151
151
|
# @since 1.3.0
|
152
152
|
# @api private
|
153
|
-
TOKENIZE_SEPARATOR =
|
153
|
+
TOKENIZE_SEPARATOR = "|"
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
data/lib/hanami/utils/escape.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hanami
|
2
4
|
module Utils
|
3
5
|
# HTML escape utilities
|
@@ -30,14 +32,14 @@ module Hanami
|
|
30
32
|
#
|
31
33
|
# @since 0.4.0
|
32
34
|
# @api private
|
33
|
-
REPLACEMENT_HEX =
|
35
|
+
REPLACEMENT_HEX = "fffd"
|
34
36
|
|
35
37
|
# Low hex codes lookup table
|
36
38
|
#
|
37
39
|
# @since 0.4.0
|
38
40
|
# @api private
|
39
41
|
HEX_CODES = (0..255).each_with_object({}) do |c, codes|
|
40
|
-
if (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A)
|
42
|
+
if (c >= 0x30 && c <= 0x39) || (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A)
|
41
43
|
codes[c] = nil
|
42
44
|
else
|
43
45
|
codes[c] = c.to_s(HEX_BASE)
|
@@ -53,8 +55,8 @@ module Hanami
|
|
53
55
|
#
|
54
56
|
# @see https://gist.github.com/jodosha/ac5dd54416de744b9600
|
55
57
|
NON_PRINTABLE_CHARS = {
|
56
|
-
0x0
|
57
|
-
0x5
|
58
|
+
0x0 => true, 0x1 => true, 0x2 => true, 0x3 => true, 0x4 => true,
|
59
|
+
0x5 => true, 0x6 => true, 0x7 => true, 0x8 => true, 0x11 => true,
|
58
60
|
0x12 => true, 0x14 => true, 0x15 => true, 0x16 => true, 0x17 => true,
|
59
61
|
0x18 => true, 0x19 => true, 0x1a => true, 0x1b => true, 0x1c => true,
|
60
62
|
0x1d => true, 0x1e => true, 0x1f => true, 0x7f => true, 0x80 => true,
|
@@ -74,12 +76,12 @@ module Hanami
|
|
74
76
|
#
|
75
77
|
# @see Hanami::Utils::Escape.html
|
76
78
|
HTML_CHARS = {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
'"' =>
|
81
|
-
"'" =>
|
82
|
-
|
79
|
+
"&" => "&",
|
80
|
+
"<" => "<",
|
81
|
+
">" => ">",
|
82
|
+
'"' => """,
|
83
|
+
"'" => "'",
|
84
|
+
"/" => "/"
|
83
85
|
}.freeze
|
84
86
|
|
85
87
|
# Lookup table for safe chars for HTML attributes.
|
@@ -92,7 +94,7 @@ module Hanami
|
|
92
94
|
# @see Lookup::Utils::Escape.html_attribute
|
93
95
|
# @see https://gist.github.com/jodosha/ac5dd54416de744b9600
|
94
96
|
HTML_ATTRIBUTE_SAFE_CHARS = {
|
95
|
-
|
97
|
+
"," => true, "." => true, "-" => true, "_" => true
|
96
98
|
}.freeze
|
97
99
|
|
98
100
|
# Lookup table for HTML attribute escape
|
@@ -102,258 +104,258 @@ module Hanami
|
|
102
104
|
#
|
103
105
|
# @see Hanami::Utils::Escape.html_attribute
|
104
106
|
HTML_ENTITIES = {
|
105
|
-
34
|
106
|
-
38
|
107
|
-
60
|
108
|
-
62
|
109
|
-
160
|
110
|
-
161
|
111
|
-
162
|
112
|
-
163
|
113
|
-
164
|
114
|
-
165
|
115
|
-
166
|
116
|
-
167
|
117
|
-
168
|
118
|
-
169
|
119
|
-
170
|
120
|
-
171
|
121
|
-
172
|
122
|
-
173
|
123
|
-
174
|
124
|
-
175
|
125
|
-
176
|
126
|
-
177
|
127
|
-
178
|
128
|
-
179
|
129
|
-
180
|
130
|
-
181
|
131
|
-
182
|
132
|
-
183
|
133
|
-
184
|
134
|
-
185
|
135
|
-
186
|
136
|
-
187
|
137
|
-
188
|
138
|
-
189
|
139
|
-
190
|
140
|
-
191
|
141
|
-
192
|
142
|
-
193
|
143
|
-
194
|
144
|
-
195
|
145
|
-
196
|
146
|
-
197
|
147
|
-
198
|
148
|
-
199
|
149
|
-
200
|
150
|
-
201
|
151
|
-
202
|
152
|
-
203
|
153
|
-
204
|
154
|
-
205
|
155
|
-
206
|
156
|
-
207
|
157
|
-
208
|
158
|
-
209
|
159
|
-
210
|
160
|
-
211
|
161
|
-
212
|
162
|
-
213
|
163
|
-
214
|
164
|
-
215
|
165
|
-
216
|
166
|
-
217
|
167
|
-
218
|
168
|
-
219
|
169
|
-
220
|
170
|
-
221
|
171
|
-
222
|
172
|
-
223
|
173
|
-
224
|
174
|
-
225
|
175
|
-
226
|
176
|
-
227
|
177
|
-
228
|
178
|
-
229
|
179
|
-
230
|
180
|
-
231
|
181
|
-
232
|
182
|
-
233
|
183
|
-
234
|
184
|
-
235
|
185
|
-
236
|
186
|
-
237
|
187
|
-
238
|
188
|
-
239
|
189
|
-
240
|
190
|
-
241
|
191
|
-
242
|
192
|
-
243
|
193
|
-
244
|
194
|
-
245
|
195
|
-
246
|
196
|
-
247
|
197
|
-
248
|
198
|
-
249
|
199
|
-
250
|
200
|
-
251
|
201
|
-
252
|
202
|
-
253
|
203
|
-
254
|
204
|
-
255
|
205
|
-
338
|
206
|
-
339
|
207
|
-
352
|
208
|
-
353
|
209
|
-
376
|
210
|
-
402
|
211
|
-
710
|
212
|
-
732
|
213
|
-
913
|
214
|
-
914
|
215
|
-
915
|
216
|
-
916
|
217
|
-
917
|
218
|
-
918
|
219
|
-
919
|
220
|
-
920
|
221
|
-
921
|
222
|
-
922
|
223
|
-
923
|
224
|
-
924
|
225
|
-
925
|
226
|
-
926
|
227
|
-
927
|
228
|
-
928
|
229
|
-
929
|
230
|
-
931
|
231
|
-
932
|
232
|
-
933
|
233
|
-
934
|
234
|
-
935
|
235
|
-
936
|
236
|
-
937
|
237
|
-
945
|
238
|
-
946
|
239
|
-
947
|
240
|
-
948
|
241
|
-
949
|
242
|
-
950
|
243
|
-
951
|
244
|
-
952
|
245
|
-
953
|
246
|
-
954
|
247
|
-
955
|
248
|
-
956
|
249
|
-
957
|
250
|
-
958
|
251
|
-
959
|
252
|
-
960
|
253
|
-
961
|
254
|
-
962
|
255
|
-
963
|
256
|
-
964
|
257
|
-
965
|
258
|
-
966
|
259
|
-
967
|
260
|
-
968
|
261
|
-
969
|
262
|
-
977
|
263
|
-
978
|
264
|
-
982
|
265
|
-
8194 =>
|
266
|
-
8195 =>
|
267
|
-
8201 =>
|
268
|
-
8204 =>
|
269
|
-
8205 =>
|
270
|
-
8206 =>
|
271
|
-
8207 =>
|
272
|
-
8211 =>
|
273
|
-
8212 =>
|
274
|
-
8216 =>
|
275
|
-
8217 =>
|
276
|
-
8218 =>
|
277
|
-
8220 =>
|
278
|
-
8221 =>
|
279
|
-
8222 =>
|
280
|
-
8224 =>
|
281
|
-
8225 =>
|
282
|
-
8226 =>
|
283
|
-
8230 =>
|
284
|
-
8240 =>
|
285
|
-
8242 =>
|
286
|
-
8243 =>
|
287
|
-
8249 =>
|
288
|
-
8250 =>
|
289
|
-
8254 =>
|
290
|
-
8260 =>
|
291
|
-
8364 =>
|
292
|
-
8465 =>
|
293
|
-
8472 =>
|
294
|
-
8476 =>
|
295
|
-
8482 =>
|
296
|
-
8501 =>
|
297
|
-
8592 =>
|
298
|
-
8593 =>
|
299
|
-
8594 =>
|
300
|
-
8595 =>
|
301
|
-
8596 =>
|
302
|
-
8629 =>
|
303
|
-
8656 =>
|
304
|
-
8657 =>
|
305
|
-
8658 =>
|
306
|
-
8659 =>
|
307
|
-
8660 =>
|
308
|
-
8704 =>
|
309
|
-
8706 =>
|
310
|
-
8707 =>
|
311
|
-
8709 =>
|
312
|
-
8711 =>
|
313
|
-
8712 =>
|
314
|
-
8713 =>
|
315
|
-
8715 =>
|
316
|
-
8719 =>
|
317
|
-
8721 =>
|
318
|
-
8722 =>
|
319
|
-
8727 =>
|
320
|
-
8730 =>
|
321
|
-
8733 =>
|
322
|
-
8734 =>
|
323
|
-
8736 =>
|
324
|
-
8743 =>
|
325
|
-
8744 =>
|
326
|
-
8745 =>
|
327
|
-
8746 =>
|
328
|
-
8747 =>
|
329
|
-
8756 =>
|
330
|
-
8764 =>
|
331
|
-
8773 =>
|
332
|
-
8776 =>
|
333
|
-
8800 =>
|
334
|
-
8801 =>
|
335
|
-
8804 =>
|
336
|
-
8805 =>
|
337
|
-
8834 =>
|
338
|
-
8835 =>
|
339
|
-
8836 =>
|
340
|
-
8838 =>
|
341
|
-
8839 =>
|
342
|
-
8853 =>
|
343
|
-
8855 =>
|
344
|
-
8869 =>
|
345
|
-
8901 =>
|
346
|
-
8968 =>
|
347
|
-
8969 =>
|
348
|
-
8970 =>
|
349
|
-
8971 =>
|
350
|
-
9001 =>
|
351
|
-
9002 =>
|
352
|
-
9674 =>
|
353
|
-
9824 =>
|
354
|
-
9827 =>
|
355
|
-
9829 =>
|
356
|
-
9830 =>
|
107
|
+
34 => "quot", # quotation mark
|
108
|
+
38 => "amp", # ampersand
|
109
|
+
60 => "lt", # less-than sign
|
110
|
+
62 => "gt", # greater-than sign
|
111
|
+
160 => "nbsp", # no-break space
|
112
|
+
161 => "iexcl", # inverted exclamation mark
|
113
|
+
162 => "cent", # cent sign
|
114
|
+
163 => "pound", # pound sign
|
115
|
+
164 => "curren", # currency sign
|
116
|
+
165 => "yen", # yen sign
|
117
|
+
166 => "brvbar", # broken bar
|
118
|
+
167 => "sect", # section sign
|
119
|
+
168 => "uml", # diaeresis
|
120
|
+
169 => "copy", # copyright sign
|
121
|
+
170 => "ordf", # feminine ordinal indicator
|
122
|
+
171 => "laquo", # left-pointing double angle quotation mark
|
123
|
+
172 => "not", # not sign
|
124
|
+
173 => "shy", # soft hyphen
|
125
|
+
174 => "reg", # registered sign
|
126
|
+
175 => "macr", # macron
|
127
|
+
176 => "deg", # degree sign
|
128
|
+
177 => "plusmn", # plus-minus sign
|
129
|
+
178 => "sup2", # superscript two
|
130
|
+
179 => "sup3", # superscript three
|
131
|
+
180 => "acute", # acute accent
|
132
|
+
181 => "micro", # micro sign
|
133
|
+
182 => "para", # pilcrow sign
|
134
|
+
183 => "middot", # middle dot
|
135
|
+
184 => "cedil", # cedilla
|
136
|
+
185 => "sup1", # superscript one
|
137
|
+
186 => "ordm", # masculine ordinal indicator
|
138
|
+
187 => "raquo", # right-pointing double angle quotation mark
|
139
|
+
188 => "frac14", # vulgar fraction one quarter
|
140
|
+
189 => "frac12", # vulgar fraction one half
|
141
|
+
190 => "frac34", # vulgar fraction three quarters
|
142
|
+
191 => "iquest", # inverted question mark
|
143
|
+
192 => "Agrave", # Latin capital letter a with grave
|
144
|
+
193 => "Aacute", # Latin capital letter a with acute
|
145
|
+
194 => "Acirc", # Latin capital letter a with circumflex
|
146
|
+
195 => "Atilde", # Latin capital letter a with tilde
|
147
|
+
196 => "Auml", # Latin capital letter a with diaeresis
|
148
|
+
197 => "Aring", # Latin capital letter a with ring above
|
149
|
+
198 => "AElig", # Latin capital letter ae
|
150
|
+
199 => "Ccedil", # Latin capital letter c with cedilla
|
151
|
+
200 => "Egrave", # Latin capital letter e with grave
|
152
|
+
201 => "Eacute", # Latin capital letter e with acute
|
153
|
+
202 => "Ecirc", # Latin capital letter e with circumflex
|
154
|
+
203 => "Euml", # Latin capital letter e with diaeresis
|
155
|
+
204 => "Igrave", # Latin capital letter i with grave
|
156
|
+
205 => "Iacute", # Latin capital letter i with acute
|
157
|
+
206 => "Icirc", # Latin capital letter i with circumflex
|
158
|
+
207 => "Iuml", # Latin capital letter i with diaeresis
|
159
|
+
208 => "ETH", # Latin capital letter eth
|
160
|
+
209 => "Ntilde", # Latin capital letter n with tilde
|
161
|
+
210 => "Ograve", # Latin capital letter o with grave
|
162
|
+
211 => "Oacute", # Latin capital letter o with acute
|
163
|
+
212 => "Ocirc", # Latin capital letter o with circumflex
|
164
|
+
213 => "Otilde", # Latin capital letter o with tilde
|
165
|
+
214 => "Ouml", # Latin capital letter o with diaeresis
|
166
|
+
215 => "times", # multiplication sign
|
167
|
+
216 => "Oslash", # Latin capital letter o with stroke
|
168
|
+
217 => "Ugrave", # Latin capital letter u with grave
|
169
|
+
218 => "Uacute", # Latin capital letter u with acute
|
170
|
+
219 => "Ucirc", # Latin capital letter u with circumflex
|
171
|
+
220 => "Uuml", # Latin capital letter u with diaeresis
|
172
|
+
221 => "Yacute", # Latin capital letter y with acute
|
173
|
+
222 => "THORN", # Latin capital letter thorn
|
174
|
+
223 => "szlig", # Latin small letter sharp sXCOMMAX German Eszett
|
175
|
+
224 => "agrave", # Latin small letter a with grave
|
176
|
+
225 => "aacute", # Latin small letter a with acute
|
177
|
+
226 => "acirc", # Latin small letter a with circumflex
|
178
|
+
227 => "atilde", # Latin small letter a with tilde
|
179
|
+
228 => "auml", # Latin small letter a with diaeresis
|
180
|
+
229 => "aring", # Latin small letter a with ring above
|
181
|
+
230 => "aelig", # Latin lowercase ligature ae
|
182
|
+
231 => "ccedil", # Latin small letter c with cedilla
|
183
|
+
232 => "egrave", # Latin small letter e with grave
|
184
|
+
233 => "eacute", # Latin small letter e with acute
|
185
|
+
234 => "ecirc", # Latin small letter e with circumflex
|
186
|
+
235 => "euml", # Latin small letter e with diaeresis
|
187
|
+
236 => "igrave", # Latin small letter i with grave
|
188
|
+
237 => "iacute", # Latin small letter i with acute
|
189
|
+
238 => "icirc", # Latin small letter i with circumflex
|
190
|
+
239 => "iuml", # Latin small letter i with diaeresis
|
191
|
+
240 => "eth", # Latin small letter eth
|
192
|
+
241 => "ntilde", # Latin small letter n with tilde
|
193
|
+
242 => "ograve", # Latin small letter o with grave
|
194
|
+
243 => "oacute", # Latin small letter o with acute
|
195
|
+
244 => "ocirc", # Latin small letter o with circumflex
|
196
|
+
245 => "otilde", # Latin small letter o with tilde
|
197
|
+
246 => "ouml", # Latin small letter o with diaeresis
|
198
|
+
247 => "divide", # division sign
|
199
|
+
248 => "oslash", # Latin small letter o with stroke
|
200
|
+
249 => "ugrave", # Latin small letter u with grave
|
201
|
+
250 => "uacute", # Latin small letter u with acute
|
202
|
+
251 => "ucirc", # Latin small letter u with circumflex
|
203
|
+
252 => "uuml", # Latin small letter u with diaeresis
|
204
|
+
253 => "yacute", # Latin small letter y with acute
|
205
|
+
254 => "thorn", # Latin small letter thorn
|
206
|
+
255 => "yuml", # Latin small letter y with diaeresis
|
207
|
+
338 => "OElig", # Latin capital ligature oe
|
208
|
+
339 => "oelig", # Latin small ligature oe
|
209
|
+
352 => "Scaron", # Latin capital letter s with caron
|
210
|
+
353 => "scaron", # Latin small letter s with caron
|
211
|
+
376 => "Yuml", # Latin capital letter y with diaeresis
|
212
|
+
402 => "fnof", # Latin small letter f with hook
|
213
|
+
710 => "circ", # modifier letter circumflex accent
|
214
|
+
732 => "tilde", # small tilde
|
215
|
+
913 => "Alpha", # Greek capital letter alpha
|
216
|
+
914 => "Beta", # Greek capital letter beta
|
217
|
+
915 => "Gamma", # Greek capital letter gamma
|
218
|
+
916 => "Delta", # Greek capital letter delta
|
219
|
+
917 => "Epsilon", # Greek capital letter epsilon
|
220
|
+
918 => "Zeta", # Greek capital letter zeta
|
221
|
+
919 => "Eta", # Greek capital letter eta
|
222
|
+
920 => "Theta", # Greek capital letter theta
|
223
|
+
921 => "Iota", # Greek capital letter iota
|
224
|
+
922 => "Kappa", # Greek capital letter kappa
|
225
|
+
923 => "Lambda", # Greek capital letter lambda
|
226
|
+
924 => "Mu", # Greek capital letter mu
|
227
|
+
925 => "Nu", # Greek capital letter nu
|
228
|
+
926 => "Xi", # Greek capital letter xi
|
229
|
+
927 => "Omicron", # Greek capital letter omicron
|
230
|
+
928 => "Pi", # Greek capital letter pi
|
231
|
+
929 => "Rho", # Greek capital letter rho
|
232
|
+
931 => "Sigma", # Greek capital letter sigma
|
233
|
+
932 => "Tau", # Greek capital letter tau
|
234
|
+
933 => "Upsilon", # Greek capital letter upsilon
|
235
|
+
934 => "Phi", # Greek capital letter phi
|
236
|
+
935 => "Chi", # Greek capital letter chi
|
237
|
+
936 => "Psi", # Greek capital letter psi
|
238
|
+
937 => "Omega", # Greek capital letter omega
|
239
|
+
945 => "alpha", # Greek small letter alpha
|
240
|
+
946 => "beta", # Greek small letter beta
|
241
|
+
947 => "gamma", # Greek small letter gamma
|
242
|
+
948 => "delta", # Greek small letter delta
|
243
|
+
949 => "epsilon", # Greek small letter epsilon
|
244
|
+
950 => "zeta", # Greek small letter zeta
|
245
|
+
951 => "eta", # Greek small letter eta
|
246
|
+
952 => "theta", # Greek small letter theta
|
247
|
+
953 => "iota", # Greek small letter iota
|
248
|
+
954 => "kappa", # Greek small letter kappa
|
249
|
+
955 => "lambda", # Greek small letter lambda
|
250
|
+
956 => "mu", # Greek small letter mu
|
251
|
+
957 => "nu", # Greek small letter nu
|
252
|
+
958 => "xi", # Greek small letter xi
|
253
|
+
959 => "omicron", # Greek small letter omicron
|
254
|
+
960 => "pi", # Greek small letter pi
|
255
|
+
961 => "rho", # Greek small letter rho
|
256
|
+
962 => "sigmaf", # Greek small letter final sigma
|
257
|
+
963 => "sigma", # Greek small letter sigma
|
258
|
+
964 => "tau", # Greek small letter tau
|
259
|
+
965 => "upsilon", # Greek small letter upsilon
|
260
|
+
966 => "phi", # Greek small letter phi
|
261
|
+
967 => "chi", # Greek small letter chi
|
262
|
+
968 => "psi", # Greek small letter psi
|
263
|
+
969 => "omega", # Greek small letter omega
|
264
|
+
977 => "thetasym", # Greek theta symbol
|
265
|
+
978 => "upsih", # Greek upsilon with hook symbol
|
266
|
+
982 => "piv", # Greek pi symbol
|
267
|
+
8194 => "ensp", # en space
|
268
|
+
8195 => "emsp", # em space
|
269
|
+
8201 => "thinsp", # thin space
|
270
|
+
8204 => "zwnj", # zero width non-joiner
|
271
|
+
8205 => "zwj", # zero width joiner
|
272
|
+
8206 => "lrm", # left-to-right mark
|
273
|
+
8207 => "rlm", # right-to-left mark
|
274
|
+
8211 => "ndash", # en dash
|
275
|
+
8212 => "mdash", # em dash
|
276
|
+
8216 => "lsquo", # left single quotation mark
|
277
|
+
8217 => "rsquo", # right single quotation mark
|
278
|
+
8218 => "sbquo", # single low-9 quotation mark
|
279
|
+
8220 => "ldquo", # left double quotation mark
|
280
|
+
8221 => "rdquo", # right double quotation mark
|
281
|
+
8222 => "bdquo", # double low-9 quotation mark
|
282
|
+
8224 => "dagger", # dagger
|
283
|
+
8225 => "Dagger", # double dagger
|
284
|
+
8226 => "bull", # bullet
|
285
|
+
8230 => "hellip", # horizontal ellipsis
|
286
|
+
8240 => "permil", # per mille sign
|
287
|
+
8242 => "prime", # prime
|
288
|
+
8243 => "Prime", # double prime
|
289
|
+
8249 => "lsaquo", # single left-pointing angle quotation mark
|
290
|
+
8250 => "rsaquo", # single right-pointing angle quotation mark
|
291
|
+
8254 => "oline", # overline
|
292
|
+
8260 => "frasl", # fraction slash
|
293
|
+
8364 => "euro", # euro sign
|
294
|
+
8465 => "image", # black-letter capital i
|
295
|
+
8472 => "weierp", # script capital pXCOMMAX Weierstrass p
|
296
|
+
8476 => "real", # black-letter capital r
|
297
|
+
8482 => "trade", # trademark sign
|
298
|
+
8501 => "alefsym", # alef symbol
|
299
|
+
8592 => "larr", # leftwards arrow
|
300
|
+
8593 => "uarr", # upwards arrow
|
301
|
+
8594 => "rarr", # rightwards arrow
|
302
|
+
8595 => "darr", # downwards arrow
|
303
|
+
8596 => "harr", # left right arrow
|
304
|
+
8629 => "crarr", # downwards arrow with corner leftwards
|
305
|
+
8656 => "lArr", # leftwards double arrow
|
306
|
+
8657 => "uArr", # upwards double arrow
|
307
|
+
8658 => "rArr", # rightwards double arrow
|
308
|
+
8659 => "dArr", # downwards double arrow
|
309
|
+
8660 => "hArr", # left right double arrow
|
310
|
+
8704 => "forall", # for all
|
311
|
+
8706 => "part", # partial differential
|
312
|
+
8707 => "exist", # there exists
|
313
|
+
8709 => "empty", # empty set
|
314
|
+
8711 => "nabla", # nabla
|
315
|
+
8712 => "isin", # element of
|
316
|
+
8713 => "notin", # not an element of
|
317
|
+
8715 => "ni", # contains as member
|
318
|
+
8719 => "prod", # n-ary product
|
319
|
+
8721 => "sum", # n-ary summation
|
320
|
+
8722 => "minus", # minus sign
|
321
|
+
8727 => "lowast", # asterisk operator
|
322
|
+
8730 => "radic", # square root
|
323
|
+
8733 => "prop", # proportional to
|
324
|
+
8734 => "infin", # infinity
|
325
|
+
8736 => "ang", # angle
|
326
|
+
8743 => "and", # logical and
|
327
|
+
8744 => "or", # logical or
|
328
|
+
8745 => "cap", # intersection
|
329
|
+
8746 => "cup", # union
|
330
|
+
8747 => "int", # integral
|
331
|
+
8756 => "there4", # therefore
|
332
|
+
8764 => "sim", # tilde operator
|
333
|
+
8773 => "cong", # congruent to
|
334
|
+
8776 => "asymp", # almost equal to
|
335
|
+
8800 => "ne", # not equal to
|
336
|
+
8801 => "equiv", # identical toXCOMMAX equivalent to
|
337
|
+
8804 => "le", # less-than or equal to
|
338
|
+
8805 => "ge", # greater-than or equal to
|
339
|
+
8834 => "sub", # subset of
|
340
|
+
8835 => "sup", # superset of
|
341
|
+
8836 => "nsub", # not a subset of
|
342
|
+
8838 => "sube", # subset of or equal to
|
343
|
+
8839 => "supe", # superset of or equal to
|
344
|
+
8853 => "oplus", # circled plus
|
345
|
+
8855 => "otimes", # circled times
|
346
|
+
8869 => "perp", # up tack
|
347
|
+
8901 => "sdot", # dot operator
|
348
|
+
8968 => "lceil", # left ceiling
|
349
|
+
8969 => "rceil", # right ceiling
|
350
|
+
8970 => "lfloor", # left floor
|
351
|
+
8971 => "rfloor", # right floor
|
352
|
+
9001 => "lang", # left-pointing angle bracket
|
353
|
+
9002 => "rang", # right-pointing angle bracket
|
354
|
+
9674 => "loz", # lozenge
|
355
|
+
9824 => "spades", # black spade suit
|
356
|
+
9827 => "clubs", # black club suit
|
357
|
+
9829 => "hearts", # black heart suit
|
358
|
+
9830 => "diams" # black diamond suit
|
357
359
|
}.freeze
|
358
360
|
|
359
361
|
# Allowed URL schemes
|
@@ -368,8 +370,10 @@ module Hanami
|
|
368
370
|
#
|
369
371
|
# It's marked with this special class for two reasons:
|
370
372
|
#
|
371
|
-
# * Don't double escape the same string (this is for `Hanami::Helpers`
|
372
|
-
#
|
373
|
+
# * Don't double escape the same string (this is for `Hanami::Helpers`
|
374
|
+
# compatibility)
|
375
|
+
# * Leave open the possibility to developers to mark a string as safe
|
376
|
+
# with an higher API (eg. `#raw` in `Hanami::View` or `Hanami::Helpers`)
|
373
377
|
#
|
374
378
|
# @since 0.4.0
|
375
379
|
# @api private
|
@@ -530,7 +534,7 @@ module Hanami
|
|
530
534
|
# @since 0.4.0
|
531
535
|
# @api private
|
532
536
|
def encode(input)
|
533
|
-
return
|
537
|
+
return "" if input.nil?
|
534
538
|
|
535
539
|
input.to_s.encode(Encoding::UTF_8)
|
536
540
|
rescue Encoding::UndefinedConversionError
|
@@ -555,7 +559,7 @@ module Hanami
|
|
555
559
|
|
556
560
|
hex = REPLACEMENT_HEX if NON_PRINTABLE_CHARS[code]
|
557
561
|
|
558
|
-
if entity = HTML_ENTITIES[code]
|
562
|
+
if entity = HTML_ENTITIES[code]
|
559
563
|
"&#{entity};"
|
560
564
|
else
|
561
565
|
"&#x#{hex};"
|