ykutils 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) 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/erubyx.rb +30 -19
  10. data/lib/ykutils/fileoputils.rb +2 -2
  11. data/lib/ykutils/gridlist.rb +49 -49
  12. data/lib/ykutils/lines.rb +143 -143
  13. data/lib/ykutils/lsutils.rb +71 -71
  14. data/lib/ykutils/nginxconfig.rb +40 -41
  15. data/lib/ykutils/nginxconfigfiles.rb +31 -31
  16. data/lib/ykutils/nkfutil.rb +148 -147
  17. data/lib/ykutils/nkfutil19.rb +9 -11
  18. data/lib/ykutils/osutil.rb +16 -16
  19. data/lib/ykutils/retcodex.rb +1 -3
  20. data/lib/ykutils/stext.rb +427 -425
  21. data/lib/ykutils/stextx.rb +32 -32
  22. data/lib/ykutils/stringutils.rb +111 -111
  23. data/lib/ykutils/treemanager.rb +33 -33
  24. data/lib/ykutils/treemanagera.rb +21 -21
  25. data/lib/ykutils/version.rb +1 -1
  26. data/lib/ykutils/xlines.rb +8 -8
  27. data/lib/ykutils/yamlop.rb +227 -227
  28. data/lib/ykutils/yamlxop.rb +35 -35
  29. data/test_data/4servers.erb +7 -7
  30. data/test_data/a.bat +5 -5
  31. data/test_data/a_ncn.bat +12 -12
  32. data/test_data/v103-3-189-127/a.northern-cross.net/base.yml +28 -28
  33. data/test_data/v103-3-189-127/a.northern-cross.net/value_host.yml +1 -1
  34. data/test_data/v103-3-189-127/b.northern-cross.net/base.yml +28 -28
  35. data/test_data/v103-3-189-127/b.northern-cross.net/value_host.yml +1 -1
  36. data/test_data/v103-3-189-127/c.northern-cross.net/base.yml +28 -28
  37. data/test_data/v103-3-189-127/c.northern-cross.net/value_host.yml +1 -1
  38. data/test_data/v103-3-189-127/d.northern-cross.info/base.yml +28 -28
  39. data/test_data/v103-3-189-127/d.northern-cross.info/value_host.yml +1 -1
  40. data/test_data/v103-3-189-127/d.northern-cross.net/base.yml +28 -28
  41. data/test_data/v103-3-189-127/d.northern-cross.net/value_host.yml +1 -1
  42. data/test_data/v103-3-189-127/e.northern-cross.info/base.yml +28 -28
  43. data/test_data/v103-3-189-127/e.northern-cross.info/value_host.yml +1 -1
  44. data/test_data/v103-3-189-127/e.northern-cross.net/base.yml +28 -28
  45. data/test_data/v103-3-189-127/e.northern-cross.net/value_host.yml +1 -1
  46. data/test_data/v103-3-189-127/f.northern-cross.info/base.yml +28 -28
  47. data/test_data/v103-3-189-127/f.northern-cross.info/value_host.yml +1 -1
  48. data/test_data/v103-3-189-127/f.northern-cross.net/base.yml +28 -28
  49. data/test_data/v103-3-189-127/f.northern-cross.net/value_host.yml +1 -1
  50. data/test_data/v103-3-189-127/t_server_1.erb +7 -7
  51. data/test_data/v103-3-189-127/template.erb +21 -21
  52. data/test_data/v103-3-189-127/template_ssl.erb +22 -22
  53. data/test_data/v103-3-189-127/template_ssl_www.erb +12 -12
  54. data/test_data/v103-3-189-127/template_www.erb +24 -24
  55. data/test_data/v103-3-189-127/value.yml +3 -3
  56. data/test_data/v103-3-189-127/value_ssl.yml +5 -5
  57. data/ykutils.gemspec +45 -43
  58. metadata +8 -9
  59. data/_config.yml +0 -1
