ykutils 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +2 -0
- data/.gitignore +3 -0
- data/.rubocop_todo.yml +15 -377
- data/Gemfile +7 -8
- data/Gemfile.lock +49 -39
- data/Rakefile +25 -8
- data/SECURITY.md +21 -0
- data/bin/console +0 -0
- data/bin/erubix +1 -1
- data/bin/erubix2 +2 -2
- data/bin/makegrid +1 -1
- data/lib/ykutils/debugutils.rb +32 -42
- data/lib/ykutils/erubyx.rb +5 -7
- data/lib/ykutils/fileoputils.rb +53 -53
- data/lib/ykutils/filepermision.rb +1 -1
- data/lib/ykutils/gridlist.rb +9 -12
- data/lib/ykutils/hasharray.rb +1 -5
- data/lib/ykutils/lines.rb +14 -12
- data/lib/ykutils/lsutils.rb +3 -5
- data/lib/ykutils/nginxconfig.rb +12 -12
- data/lib/ykutils/nginxconfigfiles.rb +10 -12
- data/lib/ykutils/nkfutil.rb +20 -20
- data/lib/ykutils/nkfutil19.rb +16 -16
- data/lib/ykutils/osutil.rb +7 -7
- data/lib/ykutils/pathop.rb +4 -3
- data/lib/ykutils/retcodex.rb +2 -17
- data/lib/ykutils/specfileop.rb +8 -10
- data/lib/ykutils/stext.rb +53 -69
- data/lib/ykutils/stextx.rb +12 -12
- data/lib/ykutils/stringutils.rb +12 -12
- data/lib/ykutils/treemanager.rb +1 -1
- data/lib/ykutils/treemanagera.rb +2 -2
- data/lib/ykutils/version.rb +1 -1
- data/lib/ykutils/yamlop.rb +30 -31
- data/lib/ykutils/yamlxop.rb +0 -5
- data/lib/ykutils.rb +4 -1
- data/ykutils.gemspec +1 -0
- metadata +5 -3
data/SECURITY.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
Use this section to tell people about which versions of your project are
|
6
|
+
currently being supported with security updates.
|
7
|
+
|
8
|
+
| Version | Supported |
|
9
|
+
| ------- | ------------------ |
|
10
|
+
| 5.1.x | :white_check_mark: |
|
11
|
+
| 5.0.x | :x: |
|
12
|
+
| 4.0.x | :white_check_mark: |
|
13
|
+
| < 4.0 | :x: |
|
14
|
+
|
15
|
+
## Reporting a Vulnerability
|
16
|
+
|
17
|
+
Use this section to tell people how to report a vulnerability.
|
18
|
+
|
19
|
+
Tell them where to go, how often they can expect to get an update on a
|
20
|
+
reported vulnerability, what to expect if the vulnerability is accepted or
|
21
|
+
declined, etc.
|
data/bin/console
CHANGED
File without changes
|
data/bin/erubix
CHANGED
@@ -13,5 +13,5 @@ while ARGV.size > ind
|
|
13
13
|
end
|
14
14
|
|
15
15
|
scope = nil
|
16
|
-
content = Ykutils::Erubyx
|
16
|
+
content = Ykutils::Erubyx.erubi_render_with_file(template_file_path, scope, value_file_path_array)
|
17
17
|
puts content
|
data/bin/erubix2
CHANGED
data/bin/makegrid
CHANGED
@@ -20,4 +20,4 @@ min_row = ARGV[0].to_i
|
|
20
20
|
max_row = ARGV[1].to_i
|
21
21
|
min_colum = ARGV[2].to_i
|
22
22
|
max_colum = ARGV[3].to_i
|
23
|
-
puts Ykutils::Gridlist
|
23
|
+
puts Ykutils::Gridlist.make_grid_list_x(min_row, max_row, min_colum, max_colum)
|
data/lib/ykutils/debugutils.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "pp"
|
2
|
-
|
3
1
|
module Ykutils
|
4
2
|
module DebugUtils
|
5
3
|
class DebugMes
|
@@ -7,25 +5,17 @@ module Ykutils
|
|
7
5
|
@warn = false
|
8
6
|
@buf = []
|
9
7
|
|
10
|
-
def self.init(debug
|
8
|
+
def self.init(debug: false)
|
11
9
|
@debug = debug
|
12
10
|
@buf = []
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.get_debug
|
20
|
-
@debug
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.set_warn(warn)
|
24
|
-
@warn = warn
|
13
|
+
class << self
|
14
|
+
attr_accessor :debug
|
25
15
|
end
|
26
16
|
|
27
|
-
|
28
|
-
|
17
|
+
class << self
|
18
|
+
attr_accessor :warn
|
29
19
|
end
|
30
20
|
|
31
21
|
def self.puts_x(mes)
|
@@ -50,43 +40,43 @@ module Ykutils
|
|
50
40
|
# puts mes
|
51
41
|
end
|
52
42
|
|
53
|
-
def
|
43
|
+
def d
|
54
44
|
self.class.get
|
55
45
|
end
|
56
46
|
|
57
47
|
def puts_current_method
|
58
|
-
d_puts
|
48
|
+
d_puts caller(1)[0].split[-1]
|
59
49
|
end
|
60
50
|
|
61
|
-
def error_exit(
|
62
|
-
puts "error(#{
|
51
|
+
def error_exit(num)
|
52
|
+
puts "error(#{num})"
|
63
53
|
pp caller(0)
|
64
54
|
exit(n)
|
65
55
|
end
|
66
56
|
|
67
57
|
def debug_utils_init
|
68
|
-
|
58
|
+
debug(false)
|
69
59
|
set_warn(0)
|
70
60
|
|
71
61
|
Ykutils::DebugUtils::DebugMes.init(false)
|
72
62
|
end
|
73
63
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
end
|
64
|
+
# def debug(val)
|
65
|
+
# # self.class.set_debug(val)
|
66
|
+
# Ykutils::DebugUtils::DebugMes.debug(val)
|
67
|
+
# end
|
78
68
|
|
79
|
-
def
|
80
|
-
|
81
|
-
end
|
69
|
+
# def debug
|
70
|
+
# Ykutils::DebugUtils::DebugMes.get_debug
|
71
|
+
# end
|
82
72
|
|
83
|
-
def
|
84
|
-
|
85
|
-
end
|
73
|
+
# def warn(val)
|
74
|
+
# Ykutils::DebugUtils::DebugMes.set_warn(val)
|
75
|
+
# end
|
86
76
|
|
87
|
-
def
|
88
|
-
|
89
|
-
end
|
77
|
+
# def warn
|
78
|
+
# Ykutils::DebugUtils::DebugMes..get_warn
|
79
|
+
# end
|
90
80
|
|
91
81
|
def d_exit(num)
|
92
82
|
exit(num) if get_debug
|
@@ -98,12 +88,12 @@ module Ykutils
|
|
98
88
|
|
99
89
|
def w1_puts(str)
|
100
90
|
set_warn(0) unless get_warn
|
101
|
-
puts(str) if get_debug
|
91
|
+
puts(str) if get_debug || (get_warn >= 1)
|
102
92
|
end
|
103
93
|
|
104
94
|
def w2_puts(str)
|
105
95
|
set_warn(0) unless get_warn
|
106
|
-
puts(str) if get_debug
|
96
|
+
puts(str) if get_debug || (get_warn >= 2)
|
107
97
|
end
|
108
98
|
|
109
99
|
def d_caller(_num)
|
@@ -115,20 +105,20 @@ module Ykutils
|
|
115
105
|
end
|
116
106
|
|
117
107
|
def d_puts_no_empty(mes)
|
118
|
-
puts mes if mes != ""
|
108
|
+
puts mes if (mes != "") && get_debug
|
119
109
|
end
|
120
110
|
|
121
|
-
def d_p(
|
122
|
-
p
|
111
|
+
def d_p(mes)
|
112
|
+
p mes if get_debug
|
123
113
|
end
|
124
114
|
|
125
|
-
def d_pp(
|
126
|
-
if
|
127
|
-
pp "debug=#{
|
115
|
+
def d_pp(mes)
|
116
|
+
if debug
|
117
|
+
pp "debug=#{debug}"
|
128
118
|
pp caller(0)
|
129
119
|
exit
|
130
120
|
end
|
131
|
-
pp
|
121
|
+
pp mes if get_debug
|
132
122
|
end
|
133
123
|
end
|
134
124
|
end
|
data/lib/ykutils/erubyx.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "tilt"
|
2
|
+
require "yaml"
|
3
3
|
|
4
4
|
module Ykutils
|
5
5
|
module Erubyx
|
6
6
|
module_function
|
7
7
|
|
8
8
|
def erubi_render(template_hash, scope, value_hash = {})
|
9
|
-
unless template_hash[:OBJ]
|
10
|
-
template_hash[:OBJ] = Tilt::ErubiTemplate.new { template_hash[:TEMPLATE] }
|
11
|
-
end
|
9
|
+
template_hash[:OBJ] = Tilt::ErubiTemplate.new { template_hash[:TEMPLATE] } unless template_hash[:OBJ]
|
12
10
|
template_hash[:OBJ].render(scope, value_hash)
|
13
11
|
end
|
14
12
|
|
@@ -25,14 +23,14 @@ module Ykutils
|
|
25
23
|
template_text = File.read(template_file_path)
|
26
24
|
template_hash = { TEMPLATE: template_text,
|
27
25
|
OBJ: nil }
|
28
|
-
value_hash = value_file_path_array.reduce({})
|
26
|
+
value_hash = value_file_path_array.reduce({}) do |hash, path|
|
29
27
|
# p path
|
30
28
|
hash0 = YAML.load_file(path)
|
31
29
|
# p hash0
|
32
30
|
hash = hash.merge(hash0)
|
33
31
|
# p hash
|
34
32
|
hash
|
35
|
-
|
33
|
+
end
|
36
34
|
# puts value_hash
|
37
35
|
erubi_render(template_hash, scope, value_hash)
|
38
36
|
end
|
data/lib/ykutils/fileoputils.rb
CHANGED
@@ -84,7 +84,7 @@ module Ykutils
|
|
84
84
|
|
85
85
|
def valid_readable_fname?(fname)
|
86
86
|
ret = false
|
87
|
-
ret = true if normal_string?(fname)
|
87
|
+
ret = true if normal_string?(fname) && File.file?(fname) && File.readable?(fname)
|
88
88
|
ret
|
89
89
|
end
|
90
90
|
|
@@ -130,7 +130,7 @@ module Ykutils
|
|
130
130
|
ret = true if File.writable?(fname)
|
131
131
|
else
|
132
132
|
unless File.directory?(fname)
|
133
|
-
dir,
|
133
|
+
dir, = File.split(fname)
|
134
134
|
ret = valid_writable_directory?(dir)
|
135
135
|
end
|
136
136
|
end
|
@@ -164,33 +164,33 @@ module Ykutils
|
|
164
164
|
pp e.traceback
|
165
165
|
@valid = false
|
166
166
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
167
|
+
return unless @valid
|
168
|
+
|
169
|
+
content = ary.join("\n")
|
170
|
+
begin
|
171
|
+
output_file.write(content)
|
172
|
+
rescue StandardError => e
|
173
|
+
pp e
|
174
|
+
pp e.traceback
|
175
|
+
@valid = false
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
def rewrite_file(
|
179
|
+
def rewrite_file(from_path1, from_path2, to_path1, to_path2)
|
180
180
|
d_p("rewrite_file")
|
181
|
-
d_p("from_path_1=#{
|
182
|
-
d_p("from_path_2=#{
|
183
|
-
d_p("to_path_1=#{
|
184
|
-
d_p("to_path_2=#{
|
181
|
+
d_p("from_path_1=#{from_path1}")
|
182
|
+
d_p("from_path_2=#{from_path2}")
|
183
|
+
d_p("to_path_1=#{to_path1}")
|
184
|
+
d_p("to_path_2=#{to_path2}")
|
185
185
|
|
186
|
-
mes = prepare_file_copy(
|
186
|
+
mes = prepare_file_copy(from_path1, from_path2, to_path1, to_path2)
|
187
187
|
|
188
188
|
puts_no_empty(mes)
|
189
189
|
|
190
190
|
return false unless @valid
|
191
191
|
|
192
|
-
from_path = File.join(
|
193
|
-
to_path = File.join(
|
192
|
+
from_path = File.join(from_path1, from_path2)
|
193
|
+
to_path = File.join(to_path1, to_path2)
|
194
194
|
ary = []
|
195
195
|
begin
|
196
196
|
File.open(from_path, "r") do |file|
|
@@ -218,66 +218,66 @@ module Ykutils
|
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
221
|
-
def prepare_file_copy(
|
221
|
+
def prepare_file_copy(from_path1, from_path2, to_path1, to_path2)
|
222
222
|
mes = ""
|
223
223
|
|
224
224
|
d_p("prepare_file_copy")
|
225
|
-
d_p("from_path_1=#{
|
226
|
-
d_p("from_path_2=#{
|
227
|
-
d_p("to_path_1=#{
|
228
|
-
d_p("to_path_2=#{
|
229
|
-
|
230
|
-
if prepare_source_dir(
|
231
|
-
unless prepare_dest_dir(
|
232
|
-
mes = "Can't write #{
|
225
|
+
d_p("from_path_1=#{from_path1}")
|
226
|
+
d_p("from_path_2=#{from_path2}")
|
227
|
+
d_p("to_path_1=#{to_path1}")
|
228
|
+
d_p("to_path_2=#{to_path2}")
|
229
|
+
|
230
|
+
if prepare_source_dir(from_path1, from_path2)
|
231
|
+
unless prepare_dest_dir(to_path1, to_path2)
|
232
|
+
mes = "Can't write #{to_path1}/#{to_path1}"
|
233
233
|
d_caller(0)
|
234
234
|
@valid = false
|
235
235
|
end
|
236
236
|
else
|
237
|
-
mes = "Can't read #{
|
237
|
+
mes = "Can't read #{from_path1}/#{from_path2}"
|
238
238
|
@valid = false
|
239
239
|
end
|
240
240
|
|
241
241
|
mes
|
242
242
|
end
|
243
243
|
|
244
|
-
def prepare_source_dir(
|
244
|
+
def prepare_source_dir(from_path1, from_path2)
|
245
245
|
state = false
|
246
|
-
from_path = File.join(
|
247
|
-
if valid_readable_directory?(
|
248
|
-
dirname,
|
246
|
+
from_path = File.join(from_path1, from_path2)
|
247
|
+
if valid_readable_directory?(from_path1)
|
248
|
+
dirname, = File.split(from_path)
|
249
249
|
state = true if valid_readable_directory?(dirname) && valid_readable_fname?(from_path)
|
250
250
|
end
|
251
251
|
state
|
252
252
|
end
|
253
253
|
|
254
|
-
def prepare_dest_dir(
|
254
|
+
def prepare_dest_dir(to_path1, to_path2)
|
255
255
|
state = true
|
256
|
-
unless valid_writable_directory?(
|
257
|
-
if File.exist?(
|
256
|
+
unless valid_writable_directory?(to_path1)
|
257
|
+
if File.exist?(to_path1)
|
258
258
|
d_caller(0)
|
259
259
|
return false
|
260
260
|
end
|
261
261
|
|
262
262
|
begin
|
263
|
-
FileUtils.mkdir_p(
|
263
|
+
FileUtils.mkdir_p(to_path1)
|
264
264
|
rescue StandardError => e
|
265
265
|
state = false
|
266
266
|
pp e
|
267
267
|
pp e.traceback
|
268
268
|
end
|
269
269
|
end
|
270
|
-
unless valid_writable_directory?(
|
270
|
+
unless valid_writable_directory?(to_path1)
|
271
271
|
d_caller(0)
|
272
272
|
return false
|
273
273
|
end
|
274
274
|
|
275
|
-
to_path = File.join(
|
276
|
-
dirname,
|
275
|
+
to_path = File.join(to_path1, to_path2)
|
276
|
+
dirname, = File.split(to_path)
|
277
277
|
unless File.exist?(dirname)
|
278
278
|
begin
|
279
279
|
FileUtils.mkdir_p(dirname)
|
280
|
-
rescue StandardError
|
280
|
+
rescue StandardError
|
281
281
|
state = false
|
282
282
|
pp caller(0)
|
283
283
|
end
|
@@ -301,22 +301,22 @@ module Ykutils
|
|
301
301
|
true
|
302
302
|
end
|
303
303
|
|
304
|
-
def copy_file(
|
304
|
+
def copy_file(from_path1, from_path2, to_path1, to_path2)
|
305
305
|
retry_flag = false
|
306
306
|
begin
|
307
|
-
from_path = File.join(
|
308
|
-
to_path = File.join(
|
307
|
+
from_path = File.join(from_path1, from_path2)
|
308
|
+
to_path = File.join(to_path1, to_path2)
|
309
309
|
FileUtils.cp(from_path, to_path)
|
310
310
|
d_puts("Copy #{from_path} -> #{to_path}")
|
311
|
-
rescue StandardError
|
312
|
-
retry_flag = prepare_file_copy(
|
311
|
+
rescue StandardError
|
312
|
+
retry_flag = prepare_file_copy(from_path1, from_path2, to_path1, to_path2)
|
313
313
|
end
|
314
314
|
|
315
315
|
if retry_flag
|
316
316
|
begin
|
317
317
|
FileUtils.cp(from_path, to_path)
|
318
318
|
d_puts("Copy #{from_path} -> #{to_path}")
|
319
|
-
rescue StandardError
|
319
|
+
rescue StandardError
|
320
320
|
@valid = false
|
321
321
|
end
|
322
322
|
end
|
@@ -331,8 +331,8 @@ module Ykutils
|
|
331
331
|
d_p(ary)
|
332
332
|
d_p(left)
|
333
333
|
if left
|
334
|
-
sub_ary = ary[(left + 1)
|
335
|
-
ret = true if sub_ary
|
334
|
+
sub_ary = ary[(left + 1)..]
|
335
|
+
ret = true if sub_ary&.index(filename)
|
336
336
|
end
|
337
337
|
|
338
338
|
ret
|
@@ -376,20 +376,20 @@ module Ykutils
|
|
376
376
|
dirname.join(basename.to_s + add_string + extname.to_s)
|
377
377
|
end
|
378
378
|
|
379
|
-
def determine_encoding(
|
379
|
+
def determine_encoding(pathn)
|
380
380
|
encodings = [Encoding::UTF_8, Encoding::EUC_JP, Encoding::Shift_JIS, Encoding::CP932]
|
381
381
|
|
382
382
|
valid_enc = nil
|
383
383
|
encodings.each do |enc|
|
384
384
|
next if valid_enc
|
385
385
|
|
386
|
-
s =
|
386
|
+
s = pathn.expand_path.read(encoding: enc)
|
387
387
|
next unless s.valid_encoding?
|
388
388
|
|
389
389
|
begin
|
390
|
-
|
390
|
+
s.encode(Encoding::CP932)
|
391
391
|
valid_enc = enc
|
392
|
-
rescue StandardError
|
392
|
+
rescue StandardError
|
393
393
|
# puts "Conversion Error! #{y}"
|
394
394
|
# puts y
|
395
395
|
end
|
data/lib/ykutils/gridlist.rb
CHANGED
@@ -1,37 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require "ykutils/erubyx"
|
2
2
|
|
3
3
|
module Ykutils
|
4
4
|
module Gridlist
|
5
|
-
TAMPLETES = { :
|
6
|
-
{ :TEMPLATE => %!
|
5
|
+
TAMPLETES = { GRID_DEF: { TEMPLATE: %(
|
7
6
|
.g-<%= row %>-<%= colum %> {
|
8
7
|
grid-row-start: <%= row %>;
|
9
8
|
grid-row-end: ,<%= row + 1 %>;
|
10
9
|
grid-column-start: <%= colum %>;
|
11
10
|
grid-column-end: <%= colum + 1 %>;
|
12
11
|
}
|
13
|
-
|
12
|
+
), OBJ: nil } }.freeze
|
14
13
|
|
15
14
|
module_function
|
16
15
|
|
17
16
|
def make_one_grid(hash, row, colum)
|
18
|
-
unless hash[:OBJ]
|
19
|
-
hash[:OBJ] = Tilt::ErubiTemplate.new { hash[:TEMPLATE] }
|
20
|
-
end
|
17
|
+
hash[:OBJ] = Tilt::ErubiTemplate.new { hash[:TEMPLATE] } unless hash[:OBJ]
|
21
18
|
hash[:OBJ].render(Object.new, { row: row, colum: colum })
|
22
19
|
end
|
23
20
|
|
24
21
|
def make_grid(template_hash, scope, min_row, max_row, min_colum, max_colum)
|
25
|
-
(min_row..max_row).map
|
26
|
-
(min_colum..max_colum).map
|
22
|
+
(min_row..max_row).map do |row|
|
23
|
+
(min_colum..max_colum).map do |colum|
|
27
24
|
# puts "#{row} #{colum}"
|
28
25
|
value_hash = { row: row, colum: colum }
|
29
26
|
# make_one_grid(template_hash, value_hash)
|
30
27
|
# p template_hash
|
31
28
|
# p value_hash
|
32
|
-
Ykutils::Erubyx
|
33
|
-
|
34
|
-
|
29
|
+
Ykutils::Erubyx.erubi_render(template_hash, scope, value_hash)
|
30
|
+
end
|
31
|
+
end
|
35
32
|
end
|
36
33
|
|
37
34
|
def make_grid_list(min_row, max_row, min_colum, max_colum)
|
data/lib/ykutils/hasharray.rb
CHANGED
@@ -34,7 +34,7 @@ module Ykutils
|
|
34
34
|
def replace(*args)
|
35
35
|
super(*args)
|
36
36
|
@ary = super.keys
|
37
|
-
@
|
37
|
+
@replace ||= []
|
38
38
|
end
|
39
39
|
|
40
40
|
def delete(ind, &block)
|
@@ -50,9 +50,5 @@ module Ykutils
|
|
50
50
|
|
51
51
|
super
|
52
52
|
end
|
53
|
-
|
54
|
-
def reject(&block)
|
55
|
-
super
|
56
|
-
end
|
57
53
|
end
|
58
54
|
end
|
data/lib/ykutils/lines.rb
CHANGED
@@ -4,7 +4,7 @@ module Ykutils
|
|
4
4
|
@line_ary = line_ary
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def line
|
8
8
|
@line_ary.shift if @line_ary.size > -1
|
9
9
|
end
|
10
10
|
end
|
@@ -20,16 +20,16 @@ module Ykutils
|
|
20
20
|
|
21
21
|
def setup; end
|
22
22
|
|
23
|
-
def
|
23
|
+
def line
|
24
24
|
@line_stack.shift if @line_stack.size > -1
|
25
25
|
end
|
26
26
|
|
27
27
|
def output_f(fname)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
return unless fname
|
29
|
+
|
30
|
+
File.open(fname, "w") do |file|
|
31
|
+
@line_stack.each do |it|
|
32
|
+
file.write(it.to_s)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -50,10 +50,11 @@ module Ykutils
|
|
50
50
|
ETC = 100
|
51
51
|
|
52
52
|
def setup
|
53
|
-
while (line = @lines.
|
53
|
+
while (line = @lines.line)
|
54
54
|
next if line.strip == ""
|
55
55
|
|
56
|
-
|
56
|
+
case line
|
57
|
+
when /^---/
|
57
58
|
case @status
|
58
59
|
when HOST_ACCOUNT_START, HOST_ACCOUNT
|
59
60
|
@line_stack.push({ "STATUS" => HOST_ACCOUNT_END,
|
@@ -66,7 +67,7 @@ module Ykutils
|
|
66
67
|
@line_stack.push({ "STATUS" => SEPARATOR,
|
67
68
|
"CONTENT" => line })
|
68
69
|
@status = SEPARATOR
|
69
|
-
|
70
|
+
when /^\s/
|
70
71
|
case @status
|
71
72
|
when HOST_ACCOUNT_START, HOST_ACCOUNT
|
72
73
|
@line_stack.push({ "STATUS" => HOST_ACCOUNT,
|
@@ -93,7 +94,7 @@ module Ykutils
|
|
93
94
|
"CONTENT" => line })
|
94
95
|
@status = ETC
|
95
96
|
end
|
96
|
-
|
97
|
+
when /^==/
|
97
98
|
case @status
|
98
99
|
when HOST_ACCOUNT_START, HOST_ACCOUNT
|
99
100
|
@line_stack.push({ "STATUS" => HOST_ACCOUNT_END,
|
@@ -122,7 +123,7 @@ module Ykutils
|
|
122
123
|
|
123
124
|
i = @line_stack.size - 1
|
124
125
|
seeking = true
|
125
|
-
while i >= 0
|
126
|
+
while (i >= 0) && seeking
|
126
127
|
case @line_stack[i]["STATUS"]
|
127
128
|
when DOMAIN_ACCOUNT_START, DOMAIN_ACCOUNT
|
128
129
|
@line_stack.push({ "STATUS" => DOMAIN_ACCOUNT_END,
|
@@ -133,6 +134,7 @@ module Ykutils
|
|
133
134
|
"CONTENT" => nil })
|
134
135
|
seeking = false
|
135
136
|
when ETC
|
137
|
+
seeking = true
|
136
138
|
else
|
137
139
|
seeking = false
|
138
140
|
end
|
data/lib/ykutils/lsutils.rb
CHANGED
@@ -5,9 +5,7 @@ module Ykytils
|
|
5
5
|
class DirEntryItem
|
6
6
|
attr_accessor :name, :user, :group, :size, :month, :day, :time, :year, :path, :type, :parent_dir, :valid
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
def parse(str, parent_dir, valid = true)
|
8
|
+
def parse(str, parent_dir, valid: true)
|
11
9
|
ary = str.split(/\s+/)
|
12
10
|
perm = ary[0]
|
13
11
|
@type = if perm[0].chr == "d"
|
@@ -49,11 +47,11 @@ module Ykytils
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def directory?
|
52
|
-
@type
|
50
|
+
@type == :DIRECTORY
|
53
51
|
end
|
54
52
|
|
55
53
|
def file?
|
56
|
-
@type
|
54
|
+
@type == :FILE
|
57
55
|
end
|
58
56
|
|
59
57
|
def owner_perm
|
data/lib/ykutils/nginxconfig.rb
CHANGED
@@ -18,23 +18,23 @@ module Ykutils
|
|
18
18
|
def extract(scope)
|
19
19
|
hashx = {}
|
20
20
|
@hash.each do |k, v|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
hashx[k] = Ykutils::Erubyx::erubi_render_with_file(template_pn, scope, value_file_path_array)
|
21
|
+
next unless k !~ /^_/
|
22
|
+
|
23
|
+
# puts k
|
24
|
+
# puts v
|
25
|
+
pn = Pathname.new(v["template"]).cleanpath
|
26
|
+
# Pathname.new(v).cleanpath
|
27
|
+
template_pn = @server_dir_pn + pn
|
28
|
+
# puts(template_pn)
|
29
|
+
value_file_path_array = v["value"].map do |x|
|
30
|
+
@virtual_domain_dir_pn + Pathname.new(x).cleanpath
|
32
31
|
end
|
32
|
+
hashx[k] = Ykutils::Erubyx.erubi_render_with_file(template_pn, scope, value_file_path_array)
|
33
33
|
end
|
34
34
|
template = File.read(@root_template_pn)
|
35
35
|
template_hash = { TEMPLATE: template,
|
36
36
|
OBJ: nil }
|
37
|
-
Ykutils::Erubyx
|
37
|
+
Ykutils::Erubyx.erubi_render(template_hash, scope, hashx)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|