ykutils 0.1.1 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +2 -1
  4. data/.rubocop_todo.yml +181 -85
  5. data/Gemfile +12 -4
  6. data/Gemfile.lock +23 -13
  7. data/bin/erubix +17 -0
  8. data/bin/erubix2 +13 -0
  9. data/bin/makegrid +4 -4
  10. data/lib/ykutils/erubyx.rb +41 -3
  11. data/lib/ykutils/fileoputils.rb +2 -2
  12. data/lib/ykutils/gridlist.rb +49 -67
  13. data/lib/ykutils/lines.rb +143 -143
  14. data/lib/ykutils/lsutils.rb +71 -71
  15. data/lib/ykutils/nginxconfig.rb +40 -0
  16. data/lib/ykutils/nginxconfigfiles.rb +31 -0
  17. data/lib/ykutils/nkfutil.rb +148 -147
  18. data/lib/ykutils/nkfutil19.rb +9 -11
  19. data/lib/ykutils/osutil.rb +16 -16
  20. data/lib/ykutils/retcodex.rb +1 -3
  21. data/lib/ykutils/stext.rb +427 -425
  22. data/lib/ykutils/stextx.rb +32 -32
  23. data/lib/ykutils/stringutils.rb +111 -111
  24. data/lib/ykutils/treemanager.rb +33 -33
  25. data/lib/ykutils/treemanagera.rb +21 -21
  26. data/lib/ykutils/version.rb +1 -1
  27. data/lib/ykutils/xlines.rb +8 -8
  28. data/lib/ykutils/yamlop.rb +227 -227
  29. data/lib/ykutils/yamlxop.rb +35 -35
  30. data/lib/ykutils.rb +4 -0
  31. data/test_data/4servers.erb +7 -0
  32. data/test_data/a.bat +5 -0
  33. data/test_data/a_ncn.bat +12 -0
  34. data/test_data/top.yml +0 -0
  35. data/test_data/v103-3-189-127/4servers.erb +0 -0
  36. data/test_data/v103-3-189-127/a.northern-cross.net/base.yml +28 -0
  37. data/test_data/v103-3-189-127/a.northern-cross.net/value_host.yml +1 -0
  38. data/test_data/v103-3-189-127/b.northern-cross.net/base.yml +28 -0
  39. data/test_data/v103-3-189-127/b.northern-cross.net/value_host.yml +1 -0
  40. data/test_data/v103-3-189-127/c.northern-cross.net/base.yml +28 -0
  41. data/test_data/v103-3-189-127/c.northern-cross.net/value_host.yml +1 -0
  42. data/test_data/v103-3-189-127/d.northern-cross.info/base.yml +28 -0
  43. data/test_data/v103-3-189-127/d.northern-cross.info/value_host.yml +1 -0
  44. data/test_data/v103-3-189-127/d.northern-cross.net/base.yml +28 -0
  45. data/test_data/v103-3-189-127/d.northern-cross.net/value_host.yml +1 -0
  46. data/test_data/v103-3-189-127/e.northern-cross.info/base.yml +28 -0
  47. data/test_data/v103-3-189-127/e.northern-cross.info/value_host.yml +1 -0
  48. data/test_data/v103-3-189-127/e.northern-cross.net/base.yml +28 -0
  49. data/test_data/v103-3-189-127/e.northern-cross.net/value_host.yml +1 -0
  50. data/test_data/v103-3-189-127/f.northern-cross.info/base.yml +28 -0
  51. data/test_data/v103-3-189-127/f.northern-cross.info/value_host.yml +1 -0
  52. data/test_data/v103-3-189-127/f.northern-cross.net/base.yml +28 -0
  53. data/test_data/v103-3-189-127/f.northern-cross.net/value_host.yml +1 -0
  54. data/test_data/v103-3-189-127/t_server_1.erb +7 -0
  55. data/test_data/v103-3-189-127/template.erb +21 -0
  56. data/test_data/v103-3-189-127/template_ssl.erb +22 -0
  57. data/test_data/v103-3-189-127/template_ssl_www.erb +12 -0
  58. data/test_data/v103-3-189-127/template_www.erb +24 -0
  59. data/test_data/v103-3-189-127/value.yml +3 -0
  60. data/test_data/v103-3-189-127/value_ssl.yml +5 -0
  61. data/ykutils.gemspec +45 -43
  62. metadata +44 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b499c160b699d72067cfa4dae524e5a7e1a20031c50c9555e7ffb3ea5fbd610a
