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.
@@ -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
  #
@@ -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) # rubocop:disable Metrics/MethodLength
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
- # It wraps a symbol or a string representing a method name that is implemented by the context within it will be called.
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
@@ -1,4 +1,6 @@
1
- require 'hanami/utils/deprecation'
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('Hanami::Utils::Class.load_from_pattern! is deprecated, please use Hanami::Utils::Class.load! instead')
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) # rubocop:disable Lint/AssignmentInCondition
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 = '|'.freeze
153
+ TOKENIZE_SEPARATOR = "|"
154
154
  end
155
155
  end
156
156
  end
@@ -1,5 +1,7 @@
1
- require 'set'
2
- require 'hanami/utils/duplicable'
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+ require "hanami/utils/duplicable"
3
5
 
4
6
  module Hanami
5
7
  module Utils
@@ -1,4 +1,6 @@
1
- require 'hanami/utils'
1
+ # frozen_string_literal: true
2
+
3
+ require "hanami/utils"
2
4
 
3
5
  module Hanami
4
6
  module Utils
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  module Utils
3
5
  # Safe dup logic
@@ -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 = 'fffd'.freeze
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) # rubocop:disable Style/ConditionalAssignment
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 => true, 0x1 => true, 0x2 => true, 0x3 => true, 0x4 => true,
57
- 0x5 => true, 0x6 => true, 0x7 => true, 0x8 => true, 0x11 => true,
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
- '&' => '&amp;',
78
- '<' => '&lt;',
79
- '>' => '&gt;',
80
- '"' => '&quot;',
81
- "'" => '&apos;',
82
- '/' => '&#x2F;'
79
+ "&" => "&amp;",
80
+ "<" => "&lt;",
81
+ ">" => "&gt;",
82
+ '"' => "&quot;",
83
+ "'" => "&apos;",
84
+ "/" => "&#x2F;"
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
- ',' => true, '.' => true, '-' => true, '_' => true
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 => 'quot', # quotation mark
106
- 38 => 'amp', # ampersand
107
- 60 => 'lt', # less-than sign
108
- 62 => 'gt', # greater-than sign
109
- 160 => 'nbsp', # no-break space
110
- 161 => 'iexcl', # inverted exclamation mark
111
- 162 => 'cent', # cent sign
112
- 163 => 'pound', # pound sign
113
- 164 => 'curren', # currency sign
114
- 165 => 'yen', # yen sign
115
- 166 => 'brvbar', # broken bar
116
- 167 => 'sect', # section sign
117
- 168 => 'uml', # diaeresis
118
- 169 => 'copy', # copyright sign
119
- 170 => 'ordf', # feminine ordinal indicator
120
- 171 => 'laquo', # left-pointing double angle quotation mark
121
- 172 => 'not', # not sign
122
- 173 => 'shy', # soft hyphen
123
- 174 => 'reg', # registered sign
124
- 175 => 'macr', # macron
125
- 176 => 'deg', # degree sign
126
- 177 => 'plusmn', # plus-minus sign
127
- 178 => 'sup2', # superscript two
128
- 179 => 'sup3', # superscript three
129
- 180 => 'acute', # acute accent
130
- 181 => 'micro', # micro sign
131
- 182 => 'para', # pilcrow sign
132
- 183 => 'middot', # middle dot
133
- 184 => 'cedil', # cedilla
134
- 185 => 'sup1', # superscript one
135
- 186 => 'ordm', # masculine ordinal indicator
136
- 187 => 'raquo', # right-pointing double angle quotation mark
137
- 188 => 'frac14', # vulgar fraction one quarter
138
- 189 => 'frac12', # vulgar fraction one half
139
- 190 => 'frac34', # vulgar fraction three quarters
140
- 191 => 'iquest', # inverted question mark
141
- 192 => 'Agrave', # Latin capital letter a with grave
142
- 193 => 'Aacute', # Latin capital letter a with acute
143
- 194 => 'Acirc', # Latin capital letter a with circumflex
144
- 195 => 'Atilde', # Latin capital letter a with tilde
145
- 196 => 'Auml', # Latin capital letter a with diaeresis
146
- 197 => 'Aring', # Latin capital letter a with ring above
147
- 198 => 'AElig', # Latin capital letter ae
148
- 199 => 'Ccedil', # Latin capital letter c with cedilla
149
- 200 => 'Egrave', # Latin capital letter e with grave
150
- 201 => 'Eacute', # Latin capital letter e with acute
151
- 202 => 'Ecirc', # Latin capital letter e with circumflex
152
- 203 => 'Euml', # Latin capital letter e with diaeresis
153
- 204 => 'Igrave', # Latin capital letter i with grave
154
- 205 => 'Iacute', # Latin capital letter i with acute
155
- 206 => 'Icirc', # Latin capital letter i with circumflex
156
- 207 => 'Iuml', # Latin capital letter i with diaeresis
157
- 208 => 'ETH', # Latin capital letter eth
158
- 209 => 'Ntilde', # Latin capital letter n with tilde
159
- 210 => 'Ograve', # Latin capital letter o with grave
160
- 211 => 'Oacute', # Latin capital letter o with acute
161
- 212 => 'Ocirc', # Latin capital letter o with circumflex
162
- 213 => 'Otilde', # Latin capital letter o with tilde
163
- 214 => 'Ouml', # Latin capital letter o with diaeresis
164
- 215 => 'times', # multiplication sign
165
- 216 => 'Oslash', # Latin capital letter o with stroke
166
- 217 => 'Ugrave', # Latin capital letter u with grave
167
- 218 => 'Uacute', # Latin capital letter u with acute
168
- 219 => 'Ucirc', # Latin capital letter u with circumflex
169
- 220 => 'Uuml', # Latin capital letter u with diaeresis
170
- 221 => 'Yacute', # Latin capital letter y with acute
171
- 222 => 'THORN', # Latin capital letter thorn
172
- 223 => 'szlig', # Latin small letter sharp sXCOMMAX German Eszett
173
- 224 => 'agrave', # Latin small letter a with grave
174
- 225 => 'aacute', # Latin small letter a with acute
175
- 226 => 'acirc', # Latin small letter a with circumflex
176
- 227 => 'atilde', # Latin small letter a with tilde
177
- 228 => 'auml', # Latin small letter a with diaeresis
178
- 229 => 'aring', # Latin small letter a with ring above
179
- 230 => 'aelig', # Latin lowercase ligature ae
180
- 231 => 'ccedil', # Latin small letter c with cedilla
181
- 232 => 'egrave', # Latin small letter e with grave
182
- 233 => 'eacute', # Latin small letter e with acute
183
- 234 => 'ecirc', # Latin small letter e with circumflex
184
- 235 => 'euml', # Latin small letter e with diaeresis
185
- 236 => 'igrave', # Latin small letter i with grave
186
- 237 => 'iacute', # Latin small letter i with acute
187
- 238 => 'icirc', # Latin small letter i with circumflex
188
- 239 => 'iuml', # Latin small letter i with diaeresis
189
- 240 => 'eth', # Latin small letter eth
190
- 241 => 'ntilde', # Latin small letter n with tilde
191
- 242 => 'ograve', # Latin small letter o with grave
192
- 243 => 'oacute', # Latin small letter o with acute
193
- 244 => 'ocirc', # Latin small letter o with circumflex
194
- 245 => 'otilde', # Latin small letter o with tilde
195
- 246 => 'ouml', # Latin small letter o with diaeresis
196
- 247 => 'divide', # division sign
197
- 248 => 'oslash', # Latin small letter o with stroke
198
- 249 => 'ugrave', # Latin small letter u with grave
199
- 250 => 'uacute', # Latin small letter u with acute
200
- 251 => 'ucirc', # Latin small letter u with circumflex
201
- 252 => 'uuml', # Latin small letter u with diaeresis
202
- 253 => 'yacute', # Latin small letter y with acute
203
- 254 => 'thorn', # Latin small letter thorn
204
- 255 => 'yuml', # Latin small letter y with diaeresis
205
- 338 => 'OElig', # Latin capital ligature oe
206
- 339 => 'oelig', # Latin small ligature oe
207
- 352 => 'Scaron', # Latin capital letter s with caron
208
- 353 => 'scaron', # Latin small letter s with caron
209
- 376 => 'Yuml', # Latin capital letter y with diaeresis
210
- 402 => 'fnof', # Latin small letter f with hook
211
- 710 => 'circ', # modifier letter circumflex accent
212
- 732 => 'tilde', # small tilde
213
- 913 => 'Alpha', # Greek capital letter alpha
214
- 914 => 'Beta', # Greek capital letter beta
215
- 915 => 'Gamma', # Greek capital letter gamma
216
- 916 => 'Delta', # Greek capital letter delta
217
- 917 => 'Epsilon', # Greek capital letter epsilon
218
- 918 => 'Zeta', # Greek capital letter zeta
219
- 919 => 'Eta', # Greek capital letter eta
220
- 920 => 'Theta', # Greek capital letter theta
221
- 921 => 'Iota', # Greek capital letter iota
222
- 922 => 'Kappa', # Greek capital letter kappa
223
- 923 => 'Lambda', # Greek capital letter lambda
224
- 924 => 'Mu', # Greek capital letter mu
225
- 925 => 'Nu', # Greek capital letter nu
226
- 926 => 'Xi', # Greek capital letter xi
227
- 927 => 'Omicron', # Greek capital letter omicron
228
- 928 => 'Pi', # Greek capital letter pi
229
- 929 => 'Rho', # Greek capital letter rho
230
- 931 => 'Sigma', # Greek capital letter sigma
231
- 932 => 'Tau', # Greek capital letter tau
232
- 933 => 'Upsilon', # Greek capital letter upsilon
233
- 934 => 'Phi', # Greek capital letter phi
234
- 935 => 'Chi', # Greek capital letter chi
235
- 936 => 'Psi', # Greek capital letter psi
236
- 937 => 'Omega', # Greek capital letter omega
237
- 945 => 'alpha', # Greek small letter alpha
238
- 946 => 'beta', # Greek small letter beta
239
- 947 => 'gamma', # Greek small letter gamma
240
- 948 => 'delta', # Greek small letter delta
241
- 949 => 'epsilon', # Greek small letter epsilon
242
- 950 => 'zeta', # Greek small letter zeta
243
- 951 => 'eta', # Greek small letter eta
244
- 952 => 'theta', # Greek small letter theta
245
- 953 => 'iota', # Greek small letter iota
246
- 954 => 'kappa', # Greek small letter kappa
247
- 955 => 'lambda', # Greek small letter lambda
248
- 956 => 'mu', # Greek small letter mu
249
- 957 => 'nu', # Greek small letter nu
250
- 958 => 'xi', # Greek small letter xi
251
- 959 => 'omicron', # Greek small letter omicron
252
- 960 => 'pi', # Greek small letter pi
253
- 961 => 'rho', # Greek small letter rho
254
- 962 => 'sigmaf', # Greek small letter final sigma
255
- 963 => 'sigma', # Greek small letter sigma
256
- 964 => 'tau', # Greek small letter tau
257
- 965 => 'upsilon', # Greek small letter upsilon
258
- 966 => 'phi', # Greek small letter phi
259
- 967 => 'chi', # Greek small letter chi
260
- 968 => 'psi', # Greek small letter psi
261
- 969 => 'omega', # Greek small letter omega
262
- 977 => 'thetasym', # Greek theta symbol
263
- 978 => 'upsih', # Greek upsilon with hook symbol
264
- 982 => 'piv', # Greek pi symbol
265
- 8194 => 'ensp', # en space
266
- 8195 => 'emsp', # em space
267
- 8201 => 'thinsp', # thin space
268
- 8204 => 'zwnj', # zero width non-joiner
269
- 8205 => 'zwj', # zero width joiner
270
- 8206 => 'lrm', # left-to-right mark
271
- 8207 => 'rlm', # right-to-left mark
272
- 8211 => 'ndash', # en dash
273
- 8212 => 'mdash', # em dash
274
- 8216 => 'lsquo', # left single quotation mark
275
- 8217 => 'rsquo', # right single quotation mark
276
- 8218 => 'sbquo', # single low-9 quotation mark
277
- 8220 => 'ldquo', # left double quotation mark
278
- 8221 => 'rdquo', # right double quotation mark
279
- 8222 => 'bdquo', # double low-9 quotation mark
280
- 8224 => 'dagger', # dagger
281
- 8225 => 'Dagger', # double dagger
282
- 8226 => 'bull', # bullet
283
- 8230 => 'hellip', # horizontal ellipsis
284
- 8240 => 'permil', # per mille sign
285
- 8242 => 'prime', # prime
286
- 8243 => 'Prime', # double prime
287
- 8249 => 'lsaquo', # single left-pointing angle quotation mark
288
- 8250 => 'rsaquo', # single right-pointing angle quotation mark
289
- 8254 => 'oline', # overline
290
- 8260 => 'frasl', # fraction slash
291
- 8364 => 'euro', # euro sign
292
- 8465 => 'image', # black-letter capital i
293
- 8472 => 'weierp', # script capital pXCOMMAX Weierstrass p
294
- 8476 => 'real', # black-letter capital r
295
- 8482 => 'trade', # trademark sign
296
- 8501 => 'alefsym', # alef symbol
297
- 8592 => 'larr', # leftwards arrow
298
- 8593 => 'uarr', # upwards arrow
299
- 8594 => 'rarr', # rightwards arrow
300
- 8595 => 'darr', # downwards arrow
301
- 8596 => 'harr', # left right arrow
302
- 8629 => 'crarr', # downwards arrow with corner leftwards
303
- 8656 => 'lArr', # leftwards double arrow
304
- 8657 => 'uArr', # upwards double arrow
305
- 8658 => 'rArr', # rightwards double arrow
306
- 8659 => 'dArr', # downwards double arrow
307
- 8660 => 'hArr', # left right double arrow
308
- 8704 => 'forall', # for all
309
- 8706 => 'part', # partial differential
310
- 8707 => 'exist', # there exists
311
- 8709 => 'empty', # empty set
312
- 8711 => 'nabla', # nabla
313
- 8712 => 'isin', # element of
314
- 8713 => 'notin', # not an element of
315
- 8715 => 'ni', # contains as member
316
- 8719 => 'prod', # n-ary product
317
- 8721 => 'sum', # n-ary summation
318
- 8722 => 'minus', # minus sign
319
- 8727 => 'lowast', # asterisk operator
320
- 8730 => 'radic', # square root
321
- 8733 => 'prop', # proportional to
322
- 8734 => 'infin', # infinity
323
- 8736 => 'ang', # angle
324
- 8743 => 'and', # logical and
325
- 8744 => 'or', # logical or
326
- 8745 => 'cap', # intersection
327
- 8746 => 'cup', # union
328
- 8747 => 'int', # integral
329
- 8756 => 'there4', # therefore
330
- 8764 => 'sim', # tilde operator
331
- 8773 => 'cong', # congruent to
332
- 8776 => 'asymp', # almost equal to
333
- 8800 => 'ne', # not equal to
334
- 8801 => 'equiv', # identical toXCOMMAX equivalent to
335
- 8804 => 'le', # less-than or equal to
336
- 8805 => 'ge', # greater-than or equal to
337
- 8834 => 'sub', # subset of
338
- 8835 => 'sup', # superset of
339
- 8836 => 'nsub', # not a subset of
340
- 8838 => 'sube', # subset of or equal to
341
- 8839 => 'supe', # superset of or equal to
342
- 8853 => 'oplus', # circled plus
343
- 8855 => 'otimes', # circled times
344
- 8869 => 'perp', # up tack
345
- 8901 => 'sdot', # dot operator
346
- 8968 => 'lceil', # left ceiling
347
- 8969 => 'rceil', # right ceiling
348
- 8970 => 'lfloor', # left floor
349
- 8971 => 'rfloor', # right floor
350
- 9001 => 'lang', # left-pointing angle bracket
351
- 9002 => 'rang', # right-pointing angle bracket
352
- 9674 => 'loz', # lozenge
353
- 9824 => 'spades', # black spade suit
354
- 9827 => 'clubs', # black club suit
355
- 9829 => 'hearts', # black heart suit
356
- 9830 => 'diams' # black diamond suit
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` compatibility)
372
- # * Leave open the possibility to developers to mark a string as safe with an higher API (eg. `#raw` in `Hanami::View` or `Hanami::Helpers`)
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 '' if input.nil?
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] # rubocop:disable Lint/AssignmentInCondition
562
+ if entity = HTML_ENTITIES[code]
559
563
  "&#{entity};"
560
564
  else
561
565
  "&#x#{hex};"