@@ -1,147 +1,148 @@
1
- # -*- coding utf-8 -*-
2
-
3
- require "nkf"
4
-
5
- module Ykutils
6
- module NKFUTIL
7
- CODE_TO_NAME = Hash.new("ASCII")
8
- CODE_TO_NAME[NKF::JIS] = "JIS"
9
- CODE_TO_NAME[NKF::EUC] = "EUC"
10
- CODE_TO_NAME[NKF::SJIS] = "SJIS"
11
- CODE_TO_NAME[NKF::BINARY] = "BINARY"
12
- CODE_TO_NAME[NKF::UTF8] = "UTF8" if NKF.const_defined?(:UTF8)
13
-
14
- def self.guess_encoding(str)
15
- CODE_TO_NAME[NKF.guess(str)]
16
- end
17
-
18
- class Assoc
19
- @@hs = {}
20
- @@config = nil
21
-
22
- def self.set(key, value)
23
- @@hs[key] = if value
24
- Assoc.convert(value)
25
- else
26
- value
27
- end
28
- end
29
-
30
- def self.get(key)
31
- @@hs[key]
32
- end
33
-
34
- def self.to_nkf_encoding_format(encoding)
35
- case encoding
36
- when "UTF8"
37
- "w"
38
- else
39
- encoding[0, 1]
40
- end
41
- end
42
-
43
- def self.config(src_encoding, dest_encoding, misc_option = nil)
44
- @@config = "-#{dest_encoding.to_s[0, 1].downcase}#{src_encoding.to_s[0, 1].upcase}"
45
- @@config += " #{misc_option}" unless misc_option.nil?
46
- end
47
-
48
- def self.auto_config_to_inner(str, misc_option = nil)
49
- src_encoding = if str
50
- Assoc.to_nkf_encoding_format(NKFUTIL.guess_encoding(str))
51
- else
52
- "A"
53
- end
54
-
55
- inner_encoding = Assoc.to_nkf_encoding_format(Assoc.get_inner_encoding)
56
- if inner_encoding != "A"
57
- @@config = "-#{inner_encoding.downcase}#{src_encoding.upcase}"
58
- @@config += " #{misc_option}" unless misc_option.nil?
59
- end
60
- src_encoding
61
- end
62
-
63
- def self.auto_config_from_inner(dest_enc, misc_option = nil)
64
- dest_encoding = Assoc.to_nkf_encoding_format(dest_enc)
65
- inner_encoding = Assoc.to_nkf_encoding_format(Assoc.get_inner_encoding)
66
- if inner_encoding != "A"
67
- @@config = "-#{dest_encoding.downcase}#{inner_encoding.upcase}"
68
- @@config += " #{misc_option}" unless misc_option.nil?
69
- end
70
- end
71
-
72
- def self.convert(str)
73
- nstr = nil
74
- unless str.nil?
75
- if @@config.nil?
76
- nstr = str
77
- else
78
- begin
79
- nstr = NKF.nkf(@@config, str)
80
- rescue StandardError => e
81
- puts e
82
- puts "========="
83
- pp caller(0)
84
- end
85
- end
86
- end
87
- nstr
88
- end
89
-
90
- def self.get_inner_encoding
91
- @@inner_encoding = $KCODE == "NONE" ? "ASCII" : $KCODE
92
- end
93
- end
94
-
95
- def self.set(key, value)
96
- Assoc.set(key, value)
97
- end
98
-
99
- def self.get(key)
100
- Assoc.get(key)
101
- end
102
-
103
- def self.convert(str)
104
- if str.nil?
105
- ""
106
- else
107
- Assoc.convert(str)
108
- end
109
- end
110
-
111
- def self.assoc_equal(target, key)
112
- target == key || target == Assoc.get(key)
113
- end
114
-
115
- def self.config(src_encoding, dest_encoding, misc_option = nil)
116
- Assoc.config(src_encoding, dest_encoding, misc_option)
117
- end
118
-
119
- def self.auto_config_to_inner(str, misc_option = nil)
120
- Assoc.auto_config_to_inner(str, misc_option)
121
- end
122
-
123
- def self.auto_config_from_inner(dest_encoding, misc_option = nil)
124
- Assoc.auto_config_to_inner(dest_encoding, misc_option)
125
- end
126
-
127
- def puts_sj(line)
128
- puts NKF.nkf("-Ws -m0", line)
129
- end
130
-
131
- def puts_u(line)
132
- puts NKF.nkf("-Sw -m0", line)
133
- end
134
-
135
- def nkf_utf8_file(infname, outfname)
136
- File.open(outfname) do |outf|
137
- File.open(infname) do |file|
138
- while line = file.gets
139
- line.chomp!
140
- oline = NKF.nkf("-w -m0", line)
141
- outf.printf("%s\n", oline)
142
- end
143
- end
144
- end
145
- end
146
- end
147
- end
1
+ # -*- coding utf-8 -*-
2
+
3
+ require "nkf"
4
+
5
+ module Ykutils
6
+ module NKFUTIL
7
+ CODE_TO_NAME = Hash.new("ASCII")
8
+ CODE_TO_NAME[NKF::JIS] = "JIS"
9
+ CODE_TO_NAME[NKF::EUC] = "EUC"
10
+ CODE_TO_NAME[NKF::SJIS] = "SJIS"
11
+ CODE_TO_NAME[NKF::BINARY] = "BINARY"
12
+ CODE_TO_NAME[NKF::UTF8] = "UTF8" if NKF.const_defined?(:UTF8)
13
+
14
+ def self.guess_encoding(str)
15
+ CODE_TO_NAME[NKF.guess(str)]
16
+ end
17
+
18
+ class Assoc
19
+ @@hs = {}
20
+ @@config = nil
21
+
22
+ def self.set(key, value)
23
+ @@hs[key] = if value
24
+ Assoc.convert(value)
25
+ else
26
+ value
27
+ end
28
+ end
29
+
30
+ def self.get(key)
31
+ @@hs[key]
32
+ end
33
+
34
+ def self.to_nkf_encoding_format(encoding)
35
+ case encoding
36
+ when "UTF8"
37
+ "w"
38
+ else
39
+ encoding[0, 1]
40
+ end
41
+ end
42
+
43
+ def self.config(src_encoding, dest_encoding, misc_option = nil)
44
+ @@config = "-#{dest_encoding.to_s[0, 1].downcase}#{src_encoding.to_s[0, 1].upcase}"
45
+ @@config += " #{misc_option}" unless misc_option.nil?
46
+ end
47
+
48
+ def self.auto_config_to_inner(str, misc_option = nil)
49
+ src_encoding =
50
+ if str
51
+ Assoc.to_nkf_encoding_format(NKFUTIL.guess_encoding(str))
52
+ else
53
+ "A"
54
+ end
55
+
56
+ inner_encoding = Assoc.to_nkf_encoding_format(Assoc.get_inner_encoding)
57
+ if inner_encoding != "A"
58
+ @@config = "-#{inner_encoding.downcase}#{src_encoding.upcase}"
59
+ @@config += " #{misc_option}" unless misc_option.nil?
60
+ end
61
+ src_encoding
62
+ end
63
+
64
+ def self.auto_config_from_inner(dest_enc, misc_option = nil)
65
+ dest_encoding = Assoc.to_nkf_encoding_format(dest_enc)
66
+ inner_encoding = Assoc.to_nkf_encoding_format(Assoc.get_inner_encoding)
67
+ if inner_encoding != "A"
68
+ @@config = "-#{dest_encoding.downcase}#{inner_encoding.upcase}"
69
+ @@config += " #{misc_option}" unless misc_option.nil?
70
+ end
71
+ end
72
+
73
+ def self.convert(str)
74
+ nstr = nil
75
+ unless str.nil?
76
+ if @@config.nil?
77
+ nstr = str
78
+ else
79
+ begin
80
+ nstr = NKF.nkf(@@config, str)
81
+ rescue StandardError => e
82
+ puts e
83
+ puts "========="
84
+ pp caller(0)
85
+ end
86
+ end
87
+ end
88
+ nstr
89
+ end
90
+
91
+ def self.get_inner_encoding
92
+ @@inner_encoding = $KCODE == "NONE" ? "ASCII" : $KCODE
93
+ end
94
+ end
95
+
96
+ def self.set(key, value)
97
+ Assoc.set(key, value)
98
+ end
99
+
100
+ def self.get(key)
101
+ Assoc.get(key)
102
+ end
103
+
104
+ def self.convert(str)
105
+ if str.nil?
106
+ ""
107
+ else
108
+ Assoc.convert(str)
109
+ end
110
+ end
111
+
112
+ def self.assoc_equal(target, key)
113
+ target == key || target == Assoc.get(key)
114
+ end
115
+
116
+ def self.config(src_encoding, dest_encoding, misc_option = nil)
117
+ Assoc.config(src_encoding, dest_encoding, misc_option)
118
+ end
119
+
120
+ def self.auto_config_to_inner(str, misc_option = nil)
121
+ Assoc.auto_config_to_inner(str, misc_option)
122
+ end
123
+
124
+ def self.auto_config_from_inner(dest_encoding, misc_option = nil)
125
+ Assoc.auto_config_to_inner(dest_encoding, misc_option)
126
+ end
127
+
128
+ def puts_sj(line)
129
+ puts NKF.nkf("-Ws -m0", line)
130
+ end
131
+
132
+ def puts_u(line)
133
+ puts NKF.nkf("-Sw -m0", line)
134
+ end
135
+
136
+ def nkf_utf8_file(infname, outfname)
137
+ File.open(outfname) do |outf|
138
+ File.open(infname) do |file|
139
+ while (line = file.gets)
140
+ line.chomp!
141
+ oline = NKF.nkf("-w -m0", line)
142
+ outf.printf("%s\n", oline)
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
@@ -37,18 +37,16 @@ module Ykutils
37
37
  CODE_TO_NAME[str.encoding.to_s]