4
- data.tar.gz: 7794129fb0a121c4ba36c4df23a110b10623a725f78f7b26903afd4eec5fcde2
3
+ metadata.gz: 4f0e6776b432deae3ef470f5b8bc48762e6ae925f3f7ccadb2e3e596386d99fc
4
+ data.tar.gz: 9ecc9d403d025fdc6b5ee86abacfdd1d5a14cb163c20031cac1a448a635f166a
5
5
  SHA512:
6
- metadata.gz: d4ad65f3b023e40bb6540580aff86225d25f7a221572eba886e1263b3616904f7a39fa43e29df7e8d9849c818589c20af01c2117fe40c72ac00f531fa4819bcc
7
- data.tar.gz: 5daa995ba943d8cf6c0011ace457c35094b78e199131a7440caff244e2bc728cf5beb0268ccc7976462d5c6af0de22871cff02c2bcad2e6d546ec6ff9b51b72f
6
+ metadata.gz: 5c48a8c783041855ce6edc53a20e0c35a4afa10abd87a53ed1b846c6ff507162e9e961a14c99d8335f41f125a1ebabc9092d01f2b71c03ec1e8ece07fee8dcdd
7
+ data.tar.gz: dd844b0ec79d592a011132850cdcf5ed98a711f8ba7984d6d310b9d61778feded846a2342fd8b038ac40cef15fd1e13afc6be909bcd7de4da46abe10604ed013
data/.gitignore CHANGED
@@ -9,3 +9,9 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.conf
13
+ /checksum/
14
+ awww.bat
15
+ /checksums/
16
+ d.bat
17
+ /vendor/
data/.rubocop.yml CHANGED
@@ -14,4 +14,5 @@ Style/StringLiteralsInInterpolation:
14
14
  EnforcedStyle: double_quotes
15
15
 
16
16
  Layout/LineLength:
17
- Max: 120
17
+ # Max: 120
18
+ Max: 140
data/.rubocop_todo.yml CHANGED
@@ -1,54 +1,16 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-06-20 10:09:15 UTC using RuboCop version 1.30.1.
3
+ # on 2022-09-07 09:47:32 UTC using RuboCop version 1.36.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 9
10
- # Configuration parameters: EnforcedStyle.
11
- # SupportedStyles: native, lf, crlf
12
- Layout/EndOfLine:
13
- Exclude:
14
- - 'Gemfile'
15
- - 'Rakefile'
16
- - 'bin/console'
17
- - 'lib/ykutils.rb'
18
- - 'lib/ykutils/lsutils.rb'
19
- - 'lib/ykutils/version.rb'
20
- # - 'spec/spec_helper.rb'
21
- # - 'spec/ykutils_spec.rb'
22
- # - 'ykutils.gemspec'
23
-
24
- # Offense count: 2
25
- # This cop supports safe autocorrection (--autocorrect).
26
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
27
- # URISchemes: http, https
28
- Layout/LineLength:
29
- Max: 175
30
-
31
- # Offense count: 7
32
- # Configuration parameters: AllowSafeAssignment.
33
- Lint/AssignmentInCondition:
34
- Exclude:
35
- - 'lib/ykutils/fileoputils2.rb'
36
- - 'lib/ykutils/lines.rb'
37
- - 'lib/ykutils/nkfutil.rb'
38
- - 'lib/ykutils/nkfutil19.rb'
39
- - 'lib/ykutils/stext.rb'
40
- - 'lib/ykutils/stextx.rb'
41
-
42
- # Offense count: 1
43
- Lint/DuplicateMethods:
44
- Exclude:
45
- - 'lib/ykutils/nkfutil19.rb'
46
-
47
9
  # Offense count: 1
