hanami-utils 2.0.0.alpha1 → 2.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/README.md +4 -5
- data/hanami-utils.gemspec +5 -4
- data/lib/hanami/interactor.rb +64 -32
- data/lib/hanami/logger.rb +13 -13
- data/lib/hanami/logger/colorizer.rb +10 -10
- data/lib/hanami/logger/filter.rb +86 -10
- data/lib/hanami/logger/formatter.rb +4 -4
- data/lib/hanami/utils.rb +4 -4
- data/lib/hanami/utils/basic_object.rb +63 -3
- data/lib/hanami/utils/blank.rb +6 -6
- data/lib/hanami/utils/callbacks.rb +4 -2
- data/lib/hanami/utils/class.rb +1 -5
- data/lib/hanami/utils/escape.rb +172 -170
- data/lib/hanami/utils/file_list.rb +22 -2
- data/lib/hanami/utils/files.rb +13 -2
- data/lib/hanami/utils/hash.rb +20 -32
- data/lib/hanami/utils/json.rb +1 -1
- data/lib/hanami/utils/kernel.rb +12 -13
- data/lib/hanami/utils/load_paths.rb +3 -3
- data/lib/hanami/utils/path_prefix.rb +33 -3
- data/lib/hanami/utils/query_string.rb +1 -1
- data/lib/hanami/utils/shell_color.rb +9 -9
- data/lib/hanami/utils/string.rb +33 -394
- data/lib/hanami/utils/version.rb +1 -1
- metadata +28 -14
@@ -103,15 +103,15 @@ module Hanami
|
|
103
103
|
|
104
104
|
# @since 0.8.0
|
105
105
|
# @api private
|
106
|
-
def _message_hash(message)
|
106
|
+
def _message_hash(message)
|
107
107
|
case message
|
108
108
|
when ::Hash
|
109
109
|
@filter.call(message)
|
110
110
|
when Exception
|
111
111
|
::Hash[
|
112
|
-
message:
|
112
|
+
message: message.message,
|
113
113
|
backtrace: message.backtrace || [],
|
114
|
-
error:
|
114
|
+
error: message.class
|
115
115
|
]
|
116
116
|
else
|
117
117
|
::Hash[message: message]
|
@@ -121,7 +121,7 @@ module Hanami
|
|
121
121
|
# @since 0.8.0
|
122
122
|
# @api private
|
123
123
|
def _format(hash)
|
124
|
-
"#{_line_front_matter(hash.delete(:app), hash.delete(:severity), hash.delete(:time))}#{SEPARATOR}#{_format_message(hash)}"
|
124
|
+
"#{_line_front_matter(hash.delete(:app), hash.delete(:severity), hash.delete(:time))}#{SEPARATOR}#{_format_message(hash)}" # rubocop:disable Layout/LineLength
|
125
125
|
end
|
126
126
|
|
127
127
|
# @since 1.2.0
|
data/lib/hanami/utils.rb
CHANGED
@@ -23,7 +23,7 @@ module Hanami
|
|
23
23
|
|
24
24
|
# Checks if the current VM is JRuby
|
25
25
|
#
|
26
|
-
# @return [TrueClass,FalseClass]
|
26
|
+
# @return [TrueClass,FalseClass] info whether the VM is JRuby or not
|
27
27
|
#
|
28
28
|
# @since 0.3.1
|
29
29
|
# @api private
|
@@ -33,7 +33,7 @@ module Hanami
|
|
33
33
|
|
34
34
|
# Checks if the current VM is Rubinius
|
35
35
|
#
|
36
|
-
# @return [TrueClass,FalseClass]
|
36
|
+
# @return [TrueClass,FalseClass] info whether the VM is Rubinius or not
|
37
37
|
#
|
38
38
|
# @since 0.3.1
|
39
39
|
# @api private
|
@@ -41,7 +41,7 @@ module Hanami
|
|
41
41
|
RUBY_ENGINE == HANAMI_RUBINIUS
|
42
42
|
end
|
43
43
|
|
44
|
-
# Recursively
|
44
|
+
# Recursively requires Ruby files under the given directory.
|
45
45
|
#
|
46
46
|
# If the directory is relative, it implies it's the path from current directory.
|
47
47
|
# If the directory is absolute, it uses as it is.
|
@@ -71,7 +71,7 @@ module Hanami
|
|
71
71
|
# @since 1.0.0
|
72
72
|
# @api private
|
73
73
|
def self.for_each_file_in(directory, &blk)
|
74
|
-
directory = directory.to_s.gsub(%r{(
|
74
|
+
directory = directory.to_s.gsub(%r{(/|\\)}, File::SEPARATOR)
|
75
75
|
directory = Pathname.new(Dir.pwd).join(directory).to_s
|
76
76
|
directory = File.join(directory, "**", "*.rb") unless directory =~ /(\*\*)/
|
77
77
|
|
@@ -6,7 +6,24 @@ module Hanami
|
|
6
6
|
#
|
7
7
|
# @since 0.3.5
|
8
8
|
class BasicObject < ::BasicObject
|
9
|
-
#
|
9
|
+
# Lookups constants at the top-level namespace, if they are missing in the
|
10
|
+
# current context.
|
11
|
+
#
|
12
|
+
# @param name [Symbol] the constant name
|
13
|
+
#
|
14
|
+
# @return [Object, Module] the constant
|
15
|
+
#
|
16
|
+
# @raise [NameError] if the constant cannot be found
|
17
|
+
#
|
18
|
+
# @since 1.3.4
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
# @see https://ruby-doc.org/core/Module.html#method-i-const_missing
|
22
|
+
def self.const_missing(name)
|
23
|
+
::Object.const_get(name)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the class for debugging purposes.
|
10
27
|
#
|
11
28
|
# @since 0.3.5
|
12
29
|
#
|
@@ -23,13 +40,56 @@ module Hanami
|
|
23
40
|
#
|
24
41
|
# @see http://ruby-doc.org/core/Object.html#method-i-inspect
|
25
42
|
#
|
26
|
-
# rubocop:disable Style/FormatString
|
27
43
|
# rubocop:disable Style/FormatStringToken
|
28
44
|
def inspect
|
29
45
|
"#<#{self.class}:#{'0x0000%x' % (__id__ << 1)}#{__inspect}>"
|
30
46
|
end
|
31
47
|
# rubocop:enable Style/FormatStringToken
|
32
|
-
|
48
|
+
|
49
|
+
# @!macro [attach] instance_of?(class)
|
50
|
+
#
|
51
|
+
# Determines if self is an instance of given class or module
|
52
|
+
#
|
53
|
+
# @param class [Class,Module] the class of module to verify
|
54
|
+
#
|
55
|
+
# @return [TrueClass,FalseClass] the result of the check
|
56
|
+
#
|
57
|
+
# @raise [TypeError] if the given argument is not of the expected types
|
58
|
+
#
|
59
|
+
# @since 1.3.2
|
60
|
+
#
|
61
|
+
# @see http://ruby-doc.org/core/Object.html#method-i-instance_of-3F
|
62
|
+
define_method :instance_of?, ::Object.instance_method(:instance_of?)
|
63
|
+
|
64
|
+
# @!macro [attach] is_a?(class)
|
65
|
+
#
|
66
|
+
# Determines if self is of the type of the object class or module
|
67
|
+
#
|
68
|
+
# @param class [Class,Module] the class of module to verify
|
69
|
+
#
|
70
|
+
# @return [TrueClass,FalseClass] the result of the check
|
71
|
+
#
|
72
|
+
# @raise [TypeError] if the given argument is not of the expected types
|
73
|
+
#
|
74
|
+
# @since 1.3.2
|
75
|
+
#
|
76
|
+
# @see http://ruby-doc.org/core/Object.html#method-i-is_a-3F
|
77
|
+
define_method :is_a?, ::Object.instance_method(:is_a?)
|
78
|
+
|
79
|
+
# @!macro [attach] kind_of?(class)
|
80
|
+
#
|
81
|
+
# Determines if self is of the kind of the object class or module
|
82
|
+
#
|
83
|
+
# @param class [Class,Module] the class of module to verify
|
84
|
+
#
|
85
|
+
# @return [TrueClass,FalseClass] the result of the check
|
86
|
+
#
|
87
|
+
# @raise [TypeError] if the given argument is not of the expected types
|
88
|
+
#
|
89
|
+
# @since 1.3.2
|
90
|
+
#
|
91
|
+
# @see http://ruby-doc.org/core/Object.html#method-i-kind_of-3F
|
92
|
+
define_method :kind_of?, ::Object.instance_method(:kind_of?)
|
33
93
|
|
34
94
|
# Alias for __id__
|
35
95
|
#
|
data/lib/hanami/utils/blank.rb
CHANGED
@@ -13,7 +13,7 @@ module Hanami
|
|
13
13
|
# @api private
|
14
14
|
STRING_MATCHER = /\A[[:space:]]*\z/.freeze
|
15
15
|
|
16
|
-
# Checks object is blank
|
16
|
+
# Checks if object is blank
|
17
17
|
#
|
18
18
|
# @example Basic Usage
|
19
19
|
# require 'hanami/utils/blank'
|
@@ -26,14 +26,14 @@ module Hanami
|
|
26
26
|
#
|
27
27
|
# @param object the argument
|
28
28
|
#
|
29
|
-
# @return [TrueClass,FalseClass]
|
29
|
+
# @return [TrueClass,FalseClass] info, whether object is blank
|
30
30
|
#
|
31
31
|
# @since 0.8.0
|
32
32
|
# @api private
|
33
|
-
def self.blank?(object)
|
33
|
+
def self.blank?(object)
|
34
34
|
case object
|
35
35
|
when String, ::String
|
36
|
-
STRING_MATCHER === object
|
36
|
+
STRING_MATCHER === object
|
37
37
|
when ::Hash, ::Array
|
38
38
|
object.empty?
|
39
39
|
when TrueClass, Numeric
|
@@ -45,7 +45,7 @@ module Hanami
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
# Checks object is filled
|
48
|
+
# Checks if object is filled
|
49
49
|
#
|
50
50
|
# @example Basic Usage
|
51
51
|
# require 'hanami/utils/blank'
|
@@ -58,7 +58,7 @@ module Hanami
|
|
58
58
|
#
|
59
59
|
# @param object the argument
|
60
60
|
#
|
61
|
-
# @return [TrueClass,FalseClass]
|
61
|
+
# @return [TrueClass,FalseClass] whether the object is filled
|
62
62
|
#
|
63
63
|
# @since 1.0.0
|
64
64
|
# @api private
|
@@ -14,7 +14,7 @@ module Hanami
|
|
14
14
|
# @since 0.1.0
|
15
15
|
# @private
|
16
16
|
class Chain
|
17
|
-
#
|
17
|
+
# Returns a new chain
|
18
18
|
#
|
19
19
|
# @return [Hanami::Utils::Callbacks::Chain]
|
20
20
|
#
|
@@ -267,7 +267,9 @@ module Hanami
|
|
267
267
|
end
|
268
268
|
|
269
269
|
# Method callback
|
270
|
-
#
|
270
|
+
#
|
271
|
+
# It wraps a symbol or a string representing a method name that is
|
272
|
+
# implemented by the context within it will be called.
|
271
273
|
#
|
272
274
|
# @since 0.1.0
|
273
275
|
# @api private
|
data/lib/hanami/utils/class.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/utils/deprecation"
|
4
|
-
|
5
3
|
module Hanami
|
6
4
|
module Utils
|
7
5
|
# Class utilities
|
@@ -74,9 +72,8 @@ module Hanami
|
|
74
72
|
load!(name, namespace) if namespace.const_defined?(name.to_s, false)
|
75
73
|
end
|
76
74
|
|
77
|
-
# rubocop:disable Metrics/MethodLength
|
78
75
|
def self.tokenize(pattern)
|
79
|
-
if match = TOKENIZE_REGEXP.match(pattern)
|
76
|
+
if match = TOKENIZE_REGEXP.match(pattern)
|
80
77
|
pre = match.pre_match
|
81
78
|
post = match.post_match
|
82
79
|
tokens = match[1].split(TOKENIZE_SEPARATOR)
|
@@ -89,7 +86,6 @@ module Hanami
|
|
89
86
|
|
90
87
|
nil
|
91
88
|
end
|
92
|
-
# rubocop:enable Metrics/MethodLength
|
93
89
|
|
94
90
|
# Regexp for .tokenize
|
95
91
|
#
|
data/lib/hanami/utils/escape.rb
CHANGED
@@ -39,7 +39,7 @@ module Hanami
|
|
39
39
|
# @since 0.4.0
|
40
40
|
# @api private
|
41
41
|
HEX_CODES = (0..255).each_with_object({}) do |c, codes|
|
42
|
-
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)
|
43
43
|
codes[c] = nil
|
44
44
|
else
|
45
45
|
codes[c] = c.to_s(HEX_BASE)
|
@@ -55,8 +55,8 @@ module Hanami
|
|
55
55
|
#
|
56
56
|
# @see https://gist.github.com/jodosha/ac5dd54416de744b9600
|
57
57
|
NON_PRINTABLE_CHARS = {
|
58
|
-
0x0
|
59
|
-
0x5
|
58
|
+
0x0 => true, 0x1 => true, 0x2 => true, 0x3 => true, 0x4 => true,
|
59
|
+
0x5 => true, 0x6 => true, 0x7 => true, 0x8 => true, 0x11 => true,
|
60
60
|
0x12 => true, 0x14 => true, 0x15 => true, 0x16 => true, 0x17 => true,
|
61
61
|
0x18 => true, 0x19 => true, 0x1a => true, 0x1b => true, 0x1c => true,
|
62
62
|
0x1d => true, 0x1e => true, 0x1f => true, 0x7f => true, 0x80 => true,
|
@@ -104,166 +104,166 @@ module Hanami
|
|
104
104
|
#
|
105
105
|
# @see Hanami::Utils::Escape.html_attribute
|
106
106
|
HTML_ENTITIES = {
|
107
|
-
34
|
108
|
-
38
|
109
|
-
60
|
110
|
-
62
|
111
|
-
160
|
112
|
-
161
|
113
|
-
162
|
114
|
-
163
|
115
|
-
164
|
116
|
-
165
|
117
|
-
166
|
118
|
-
167
|
119
|
-
168
|
120
|
-
169
|
121
|
-
170
|
122
|
-
171
|
123
|
-
172
|
124
|
-
173
|
125
|
-
174
|
126
|
-
175
|
127
|
-
176
|
128
|
-
177
|
129
|
-
178
|
130
|
-
179
|
131
|
-
180
|
132
|
-
181
|
133
|
-
182
|
134
|
-
183
|
135
|
-
184
|
136
|
-
185
|
137
|
-
186
|
138
|
-
187
|
139
|
-
188
|
140
|
-
189
|
141
|
-
190
|
142
|
-
191
|
143
|
-
192
|
144
|
-
193
|
145
|
-
194
|
146
|
-
195
|
147
|
-
196
|
148
|
-
197
|
149
|
-
198
|
150
|
-
199
|
151
|
-
200
|
152
|
-
201
|
153
|
-
202
|
154
|
-
203
|
155
|
-
204
|
156
|
-
205
|
157
|
-
206
|
158
|
-
207
|
159
|
-
208
|
160
|
-
209
|
161
|
-
210
|
162
|
-
211
|
163
|
-
212
|
164
|
-
213
|
165
|
-
214
|
166
|
-
215
|
167
|
-
216
|
168
|
-
217
|
169
|
-
218
|
170
|
-
219
|
171
|
-
220
|
172
|
-
221
|
173
|
-
222
|
174
|
-
223
|
175
|
-
224
|
176
|
-
225
|
177
|
-
226
|
178
|
-
227
|
179
|
-
228
|
180
|
-
229
|
181
|
-
230
|
182
|
-
231
|
183
|
-
232
|
184
|
-
233
|
185
|
-
234
|
186
|
-
235
|
187
|
-
236
|
188
|
-
237
|
189
|
-
238
|
190
|
-
239
|
191
|
-
240
|
192
|
-
241
|
193
|
-
242
|
194
|
-
243
|
195
|
-
244
|
196
|
-
245
|
197
|
-
246
|
198
|
-
247
|
199
|
-
248
|
200
|
-
249
|
201
|
-
250
|
202
|
-
251
|
203
|
-
252
|
204
|
-
253
|
205
|
-
254
|
206
|
-
255
|
207
|
-
338
|
208
|
-
339
|
209
|
-
352
|
210
|
-
353
|
211
|
-
376
|
212
|
-
402
|
213
|
-
710
|
214
|
-
732
|
215
|
-
913
|
216
|
-
914
|
217
|
-
915
|
218
|
-
916
|
219
|
-
917
|
220
|
-
918
|
221
|
-
919
|
222
|
-
920
|
223
|
-
921
|
224
|
-
922
|
225
|
-
923
|
226
|
-
924
|
227
|
-
925
|
228
|
-
926
|
229
|
-
927
|
230
|
-
928
|
231
|
-
929
|
232
|
-
931
|
233
|
-
932
|
234
|
-
933
|
235
|
-
934
|
236
|
-
935
|
237
|
-
936
|
238
|
-
937
|
239
|
-
945
|
240
|
-
946
|
241
|
-
947
|
242
|
-
948
|
243
|
-
949
|
244
|
-
950
|
245
|
-
951
|
246
|
-
952
|
247
|
-
953
|
248
|
-
954
|
249
|
-
955
|
250
|
-
956
|
251
|
-
957
|
252
|
-
958
|
253
|
-
959
|
254
|
-
960
|
255
|
-
961
|
256
|
-
962
|
257
|
-
963
|
258
|
-
964
|
259
|
-
965
|
260
|
-
966
|
261
|
-
967
|
262
|
-
968
|
263
|
-
969
|
264
|
-
977
|
265
|
-
978
|
266
|
-
982
|
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
267
|
8194 => "ensp", # en space
|
268
268
|
8195 => "emsp", # em space
|
269
269
|
8201 => "thinsp", # thin space
|
@@ -370,8 +370,10 @@ module Hanami
|
|
370
370
|
#
|
371
371
|
# It's marked with this special class for two reasons:
|
372
372
|
#
|
373
|
-
# * Don't double escape the same string (this is for `Hanami::Helpers`
|
374
|
-
#
|
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`)
|
375
377
|
#
|
376
378
|
# @since 0.4.0
|
377
379
|
# @api private
|
@@ -399,7 +401,7 @@ module Hanami
|
|
399
401
|
end
|
400
402
|
end
|
401
403
|
|
402
|
-
#
|
404
|
+
# Escapes HTML contents
|
403
405
|
#
|
404
406
|
# This MUST be used only for tag contents.
|
405
407
|
# Please use `html_attribute` for escaping HTML attributes.
|
@@ -432,7 +434,7 @@ module Hanami
|
|
432
434
|
result
|
433
435
|
end
|
434
436
|
|
435
|
-
#
|
437
|
+
# Escapes HTML attributes
|
436
438
|
#
|
437
439
|
# This can be used both for HTML attributes and contents.
|
438
440
|
# Please note that this is more computational expensive.
|
@@ -465,7 +467,7 @@ module Hanami
|
|
465
467
|
result
|
466
468
|
end
|
467
469
|
|
468
|
-
#
|
470
|
+
# Escapes URL for HTML attributes (href, src, etc..).
|
469
471
|
#
|
470
472
|
# It extracts from the given input the first valid URL that matches the
|
471
473
|
# whitelisted schemes (default: http, https and mailto).
|
@@ -523,7 +525,7 @@ module Hanami
|
|
523
525
|
class << self
|
524
526
|
private
|
525
527
|
|
526
|
-
#
|
528
|
+
# Encodes the given string into UTF-8
|
527
529
|
#
|
528
530
|
# @param input [String] the input
|
529
531
|
#
|
@@ -557,7 +559,7 @@ module Hanami
|
|
557
559
|
|
558
560
|
hex = REPLACEMENT_HEX if NON_PRINTABLE_CHARS[code]
|
559
561
|
|
560
|
-
if entity = HTML_ENTITIES[code]
|
562
|
+
if entity = HTML_ENTITIES[code]
|
561
563
|
"&#{entity};"
|
562
564
|
else
|
563
565
|
"&#x#{hex};"
|