ykutils 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +27 -0
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +332 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -1
- data/Gemfile.lock +71 -0
- data/LICENSE.txt +21 -0
- data/README.md +12 -8
- data/Rakefile +11 -0
- data/bin/console +2 -1
- data/bin/makegrid +23 -0
- data/bin/setup +2 -1
- data/lib/ykutils/datastructop.rb +58 -0
- data/lib/ykutils/debugutils.rb +28 -35
- data/lib/ykutils/erubyx.rb +14 -0
- data/lib/ykutils/fileoputils.rb +401 -0
- data/lib/ykutils/filepermision.rb +8 -9
- data/lib/ykutils/gridlist.rb +67 -0
- data/lib/ykutils/hasharray.rb +13 -22
- data/lib/ykutils/lines.rb +143 -154
- data/lib/ykutils/lsutils.rb +71 -72
- data/lib/ykutils/nkfutil.rb +147 -155
- data/lib/ykutils/nkfutil19.rb +88 -84
- data/lib/ykutils/osutil.rb +16 -19
- data/lib/ykutils/pathop.rb +16 -18
- data/lib/ykutils/retcodex.rb +9 -11
- data/lib/ykutils/specfileop.rb +82 -91
- data/lib/ykutils/stext.rb +425 -462
- data/lib/ykutils/stextx.rb +32 -33
- data/lib/ykutils/stringutils.rb +111 -125
- data/lib/ykutils/treemanager.rb +33 -36
- data/lib/ykutils/treemanagera.rb +21 -26
- data/lib/ykutils/version.rb +3 -1
- data/lib/ykutils/xlines.rb +8 -9
- data/lib/ykutils/yamlop.rb +227 -0
- data/lib/ykutils/yamlxop.rb +35 -34
- data/lib/ykutils.rb +24 -0
- data/sig/ykutils.rbs +4 -0
- data/ykutils.gemspec +43 -27
- metadata +53 -26
- data/.travis.yml +0 -3
- data/lib/ykutils/fileoputils2.rb +0 -443
data/lib/ykutils/nkfutil.rb
CHANGED
@@ -1,155 +1,147 @@
|
|
1
|
-
# -*- coding utf-8 -*-
|
2
|
-
|
3
|
-
require
|
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
|
15
|
-
CODE_TO_NAME[NKF.guess(str)]
|
16
|
-
end
|
17
|
-
|
18
|
-
class Assoc
|
19
|
-
@@hs = {}
|
20
|
-
@@config = nil
|
21
|
-
|
22
|
-
def
|
23
|
-
if value
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def
|
31
|
-
@@hs[key]
|
32
|
-
end
|
33
|
-
|
34
|
-
def
|
35
|
-
case encoding
|
36
|
-
when "UTF8"
|
37
|
-
"w"
|
38
|
-
else
|
39
|
-
encoding[0,1]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@@config
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
outf.printf("%s\n" , oline )
|
149
|
-
end
|
150
|
-
}
|
151
|
-
}
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
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 = 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
|
data/lib/ykutils/nkfutil19.rb
CHANGED
@@ -1,70 +1,74 @@
|
|
1
1
|
# -*- coding utf-8 -*-
|
2
2
|
|
3
|
-
require
|
3
|
+
require "nkf"
|
4
4
|
|
5
5
|
module Ykutils
|
6
6
|
module NKFUTIL
|
7
|
-
#ASCII-8BIT
|
8
|
-
#US-ASCII
|
9
|
-
CODE_TO_NAME
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
7
|
+
# ASCII-8BIT
|
8
|
+
# US-ASCII
|
9
|
+
unless CODE_TO_NAME
|
10
|
+
CODE_TO_NAME = Hash.new("ASCII")
|
11
|
+
CODE_TO_NAME["US-ASCII"] = "ASCII"
|
12
|
+
CODE_TO_NAME["stateless-ISO-2022-JP"] = "JIS"
|
13
|
+
CODE_TO_NAME["ISO-2022-JP"] = "JIS"
|
14
|
+
CODE_TO_NAME["ISO-2022-JP-2"] = "JIS"
|
15
|
+
CODE_TO_NAME["EUC-JP"] = "EUC"
|
16
|
+
CODE_TO_NAME["eucJP-ms"] = "EUC"
|
17
|
+
CODE_TO_NAME["Shift_JIS"] = "SJIS"
|
18
|
+
CODE_TO_NAME["Windows-31J"] = "SJIS"
|
19
|
+
CODE_TO_NAME["ASCII-8BIT"] = "BINARY"
|
20
|
+
CODE_TO_NAME["UTF-8"] = "UTF8"
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
NAME_TO_ENCODING
|
25
|
+
rescue => ex
|
26
|
+
NAME_TO_ENCODING = Hash.new("US-ASCII")
|
27
|
+
NAME_TO_ENCODING["UTF8"] = "UTF-8"
|
28
|
+
NAME_TO_ENCODING["ASCII"] = "US-ASCII"
|
29
|
+
NAME_TO_ENCODING["JIS"] = "ISO-2022-JP"
|
30
|
+
NAME_TO_ENCODING["EUC"] = "EUC-JP"
|
31
|
+
NAME_TO_ENCODING["SJIS"] = "Winodws-31J"
|
32
|
+
NAME_TO_ENCODING["BINARY"] = "ASCII-8BIT"
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
+
def self.guess_encoding(str)
|
36
|
+
puts "**#{str.encoding}"
|
37
|
+
CODE_TO_NAME[str.encoding.to_s]
|
35
38
|
end
|
36
39
|
|
40
|
+
def self.config(src_encoding, dest_encoding, misc_option = nil); end
|
41
|
+
|
37
42
|
class Assoc
|
38
43
|
@@hs = {}
|
39
44
|
@@config = nil
|
40
45
|
|
41
|
-
def
|
42
|
-
if value
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
def self.set(key, value)
|
47
|
+
@@hs[key] = if value
|
48
|
+
Assoc.convert(value)
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
|
-
def
|
54
|
+
def self.get(key)
|
50
55
|
@@hs[key]
|
51
56
|
end
|
52
57
|
|
53
|
-
def
|
54
|
-
NAME_TO_ENCODING[
|
58
|
+
def self.to_nkf_encoding_format(encoding)
|
59
|
+
NAME_TO_ENCODING[encoding]
|
55
60
|
end
|
56
61
|
|
57
|
-
|
58
|
-
def Assoc.config( src_encoding, dest_encoding , misc_option = nil )
|
62
|
+
def self.config(_src_encoding, dest_encoding, _misc_option = nil)
|
59
63
|
@@config = dest_encoding
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
63
|
-
if str
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
def self.auto_config_to_inner(str, _misc_option = nil)
|
67
|
+
src_encoding = if str
|
68
|
+
Assoc.to_nkf_encoding_format(NKFUTIL.guess_encoding(str))
|
69
|
+
else
|
70
|
+
"US-ASCII"
|
71
|
+
end
|
68
72
|
|
69
73
|
# inner_encoding = Assoc.to_nkf_encoding_format( Assoc.get_inner_encoding )
|
70
74
|
# if inner_encoding != "US-ASCII"
|
@@ -74,8 +78,8 @@ module Ykutils
|
|
74
78
|
src_encoding
|
75
79
|
end
|
76
80
|
|
77
|
-
def
|
78
|
-
dest_encoding = Assoc.to_nkf_encoding_format(
|
81
|
+
def self.auto_config_from_inner(dest_enc, _misc_option = nil)
|
82
|
+
dest_encoding = Assoc.to_nkf_encoding_format(dest_enc)
|
79
83
|
# inner_encoding = Assoc.to_nkf_encoding_format( Assoc.get_inner_encoding )
|
80
84
|
# if inner_encoding != "US-ASCII"
|
81
85
|
# @@config = dest_encoding.downcase
|
@@ -83,20 +87,20 @@ module Ykutils
|
|
83
87
|
# end
|
84
88
|
end
|
85
89
|
|
86
|
-
def
|
90
|
+
def self.convert(str)
|
87
91
|
nstr = nil
|
88
|
-
|
89
|
-
if @@config
|
92
|
+
unless str.nil?
|
93
|
+
if @@config.nil?
|
94
|
+
nstr = str
|
95
|
+
else
|
90
96
|
begin
|
91
97
|
# nstr = NKF.nkf( @@config , str )
|
92
|
-
nstr = str.encode(
|
93
|
-
rescue =>
|
94
|
-
puts
|
98
|
+
nstr = str.encode(@@config)
|
99
|
+
rescue StandardError => e
|
100
|
+
puts e
|
95
101
|
puts "========="
|
96
102
|
pp caller(0)
|
97
103
|
end
|
98
|
-
else
|
99
|
-
nstr = str
|
100
104
|
end
|
101
105
|
end
|
102
106
|
nstr
|
@@ -107,59 +111,59 @@ module Ykutils
|
|
107
111
|
# end
|
108
112
|
end
|
109
113
|
|
110
|
-
def
|
111
|
-
Assoc.set(
|
114
|
+
def self.set(key, value)
|
115
|
+
Assoc.set(key, value)
|
112
116
|
end
|
113
117
|
|
114
|
-
def
|
115
|
-
Assoc.get(
|
118
|
+
def self.get(key)
|
119
|
+
Assoc.get(key)
|
116
120
|
end
|
117
121
|
|
118
|
-
def
|
119
|
-
if str
|
120
|
-
Assoc.convert( str )
|
121
|
-
else
|
122
|
+
def self.convert(str)
|
123
|
+
if str.nil?
|
122
124
|
""
|
125
|
+
else
|
126
|
+
Assoc.convert(str)
|
123
127
|
end
|
124
128
|
end
|
125
129
|
|
126
|
-
def
|
127
|
-
target == key || target == Assoc.get(
|
130
|
+
def self.assoc_equal(target, key)
|
131
|
+
target == key || target == Assoc.get(key)
|
128
132
|
end
|
129
133
|
|
130
|
-
def
|
131
|
-
Assoc.config(
|
132
|
-
end
|
134
|
+
def self.config(src_encoding, dest_encoding, misc_option = nil)
|
135
|
+
Assoc.config(src_encoding, dest_encoding, misc_option)
|
136
|
+
end
|
133
137
|
|
134
|
-
def
|
135
|
-
Assoc.auto_config_to_inner(
|
138
|
+
def self.auto_config_to_inner(str, misc_option = nil)
|
139
|
+
Assoc.auto_config_to_inner(str, misc_option)
|
136
140
|
end
|
137
141
|
|
138
|
-
def
|
139
|
-
Assoc.auto_config_to_inner(
|
140
|
-
end
|
142
|
+
def self.auto_config_from_inner(dest_encoding, misc_option = nil)
|
143
|
+
Assoc.auto_config_to_inner(dest_encoding, misc_option)
|
144
|
+
end
|
141
145
|
|
142
|
-
def puts_sj(
|
143
|
-
puts line.encod(
|
146
|
+
def puts_sj(line)
|
147
|
+
puts line.encod(NAME_TO_ENCODING["SJIS"])
|
144
148
|
# puts NKF.nkf( "-Ws -m0" , line )
|
145
149
|
end
|
146
150
|
|
147
|
-
def puts_u(
|
148
|
-
puts line.encod(
|
149
|
-
puts NKF.nkf(
|
151
|
+
def puts_u(line)
|
152
|
+
puts line.encod(NAME_TO_ENCODING["UTF8"])
|
153
|
+
puts NKF.nkf("-Sw -m0", line)
|
150
154
|
end
|
151
155
|
|
152
|
-
def nkf_utf8_file(
|
153
|
-
File.open(
|
154
|
-
File.open(
|
156
|
+
def nkf_utf8_file(infname, outfname)
|
157
|
+
File.open(outfname) do |outf|
|
158
|
+
File.open(infname) do |file|
|
155
159
|
while line = file.gets
|
156
160
|
line.chomp!
|
157
161
|
# oline = NKF.nkf( "-w -m0" , line )
|
158
|
-
oline = line.encode(
|
159
|
-
outf.printf("%s\n"
|
162
|
+
oline = line.encode(NAME_TO_ENCODING["UTF8"])
|
163
|
+
outf.printf("%s\n", oline)
|
160
164
|
end
|
161
|
-
|
162
|
-
|
165
|
+
end
|
166
|
+
end
|
163
167
|
end
|
164
168
|
end
|
165
169
|
end
|
data/lib/ykutils/osutil.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
module Ykutils
|
4
|
-
class OSUtil
|
5
|
-
@@os = nil
|
6
|
-
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
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
|
data/lib/ykutils/pathop.rb
CHANGED
@@ -1,37 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require "pathname"
|
2
2
|
|
3
3
|
module Ykutils
|
4
4
|
module PathOp
|
5
|
-
def get_buddy_path(
|
6
|
-
one_path = Pathname.new(
|
5
|
+
def get_buddy_path(fname, append_name = "", extname = "")
|
6
|
+
one_path = Pathname.new(fname).expand_path
|
7
7
|
dir_path = one_path.dirname
|
8
8
|
base_path = one_path.basename(".*")
|
9
|
-
append_name = "-2" unless
|
9
|
+
append_name = "-2" unless append_name.empty? or extname.empty?
|
10
10
|
extname ||= one_path.extname
|
11
11
|
|
12
|
-
[one_path
|
12
|
+
[one_path, dir_path.join(base_path.to_s + append_name + extname)]
|
13
13
|
end
|
14
14
|
|
15
|
-
def determine_fname_for_update(
|
16
|
-
get_buddy_path(
|
15
|
+
def determine_fname_for_update(fname, ext = ".bak")
|
16
|
+
get_buddy_path(fname, "", ext)
|
17
17
|
end
|
18
18
|
|
19
|
-
def determine_fname_for_update2(
|
19
|
+
def determine_fname_for_update2(fname)
|
20
20
|
begin
|
21
|
-
ctime = File.ctime(
|
22
|
-
rescue =>
|
21
|
+
ctime = File.ctime(fname)
|
22
|
+
rescue StandardError => e
|
23
23
|
end
|
24
|
-
ctime
|
24
|
+
ctime ||= Time.now
|
25
25
|
ary = ctime.to_s.split(" ")
|
26
|
-
extname = File.extname(
|
27
|
-
append = ["", ary[0]
|
28
|
-
get_buddy_path(
|
26
|
+
extname = File.extname(fname)
|
27
|
+
append = ["", ary[0], ary[1].gsub(":", "-")].join("-")
|
28
|
+
get_buddy_path(fname, append, extname)
|
29
29
|
end
|
30
30
|
|
31
|
-
def file_ensure(
|
32
|
-
File.open(
|
31
|
+
def file_ensure(fname)
|
32
|
+
File.open(fname, "w").close unless File.exist?(fname)
|
33
33
|
end
|
34
|
-
|
35
34
|
end
|
36
35
|
end
|
37
|
-
|