48
- # This cop supports unsafe autocorrection (--autocorrect-all).
49
- Lint/DuplicateRequire:
10
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
11
+ Lint/DuplicateBranch:
50
12
  Exclude:
51
- - 'lib/ykutils.rb'
13
+ - 'lib/ykutils/stext.rb'
52
14
 
53
15
  # Offense count: 6
54
16
  # Configuration parameters: AllowComments.
@@ -57,11 +19,9 @@ Lint/EmptyWhen:
57
19
  - 'lib/ykutils/lines.rb'
58
20
  - 'lib/ykutils/stext.rb'
59
21
 
60
- # Offense count: 4
22
+ # Offense count: 1
61
23
  Lint/MissingSuper:
62
24
  Exclude:
63
- - 'lib/ykutils/retcodex.rb'
64
- - 'lib/ykutils/stext.rb'
65
25
  - 'lib/ykutils/yamlxop.rb'
66
26
 
67
27
  # Offense count: 2
@@ -69,6 +29,15 @@ Lint/NestedMethodDefinition:
69
29
  Exclude:
70
30
  - 'lib/ykutils/stextx.rb'
71
31
 
32
+ # Offense count: 4
33
+ # This cop supports safe autocorrection (--autocorrect).
34
+ Lint/ScriptPermission:
35
+ Exclude:
36
+ - 'bin/console'
37
+ - 'bin/erubix'
38
+ - 'bin/erubix2'
39
+ - 'bin/makegrid'
40
+
72
41
  # Offense count: 3
73
42
  Lint/ShadowingOuterLocalVariable:
74
43
  Exclude:
@@ -81,11 +50,12 @@ Lint/SuppressedException:
81
50
  Exclude:
82
51
  - 'lib/ykutils/pathop.rb'
83
52
 
84
- # Offense count: 21
53
+ # Offense count: 22
85
54
  Lint/UselessAssignment:
86
55
  Exclude:
87
- - 'lib/ykutils/fileoputils2.rb'
56
+ - 'lib/ykutils/fileoputils.rb'
88
57
  - 'lib/ykutils/filepermision.rb'
58
+ - 'lib/ykutils/nkfutil19.rb'
89
59
  - 'lib/ykutils/pathop.rb'
90
60
  - 'lib/ykutils/specfileop.rb'
91
61
  - 'lib/ykutils/stext.rb'
@@ -100,44 +70,44 @@ Lint/UselessMethodDefinition:
100
70
  - 'lib/ykutils/hasharray.rb'
101
71
  - 'lib/ykutils/stext.rb'
102
72
 
103
- # Offense count: 1
104
- # Configuration parameters: CheckForMethodsWithNoSideEffects.
105
- Lint/Void:
106
- Exclude:
107
- - 'lib/ykutils/stext.rb'
108
-
109
- # Offense count: 14
110
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
73
+ # Offense count: 15
74
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
111
75
  Metrics/AbcSize:
112
76
  Max: 43
113
77
 
78
+ # Offense count: 2
79
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
80
+ # AllowedMethods: refine
81
+ Metrics/BlockLength:
82
+ Max: 41
83
+
114
84
  # Offense count: 2
115
85
  # Configuration parameters: CountComments, CountAsOne.
116
86
  Metrics/ClassLength:
117
- Max: 185
87
+ Max: 183
118
88
 
119
89
  # Offense count: 6
120
- # Configuration parameters: IgnoredMethods.
90
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
121
91
  Metrics/CyclomaticComplexity:
122
92
  Max: 21
123
93
 
124
- # Offense count: 42
125
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
94
+ # Offense count: 43
95
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
126
96
  Metrics/MethodLength:
127
97
  Max: 85
128
98
 
129
99
  # Offense count: 2
130
100
  # Configuration parameters: CountComments, CountAsOne.
131
101
  Metrics/ModuleLength:
132
- Max: 339
102
+ Max: 337
133
103
 
134
- # Offense count: 2
104
+ # Offense count: 3
135
105
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
136
106
  Metrics/ParameterLists:
137
107
  Max: 6
138
108
 
139
109
  # Offense count: 5