38
38
  end
39
39
 
40
- def self.config(src_encoding, dest_encoding, misc_option = nil); end
41
-
42
40
  class Assoc
43
41
  @@hs = {}
44
42
  @@config = nil
45
43
 
46
44
  def self.set(key, value)
47
45
  @@hs[key] = if value
48
- Assoc.convert(value)
49
- else
50
- value
51
- end
46
+ Assoc.convert(value)
47
+ else
48
+ value
49
+ end
52
50
  end
53
51
 
54
52
  def self.get(key)
@@ -65,10 +63,10 @@ module Ykutils
65
63
 
66
64
  def self.auto_config_to_inner(str, _misc_option = nil)
67
65
  src_encoding = if str
68
- Assoc.to_nkf_encoding_format(NKFUTIL.guess_encoding(str))
69
- else
70
- "US-ASCII"
71
- end
66
+ Assoc.to_nkf_encoding_format(NKFUTIL.guess_encoding(str))
67
+ else
68
+ "US-ASCII"
69
+ end
72
70
 
73
71
  # inner_encoding = Assoc.to_nkf_encoding_format( Assoc.get_inner_encoding )
74
72
  # if inner_encoding != "US-ASCII"
@@ -156,7 +154,7 @@ module Ykutils
156
154
  def nkf_utf8_file(infname, outfname)
