ykutils 0.1.4 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/.rubocop.yml +2 -1
  4. data/.rubocop_todo.yml +181 -85
  5. data/Gemfile +11 -11
  6. data/Gemfile.lock +17 -12
  7. data/bin/erubix +1 -1
  8. data/bin/makegrid +4 -4
  9. data/lib/ykutils/debugutils.rb +44 -32
  10. data/lib/ykutils/erubyx.rb +30 -19
  11. data/lib/ykutils/fileoputils.rb +2 -2
  12. data/lib/ykutils/gridlist.rb +49 -49
  13. data/lib/ykutils/lines.rb +143 -143
  14. data/lib/ykutils/lsutils.rb +71 -71
  15. data/lib/ykutils/nginxconfig.rb +40 -41
  16. data/lib/ykutils/nginxconfigfiles.rb +31 -31
  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/test_data/4servers.erb +7 -7
  31. data/test_data/a.bat +5 -5
  32. data/test_data/a_ncn.bat +12 -12
  33. data/test_data/v103-3-189-127/a.northern-cross.net/base.yml +28 -28
  34. data/test_data/v103-3-189-127/a.northern-cross.net/value_host.yml +1 -1
  35. data/test_data/v103-3-189-127/b.northern-cross.net/base.yml +28 -28
  36. data/test_data/v103-3-189-127/b.northern-cross.net/value_host.yml +1 -1
  37. data/test_data/v103-3-189-127/c.northern-cross.net/base.yml +28 -28
  38. data/test_data/v103-3-189-127/c.northern-cross.net/value_host.yml +1 -1
  39. data/test_data/v103-3-189-127/d.northern-cross.info/base.yml +28 -28
  40. data/test_data/v103-3-189-127/d.northern-cross.info/value_host.yml +1 -1
  41. data/test_data/v103-3-189-127/d.northern-cross.net/base.yml +28 -28
  42. data/test_data/v103-3-189-127/d.northern-cross.net/value_host.yml +1 -1
  43. data/test_data/v103-3-189-127/e.northern-cross.info/base.yml +28 -28
  44. data/test_data/v103-3-189-127/e.northern-cross.info/value_host.yml +1 -1
  45. data/test_data/v103-3-189-127/e.northern-cross.net/base.yml +28 -28
  46. data/test_data/v103-3-189-127/e.northern-cross.net/value_host.yml +1 -1
  47. data/test_data/v103-3-189-127/f.northern-cross.info/base.yml +28 -28
  48. data/test_data/v103-3-189-127/f.northern-cross.info/value_host.yml +1 -1
  49. data/test_data/v103-3-189-127/f.northern-cross.net/base.yml +28 -28
  50. data/test_data/v103-3-189-127/f.northern-cross.net/value_host.yml +1 -1
  51. data/test_data/v103-3-189-127/t_server_1.erb +7 -7
  52. data/test_data/v103-3-189-127/template.erb +21 -21
  53. data/test_data/v103-3-189-127/template_ssl.erb +22 -22
  54. data/test_data/v103-3-189-127/template_ssl_www.erb +12 -12
  55. data/test_data/v103-3-189-127/template_www.erb +24 -24
  56. data/test_data/v103-3-189-127/value.yml +3 -3
  57. data/test_data/v103-3-189-127/value_ssl.yml +5 -5
  58. data/ykutils.gemspec +45 -43
  59. metadata +8 -9
  60. data/_config.yml +0 -1