140
- # Configuration parameters: IgnoredMethods.
110
+ # Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
141
111
  Metrics/PerceivedComplexity:
142
112
  Max: 18
143
113
 
@@ -164,23 +134,31 @@ Naming/MethodName:
164
134
  Exclude:
165
135
  - 'lib/ykutils/treemanagera.rb'
166
136
 
167
- # Offense count: 8
137
+ # Offense count: 9
168
138
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
169
- # AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
139
+ # AllowedNames: as, at, by, db, id, in, io, ip, of, on, os, pp, to
170
140
  Naming/MethodParameterName:
171
141
  Exclude:
172
142
  - 'lib/ykutils/debugutils.rb'
173
- - 'lib/ykutils/fileoputils2.rb'
143
+ - 'lib/ykutils/fileoputils.rb'
144
+ - 'lib/ykutils/nginxconfigfiles.rb'
174
145
  - 'lib/ykutils/stext.rb'
175
146
  - 'lib/ykutils/stringutils.rb'
176
147
 
148
+ # Offense count: 1
149
+ # This cop supports safe autocorrection (--autocorrect).
150
+ # Configuration parameters: PreferredName.
151
+ Naming/RescuedExceptionsVariableName:
152
+ Exclude:
153
+ - 'lib/ykutils/nkfutil19.rb'
154
+
177
155
  # Offense count: 17
178
156
  # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
179
157
  # SupportedStyles: snake_case, normalcase, non_integer
180
158
  # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
181
159
  Naming/VariableNumber:
182
160
  Exclude:
183
- - 'lib/ykutils/fileoputils2.rb'
161
+ - 'lib/ykutils/fileoputils.rb'
184
162
  - 'lib/ykutils/stringutils.rb'
185
163
 
186
164
  # Offense count: 12
@@ -190,16 +168,31 @@ Naming/VariableNumber:
190
168
  Style/AndOr:
191
169
  Exclude:
192
170
  - 'lib/ykutils/debugutils.rb'
193
- - 'lib/ykutils/fileoputils2.rb'
171
+ - 'lib/ykutils/fileoputils.rb'
194
172
  - 'lib/ykutils/lines.rb'
195
173
  - 'lib/ykutils/pathop.rb'
196
174
  - 'lib/ykutils/specfileop.rb'
197
175
  - 'lib/ykutils/stext.rb'
198
176
  - 'lib/ykutils/yamlop.rb'
199
177
 
178
+ # Offense count: 8
179
+ # This cop supports safe autocorrection (--autocorrect).
180
+ # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
181
+ # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
182
+ # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
183
+ # FunctionalMethods: let, let!, subject, watch
184
+ # AllowedMethods: lambda, proc, it
185
+ Style/BlockDelimiters:
186
+ Exclude:
187
+ - 'lib/ykutils/erubyx.rb'
188
+ - 'lib/ykutils/gridlist.rb'
189
+ - 'lib/ykutils/nginxconfig.rb'
190
+ - 'lib/ykutils/nginxconfigfiles.rb'
191
+ - 'spec/ykutils_spec.rb'
192
+
200
193
  # Offense count: 2
201
194
  # This cop supports safe autocorrection (--autocorrect).
202
- # Configuration parameters: AllowOnConstant.
195
+ # Configuration parameters: AllowOnConstant, AllowOnSelfClass.
203
196
  Style/CaseEquality:
204
197
  Exclude:
205
198
  - 'lib/ykutils/lsutils.rb'
@@ -218,20 +211,42 @@ Style/ClassVars:
218
211
  - 'lib/ykutils/nkfutil19.rb'
219
212
  - 'lib/ykutils/osutil.rb'
220
213
 
221
- # Offense count: 34
214
+ # Offense count: 1
215
+ # This cop supports unsafe autocorrection (--autocorrect-all).
216
+ Style/CollectionCompact:
217
+ Exclude:
218
+ - 'lib/ykutils/specfileop.rb'
219
+
220
+ # Offense count: 7
221
+ # This cop supports safe autocorrection (--autocorrect).
222
+ Style/ColonMethodCall:
223
+ Exclude:
224
+ - 'bin/erubix'
225
+ - 'bin/makegrid'
226
+ - 'lib/ykutils/gridlist.rb'
227
+ - 'lib/ykutils/nginxconfig.rb'
228
+ - 'spec/ykutils_spec.rb'
229
+
230
+ # Offense count: 38
222
231
  # Configuration parameters: AllowedConstants.
