hanami-utils 2.0.0.alpha1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hanami
4
+ # Shared Rack middleware for Hanami apps.
5
+ #
6
+ # This module is defined in hanami-utils so that any gem providing middleware can use its
7
+ # resources.
8
+ #
9
+ # @since 2.0.0
4
10
  module Middleware
5
- # Hanami middleware utils
6
-
11
+ # Base class for all errors raised during middleware loading.
12
+ #
7
13
  # @since 2.0.0
8
- class Error < ::StandardError
14
+ # @api public
15
+ class Error < StandardError
9
16
  end
10
17
  end
11
18
  end
@@ -11,9 +11,9 @@ module Hanami
11
11
  #
12
12
  # @since 0.8.0
13
13
  # @api private
14
- STRING_MATCHER = /\A[[:space:]]*\z/.freeze
14
+ STRING_MATCHER = /\A[[:space:]]*\z/
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) # rubocop:disable Metrics/MethodLength
33
+ def self.blank?(object)
34
34
  case object
35
35
  when String, ::String
36
- STRING_MATCHER === object # rubocop:disable Style/CaseEquality
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
- # Return a new chain
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
- # It wraps a symbol or a string representing a method name that is implemented by the context within it will be called.
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
@@ -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
@@ -73,35 +71,6 @@ module Hanami
73
71
  def self.load(name, namespace = Object)
74
72
  load!(name, namespace) if namespace.const_defined?(name.to_s, false)
75
73
  end
76
-
77
- # rubocop:disable Metrics/MethodLength
78
- def self.tokenize(pattern)
79
- if match = TOKENIZE_REGEXP.match(pattern) # rubocop:disable Lint/AssignmentInCondition
80
- pre = match.pre_match
81
- post = match.post_match
82
- tokens = match[1].split(TOKENIZE_SEPARATOR)
83
- tokens.each do |token|
84
- yield("#{pre}#{token}#{post}")
85
- end
86
- else
87
- yield(pattern)
88
- end
89
-
90
- nil
91
- end
92
- # rubocop:enable Metrics/MethodLength
93
-
94
- # Regexp for .tokenize
95
- #
96
- # @since 1.3.0
97
- # @api private
98
- TOKENIZE_REGEXP = /\((.*)\)/.freeze
99
-
100
- # Separator for .tokenize
101
- #
102
- # @since 1.3.0
103
- # @api private
104
- TOKENIZE_SEPARATOR = "|"
105
74
  end
106
75
  end
107
76
  end
@@ -75,13 +75,13 @@ module Hanami
75
75
  def class_attribute(*attributes)
76
76
  attributes.each do |attr|
77
77
  singleton_class.class_eval %(
78
- def #{attr}
79
- class_attributes[:#{attr}]
80
- end
81
-
82
- def #{attr}=(value)
83
- class_attributes[:#{attr}] = value
84
- end
78
+ def #{attr} # def foo
79
+ class_attributes[:#{attr}] # class_attributes[:foo]
80
+ end # end
81
+ #
82
+ def #{attr}=(value) # def foo=(value)
83
+ class_attributes[:#{attr}] = value # class_attributes[:foo] = value
84
+ end # end
85
85
  ), __FILE__, __LINE__ - 8
86
86
  end
87
87
  end
@@ -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) # rubocop:disable Style/ConditionalAssignment
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 => true, 0x1 => true, 0x2 => true, 0x3 => true, 0x4 => true,
59
- 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,
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 => "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
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` compatibility)
374
- # * 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`)
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
- # Escape HTML contents
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
- # Escape HTML attributes
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
- # Escape URL for HTML attributes (href, src, etc..).
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
- # Encode the given string into UTF-8
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] # rubocop:disable Lint/AssignmentInCondition
562
+ if entity = HTML_ENTITIES[code]
561
563
  "&#{entity};"
562
564
  else
563
565
  "&#x#{hex};"
@@ -6,7 +6,7 @@ module Hanami
6
6
  #
7
7
  # @since 0.9.0
8
8
  module FileList
9
- # Return an ordered list of files, consistent across operating systems
9
+ # Returns an ordered list of files, consistent across operating systems
10
10
  #
11
11
  # It has the same signature of <tt>Dir.glob</tt>, it just guarantees to
12
12
  # order the results before to return them.
@@ -14,8 +14,28 @@ module Hanami
14
14
  # @since 0.9.0
15
15
  #
16
16
  # @see https://ruby-doc.org/core/Dir.html#method-c-glob
17
+ #
18
+ # @example simple usage
19
+ # require "hanami/utils/file_list"
20
+ #
21
+ # Hanami::Utils::FileList["spec/support/fixtures/file_list/*.rb"]
22
+ # # => [
23
+ # "spec/support/fixtures/file_list/a.rb",
24
+ # "spec/support/fixtures/file_list/aa.rb",
25
+ # "spec/support/fixtures/file_list/ab.rb"
26
+ # ]
27
+ #
28
+ # @example token usage
29
+ # require "hanami/utils/file_list"
30
+ #
31
+ # Hanami::Utils::FileList["spec", "support", "fixtures", "file_list", "*.rb"]
32
+ # # => [
33
+ # "spec/support/fixtures/file_list/a.rb",
34
+ # "spec/support/fixtures/file_list/aa.rb",
35
+ # "spec/support/fixtures/file_list/ab.rb"
36
+ # ]
17
37
  def self.[](*args)
18
- Dir.glob(*args).sort!
38
+ Dir.glob(::File.join(*args)).sort!
19
39
  end
20
40
  end
21
41
  end
@@ -147,6 +147,7 @@ module Hanami
147
147
  mkdir_p(path)
148
148
 
149
149
  content = ::File.readlines(path)
150
+ content << "\n" if _append_newline?(content)
150
151
  content << "#{contents}\n"
151
152
 
152
153
  write(path, content)
@@ -307,13 +308,13 @@ module Hanami
307
308
  #
308
309
  # # class App
309
310
  # # end
310
- def self.remove_block(path, target) # rubocop:disable Metrics/AbcSize
311
+ def self.remove_block(path, target)
311
312
  content = ::File.readlines(path)
312
313
  starting = index(content, path, target)
313
314
  line = content[starting]
314
315
  size = line[/\A[[:space:]]*/].bytesize
315
316
  closing = (" " * size) + (/{/.match?(target) ? "}" : "end")
316
- ending = starting + index(content[starting..-1], path, closing)
317
+ ending = starting + index(content[starting..], path, closing)
317
318
 
318
319
  content.slice!(starting..ending)
319
320
  write(path, content)
@@ -435,6 +436,16 @@ module Hanami
435
436
  end
436
437
 
437
438
  private_class_method :line_number
439
+
440
+ # @since 1.3.6
441
+ # @api private
442
+ def self._append_newline?(content)
443
+ return false if content.empty?
444
+
445
+ !content.last.end_with?("\n")
446
+ end
447
+
448
+ private_class_method :_append_newline?
438
449
  end
439
450
  end
440
451
  end