hikiutils 0.2.3.6 → 0.2.3.7
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/hikiutils.gemspec~ +43 -0
- data/hikiutils_bob/Rakefile +78 -48
- data/hikiutils_bob/figs/hikiutils_bob.pdf +0 -0
- data/hikiutils_bob/hikiutils_bob.hiki +4 -2
- data/hikiutils_bob/latex_dir/hikiutils_bob.log +13 -15
- 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.tex +3 -0
- data/hikiutils_bob/latex_dir/hikiutils_bob.toc +1 -1
- data/hikiutils_bob/latex_dir/latex_all).aux +21 -0
- data/hikiutils_bob/latex_dir/latex_all.tex +1 -3
- data/hikiutils_bob/latex_dir/sync).aux +21 -0
- data/hikiutils_bob/latex_dir/sync.aux +1 -1
- data/hikiutils_bob/latex_dir/sync.log +81 -66
- data/hikiutils_bob/latex_dir/sync.pdf +0 -0
- data/hikiutils_bob/latex_dir/sync.synctex.gz +0 -0
- data/hikiutils_bob/latex_dir/sync.tex +3 -3
- data/hikiutils_bob/latex_dir/sync.toc +17 -0
- data/hikiutils_bob/sync.hiki +5 -3
- data/hikiutils_yamane/Rakefile +62 -23
- data/hikiutils_yamane/clidescription.hiki +35 -0
- data/hikiutils_yamane/code.hiki +285 -0
- data/hikiutils_yamane/compare.hiki +309 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.001.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.002.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.003.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.004.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.005.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.006.jpg +0 -0
- data/hikiutils_yamane/figs/hikiutils_yamane_09_copy.007.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane.hiki +15 -23
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.001.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.002.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.003.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.004.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.005.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.006.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/222/343/202/232/343/203/274.007.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.001.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.002.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.003.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.004.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.005.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.006.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274/hikiutils_yamane_09 /343/201/256/343/202/263/343/203/224/343/203/274.007.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09.key +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_FamilyChineseOahu_EN_00317_2040x1360-small-12.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_FamilyChineseOahu_EN_02016_981x654-small-14.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_familychineseoahu_en_00317_2040x1360-96.jpeg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_familychineseoahu_en_02016_981x654-97.jpeg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_familychineseoahu_en_02390_2880x1921-94.jpeg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/110809_familychineseoahu_en_02390_2880x1921-small-95.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt0@2x-102.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt10@2x-112.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt1@2x-103.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt2@2x-104.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt3@2x-105.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt4@2x-106.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt5@2x-107.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt6@2x-108.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt7@2x-109.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt8@2x-110.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/mt9@2x-111.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/pasted-image-100.tiff +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/pasted-image-98.tiff +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/pasted-image-small-101.png +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/pasted-image-small-99.png +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st0-113.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st1-114.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st2-115.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st3-116.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st4-117.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st5-118.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/st6-119.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Data/tile_paper_medgray-93.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Index.zip +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Metadata/BuildVersionHistory.plist +8 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Metadata/DocumentIdentifier +1 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/Metadata/Properties.plist +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/preview-micro.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/preview-web.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy.key/preview.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.001.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.002.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.003.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.004.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.005.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.006.jpg +0 -0
- data/hikiutils_yamane/hikiutils_yamane_09_copy/hikiutils_yamane_09_copy.007.jpg +0 -0
- data/hikiutils_yamane/latex_dir/abstract.aux +2 -2
- data/hikiutils_yamane/latex_dir/clidescription.aux +25 -0
- data/hikiutils_yamane/latex_dir/clidescription.tex +42 -0
- data/hikiutils_yamane/latex_dir/code.aux +41 -0
- data/hikiutils_yamane/latex_dir/code.tex +319 -0
- data/hikiutils_yamane/latex_dir/compare.aux +40 -0
- data/hikiutils_yamane/latex_dir/compare.tex +351 -0
- data/hikiutils_yamane/latex_dir/head.tex +1 -0
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.aux +8 -0
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.log +159 -63
- 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 -10
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.toc +48 -20
- data/hikiutils_yamane/latex_dir/introduction.aux +7 -7
- data/hikiutils_yamane/latex_dir/purpose.aux +25 -0
- data/hikiutils_yamane/latex_dir/purpose.tex +21 -0
- data/hikiutils_yamane/latex_dir/results.aux +22 -31
- data/hikiutils_yamane/latex_dir/results.tex +100 -318
- data/hikiutils_yamane/mi +0 -0
- data/hikiutils_yamane/purpose.hiki +18 -0
- data/hikiutils_yamane/results.hiki +11 -277
- data/lib/hikiutils/version.rb +1 -1
- data/lib/templates/Rakefile_hiki_sync +56 -20
- data/lib/templates/head.tex +1 -0
- metadata +84 -3
- data/hikiutils_yamane/hikiutils_yamane.key~11b9dba1272d2104b420497d11c6eda206ace6c2 +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -109,12 +109,12 @@ figsディレクトリー内のファイルはhiki/cache/attache/hikiutils\_bob
|
|
|
109
109
|
\verb|{{attach_view(hogehoge.png)}}|
|
|
110
110
|
という記述が必要となる.
|
|
111
111
|
|
|
112
|
-
\subsubsection{rake convert}
|
|
112
|
+
\subsubsection{rake convert VAL DIR}
|
|
113
113
|
keynoteが吐き出したイメージを変換するためのコマンド.ImageMagickがインストールされている必要がある.ない場合は,自分でbrewからinstallするか,\verb|https://www.imagemagick.org/script/binary-releases.php|からダウンロード.うまくいかない場合はdonkeyに聞いてみてください.
|
|
114
114
|
\begin{quote}\begin{verbatim}
|
|
115
115
|
rake convert 80 hikiutils_bob
|
|
116
116
|
\end{verbatim}\end{quote}
|
|
117
|
-
によって,hikiutils\_bob
|
|
117
|
+
によって,DIR=hikiutils\_bobにあるpngファイルをVAL=80%に縮小してfigsにためる.
|
|
118
118
|
|
|
119
119
|
\subsubsection{rake force\_sync}
|
|
120
120
|
hikiシステム側で直接変更を加えると,hikiutilsがsyncした時と差ができる.これを検知して,ユーザに注意を喚起する仕組みがある(rake check\_previous).これはsyncした時に自動的に呼び出される.違いの出たfilesを修正した後に強制的に同期をとるためのコマンドとして,force\_syncが用意されている.
|
|
@@ -131,7 +131,7 @@ rake increment 2 tmp.hiki > tmp2.hiki
|
|
|
131
131
|
としてattach\_viewのページ番号を単純に増加させることができる.
|
|
132
132
|
|
|
133
133
|
\subsubsection{rake number}
|
|
134
|
-
|
|
134
|
+
rake incrementと同じくfigs内の通し番号が変わった時にattach\_viewの通し番号を調整するコマンド.
|
|
135
135
|
\begin{lstlisting}[style=]
|
|
136
136
|
rake number 3 hikiutils_bob.hiki > tmp.hiki
|
|
137
137
|
cp tmp.hiki hikiutils_bob.hiki
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
\contentsline {section}{\numberline {1}イントロダクション}{1}
|
|
2
|
+
\contentsline {section}{\numberline {2}hikiとの同期}{1}
|
|
3
|
+
\contentsline {subsection}{\numberline {2.1}hikiutilsのinstall}{1}
|
|
4
|
+
\contentsline {subsection}{\numberline {2.2}個別ディレクトリーの構成}{2}
|
|
5
|
+
\contentsline {subsection}{\numberline {2.3}一般的な執筆手順}{3}
|
|
6
|
+
\contentsline {subsection}{\numberline {2.4}rakeが用意しているタスク}{3}
|
|
7
|
+
\contentsline {subsubsection}{\numberline {2.4.1}rake sync}{3}
|
|
8
|
+
\contentsline {subsubsection}{\numberline {2.4.2}rake convert VAL DIR}{4}
|
|
9
|
+
\contentsline {subsubsection}{\numberline {2.4.3}rake force\_sync}{4}
|
|
10
|
+
\contentsline {subsubsection}{\numberline {2.4.4}rake chenv}{4}
|
|
11
|
+
\contentsline {subsubsection}{\numberline {2.4.5}rake increment}{4}
|
|
12
|
+
\contentsline {subsubsection}{\numberline {2.4.6}rake number}{4}
|
|
13
|
+
\contentsline {subsection}{\numberline {2.5}githubによる同期}{4}
|
|
14
|
+
\contentsline {subsection}{\numberline {2.6}hikiutil関連のヘルプ}{5}
|
|
15
|
+
\contentsline {subsubsection}{\numberline {2.6.1}hikiで卒論を書くときの初期化と掟}{5}
|
|
16
|
+
\contentsline {subsubsection}{\numberline {2.6.2}error対応}{5}
|
|
17
|
+
\contentsline {subsubsection}{\numberline {2.6.3}図表:すべての図表をkeynoteにまとめる,タイトルを分かりやすく書く}{6}
|
data/hikiutils_bob/sync.hiki
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{{toc}}
|
|
2
|
+
!title:卒論編集システムにおけるhikiとの同期
|
|
3
|
+
!author:関西学院大学理工学部情報科学科 西谷滋人
|
|
2
4
|
!イントロダクション
|
|
3
5
|
卒業論文は,大学で課される普通の授業のレポートに比べて多くの情報内容が要求されます.また,研究という側面から体裁や版権など多くの出版における掟を遵守しながら,高い品質を保つ必要です.そのため,指導教官との編集作業が重要となるます.編集作業の効率を高めるためには,共同作業を促進するプラットフォームが必要です.
|
|
4
6
|
|
|
@@ -83,11 +85,11 @@ figsディレクトリー内のファイルはhiki/cache/attache/hikiutils_bob
|
|
|
83
85
|
{{attach_view(hogehoge.png, hikiutils_bob)}}
|
|
84
86
|
という記述が必要となる.
|
|
85
87
|
|
|
86
|
-
!!!rake convert
|
|
88
|
+
!!!rake convert VAL DIR
|
|
87
89
|
keynoteが吐き出したイメージを変換するためのコマンド.ImageMagickがインストールされている必要がある.ない場合は,自分でbrewからinstallするか,[[https://www.imagemagick.org/script/binary-releases.php]]からダウンロード.うまくいかない場合はdonkeyに聞いてみてください.
|
|
88
90
|
|
|
89
91
|
rake convert 80 hikiutils_bob
|
|
90
|
-
によって,hikiutils_bob
|
|
92
|
+
によって,DIR=hikiutils_bobにあるpngファイルをVAL=80%に縮小してfigsにためる.
|
|
91
93
|
|
|
92
94
|
!!!rake force_sync
|
|
93
95
|
hikiシステム側で直接変更を加えると,hikiutilsがsyncした時と差ができる.これを検知して,ユーザに注意を喚起する仕組みがある(rake check_previous).これはsyncした時に自動的に呼び出される.違いの出たfilesを修正した後に強制的に同期をとるためのコマンドとして,force_syncが用意されている.
|
|
@@ -104,7 +106,7 @@ rake increment 2 tmp.hiki > tmp2.hiki
|
|
|
104
106
|
としてattach_viewのページ番号を単純に増加させることができる.
|
|
105
107
|
|
|
106
108
|
!!!rake number
|
|
107
|
-
|
|
109
|
+
rake incrementと同じくfigs内の通し番号が変わった時にattach_viewの通し番号を調整するコマンド.
|
|
108
110
|
<<< bash
|
|
109
111
|
rake number 3 hikiutils_bob.hiki > tmp.hiki
|
|
110
112
|
cp tmp.hiki hikiutils_bob.hiki
|
data/hikiutils_yamane/Rakefile
CHANGED
|
@@ -9,8 +9,15 @@ rescue => e
|
|
|
9
9
|
exit
|
|
10
10
|
end
|
|
11
11
|
dirnames=Dir.pwd.split('/')
|
|
12
|
-
basename = (dirnames[-1]=='hikis')? dirnames[-2] : dirnames[-1]
|
|
12
|
+
$basename = (dirnames[-1]=='hikis')? dirnames[-2] : dirnames[-1]
|
|
13
13
|
$latex_dir= 'latex_dir'
|
|
14
|
+
$section_layer = {}
|
|
15
|
+
|
|
16
|
+
task :github do
|
|
17
|
+
status, stdout, stderr = systemu %q( git remote -v |grep origin )
|
|
18
|
+
p github_dir=stdout.match(/(.+):(.+) \(push\)/)[2]
|
|
19
|
+
system "open https://github.com/#{github_dir}"
|
|
20
|
+
end
|
|
14
21
|
|
|
15
22
|
task :default do
|
|
16
23
|
system 'rake -T'
|
|
@@ -26,32 +33,63 @@ task :latex_wrap => [:latex_base, :change_wrap] do
|
|
|
26
33
|
exit
|
|
27
34
|
end
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
task :latex_all do
|
|
31
|
-
p entries=Dir.entries('.')
|
|
36
|
+
def latex_loop(entries,opts={})
|
|
32
37
|
main_file=""
|
|
33
38
|
entries.each{|file|
|
|
34
|
-
|
|
39
|
+
options={:latex_all=>true}
|
|
40
|
+
next unless file.split('.')[1]=='hiki'
|
|
35
41
|
next if file.include?('.hikirc')
|
|
36
42
|
f_name =File.basename(file,'.hiki')
|
|
37
|
-
if
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
if opts[:main]
|
|
44
|
+
if f_name==$basename
|
|
45
|
+
options[:latex]="--listings --head latex_dir/head.tex -p "
|
|
46
|
+
options[:main]=true
|
|
47
|
+
main_file=f_name
|
|
48
|
+
convert_to_latex(file, options)
|
|
49
|
+
end
|
|
40
50
|
else
|
|
41
|
-
|
|
51
|
+
if f_name!=$basename
|
|
52
|
+
p level = $section_layer[f_name] || 1
|
|
53
|
+
options[:latex]="-l #{level} --listings -b "
|
|
54
|
+
convert_to_latex(file, options)
|
|
55
|
+
end
|
|
42
56
|
end
|
|
43
|
-
convert_to_latex(file, option)
|
|
44
57
|
}
|
|
58
|
+
return main_file
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def check_section_layers(lines)
|
|
62
|
+
p reg_exp = Regexp.new("#{$basename}_(.+)")
|
|
63
|
+
lines.each{|line|
|
|
64
|
+
p line
|
|
65
|
+
if m=line.match(/(!+)\[\[(.+)\]\]/)
|
|
66
|
+
p count = m[1].count('!')
|
|
67
|
+
p file_name=m[2].match(reg_exp)[1]
|
|
68
|
+
$section_layer[file_name]=count
|
|
69
|
+
end
|
|
70
|
+
}
|
|
71
|
+
p $section_layer
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc "latex conversion whole hiki files in the current dir."
|
|
75
|
+
task :latex_all do
|
|
76
|
+
p entries=Dir.entries('.')
|
|
77
|
+
main_file = latex_loop(entries,opts={:main=>true})
|
|
78
|
+
latex_loop(entries)
|
|
45
79
|
cont=""
|
|
80
|
+
p reg_exp = Regexp.new("#{$basename}_(.+)")
|
|
46
81
|
File.readlines(File.join($latex_dir,"#{main_file}.tex")).each{|line|
|
|
47
|
-
if line.match(/section{(.+)}/)
|
|
48
|
-
if m=line.match(
|
|
82
|
+
if line.match(/section{(.+)}/)
|
|
83
|
+
if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
|
|
84
|
+
p m
|
|
85
|
+
p m_t=m[2].match(reg_exp)[1]
|
|
86
|
+
line = "\\include{#{m_t}}\n"
|
|
87
|
+
elsif m=line.match(/section{\\verb\|(.+)\|}/)
|
|
49
88
|
p m
|
|
50
|
-
p reg_exp = Regexp.new("#{basename}_(.+)")
|
|
51
89
|
p m_t=m[1].match(reg_exp)[1]
|
|
52
90
|
line = "\\include{#{m_t}}\n"
|
|
53
91
|
else
|
|
54
|
-
line = ""
|
|
92
|
+
# line = ""
|
|
55
93
|
end
|
|
56
94
|
end
|
|
57
95
|
cont << line
|
|
@@ -68,26 +106,28 @@ task :latex_base do
|
|
|
68
106
|
system("open #{$save_name}")
|
|
69
107
|
end
|
|
70
108
|
|
|
71
|
-
def convert_to_latex(file_name,
|
|
109
|
+
def convert_to_latex(file_name, options={})
|
|
72
110
|
p file_name = file_name.include?('.hiki')? file_name : file_name+'.hiki'
|
|
73
111
|
p tex_name = File.basename(file_name,'.hiki')+'.tex'
|
|
74
112
|
p $save_name = ARGV[2] || File.join($latex_dir,tex_name)
|
|
75
113
|
pre_name = File.join($latex_dir,'pre.tex')
|
|
76
114
|
p pre_command = File.exist?(pre_name) ? '--pre '+pre_name : nil
|
|
77
115
|
lines = File.readlines(file_name)
|
|
116
|
+
check_section_layers(lines) if options[:main]
|
|
78
117
|
cont = ""
|
|
79
118
|
lines.each{|line|
|
|
80
119
|
if m=line.match(/\{\{attach_view\((.*),(.*)\)\}\}/)
|
|
81
120
|
p line="\{\{attach_view\(#{m[1]}\)\}\}\n"
|
|
121
|
+
elsif options[:latex_all]
|
|
122
|
+
line="" if line.match(/title:|author:|date:/)
|
|
82
123
|
end
|
|
83
124
|
cont << line
|
|
84
125
|
}
|
|
85
126
|
tf1,tf2='tmp1.txt','tmp2.txt'
|
|
86
127
|
File.open(tf1,'w'){|file| file.print cont}
|
|
87
|
-
system "hiki2latex #{pre_command} #{
|
|
128
|
+
system "hiki2latex #{pre_command} #{options[:latex]} #{tf1} > #{tf2}"
|
|
88
129
|
lines = File.readlines(tf2)
|
|
89
130
|
system "rm #{tf1} #{tf2}"
|
|
90
|
-
|
|
91
131
|
cont = ""
|
|
92
132
|
lines.each{|line|
|
|
93
133
|
if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
|
|
@@ -193,15 +233,15 @@ desc "sync0 hikis and figs to hiki directory"
|
|
|
193
233
|
task :sync0 do
|
|
194
234
|
entries=Dir.entries('.')
|
|
195
235
|
entries[2..-1].each{|source| #cp *.hiki
|
|
196
|
-
next unless source.
|
|
236
|
+
next unless source.split('.')[1]=='hiki'
|
|
197
237
|
next if source.include?('.hikirc')
|
|
198
238
|
p base = source.split('.')[0]
|
|
199
|
-
name = (base
|
|
239
|
+
name = (base==$basename)? base : $basename+'_'+base
|
|
200
240
|
p target = File.join(target_dir,'text',name)
|
|
201
241
|
FileUtils.cp(source,target,:verbose=>true)
|
|
202
242
|
}
|
|
203
243
|
p entries=Dir.entries('./figs') #cp files in figs
|
|
204
|
-
p target = File.join(target_dir,'cache','attach'
|
|
244
|
+
p target = File.join(target_dir,'cache','attach',$basename)
|
|
205
245
|
FileUtils.mkdir_p(target,:verbose=>true) unless File.exists?(target)
|
|
206
246
|
entries[2..-1].each{|file|
|
|
207
247
|
p source = File.join('./figs',file)
|
|
@@ -209,7 +249,7 @@ task :sync0 do
|
|
|
209
249
|
}
|
|
210
250
|
|
|
211
251
|
File.open('./.hikirc','w'){|file|
|
|
212
|
-
status, stdout, stderr =systemu "hiki -l #{basename}*"
|
|
252
|
+
status, stdout, stderr =systemu "hiki -l #{$basename}*"
|
|
213
253
|
file.print(target_dir+"\n")
|
|
214
254
|
stdout.split("\n")[3..-1].each{|line|
|
|
215
255
|
file.print line+"\n"
|
|
@@ -240,7 +280,7 @@ desc "check previou and current sync"
|
|
|
240
280
|
task :check_previous do
|
|
241
281
|
current={}
|
|
242
282
|
print "current hiki dir\n"
|
|
243
|
-
status, stdout, stderr = systemu("hiki -l #{basename}*")
|
|
283
|
+
status, stdout, stderr = systemu("hiki -l #{$basename}*")
|
|
244
284
|
stdout.split("\n")[3..-1].each{|line|
|
|
245
285
|
p line
|
|
246
286
|
file= line.split(/\s+/)[-1]
|
|
@@ -262,7 +302,6 @@ task :check_previous do
|
|
|
262
302
|
if changed.size != 0
|
|
263
303
|
print("hiki dirで変更が発生しています.\n")
|
|
264
304
|
changed.each{|line| print line+"\n"}
|
|
265
|
-
print("問題がなければrake force_syncで強制同期してください.\n")
|
|
266
305
|
exit
|
|
267
306
|
end
|
|
268
307
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{{toc}}
|
|
2
|
+
!CLIのコード
|
|
3
|
+
hikiutilsのコマンドライン解析ツールをoptparseからthorに換えることでコマンドの書き換えを行うことができた.
|
|
4
|
+
また,thorで書かれたhikiutilsはoptparseで書かれたものよりもコードが短くなり,コマンドの解析も簡単に行えることができた.
|
|
5
|
+
ここではthorとoptparseのコードを比較しthorの良さを確認する.
|
|
6
|
+
!!CLIの解説
|
|
7
|
+
!!!Thor
|
|
8
|
+
Thorとは,コマンドラインツールの作成を支援するライブラリのことである.
|
|
9
|
+
gitやbundlerのようにサブコマンドを含むコマンドラインツールを簡単に作成することができる[1-2].
|
|
10
|
+
|
|
11
|
+
Thorの基本的な流れとしては
|
|
12
|
+
|
|
13
|
+
#Thorを継承したクラスのパブリックメソッドがコマンドになる
|
|
14
|
+
#クラス.start(ARGV)でコマンドラインの処理をスタートする
|
|
15
|
+
という流れである[1-2].
|
|
16
|
+
|
|
17
|
+
startに渡す引数が空の場合,Thorはクラスのヘルプリストを出力する.
|
|
18
|
+
また,Thorはサブコマンドやサブサブコマンドも作ることができる.
|
|
19
|
+
!!!optparse
|
|
20
|
+
optparseとは,getoptよりも簡便で,柔軟性に富み,かつ強力なコマンドライン解析ライブラリである.
|
|
21
|
+
optparseでは,より宣言的なスタイルのコマンドライン解析手法,すなわちOptionParserのインスタンスでコマンドラインを解析するという手法をとっている.
|
|
22
|
+
これを使うと,GNU/POSIX構文でオプションを指定できるだけでなく,使用法やヘルプメッセージの生成も行える[1-3].
|
|
23
|
+
|
|
24
|
+
利用頻度はあまり高くないが古くから開発され,使用例が広く紹介されている.
|
|
25
|
+
|
|
26
|
+
optparseの基本的な流れとしては
|
|
27
|
+
|
|
28
|
+
#OptionParserオブジェクトoptを生成する
|
|
29
|
+
#オプションを取り扱うブロックをopt.onに登録する
|
|
30
|
+
#opt.parse(ARGV)でコマンドラインを実際にparseする
|
|
31
|
+
という流れである.
|
|
32
|
+
|
|
33
|
+
OptionParserはコマンドラインのオプション取り扱うためのクラスであるためオブジェクトoptを生成されopt.onにコマンドを登録することができる.
|
|
34
|
+
しかし,OptionParser\#onにはコマンドが登録されているだけであるため,OptionParser\#parseが呼ばれた時,コマンドラインにオプションが指定されていれば実行される.
|
|
35
|
+
optparseにはデフォルトとして--helpと--versionオプションを認識する[1-4].
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
{{toc}}
|
|
2
|
+
!Thorの初期化
|
|
3
|
+
{{attach_view(hikiutils_yamane_09_copy.003.jpg,hikiutils_yamane)}}
|
|
4
|
+
*Thorのinitializeでのコード
|
|
5
|
+
#Hikithor::CLI.start(ARGV)が呼ばれる
|
|
6
|
+
#initializeメソッドが呼ばれる
|
|
7
|
+
#これではThorのinitializeメソッドが呼ばれない
|
|
8
|
+
#superを書くことでThorのinitializeメソッドが呼ばれる
|
|
9
|
+
optparseではrequireでoptparseを呼びoptparseのinitializeを定義する必要はないが,Thorはinitializeを定義する必要がある.
|
|
10
|
+
Thorの定義方法はrequireでThorを呼びCLIクラスで継承し,initializeメソッドにsuperを書くことでThorのinitializeが呼ばれる.
|
|
11
|
+
initializeメソッド内ではThorの初期設定がされていないため,スーパークラスのメソッドを読み出してくれるsuperを書き加えることで図のようにinitializeメソッド内でThorのinitilalizeメソッドが
|
|
12
|
+
呼ばれ定義される.
|
|
13
|
+
!!コード
|
|
14
|
+
<<< ruby
|
|
15
|
+
# -*- coding: utf-8 -*-
|
|
16
|
+
require 'thor'
|
|
17
|
+
require 'kconv'
|
|
18
|
+
require 'hikidoc'
|
|
19
|
+
require 'erb'
|
|
20
|
+
require "hikiutils/version"
|
|
21
|
+
require "hikiutils/tmarshal"
|
|
22
|
+
require "hikiutils/infodb"
|
|
23
|
+
require 'systemu'
|
|
24
|
+
require 'fileutils'
|
|
25
|
+
require 'yaml'
|
|
26
|
+
require 'pp'
|
|
27
|
+
|
|
28
|
+
module Hikithor
|
|
29
|
+
|
|
30
|
+
DATA_FILE=File.join(ENV['HOME'],'.hikirc')
|
|
31
|
+
attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
|
|
32
|
+
|
|
33
|
+
class CLI < Thor
|
|
34
|
+
def initialize(*args)
|
|
35
|
+
super
|
|
36
|
+
@data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
|
|
37
|
+
data_path = File.join(ENV['HOME'], '.hikirc')
|
|
38
|
+
DataFiles.prepare(data_path)
|
|
39
|
+
|
|
40
|
+
file = File.open(DATA_FILE,'r')
|
|
41
|
+
@src = YAML.load(file.read)
|
|
42
|
+
file.close
|
|
43
|
+
@target = @src[:target]
|
|
44
|
+
@l_dir=@src[:srcs][@target][:local_dir]
|
|
45
|
+
browser = @src[:browser]
|
|
46
|
+
@browser = (browser==nil) ? 'firefox' : browser
|
|
47
|
+
p editor_command = @src[:editor_command]
|
|
48
|
+
@editor_command = (editor_command==nil) ? 'open -a mi' : editor_command
|
|
49
|
+
end
|
|
50
|
+
>>>
|
|
51
|
+
!コマンド表示と処理
|
|
52
|
+
!!Thor
|
|
53
|
+
{{attach_view(hikiutils_yamane_09_copy.004.jpg,hikiutils_yamane)}}
|
|
54
|
+
#コマンド名,コマンドの説明を一覧に表示させる
|
|
55
|
+
#パブリックメソッドのコマンドを別のコマンド名でも実行できるようにする
|
|
56
|
+
#コマンドの命令の実行コード
|
|
57
|
+
Thorではdescで一覧を表示させるコマンド名,コマンドの説明を登録する.しかし,ここで記述したコマンドは一覧で表示させるものであり,実行されることはないので実際のコマンドと対応させる必要がある.
|
|
58
|
+
Thorでは処理実行を行うメソッドがコマンドとなる.しかし,それではコマンド名は1つしか使うことができない.
|
|
59
|
+
ここで用いるものがmapである.
|
|
60
|
+
<<<
|
|
61
|
+
map A => B
|
|
62
|
+
>>>
|
|
63
|
+
mapとはBでしか読めないものをAでも読めるようにしてくれるものである.
|
|
64
|
+
よって,これを使うことで別のコマンドも指定することができる.
|
|
65
|
+
!!optparse
|
|
66
|
+
{{attach_view(hikiutils_yamane_09_copy.005.jpg,hikiutils_yamane)}}
|
|
67
|
+
#OptionParserオブジェクトoptを生成
|
|
68
|
+
#optにコマンドを登録
|
|
69
|
+
#入力されたコマンドの処理のメソッドへ移動
|
|
70
|
+
optparseではOptionParserオブジェクトoptの生成を行い,コマンドをoptに登録することでコマンドを作成することができる.しかし,これはコマンドを登録しているだけで
|
|
71
|
+
コマンドの一覧ではこれを表示することができるが,コマンドの実行を行うためには実行を行うためのメソッドを作成する必要がある.optparseでのコマンドの実行はoptで登録された
|
|
72
|
+
コマンドが入力されることでそれぞれのコマンドの処理を行うメソッドに移動し処理を行う.しかし,このコマンド登録はハイフンを付けたコマンドしか登録ができず,ハイフンなしのコマンド登録は
|
|
73
|
+
また別の手段でやらなくてはいけない.
|
|
74
|
+
以上より,Thorではコマンドの指定と処理にはdesc,map,処理メソッドだけで済むが,optparseではコマンドを登録するためのメソッドと処理メソッドが必要になってくる.
|
|
75
|
+
また,コマンドはThorでは処理メソッドがコマンド名になるが,optparseではコマンドを登録するための処理も必要となってくる.
|
|
76
|
+
|
|
77
|
+
!!コード
|
|
78
|
+
*Thor
|
|
79
|
+
<<< ruby
|
|
80
|
+
desc 'show,--show', 'show sources'
|
|
81
|
+
map "--show" => "show"
|
|
82
|
+
def show
|
|
83
|
+
printf("target_no:%i\n",@src[:target])
|
|
84
|
+
printf("editor_command:%s\n",@src[:editor_command])
|
|
85
|
+
@i_size,@n_size,@l_size,@g_size=3,5,30,15 #i,g_size are fixed
|
|
86
|
+
n_l,l_l=0,0
|
|
87
|
+
@src[:srcs].each_with_index{|src,i|
|
|
88
|
+
n_l =(n_l= src[:nick_name].length)>@n_size? n_l:@n_size
|
|
89
|
+
l_l =(l_l= src[:local_dir].length)>@l_size? l_l:@l_size
|
|
90
|
+
}
|
|
91
|
+
@n_size,@l_size=n_l,l_l
|
|
92
|
+
command = Command.new
|
|
93
|
+
header = command.display_format('id','name','local directory','global uri',@i_size,@n_size,@l_size,@g_size)
|
|
94
|
+
|
|
95
|
+
puts header
|
|
96
|
+
puts '-' * header.size
|
|
97
|
+
|
|
98
|
+
@src[:srcs].each_with_index{|src,i|
|
|
99
|
+
target = i==@src[:target] ? '*':' '
|
|
100
|
+
id = target+i.to_s
|
|
101
|
+
name=src[:nick_name]
|
|
102
|
+
local=src[:local_dir]
|
|
103
|
+
global=src[:global_uri]
|
|
104
|
+
puts command.display_format(id,name,local,global,@i_size,@n_size,@l_size,@g_size)
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
>>>
|
|
108
|
+
*optparse
|
|
109
|
+
<<< ruby
|
|
110
|
+
def execute
|
|
111
|
+
@argv << '--help' if @argv.size==0
|
|
112
|
+
command_parser = OptionParser.new do |opt|
|
|
113
|
+
opt.on('-v', '--version','show program Version.') { |v|
|
|
114
|
+
opt.version = HikiUtils::VERSION
|
|
115
|
+
puts opt.ver
|
|
116
|
+
}
|
|
117
|
+
opt.on('-s', '--show','show sources') {show_sources}
|
|
118
|
+
opt.on('-a', '--add','add sources info') {add_sources }
|
|
119
|
+
opt.on('-t', '--target VAL','set target id') {|val| set_target(val)}
|
|
120
|
+
opt.on('-e', '--edit FILE','open file') {|file| edit_file(file) }
|
|
121
|
+
opt.on('-l', '--list [FILE]','list files') {|file| list_files(file)}
|
|
122
|
+
opt.on('-u', '--update FILE','update file') {|file| update_file(file) }
|
|
123
|
+
opt.on('-r', '--rsync','rsync files') {rsync_files}
|
|
124
|
+
opt.on('--database FILE','read database file') {|file| db_file(file)}
|
|
125
|
+
opt.on('--display FILE','display converted hikifile') {|file| display(file)}
|
|
126
|
+
opt.on('-c', '--checkdb','check database file') {check_db}
|
|
127
|
+
opt.on('--remove FILE','remove file') {|file| remove_file(file)}
|
|
128
|
+
opt.on('--move FILES','move file1,file2',Array) {|files| move_file(files)}
|
|
129
|
+
opt.on('--euc FILE','translate file to euc') {|file| euc_file(file)}
|
|
130
|
+
opt.on('--initialize','initialize source directory') {dir_init() }
|
|
131
|
+
end
|
|
132
|
+
begin
|
|
133
|
+
command_parser.parse!(@argv)
|
|
134
|
+
rescue=> eval
|
|
135
|
+
p eval
|
|
136
|
+
end
|
|
137
|
+
dump_sources
|
|
138
|
+
exit
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def show_sources()
|
|
142
|
+
printf("target_no:%i\n",@src[:target])
|
|
143
|
+
printf("editor_command:%s\n",@src[:editor_command])
|
|
144
|
+
check_display_size()
|
|
145
|
+
header = display_format('id','name','local directory','global uri')
|
|
146
|
+
|
|
147
|
+
puts header
|
|
148
|
+
puts '-' * header.size
|
|
149
|
+
|
|
150
|
+
@src[:srcs].each_with_index{|src,i|
|
|
151
|
+
target = i==@src[:target] ? '*':' '
|
|
152
|
+
id = target+i.to_s
|
|
153
|
+
name=src[:nick_name]
|
|
154
|
+
local=src[:local_dir]
|
|
155
|
+
global=src[:global_uri]
|
|
156
|
+
puts display_format(id,name,local,global)
|
|
157
|
+
}
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def add_sources
|
|
161
|
+
cont = {}
|
|
162
|
+
@data_name.each{|name|
|
|
163
|
+
printf("%s ? ", name)
|
|
164
|
+
tmp = gets.chomp
|
|
165
|
+
cont[name.to_sym] = tmp
|
|
166
|
+
}
|
|
167
|
+
@src[:srcs] << cont
|
|
168
|
+
show_sources
|
|
169
|
+
end
|
|
170
|
+
>>>
|
|
171
|
+
!CLIの実行
|
|
172
|
+
!!Thor
|
|
173
|
+
{{attach_view(hikiutils_yamane_09_copy.006.jpg,hikiutils_yamane)}}
|
|
174
|
+
*実行手順
|
|
175
|
+
|
|
176
|
+
#hiki_thorのHikithor::CLI.start(ARGV)でhikiutils_thor.rbのCLIクラスを呼ぶ
|
|
177
|
+
#hikiutils_thor.rbのCLIクラスのメソッドを順に実行していく
|
|
178
|
+
|
|
179
|
+
Thorではstart(ARGV)を呼び出すことでCLIを開始する.Hikithor::CLI.start(ARGV)を実行されることによりrequireで呼ばれているhikiutils_thor.rbのCLIコマンドを順に実行する.
|
|
180
|
+
そして,入力されたコマンドと一致するメソッドを探し,そのコマンドの処理が実行される.
|
|
181
|
+
!!optparse
|
|
182
|
+
{{attach_view(hikiutils_yamane_09_copy.007.jpg,hikiutils_yamane)}}
|
|
183
|
+
*実行手順
|
|
184
|
+
|
|
185
|
+
#HikiのHikiUtils::Command.run(ARGV)でhikiutils.rbのrunメソッドを呼ぶ
|
|
186
|
+
#new(argv).executeでexecuteメソッドが実行される
|
|
187
|
+
一方,optparseではHikiutils::Command.run(ARGV)を実行される.requireで呼び出されたhikiutils.rbでrunメソッドが実行される.
|
|
188
|
+
そこでコマンドを登録しているexecuteメソッドへ移動し入力したコマンドと対応させる.そして,対応したコマンドの処理が行われるメソッドに移動することで実行される.
|
|
189
|
+
このようにoptparseでは実行を行うためのメソッドが必要であるが,Thorではクラスのメソッドを順に実行していくため
|
|
190
|
+
runメソッドとexecuteメソッドは必要ない.また,optparseでの実行手順はメソッドの移動回数が多く複雑であるが,Thorは単純で分かりやすいものとなっている.
|
|
191
|
+
!!コード
|
|
192
|
+
*Thor
|
|
193
|
+
<<< ruby
|
|
194
|
+
#!/usr/bin/env ruby
|
|
195
|
+
|
|
196
|
+
require "hikiutils_thor"
|
|
197
|
+
|
|
198
|
+
Hikithor::CLI.start(ARGV)
|
|
199
|
+
>>>
|
|
200
|
+
<<< ruby
|
|
201
|
+
# -*- coding: utf-8 -*-
|
|
202
|
+
require 'thor'
|
|
203
|
+
require 'kconv'
|
|
204
|
+
require 'hikidoc'
|
|
205
|
+
require 'erb'
|
|
206
|
+
require "hikiutils/version"
|
|
207
|
+
require "hikiutils/tmarshal"
|
|
208
|
+
require "hikiutils/infodb"
|
|
209
|
+
require 'systemu'
|
|
210
|
+
require 'fileutils'
|
|
211
|
+
require 'yaml'
|
|
212
|
+
require 'pp'
|
|
213
|
+
|
|
214
|
+
module Hikithor
|
|
215
|
+
|
|
216
|
+
DATA_FILE=File.join(ENV['HOME'],'.hikirc')
|
|
217
|
+
attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
|
|
218
|
+
|
|
219
|
+
class CLI < Thor
|
|
220
|
+
def initialize(*args)
|
|
221
|
+
super
|
|
222
|
+
@data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
|
|
223
|
+
data_path = File.join(ENV['HOME'], '.hikirc')
|
|
224
|
+
DataFiles.prepare(data_path)
|
|
225
|
+
|
|
226
|
+
file = File.open(DATA_FILE,'r')
|
|
227
|
+
@src = YAML.load(file.read)
|
|
228
|
+
file.close
|
|
229
|
+
@target = @src[:target]
|
|
230
|
+
@l_dir=@src[:srcs][@target][:local_dir]
|
|
231
|
+
browser = @src[:browser]
|
|
232
|
+
@browser = (browser==nil) ? 'firefox' : browser
|
|
233
|
+
|
|
234
|
+
>>>
|
|
235
|
+
*optparse
|
|
236
|
+
<<< ruby
|
|
237
|
+
#!/usr/bin/env ruby
|
|
238
|
+
|
|
239
|
+
require "hikiutils"
|
|
240
|
+
|
|
241
|
+
HikiUtils::Command.run(ARGV)
|
|
242
|
+
>>>
|
|
243
|
+
<<< ruby
|
|
244
|
+
def self.run(argv=[])
|
|
245
|
+
print "hikiutils: provide utilities for helping hiki editing.\n"
|
|
246
|
+
new(argv).execute
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
def execute
|
|
250
|
+
@argv << '--help' if @argv.size==0
|
|
251
|
+
command_parser = OptionParser.new do |opt|
|
|
252
|
+
opt.on('-v', '--version','show program Version.') { |v|
|
|
253
|
+
opt.version = HikiUtils::VERSION
|
|
254
|
+
puts opt.ver
|
|
255
|
+
}
|
|
256
|
+
opt.on('-s', '--show','show sources') {show_sources}
|
|
257
|
+
opt.on('-a', '--add','add sources info') {add_sources }
|
|
258
|
+
opt.on('-t', '--target VAL','set target id') {|val| set_target(val) }
|
|
259
|
+
opt.on('-e', '--edit FILE','open file') {|file| edit_file(file) }
|
|
260
|
+
opt.on('-l', '--list [FILE]','list files') {|file| list_files(file) }
|
|
261
|
+
opt.on('-u', '--update FILE','update file') {|file| update_file(file) }
|
|
262
|
+
opt.on('-r', '--rsync','rsync files') {rsync_files}
|
|
263
|
+
opt.on('--database FILE','read database file') {|file| db_file(file)}
|
|
264
|
+
opt.on('--display FILE','display converted hikifile') {|file| display(f\
|
|
265
|
+
ile)}
|
|
266
|
+
opt.on('-c', '--checkdb','check database file') {check_db}
|
|
267
|
+
opt.on('--remove FILE','remove file') {|file| remove_file(file)}
|
|
268
|
+
opt.on('--move FILES','move file1,file2',Array) {|files| move_file(file\
|
|
269
|
+
s)}
|
|
270
|
+
opt.on('--euc FILE','translate file to euc') {|file| euc_file(file) }
|
|
271
|
+
opt.on('--initialize','initialize source directory') {dir_init() }
|
|
272
|
+
end
|
|
273
|
+
begin
|
|
274
|
+
command_parser.parse!(@argv)
|
|
275
|
+
rescue=> eval
|
|
276
|
+
p eval
|
|
277
|
+
end
|
|
278
|
+
dump_sources
|
|
279
|
+
exit
|
|
280
|
+
end
|
|
281
|
+
>>>
|
|
282
|
+
コードからもThorのほうが短くなっていることが分かる.
|
|
283
|
+
よって,Thorとoptparseでのコードの違いは以上の部分になるが全体的にもThorのほうがコードが短くなり,
|
|
284
|
+
コマンドの定義も簡単に行うことができる.また,実行手順も分かりやすくコードが読みやすいため書き換えもすぐ行うことが
|
|
285
|
+
できるので,より直感的なコマンドを実装することも可能となった.
|