223
232
  Style/Documentation:
224
233
  Enabled: false
225
234
 
235
+ # Offense count: 1
236
+ # This cop supports safe autocorrection (--autocorrect).
237
+ Style/EachWithObject:
238
+ Exclude:
239
+ - 'spec/ykutils_spec.rb'
240
+
226
241
  # Offense count: 2
227
242
  # This cop supports safe autocorrection (--autocorrect).
228
- # Configuration parameters: EnforcedStyle.
243
+ # Configuration parameters: EnforcedStyle, AllowComments.
229
244
  # SupportedStyles: empty, nil, both
230
245
  Style/EmptyElse:
231
246
  Exclude:
232
247
  - 'lib/ykutils/stringutils.rb'
233
248
 
234
- # Offense count: 22
249
+ # Offense count: 26
235
250
  # This cop supports unsafe autocorrection (--autocorrect-all).
236
251
  # Configuration parameters: EnforcedStyle.
237
252
  # SupportedStyles: always, always_true, never
@@ -248,12 +263,28 @@ Style/GlobalVars:
248
263
  # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
249
264
  Style/GuardClause:
250
265
  Exclude:
251
- - 'lib/ykutils/fileoputils2.rb'
266
+ - 'lib/ykutils/fileoputils.rb'
252
267
  - 'lib/ykutils/lines.rb'
253
268
  - 'lib/ykutils/nkfutil.rb'
254
269
  - 'lib/ykutils/stext.rb'
255
270
  - 'lib/ykutils/yamlop.rb'
256
271
 
272
+ # Offense count: 3
273
+ # This cop supports safe autocorrection (--autocorrect).
274
+ # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
275
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
276
+ # SupportedShorthandSyntax: always, never, either, consistent
277
+ Style/HashSyntax:
278
+ Exclude:
279
+ - 'lib/ykutils/gridlist.rb'
280
+
281
+ # Offense count: 2
282
+ # This cop supports safe autocorrection (--autocorrect).
283
+ Style/IfUnlessModifier:
284
+ Exclude:
285
+ - 'lib/ykutils/erubyx.rb'
286
+ - 'lib/ykutils/gridlist.rb'
287
+
257
288
  # Offense count: 1
258
289
  # This cop supports unsafe autocorrection (--autocorrect-all).
259
290
  # Configuration parameters: InverseMethods, InverseBlocks.
@@ -261,9 +292,26 @@ Style/InverseMethods:
261
292
  Exclude:
262
293
  - 'lib/ykutils/specfileop.rb'
263
294
 
295
+ # Offense count: 1
296
+ # This cop supports unsafe autocorrection (--autocorrect-all).
297
+ # Configuration parameters: EnforcedStyle.
298
+ # SupportedStyles: literals, strict
299
+ Style/MutableConstant:
300
+ Exclude:
301
+ - 'lib/ykutils/gridlist.rb'
302
+
303
+ # Offense count: 2
304
+ # This cop supports safe autocorrection (--autocorrect).
305
+ # Configuration parameters: EnforcedStyle, MinBodyLength.
306
+ # SupportedStyles: skip_modifier_ifs, always
307
+ Style/Next:
308
+ Exclude:
309
+ - 'lib/ykutils/nginxconfig.rb'
310
+ - 'lib/ykutils/nginxconfigfiles.rb'
311
+
264
312
  # Offense count: 6
265
313
  # This cop supports unsafe autocorrection (--autocorrect-all).
266
- # Configuration parameters: EnforcedStyle, IgnoredMethods.
314
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns, IgnoredMethods.
267
315
  # SupportedStyles: predicate, comparison
268
316
  Style/NumericPredicate:
269
317
  Exclude:
@@ -283,35 +331,90 @@ Style/OptionalBooleanParameter:
283
331
  - 'lib/ykutils/stextx.rb'