157
155
  File.open(outfname) do |outf|
158
156
  File.open(infname) do |file|
159
- while line = file.gets
157
+ while (line = file.gets)
160
158
  line.chomp!
161
159
  # oline = NKF.nkf( "-w -m0" , line )
162
160
  oline = line.encode(NAME_TO_ENCODING["UTF8"])
@@ -1,16 +1,16 @@
1
- require "pathname"
2
-
3
- module Ykutils
4
- class OSUtil
5
- @@os = nil
6
-
7
- def self.runtime
8
- @@os ||= if Pathname.pwd.to_s =~ %r{^/cygdrive}
9
- :CYGWIN
10
- else
11
- :ELSE
12
- end
13
- @@os
14
- end
15
- end
16
- end
1
+ require "pathname"
2
+
3
+ module Ykutils
4
+ class OSUtil
5
+ @@os = nil
6
+
7
+ def self.runtime
8
+ @@os ||= if Pathname.pwd.to_s =~ %r{^/cygdrive}
9
+ :CYGWIN
10
+ else
11
+ :ELSE
12
+ end
13
+ @@os
14
+ end
15
+ end
16
+ end
@@ -40,9 +40,7 @@ module Ykutils
40
40
 
41
41
  def initialize(ret, bool, mes)
42
42
  @val = { "ret" => ret, "bool" => bool, "mes" => mes }
43
- @ret = ret
44
- @bool = bool
45
- @mes = mes
43
+ super(@val)
46
44
  end
47
45
  end
48
46
  end