@@ -1,32 +1,32 @@
1
- require "ykutils/debugutils"
2
- require "ykutils/stext"
3
- require "ykutils/xlines"
4
-
5
- module Ykutils
6
- class StructuredTextForX < StructuredText
7
- include DebugUtils
8
-
9
- def initialize(debug = false)
10
- super()
11
-
12
- debug_utils_init
13
- set_debug(debug)
14
- ends
15
-
16
- def analyze(line_ary, _fname = nil)
17
- lines = XLines.new(line_ary)
18
- # lines.output_f( fname )
19
-
20
- analyze_sub(lines)
21
- end
22
-
23
- def analyze_sub(lines)
24
- puts_current_method
25
-
26
- while line = lines.get_line
27
- # p line
28
- end
29
- end
30
- end
31
- end
32
- end
1
+ require "ykutils/debugutils"
2
+ require "ykutils/stext"
3
+ require "ykutils/xlines"
4
+
5
+ module Ykutils
6
+ class StructuredTextForX < StructuredText
7
+ include DebugUtils
8
+
9
+ def initialize(debug = false)
10
+ super()
11
+
12
+ debug_utils_init
13
+ set_debug(debug)
14
+ ends
15
+
16
+ def analyze(line_ary, _fname = nil)
17
+ lines = XLines.new(line_ary)
18
+ # lines.output_f( fname )
19
+
20
+ analyze_sub(lines)
21
+ end
22
+
23
+ def analyze_sub(lines)
24
+ puts_current_method
25
+
26
+ while (line = lines.get_line)
27
+ # p line
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,111 +1,111 @@
1
- module Ykutils
2
- module StringUtils
3
- def nil_to_nullstring(str)
4
- str || ""
5
- end
6
-
7
- def get_basename_ext(it)
8
- bn0 = it.basename.to_s
9
- if RUBY_VERSION > "1.9"
10
- # bn0.encode!( "internal" )
11
- bn0.encode! "UTF-8"
12
- end
13
- list = bn0.split(".")
14
- case list.size
15
- when 0
16
- bname = ""
17
- ext = ""
18
- when 1
19
- bname = list[0]
20
- ext = ""
21
- when 2
22
- bname = list[0]
23
- ext = list[1]
24
- else
25
- bname_size = list.size - 1
26
- bname = list[0, bname_size].join(".")
27
- ext = list[-1]
28
- end
29
- [bname, ext]
30
- end
31
-
32
- def normal_string?(str)
33
- ret = false
34
- if str
35
- s = str.strip
36
- ret = true if s != "" && (s =~ %r{^[0-9A-Za-z_:./\-]+$})
37
- end
38
- ret
39
- end
40
-
41
- def get_normalized_string(str)
42
- ret = ""
43
- ret = str.strip if str
44
- ret
45
- end
46
-
47
- def make_content_from_template(template_ary, tag_value_hash, separator)
48
- content_ary = []
49
-
50
- reg_hash = {}
51
- tag_value_hash.each do |k, _v|
52
- reg_hash[k] = Regexp.new(separator + k + separator)
53
- end
54
-
55
- template_ary.each do |line|
56
- reg_hash.each do |k, v|
57
- line = line.sub(v, tag_value_hash[k])
58
- end
59
- content_ary << line
60
- end
61
- content_ary
62
- end
63
-
64
- def indent(n)
65
- n ||= 0
66
- @indent_hash ||= {}
67
- @indent_hash[n] ||= " " * n
68
- @indent_hash[n]
69
- end
70
-
71
- def print_hier(data, level)
72
- case data.class.to_s
73
- when "Hash"
74
- data.each do |_k, v|
75
- # puts "#{indent(level)}#{k}|#{v.class} #{if v.class.to_s == 'String' then v.size else '' end }"
76
- # puts "#{indent(level)}#{k}|#{v.class}"
77
- print_hier(v, level + 1)
78
- end
79
- when "Array"
80
- data.each do |v|
81
- print_hier(v, level + 1)
82
- end
83
- else
84
- # puts "#{indent(level)}|#{data.class}"
85
- end
86
- end
87
-
88
- def print_hier_2(data, level)
89
- case data.class.to_s
90
- when "Hash"
91
- data.each do |k, v|
92
- # puts "#{indent(level)}#{k}|#{v.class} #{if v.class.to_s == 'String' then v.size else '' end }"
93
- str = "#{indent(level)}#{k}|#{v.class}"
94
- if v.instance_of?(Array)
95
- num = v.size
96
- str += ("|" + num.to_s)
97
- str += "###################" if num > 1
98
- end
99
- # puts str
100
- print_hier_2(v, level + 1) if k != "group"
101
- end
102
- when "Array"
103
- data.each do |v|
104
- print_hier_2(v, level + 1)
105
- end
106
- else
107
- # puts "#{indent(level)}|#{data.class}"
108
- end
109
- end
110
- end
111
- end
1
+ module Ykutils
2
+ module StringUtils
3
+ def nil_to_nullstring(str)
4
+ str || ""
5
+ end
6
+
7
+ def get_basename_ext(it)
8
+ bn0 = it.basename.to_s
9
+ if RUBY_VERSION > "1.9"
10
+ # bn0.encode!( "internal" )
11
+ bn0.encode! "UTF-8"
12
+ end
13
+ list = bn0.split(".")
14
+ case list.size
15
+ when 0
16
+ bname = ""
17
+ ext = ""
18
+ when 1
19
+ bname = list[0]
20
+ ext = ""
21
+ when 2
22
+ bname = list[0]
23
+ ext = list[1]
24
+ else
25
+ bname_size = list.size - 1
26
+ bname = list[0, bname_size].join(".")
27
+ ext = list[-1]
28
+ end
29
+ [bname, ext]
30
+ end
31
+
32
+ def normal_string?(str)
33
+ ret = false
34
+ if str
35
+ s = str.strip
36
+ ret = true if s != "" && (s =~ %r{^[0-9A-Za-z_:./\-]+$})
37
+ end
38
+ ret
39
+ end
40
+
41
+ def get_normalized_string(str)
42
+ ret = ""
43
+ ret = str.strip if str
44
+ ret
45
+ end
46
+
47
+ def make_content_from_template(template_ary, tag_value_hash, separator)
48
+ content_ary = []
49
+
50
+ reg_hash = {}
51
+ tag_value_hash.each do |k, _v|
52
+ reg_hash[k] = Regexp.new(separator + k + separator)
53
+ end
54
+
55
+ template_ary.each do |line|
56
+ reg_hash.each do |k, v|
57
+ line = line.sub(v, tag_value_hash[k])
58
+ end
59
+ content_ary << line
60
+ end
61
+ content_ary
62
+ end
63
+
64
+ def indent(n)
65
+ n ||= 0
66
+ @indent_hash ||= {}
67
+ @indent_hash[n] ||= " " * n
68
+ @indent_hash[n]
69
+ end
70
+
71
+ def print_hier(data, level)
72
+ case data.class.to_s
73
+ when "Hash"
74
+ data.each do |_k, v|
75
+ # puts "#{indent(level)}#{k}|#{v.class} #{if v.class.to_s == 'String' then v.size else '' end }"
76
+ # puts "#{indent(level)}#{k}|#{v.class}"
77
+ print_hier(v, level + 1)
78
+ end
79
+ when "Array"
80
+ data.each do |v|
81
+ print_hier(v, level + 1)
82
+ end
83
+ else
84
+ # puts "#{indent(level)}|#{data.class}"
85
+ end
86
+ end
87
+
88
+ def print_hier_2(data, level)
89
+ case data.class.to_s
90
+ when "Hash"
91
+ data.each do |k, v|
92
+ # puts "#{indent(level)}#{k}|#{v.class} #{if v.class.to_s == 'String' then v.size else '' end }"
93
+ str = "#{indent(level)}#{k}|#{v.class}"
94
+ if v.instance_of?(Array)
95
+ num = v.size
96
+ str += ("|" + num.to_s)
97
+ str += "###################" if num > 1
98
+ end
99
+ # puts str
100
+ print_hier_2(v, level + 1) if k != "group"
101
+ end
102
+ when "Array"
103
+ data.each do |v|
104
+ print_hier_2(v, level + 1)
105
+ end
106
+ else
107
+ # puts "#{indent(level)}|#{data.class}"
108
+ end
109
+ end
110
+ end
111
+ end
@@ -1,33 +1,33 @@
1
- require "tsort"
2
-
3
- module Ykytils
4
- class TreeManager
5
- include TSort
6
-
7
- def initialize
8
- @table = {}
9
- end
10
-
11
- def add(parent_name, name)
12
- if parent_name
13
- parent = @table[parent_name]
14
- if parent
15
- @table[parent_name] << name
16
- else
17
- @table[parent_name] = [name]
18
- end
19
- else
20
- @table[name] = []
21
- end
22
- end
23
-
24
- def tsort_each_child(node, &block)
25
- ary = @table[node]
26
- ary.each(&block) if ary
27
- end
28
-
29
- def tsort_each_node(&block)
30
- @table.keys.each(&block)
31
- end
32
- end
33
- end
1
+ require "tsort"
2
+
3
+ module Ykytils
4
+ class TreeManager
5
+ include TSort
6
+
7
+ def initialize
8
+ @table = {}
9
+ end
10
+
11
+ def add(parent_name, name)
12
+ if parent_name
13
+ parent = @table[parent_name]
14
+ if parent
15
+ @table[parent_name] << name
16
+ else
17
+ @table[parent_name] = [name]
18
+ end
19
+ else
20
+ @table[name] = []
21
+ end
22
+ end
23
+
24
+ def tsort_each_child(node, &block)
25
+ ary = @table[node]
26
+ ary.each(&block) if ary
27
+ end
28
+
29
+ def tsort_each_node(&block)
30
+ @table.keys.each(&block)
31
+ end
32
+ end
33
+ end
@@ -1,21 +1,21 @@
1
- require "ykutils/treemanager"
2
-
3
- module Ykutils
4
- class TreeManager
5
- def addTag(node_name, tag_name)
6
- @tag ||= {}
7
-
8
- if @tag[node_name]
9
- @tag[node_name] << tag_name
10
- else
11
- @tag[node_name] = [tag_name]
12
- end
13
- end
14
-
15
- def getTag(node_name)
16
- ret = nil
17
- ret = @tag[node_name] if @tag
18
- ret
19
- end
20
- end
21
- end
1
+ require "ykutils/treemanager"
2
+
3
+ module Ykutils
4
+ class TreeManager
5
+ def addTag(node_name, tag_name)
6
+ @tag ||= {}
7
+
8
+ if @tag[node_name]
9
+ @tag[node_name] << tag_name
10
+ else
11
+ @tag[node_name] = [tag_name]
12
+ end
13
+ end
14
+
15
+ def getTag(node_name)
16
+ ret = nil
17
+ ret = @tag[node_name] if @tag
18
+ ret
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ykutils
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -1,8 +1,8 @@
1
- require "ykutils/debugutils"
2
- require "ykutils/lines"
3
-
4
- module Ykutils
5
- class XLines < Lines
6
- include DebugUtils
7
- end
8
- end
1
+ require "ykutils/debugutils"
2
+ require "ykutils/lines"
3
+
4
+ module Ykutils
5
+ class XLines < Lines
6
+ include DebugUtils
7
+ end
8
+ end