284
332
  - 'lib/ykutils/yamlop.rb'
285
333
 
334
+ # Offense count: 1
335
+ # This cop supports safe autocorrection (--autocorrect).
336
+ # Configuration parameters: PreferredDelimiters.
337
+ Style/PercentLiteralDelimiters:
338
+ Exclude:
339
+ - 'lib/ykutils/gridlist.rb'
340
+
341
+ # Offense count: 1
342
+ # This cop supports unsafe autocorrection (--autocorrect-all).
343
+ # Configuration parameters: Methods.
344
+ Style/RedundantArgument:
345
+ Exclude:
346
+ - 'lib/ykutils/pathop.rb'
347
+
348
+ # Offense count: 2
349
+ # This cop supports unsafe autocorrection (--autocorrect-all).
350
+ # Configuration parameters: AllowComments.
351
+ Style/RedundantInitialize:
352
+ Exclude:
353
+ - 'lib/ykutils/lsutils.rb'
354
+ - 'lib/ykutils/stext.rb'
355
+
356
+ # Offense count: 1
357
+ # This cop supports safe autocorrection (--autocorrect).
358
+ Style/RedundantParentheses:
359
+ Exclude:
360
+ - 'lib/ykutils/debugutils.rb'
361
+
362
+ # Offense count: 1
363
+ # This cop supports safe autocorrection (--autocorrect).
364
+ # Configuration parameters: EnforcedStyle.
365
+ # SupportedStyles: implicit, explicit
366
+ Style/RescueStandardError:
367
+ Exclude:
368
+ - 'lib/ykutils/nkfutil19.rb'
369
+
286
370
  # Offense count: 6
287
371
  # This cop supports unsafe autocorrection (--autocorrect-all).
288
372
  # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
289
373
  # AllowedMethods: present?, blank?, presence, try, try!
290
374
  Style/SafeNavigation:
291
375
  Exclude:
292
- - 'lib/ykutils/fileoputils2.rb'
376
+ - 'lib/ykutils/fileoputils.rb'
293
377
  - 'lib/ykutils/stext.rb'
294
378
  - 'lib/ykutils/treemanager.rb'
295
379
 
380
+ # Offense count: 1
381
+ # This cop supports unsafe autocorrection (--autocorrect-all).
382
+ Style/SelectByRegexp:
383
+ Exclude:
384
+ - 'lib/ykutils/yamlop.rb'
385
+
296
386
  # Offense count: 1
297
387
  # This cop supports unsafe autocorrection (--autocorrect-all).
298
388
  Style/SlicingWithRange:
299
389
  Exclude:
300
- - 'lib/ykutils/fileoputils2.rb'
390
+ - 'lib/ykutils/fileoputils.rb'
301
391
 
302
- # Offense count: 3
392
+ # Offense count: 4
303
393
  # This cop supports unsafe autocorrection (--autocorrect-all).
304
394
  # Configuration parameters: Mode.
305
395
  Style/StringConcatenation:
306
396
  Exclude:
397
+ - 'lib/ykutils.rb'
307
398
  - 'lib/ykutils/stext.rb'
308
399
  - 'lib/ykutils/stringutils.rb'
309
400
  - 'lib/ykutils/yamlop.rb'
310
401
 
402
+ # Offense count: 7
403
+ # This cop supports safe autocorrection (--autocorrect).
404
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
405
+ # SupportedStyles: single_quotes, double_quotes
406
+ Style/StringLiterals:
407
+ Exclude:
408
+ - 'bin/erubix2'
409
+ - 'lib/ykutils.rb'
410
+ - 'lib/ykutils/erubyx.rb'
411
+ - 'lib/ykutils/gridlist.rb'
412
+ - 'lib/ykutils/nginxconfigfiles.rb'
413
+
311
414
  # Offense count: 2
312
415
  # This cop supports unsafe autocorrection (--autocorrect-all).
313
- # Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments.
314
- # IgnoredMethods: respond_to, define_method
416
+ # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, IgnoredMethods, AllowComments.
417
+ # AllowedMethods: respond_to, define_method
315
418
  Style/SymbolProc:
