hikiutils 0.2.3.4 → 0.2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/hiki +1 -3
- data/exe/hiki_thor +0 -3
- data/exe/hiki_thor~ +8 -0
- data/exe/hiki~ +8 -0
- data/hikiutils.gemspec +1 -0
- data/hikiutils_bob/Rakefile +10 -27
- data/hikiutils_bob/figs/hikiutils_bob.004.jpeg +0 -0
- data/hikiutils_bob/{private_dir.graffle → hikiutils_bob.graffle} +1 -1
- data/hikiutils_bob/hikiutils_bob.key +0 -0
- data/hikiutils_bob/hikiutils_bob/hikiutils_bob.004.jpeg +0 -0
- data/hikiutils_bob/latex_all.hiki +7 -3
- data/hikiutils_bob/latex_dir/hikiutils_bob.log +99 -84
- data/hikiutils_bob/latex_dir/hikiutils_bob.pdf +0 -0
- data/hikiutils_bob/latex_dir/hikiutils_bob.synctex.gz +0 -0
- data/hikiutils_bob/latex_dir/hikiutils_bob.toc +14 -10
- data/hikiutils_bob/latex_dir/latex_all.aux +10 -10
- data/hikiutils_bob/latex_dir/latex_all.tex +14 -5
- data/hikiutils_bob/latex_dir/sync.aux +14 -8
- data/hikiutils_bob/latex_dir/sync.tex +70 -17
- data/hikiutils_bob/sync.hiki +44 -7
- data/hikiutils_yamane/Rakefile +32 -31
- data/hikiutils_yamane/abstract.hiki +1 -0
- data/hikiutils_yamane/backup/hikiutils%28optparse%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%29 +309 -0
- data/hikiutils_yamane/backup/hikiutils%28thor%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%29 +1 -0
- data/hikiutils_yamane/backup/hikiutils_yamane +703 -0
- data/hikiutils_yamane/backup/hikiutils_yamane.hiki +0 -0
- data/hikiutils_yamane/backup/hikiutils_yamane_#hikiutils_yamane +1 -0
- data/hikiutils_yamane/backup/hikiutils_yamane_command_table +19 -0
- data/hikiutils_yamane/backup/hikiutils_yamane_introduction +7 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.001.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.001.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.002.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.002.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.003.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.003.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.004.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.004.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.005.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.005.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.006.jpeg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane.007.jpeg +0 -0
- data/hikiutils_yamane/hikiutils_yamane.hiki +37 -1
- data/hikiutils_yamane/hikiutils_yamane.key +0 -0
- data/hikiutils_yamane/hikiutils_yamane.key~11b9dba1272d2104b420497d11c6eda206ace6c2 +0 -0
- data/hikiutils_yamane/introduction.hiki +27 -0
- data/hikiutils_yamane/latex_dir/abstract.aux +22 -0
- data/hikiutils_yamane/latex_dir/abstract.tex +1 -0
- data/hikiutils_yamane/latex_dir/command_table.tex +1 -1
- data/hikiutils_yamane/latex_dir/head.tex +2 -2
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.aux +3 -0
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.log +224 -84
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.pdf +0 -0
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.synctex.gz +0 -0
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.tex +16 -2
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.toc +20 -0
- data/hikiutils_yamane/latex_dir/introduction.aux +26 -0
- data/hikiutils_yamane/latex_dir/introduction.tex +33 -0
- data/hikiutils_yamane/latex_dir/results.aux +45 -0
- data/hikiutils_yamane/latex_dir/results.tex +342 -0
- data/hikiutils_yamane/latex_dir/system.tex +23 -0
- data/hikiutils_yamane/results.hiki +376 -0
- data/hikiutils_yamane/system.hiki +18 -0
- data/lib/hikiutils.rb +7 -3
- data/lib/hikiutils.rb~ +387 -0
- data/lib/hikiutils/version.rb +1 -1
- data/lib/hikiutils_thor.rb +36 -20
- data/lib/hikiutils_thor.rb~ +324 -0
- data/lib/templates/Rakefile_hiki_sync +35 -31
- metadata +57 -3
data/lib/hikiutils/version.rb
CHANGED
data/lib/hikiutils_thor.rb
CHANGED
|
@@ -3,6 +3,7 @@ require 'thor'
|
|
|
3
3
|
require 'kconv'
|
|
4
4
|
require 'hikidoc'
|
|
5
5
|
require 'erb'
|
|
6
|
+
require "hikiutils/version"
|
|
6
7
|
require "hikiutils/tmarshal"
|
|
7
8
|
require "hikiutils/infodb"
|
|
8
9
|
require 'systemu'
|
|
@@ -15,10 +16,9 @@ module Hikithor
|
|
|
15
16
|
DATA_FILE=File.join(ENV['HOME'],'.hikirc')
|
|
16
17
|
attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
|
|
17
18
|
|
|
18
|
-
|
|
19
19
|
class CLI < Thor
|
|
20
20
|
def initialize(*args)
|
|
21
|
-
|
|
21
|
+
super
|
|
22
22
|
@data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
|
|
23
23
|
data_path = File.join(ENV['HOME'], '.hikirc')
|
|
24
24
|
DataFiles.prepare(data_path)
|
|
@@ -32,7 +32,7 @@ module Hikithor
|
|
|
32
32
|
@browser = (browser==nil) ? 'firefox' : browser
|
|
33
33
|
p editor_command = @src[:editor_command]
|
|
34
34
|
@editor_command = (editor_command==nil) ? 'open -a mi' : editor_command
|
|
35
|
-
|
|
35
|
+
end
|
|
36
36
|
HTML_TEMPLATE = <<EOS
|
|
37
37
|
<!DOCTYPE html
|
|
38
38
|
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
@@ -50,8 +50,9 @@ HTML_TEMPLATE = <<EOS
|
|
|
50
50
|
</html>
|
|
51
51
|
EOS
|
|
52
52
|
|
|
53
|
-
desc 'show', 'show sources'
|
|
54
|
-
|
|
53
|
+
desc 'show,--show', 'show sources'
|
|
54
|
+
map "--show" => "show"
|
|
55
|
+
def show
|
|
55
56
|
printf("target_no:%i\n",@src[:target])
|
|
56
57
|
printf("editor_command:%s\n",@src[:editor_command])
|
|
57
58
|
@i_size,@n_size,@l_size,@g_size=3,5,30,15 #i,g_size are fixed
|
|
@@ -77,12 +78,16 @@ EOS
|
|
|
77
78
|
}
|
|
78
79
|
end
|
|
79
80
|
|
|
80
|
-
desc 'version', 'show program version'
|
|
81
|
+
desc 'version,--version,-v', 'show program version'
|
|
82
|
+
map "--version" => "version"
|
|
83
|
+
map "-v" => "version"
|
|
81
84
|
def version
|
|
82
|
-
puts
|
|
85
|
+
puts HikiUtils::VERSION
|
|
83
86
|
end
|
|
84
87
|
|
|
85
|
-
desc 'add', 'add sources info'
|
|
88
|
+
desc 'add,--add', 'add sources info'
|
|
89
|
+
map "--add" => "add"
|
|
90
|
+
option :add
|
|
86
91
|
def add
|
|
87
92
|
cont = {}
|
|
88
93
|
@data_name.each{|name|
|
|
@@ -94,15 +99,16 @@ EOS
|
|
|
94
99
|
show
|
|
95
100
|
end
|
|
96
101
|
|
|
97
|
-
desc 'target VAL', 'set target id'
|
|
102
|
+
desc 'target VAL,--target VAL', 'set target id'
|
|
103
|
+
map "--target" => "target"
|
|
98
104
|
def target(val)
|
|
99
105
|
@src[:target] = val.to_i
|
|
100
106
|
show
|
|
101
107
|
end
|
|
102
108
|
|
|
103
|
-
desc 'edit FILE', 'open file'
|
|
109
|
+
desc 'edit FILE,--edit FILE', 'open file'
|
|
110
|
+
map "--edit" => "edit"
|
|
104
111
|
def edit(file)
|
|
105
|
-
p @l_dir
|
|
106
112
|
t_file=File.join(@l_dir,'text',file)
|
|
107
113
|
if !File.exist?(t_file) then
|
|
108
114
|
file=File.open(t_file,'w')
|
|
@@ -113,7 +119,8 @@ EOS
|
|
|
113
119
|
system command
|
|
114
120
|
end
|
|
115
121
|
|
|
116
|
-
desc 'list [FILE]', 'list files'
|
|
122
|
+
desc 'list [FILE],--list [FILE]', 'list files'
|
|
123
|
+
map "--list" => "list"
|
|
117
124
|
def list(file)
|
|
118
125
|
file ='' if file==nil
|
|
119
126
|
t_file=File.join(@l_dir,'text')
|
|
@@ -121,7 +128,8 @@ EOS
|
|
|
121
128
|
print `cd #{t_file} ; ls -lt #{file}*`
|
|
122
129
|
end
|
|
123
130
|
|
|
124
|
-
desc 'update FILE', 'update file'
|
|
131
|
+
desc 'update FILE,--update FILE', 'update file'
|
|
132
|
+
map "--update" => "update"
|
|
125
133
|
def update(file0)
|
|
126
134
|
file = (file0==nil) ? 'FrontPage' : file0
|
|
127
135
|
t_file=File.join(@l_dir,'cache/parser',file)
|
|
@@ -135,7 +143,9 @@ EOS
|
|
|
135
143
|
p "If you get 整形式になっていません, try login as a valid user."
|
|
136
144
|
end
|
|
137
145
|
|
|
138
|
-
desc 'rsync', 'rsync files'
|
|
146
|
+
desc 'rsync,--rsync', 'rsync files'
|
|
147
|
+
map "--rsync" => "rsync"
|
|
148
|
+
option :rsync
|
|
139
149
|
def rsync
|
|
140
150
|
p local = @l_dir
|
|
141
151
|
p global = @src[:srcs][@target][:global_dir]
|
|
@@ -143,13 +153,15 @@ EOS
|
|
|
143
153
|
system command
|
|
144
154
|
end
|
|
145
155
|
|
|
146
|
-
desc 'datebase FILE', 'read datebase file'
|
|
156
|
+
desc 'datebase FILE,--database FILE', 'read datebase file'
|
|
157
|
+
map "--database" => "database"
|
|
147
158
|
def database(file_name)
|
|
148
159
|
info=InfoDB.new(@l_dir)
|
|
149
160
|
p info.show(file_name)
|
|
150
161
|
end
|
|
151
162
|
|
|
152
|
-
desc 'display FILE', 'display converted hikifile'
|
|
163
|
+
desc 'display FILE,--display FILE', 'display converted hikifile'
|
|
164
|
+
map "--display" => "display"
|
|
153
165
|
def display(file)
|
|
154
166
|
body = HikiDoc.to_html(File.read(file))
|
|
155
167
|
source = HTML_TEMPLATE
|
|
@@ -161,13 +173,15 @@ EOS
|
|
|
161
173
|
system "open #{t.path}"
|
|
162
174
|
end
|
|
163
175
|
|
|
164
|
-
desc 'checkdb', 'check database file'
|
|
176
|
+
desc 'checkdb,--checkdb', 'check database file'
|
|
177
|
+
map "--checkdb" => "checkdb"
|
|
165
178
|
def checkdb
|
|
166
179
|
result= InfoDB.new(@l_dir).show_inconsist
|
|
167
180
|
print (result=='') ? "db agrees with text dir.\n" : result
|
|
168
181
|
end
|
|
169
182
|
|
|
170
|
-
desc 'remove [FILE]', 'remove files'
|
|
183
|
+
desc 'remove [FILE],--remove [FILE]', 'remove files'
|
|
184
|
+
map "--remove" => "remove"
|
|
171
185
|
def remove(file_name)
|
|
172
186
|
p text_path = File.join(@l_dir,'text',file_name)
|
|
173
187
|
p attach_path = File.join(@l_dir,'cache/attach',file_name)
|
|
@@ -189,7 +203,8 @@ EOS
|
|
|
189
203
|
info.dump
|
|
190
204
|
end
|
|
191
205
|
|
|
192
|
-
desc 'move [FILE]', 'move file'
|
|
206
|
+
desc 'move [FILE],--move [FILE]', 'move file'
|
|
207
|
+
map "--move" => "move"
|
|
193
208
|
def move(files)
|
|
194
209
|
begin
|
|
195
210
|
p file1_path = File.join(@l_dir,'text',files[0])
|
|
@@ -251,7 +266,8 @@ EOS
|
|
|
251
266
|
info.dump
|
|
252
267
|
end
|
|
253
268
|
|
|
254
|
-
desc 'euc FILE', 'translate file to euc'
|
|
269
|
+
desc 'euc FILE,--euc FILE', 'translate file to euc'
|
|
270
|
+
map "--euc" => "euc"
|
|
255
271
|
def euc(file)
|
|
256
272
|
p file_path = File.join(@l_dir,'text',file)
|
|
257
273
|
cont = File.readlines(file_path)
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
require 'thor'
|
|
3
|
+
require 'kconv'
|
|
4
|
+
require 'hikidoc'
|
|
5
|
+
require 'erb'
|
|
6
|
+
require "hikiutils/version"
|
|
7
|
+
require "hikiutils/tmarshal"
|
|
8
|
+
require "hikiutils/infodb"
|
|
9
|
+
require 'systemu'
|
|
10
|
+
require 'fileutils'
|
|
11
|
+
require 'yaml'
|
|
12
|
+
require 'pp'
|
|
13
|
+
|
|
14
|
+
module Hikithor
|
|
15
|
+
|
|
16
|
+
DATA_FILE=File.join(ENV['HOME'],'.hikirc')
|
|
17
|
+
attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CLI < Thor
|
|
21
|
+
def initialize(*args)
|
|
22
|
+
super
|
|
23
|
+
@data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
|
|
24
|
+
data_path = File.join(ENV['HOME'], '.hikirc')
|
|
25
|
+
DataFiles.prepare(data_path)
|
|
26
|
+
|
|
27
|
+
file = File.open(DATA_FILE,'r')
|
|
28
|
+
@src = YAML.load(file.read)
|
|
29
|
+
file.close
|
|
30
|
+
@target = @src[:target]
|
|
31
|
+
@l_dir=@src[:srcs][@target][:local_dir]
|
|
32
|
+
browser = @src[:browser]
|
|
33
|
+
@browser = (browser==nil) ? 'firefox' : browser
|
|
34
|
+
p editor_command = @src[:editor_command]
|
|
35
|
+
@editor_command = (editor_command==nil) ? 'open -a mi' : editor_command
|
|
36
|
+
end
|
|
37
|
+
HTML_TEMPLATE = <<EOS
|
|
38
|
+
<!DOCTYPE html
|
|
39
|
+
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
40
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
|
41
|
+
<html lang="ja">
|
|
42
|
+
<html>
|
|
43
|
+
<head>
|
|
44
|
+
<meta http-equiv="Content-Language" content="ja">
|
|
45
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
46
|
+
<title><%= title %></title>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
<%= body %>
|
|
50
|
+
</body>
|
|
51
|
+
</html>
|
|
52
|
+
EOS
|
|
53
|
+
|
|
54
|
+
desc 'show,--show', 'show sources'
|
|
55
|
+
map "--show" => "show"
|
|
56
|
+
def show
|
|
57
|
+
printf("target_no:%i\n",@src[:target])
|
|
58
|
+
printf("editor_command:%s\n",@src[:editor_command])
|
|
59
|
+
@i_size,@n_size,@l_size,@g_size=3,5,30,15 #i,g_size are fixed
|
|
60
|
+
n_l,l_l=0,0
|
|
61
|
+
@src[:srcs].each_with_index{|src,i|
|
|
62
|
+
n_l =(n_l= src[:nick_name].length)>@n_size? n_l:@n_size
|
|
63
|
+
l_l =(l_l= src[:local_dir].length)>@l_size? l_l:@l_size
|
|
64
|
+
}
|
|
65
|
+
@n_size,@l_size=n_l,l_l
|
|
66
|
+
command = Command.new
|
|
67
|
+
header = command.display_format('id','name','local directory','global uri',@i_size,@n_size,@l_size,@g_size)
|
|
68
|
+
|
|
69
|
+
puts header
|
|
70
|
+
puts '-' * header.size
|
|
71
|
+
|
|
72
|
+
@src[:srcs].each_with_index{|src,i|
|
|
73
|
+
target = i==@src[:target] ? '*':' '
|
|
74
|
+
id = target+i.to_s
|
|
75
|
+
name=src[:nick_name]
|
|
76
|
+
local=src[:local_dir]
|
|
77
|
+
global=src[:global_uri]
|
|
78
|
+
puts command.display_format(id,name,local,global,@i_size,@n_size,@l_size,@g_size)
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
desc 'version,--version,-v', 'show program version'
|
|
83
|
+
map "--version" => "version"
|
|
84
|
+
map "-v" => "version"
|
|
85
|
+
def version
|
|
86
|
+
puts HikiUtils::VERSION
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
desc 'add,--add', 'add sources info'
|
|
90
|
+
map "--add" => "add"
|
|
91
|
+
option :add
|
|
92
|
+
def add
|
|
93
|
+
cont = {}
|
|
94
|
+
@data_name.each{|name|
|
|
95
|
+
printf("%s ? ", name)
|
|
96
|
+
tmp = STDIN.gets.chomp
|
|
97
|
+
cont[name.to_sym] = tmp
|
|
98
|
+
}
|
|
99
|
+
@src[:srcs] << cont
|
|
100
|
+
show
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc 'target VAL,--target VAL', 'set target id'
|
|
104
|
+
map "--target" => "target"
|
|
105
|
+
def target(val)
|
|
106
|
+
@src[:target] = val.to_i
|
|
107
|
+
show
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
desc 'edit FILE,--edit FILE', 'open file'
|
|
111
|
+
map "--edit" => "edit"
|
|
112
|
+
def edit(file)
|
|
113
|
+
t_file=File.join(@l_dir,'text',file)
|
|
114
|
+
if !File.exist?(t_file) then
|
|
115
|
+
file=File.open(t_file,'w')
|
|
116
|
+
file.close
|
|
117
|
+
File.chmod(0777,t_file)
|
|
118
|
+
end
|
|
119
|
+
p command="#{@editor_command} #{t_file}"
|
|
120
|
+
system command
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
desc 'list [FILE],--list [FILE]', 'list files'
|
|
124
|
+
map "--list" => "list"
|
|
125
|
+
def list(file)
|
|
126
|
+
file ='' if file==nil
|
|
127
|
+
t_file=File.join(@l_dir,'text')
|
|
128
|
+
print "target_dir : "+t_file+"\n"
|
|
129
|
+
print `cd #{t_file} ; ls -lt #{file}*`
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
desc 'update FILE,--update FILE', 'update file'
|
|
133
|
+
map "--update" => "update"
|
|
134
|
+
def update(file0)
|
|
135
|
+
file = (file0==nil) ? 'FrontPage' : file0
|
|
136
|
+
t_file=File.join(@l_dir,'cache/parser',file)
|
|
137
|
+
FileUtils.rm(t_file,:verbose=>true)
|
|
138
|
+
info=InfoDB.new(@l_dir)
|
|
139
|
+
info.update(file0)
|
|
140
|
+
l_path = @src[:srcs][@target][:local_uri]
|
|
141
|
+
p command="open -a #{@browser} \'#{l_path}/?#{file}\'"
|
|
142
|
+
system command
|
|
143
|
+
p "If you get open error, try rackup from the src_dir."
|
|
144
|
+
p "If you get 整形式になっていません, try login as a valid user."
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
desc 'rsync,--rsync', 'rsync files'
|
|
148
|
+
map "--rsync" => "rsync"
|
|
149
|
+
option :rsync
|
|
150
|
+
def rsync
|
|
151
|
+
p local = @l_dir
|
|
152
|
+
p global = @src[:srcs][@target][:global_dir]
|
|
153
|
+
p command="rsync -auvz -e ssh #{local}/ #{global}"
|
|
154
|
+
system command
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
desc 'datebase FILE,--database FILE', 'read datebase file'
|
|
158
|
+
map "--database" => "database"
|
|
159
|
+
def database(file_name)
|
|
160
|
+
info=InfoDB.new(@l_dir)
|
|
161
|
+
p info.show(file_name)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
desc 'display FILE,--display FILE', 'display converted hikifile'
|
|
165
|
+
map "--display" => "display"
|
|
166
|
+
def display(file)
|
|
167
|
+
body = HikiDoc.to_html(File.read(file))
|
|
168
|
+
source = HTML_TEMPLATE
|
|
169
|
+
title = File.basename(file)
|
|
170
|
+
erb = ERB.new(source)
|
|
171
|
+
t = File.open(file+".html",'w')
|
|
172
|
+
t.puts(erb.result(binding))
|
|
173
|
+
t.close
|
|
174
|
+
system "open #{t.path}"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
desc 'checkdb,--checkdb', 'check database file'
|
|
178
|
+
map "--checkdb" => "checkdb"
|
|
179
|
+
def checkdb
|
|
180
|
+
result= InfoDB.new(@l_dir).show_inconsist
|
|
181
|
+
print (result=='') ? "db agrees with text dir.\n" : result
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
desc 'remove [FILE],--remove [FILE]', 'remove files'
|
|
185
|
+
map "--remove" => "remove"
|
|
186
|
+
def remove(file_name)
|
|
187
|
+
p text_path = File.join(@l_dir,'text',file_name)
|
|
188
|
+
p attach_path = File.join(@l_dir,'cache/attach',file_name)
|
|
189
|
+
begin
|
|
190
|
+
File.delete(text_path)
|
|
191
|
+
rescue => evar
|
|
192
|
+
puts evar.to_s
|
|
193
|
+
end
|
|
194
|
+
begin
|
|
195
|
+
Dir.rmdir(attach_path)
|
|
196
|
+
rescue => evar
|
|
197
|
+
puts evar.to_s
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
info=InfoDB.new(@l_dir)
|
|
201
|
+
p "delete "
|
|
202
|
+
del_file=info.delete(file_name)
|
|
203
|
+
info.show_link(file_name)
|
|
204
|
+
info.dump
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
desc 'move [FILE],--move [FILE]', 'move file'
|
|
208
|
+
map "--move" => "move"
|
|
209
|
+
def move(files)
|
|
210
|
+
begin
|
|
211
|
+
p file1_path = File.join(@l_dir,'text',files[0])
|
|
212
|
+
p file2_path = File.join(@l_dir,'text',files[1])
|
|
213
|
+
rescue => evar
|
|
214
|
+
puts evar.to_s
|
|
215
|
+
puts "error on move_files, check the input format, especially comma separation."
|
|
216
|
+
exit
|
|
217
|
+
end
|
|
218
|
+
return if file1_path==file2_path
|
|
219
|
+
if File.exist?(file2_path) then
|
|
220
|
+
print ("moving target #{files[1]} exists.\n")
|
|
221
|
+
print ("first remove#{files[1]}.\n")
|
|
222
|
+
return
|
|
223
|
+
else
|
|
224
|
+
File.rename(file1_path,file2_path)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
info=InfoDB.new(@l_dir)
|
|
228
|
+
|
|
229
|
+
db = info.db
|
|
230
|
+
|
|
231
|
+
pp file0=db[files[0]]
|
|
232
|
+
db.delete(files[0])
|
|
233
|
+
db[files[1]]=file0
|
|
234
|
+
db[files[1]][:title]=files[1] if db[files[1]][:title]==files[0]
|
|
235
|
+
pp db[files[1]]
|
|
236
|
+
|
|
237
|
+
db.each{|ele|
|
|
238
|
+
ref = ele[1][:references]
|
|
239
|
+
if ref.include?(files[0]) then
|
|
240
|
+
p link_file=ele[0]
|
|
241
|
+
link_path = File.join(@l_dir,'text',link_file)
|
|
242
|
+
|
|
243
|
+
cont = File.read(link_path)
|
|
244
|
+
if Kconv.iseuc(cont) then
|
|
245
|
+
print "euc\n"
|
|
246
|
+
utf8_cont=cont.toutf8
|
|
247
|
+
utf8_cont.gsub!(/#{files[0]}/,"#{files[1]}")
|
|
248
|
+
cont = utf8_cont.toeuc
|
|
249
|
+
else
|
|
250
|
+
cont.gsub!(/#{files[0]}/,"#{files[1]}")
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
File.write(link_path,cont)
|
|
254
|
+
|
|
255
|
+
ref.delete(files[0])
|
|
256
|
+
ref << files[1]
|
|
257
|
+
|
|
258
|
+
p cache_path = File.join(@l_dir,'cache/parser',link_file)
|
|
259
|
+
begin
|
|
260
|
+
File.delete(cache_path)
|
|
261
|
+
rescue => evar
|
|
262
|
+
puts evar.to_s
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
info.dump
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
desc 'euc FILE,--euc FILE', 'translate file to euc'
|
|
271
|
+
map "--euc" => "euc"
|
|
272
|
+
def euc(file)
|
|
273
|
+
p file_path = File.join(@l_dir,'text',file)
|
|
274
|
+
cont = File.readlines(file_path)
|
|
275
|
+
cont.each{|line| puts line.toeuc }
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
class Command
|
|
280
|
+
def display_format(id, name, local, global, i_size, n_size, l_size, g_size)
|
|
281
|
+
name_length = n_size-full_width_count(name)
|
|
282
|
+
local_length = l_size-full_width_count(local)
|
|
283
|
+
global_string= global.size < g_size ? global : global[0..g_size]
|
|
284
|
+
[id.to_s.rjust(i_size), name.ljust(name_length),
|
|
285
|
+
local.ljust(local_length),
|
|
286
|
+
global_string.ljust(g_size)].join(' | ')
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def full_width_count(string)
|
|
290
|
+
string.each_char.select{|char| !(/[ -~。-゚]/.match(char))}.count
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
module DataFiles
|
|
297
|
+
def self.prepare(data_path)
|
|
298
|
+
create_file_if_not_exists(data_path)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def self.create_file_if_not_exists(data_path)
|
|
302
|
+
return if File::exists?(data_path)
|
|
303
|
+
create_data_file(data_path)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def self.create_data_file(data_path)
|
|
307
|
+
print "make #{data_path}\n"
|
|
308
|
+
init_data_file(data_path)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# initialize source file by dummy data
|
|
312
|
+
def self.init_data_file(data_path)
|
|
313
|
+
@src = {:target => 0, :editor_command => 'open -a mi',
|
|
314
|
+
:srcs=>[{:nick_name => 'hoge', :local_dir => 'hogehoge',
|
|
315
|
+
:local_uri => 'http://localhost/~hoge',
|
|
316
|
+
:global_dir => 'hoge@global_host:/hoge',
|
|
317
|
+
:global_uri => 'http://hoge'}]}
|
|
318
|
+
file = File.open(data_path,'w')
|
|
319
|
+
YAML.dump(@src,file)
|
|
320
|
+
file.close
|
|
321
|
+
end
|
|
322
|
+
private_class_method :create_file_if_not_exists, :create_data_file, :init_data_file
|
|
323
|
+
end
|
|
324
|
+
|