316
419
  Exclude:
317
420
  - 'lib/ykutils/stext.rb'
@@ -323,10 +426,3 @@ Style/ZeroLengthPredicate:
323
426
  Exclude:
324
427
  - 'lib/ykutils/specfileop.rb'
325
428
  - 'lib/ykutils/stext.rb'
326
-
327
- # Offense count: 2
328
- # This cop supports safe autocorrection (--autocorrect).
329
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
330
- # URISchemes: http, https
331
- Layout/LineLength:
332
- Max: 175
data/Gemfile CHANGED
@@ -5,11 +5,19 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in ykutils.gemspec
6
6
  gemspec
7
7
 
8
+ gem "erubi"
9
+ gem "filex"
8
10
  gem "rake", "~> 13.0"
9
-
10
11
  gem "rspec", "~> 3.0"
11
-
12
12
  gem "rubocop", "~> 1.21"
13
-
13
+ gem "rubocop-rake"
14
+ gem "rubocop-rspec"
14
15
  gem "tilt"
15
- gem "erubi"
16
+
17
+ group :development, optional: true do
18
+ gem "yard"
19
+ end
20
+
21
+ # group :test, optional: true do
22
+ #
23
+ # end
data/Gemfile.lock CHANGED
@@ -1,22 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ykutils (0.1.1)
4
+ ykutils (0.1.6)
5
+ erubi
5
6
  filex
7
+ tilt
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
9
11
  specs:
10
12
  ast (2.4.2)
11
13
  diff-lcs (1.5.0)
12
- erubi (1.10.0)
14
+ erubi (1.11.0)
13
15
  erubis (2.7.0)
14
16
  filex (0.1.7)
15
17
  erubis
16
18
  messagex
19
+ json (2.6.2)
17
20
  messagex (0.1.5)
18
21
  parallel (1.22.1)
19
- parser (3.1.2.0)
22
+ parser (3.1.2.1)
20
23
  ast (~> 2.4.1)
21
24
  rainbow (3.1.1)
22
25
  rake (13.0.6)
@@ -35,37 +38,44 @@ GEM
35
38
  diff-lcs (>= 1.2.0, < 2.0)
36
39
  rspec-support (~> 3.11.0)
37
40
  rspec-support (3.11.0)
38
- rubocop (1.30.1)
41
+ rubocop (1.36.0)
42
+ json (~> 2.3)
39
43
  parallel (~> 1.10)
40
- parser (>= 3.1.0.0)
44
+ parser (>= 3.1.2.1)
41
45
  rainbow (>= 2.2.2, < 4.0)
42
46
  regexp_parser (>= 1.8, < 3.0)
43
47
  rexml (>= 3.2.5, < 4.0)
44
- rubocop-ast (>= 1.18.0, < 2.0)
48
+ rubocop-ast (>= 1.20.1, < 2.0)
45
49
  ruby-progressbar (~> 1.7)
46
50
  unicode-display_width (>= 1.4.0, < 3.0)
47
- rubocop-ast (1.18.0)
51
+ rubocop-ast (1.21.0)
48
52
  parser (>= 3.1.1.0)
49
53
  rubocop-rake (0.6.0)
50
54
  rubocop (~> 1.0)
51
- rubocop-rspec (2.11.1)
52
- rubocop (~> 1.19)
55
+ rubocop-rspec (2.12.1)
56
+ rubocop (~> 1.31)
53
57
  ruby-progressbar (1.11.0)
54
- tilt (2.0.10)
55
- unicode-display_width (2.1.0)
58
+ tilt (2.0.11)
59
+ unicode-display_width (2.2.0)
60
+ webrick (1.7.0)
61
+ yard (0.9.28)
62
+ webrick (~> 1.7.0)
56
63
 
57
64
  PLATFORMS
58
- x64-mingw-ucrt
65
+ x64-mingw32
66
+ x86_64-linux
59
67
 
60
68
  DEPENDENCIES
61
69
  erubi
70
+ filex
62
71
  rake (~> 13.0)
63
72
  rspec (~> 3.0)
64
73
  rubocop (~> 1.21)
65
74
  rubocop-rake
66
75
  rubocop-rspec
67
76
  tilt
77
+ yard
68
78
  ykutils!
69
79
 
70
80
  BUNDLED WITH
71
- 2.3.7
81
+ 2.3.9
data/bin/erubix ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ykutils"
6
+
7
+ template_file_path = ARGV[0]
8
+ value_file_path_array = [ARGV[1]]
9
+ ind = 2
10
+ while ARGV.size > ind
11
+ value_file_path_array << ARGV[ind]
12
+ ind += 1
13
+ end
14
+
15
+ scope = nil
16
+ content = Ykutils::Erubyx::erubi_render_with_file(template_file_path, scope, value_file_path_array)
17
+ puts content
data/bin/erubix2 ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ykutils"
6
+ require 'yaml'
7
+ require 'find'
8
+
9
+ ncf = Ykutils::Nginxconfigfiles.new
10
+ re = /base.yml$/
11
+ start_dir = ARGV[0]
12
+ file_list = ncf.get_file_list(start_dir, re)
13
+ ncf.output(file_list)
data/bin/makegrid CHANGED
@@ -11,11 +11,11 @@ require "ykutils"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- #require "irb"
15
- #IRB.start(__FILE__)
16
- #puts( make_grid(1 , 2) )
14
+ # require "irb"
15
+ # IRB.start(__FILE__)
16
+ # puts( make_grid(1 , 2) )
17
17
 
18
- #puts Ykutils::Erubyx::make_grid_list()
18
+ # puts Ykutils::Erubyx::make_grid_list()
19
19
  min_row = ARGV[0].to_i
20
20
  max_row = ARGV[1].to_i
21
21
  min_colum = ARGV[2].to_i
@@ -1,14 +1,52 @@
1
1
  require 'tilt'
2
+ require 'yaml'
2
3
 
3
4
  module Ykutils
4
5
  module Erubyx
5
6
  module_function
6
7
 
7
- def erubi_render(template_hash, scope, value_hash)
8
+ def erubi_render(template_hash, scope, value_hash = {})
8
9
  unless template_hash[:OBJ]
9
- template_hash[:OBJ] = Tilt::ErubiTemplate.new{ template_hash[:TEMPLATE] }
10
+ template_hash[:OBJ] = Tilt::ErubiTemplate.new { template_hash[:TEMPLATE] }
10
11
  end
11
- template_hash[:OBJ].render( scope, value_hash )
12
+ template_hash[:OBJ].render(scope, value_hash)
13
+ end
14
+
15
+ ##
16
+ # `erubi_render_with_file` takes a template file path, a scope, and a value file path, reads the
17
+ # template file, loads the value file, and then calls `erubi_render` with the template hash, scope,
18
+ # and value hash
19
+ #
20
+ # Args:
21
+ # template_file_path: The path to the template file.
22
+ # scope: the scope of the template. This is the name of the directory that the template is in.
23
+ # value_file_path: The path to the YAML file that contains the values to be used in the template.
24
+ def erubi_render_with_file(template_file_path, scope, value_file_path_array)
25
+ template_text = File.read(template_file_path)
26
+ template_hash = { TEMPLATE: template_text,
27
+ OBJ: nil }
28
+ value_hash = value_file_path_array.reduce({}) { |hash, path|
29
+ # p path
30
+ hash0 = YAML.load_file(path)
31
+ # p hash0
32
+ hash = hash.merge(hash0)
33
+ # p hash
34
+ hash
35
+ }
36
+ # puts value_hash
37
+ erubi_render(template_hash, scope, value_hash)
38
+ end
39
+
40
+ def erubi_render_with_template_file(template_file_path, scope, value_hash = {})
41
+ template_text = File.read(template_file_path)
42
+ template_hash = make_template_hash(template_text)
43
+ # puts value_hash
44
+ erubi_render(template_hash, scope, value_hash)
45
+ end
46
+
47
+ def make_template_hash(text)
48
+ { TEMPLATE: text,
49
+ OBJ: nil }
12
50
  end
13
51
  end
14
52
  end