hikiutils 0.2.3.15 → 0.2.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hikiutils_yamane/Rakefile +11 -4
- data/hikiutils_yamane/hikiutils_yamane.hiki +4 -4
- data/hikiutils_yamane/latex_dir/discussion.aux +2 -2
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.log +60 -64
- 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 +7 -5
- data/hikiutils_yamane/latex_dir/hikiutils_yamane.toc +5 -5
- data/hikiutils_yamane/latex_dir/introduction.tex +1 -1
- data/hikiutils_yamane/latex_dir/method.aux +3 -3
- data/hikiutils_yamane/latex_dir/method.tex +12 -6
- data/hikiutils_yamane/latex_dir/results.aux +10 -9
- data/hikiutils_yamane/latex_dir/results.tex +42 -34
- data/hikiutils_yamane/method.hiki +7 -3
- data/hikiutils_yamane/results.hiki +34 -31
- data/lib/hikiutils/version.rb +1 -1
- data/lib/templates/Rakefile_hiki_sync +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1a5c575e0620e966b2df629ea55328d3e96c712
|
4
|
+
data.tar.gz: 35159b030aa4d490796706c24043f8388d266587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba083977c2fec6016885cfa5e06c4d28104cfddfeb065614fca4b3f744ab5f76d6670b3843fda0195847ada542203c5c9e8aeba5e534a655dd160f1f917b13e8
|
7
|
+
data.tar.gz: c40c231fc2715f409c2a7ca781093940e0a1151f0885fd7f80b9532ed8b292bbb0f414e0c2d46d74ff5344f2e128aa6a7900e752103082bd686ef74d8bf66523
|
data/hikiutils_yamane/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
1
3
|
# -*- coding: utf-8 -*-
|
2
4
|
require 'systemu'
|
3
5
|
require 'tempfile'
|
@@ -186,7 +188,10 @@ end
|
|
186
188
|
|
187
189
|
def check_bounding_box
|
188
190
|
# $bounding_box="0 0 442 432"
|
189
|
-
$bounding_box=" 0 0 737 553"
|
191
|
+
# $bounding_box=" 0 0 737 553"
|
192
|
+
# $fig_width="10"
|
193
|
+
$bounding_box=" 0 0 937 753"
|
194
|
+
$fig_width="12"
|
190
195
|
end
|
191
196
|
|
192
197
|
desc "すべてのhikiファイルをlatex変換"
|
@@ -206,7 +211,7 @@ task :latex_all do
|
|
206
211
|
line = ''
|
207
212
|
end
|
208
213
|
end
|
209
|
-
line ="\\usepackage{listings,jlisting}" if line.match(/\\usepackage{listings}/)
|
214
|
+
line ="\\usepackage{url}\n\\usepackage{listings,jlisting}\n" if line.match(/\\usepackage{listings}/)
|
210
215
|
if line.match(/section{(.+)}/)
|
211
216
|
if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
|
212
217
|
p m
|
@@ -273,10 +278,12 @@ def convert_to_latex(file_name, options={})
|
|
273
278
|
line = "\\end{thebibliography}\n"
|
274
279
|
end
|
275
280
|
if m=line.match(/\\item\[(.+)\](.+)/) and in_bib==true
|
276
|
-
|
281
|
+
tmp=m[2].gsub!(/\\verb\|(.*?)\|/){ "\\url{#{$1}}" }
|
282
|
+
line ="\\bibitem{#{m[1]}} #{tmp}"
|
283
|
+
puts line.blue
|
277
284
|
end
|
278
285
|
if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
|
279
|
-
p line="\\includegraphics\[width
|
286
|
+
p line="\\includegraphics\[width=#{$fig_width}cm,bb=#{$bounding_box}\]\{../figs/#{m[1]}\}\n"
|
280
287
|
cont << line
|
281
288
|
else
|
282
289
|
cont << line
|
@@ -14,10 +14,10 @@
|
|
14
14
|
//!![[hikiutilsのthorのコード解説|hikiutils_yamane_thor]]
|
15
15
|
![[議論|hikiutils_yamane_discussion]]
|
16
16
|
!reference:
|
17
|
-
:1-1: hikidoc, https://rubygems.org/gems/hikidoc/versions/0.1.0, https://github.com/hiki/hikidoc,2017/1/30 アクセス.
|
17
|
+
:1-1: hikidoc, https://rubygems.org/gems/hikidoc/versions/0.1.0, https://github.com/hiki/hikidoc, 2017/1/30 アクセス.
|
18
18
|
// 「hiki」,hikiwiki.org/ja/about.html ,2017/1/30 アクセス.
|
19
19
|
// 「hikiutils」,https://rubygems.org/gems/hikiutils ,2017/1/30 アクセス.
|
20
20
|
// 「The Ruby Toolbox」, CLI Option Parsers,https://www.ruby-toolbox.com/categories/CLI_Option_Parsers ,2017/1/30 アクセス.
|
21
|
-
:1-2: 「Thorの使い方まとめ」,http://qiita.com/succi0303/items/32560103190436c9435b 2015/01/14更新,2017/1/30 アクセス.
|
22
|
-
:1-3: 「15.5. optparse - コマンドラインオプション解析器」, http://docs.python.jp/2/library/optparse.html
|
23
|
-
:1-4: 「library optparse」, https://docs.ruby-lang.org/ja/latest/library/optparse.html
|
21
|
+
:1-2: 「Thorの使い方まとめ」, http://qiita.com/succi0303/items/32560103190436c9435b 2015/01/14更新, 2017/1/30 アクセス.
|
22
|
+
:1-3: 「15.5. optparse - コマンドラインオプション解析器」, http://docs.python.jp/2/library/optparse.html, 2017/1/30 アクセス.
|
23
|
+
:1-4: 「library optparse」, https://docs.ruby-lang.org/ja/latest/library/optparse.html, 2017/1/30 アクセス.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
\relax
|
2
|
-
\@writefile{toc}{\contentsline {section}{\numberline {5}optparseからThorへの移行}{
|
2
|
+
\@writefile{toc}{\contentsline {section}{\numberline {5}optparseからThorへの移行}{24}}
|
3
3
|
\@setckpt{discussion}{
|
4
|
-
\setcounter{page}{
|
4
|
+
\setcounter{page}{25}
|
5
5
|
\setcounter{equation}{0}
|
6
6
|
\setcounter{enumi}{2}
|
7
7
|
\setcounter{enumii}{0}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
This is e-pTeX, Version 3.14159265-p3.7-160201-2.6 (utf8.euc) (TeX Live 2016) (preloaded format=platex 2017.1.26)
|
1
|
+
This is e-pTeX, Version 3.14159265-p3.7-160201-2.6 (utf8.euc) (TeX Live 2016) (preloaded format=platex 2017.1.26) 14 FEB 2017 14:31
|
2
2
|
entering extended mode
|
3
3
|
restricted \write18 enabled.
|
4
4
|
file:line:error style messages enabled.
|
@@ -87,6 +87,10 @@ Package color Info: Driver file: dvipdfmx.def on input line 147.
|
|
87
87
|
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/dvipsnam.def
|
88
88
|
File: dvipsnam.def 2016/06/17 v3.0m Driver-dependent file (DPC,SPQR)
|
89
89
|
))
|
90
|
+
(/usr/local/texlive/2016/texmf-dist/tex/latex/url/url.sty
|
91
|
+
\Urlmuskip=\muskip10
|
92
|
+
Package: url 2013/09/16 ver 3.4 Verb mode for urls, etc.
|
93
|
+
)
|
90
94
|
(/usr/local/texlive/2016/texmf-dist/tex/latex/listings/listings.sty
|
91
95
|
\lst@mode=\count91
|
92
96
|
\lst@gtempboxa=\box42
|
@@ -143,51 +147,51 @@ LaTeX Warning: Label `default' multiply defined.
|
|
143
147
|
) (./discussion.aux))
|
144
148
|
\openout1 = `hikiutils_yamane.aux'.
|
145
149
|
|
146
|
-
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line
|
147
|
-
LaTeX Font Info: ... okay on input line
|
148
|
-
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line
|
149
|
-
LaTeX Font Info: ... okay on input line
|
150
|
-
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line
|
151
|
-
LaTeX Font Info: ... okay on input line
|
152
|
-
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line
|
153
|
-
LaTeX Font Info: ... okay on input line
|
154
|
-
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line
|
155
|
-
LaTeX Font Info: ... okay on input line
|
156
|
-
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line
|
157
|
-
LaTeX Font Info: ... okay on input line
|
158
|
-
LaTeX Font Info: Checking defaults for JY1/mc/m/n on input line
|
159
|
-
LaTeX Font Info: ... okay on input line
|
160
|
-
LaTeX Font Info: Checking defaults for JT1/mc/m/n on input line
|
161
|
-
LaTeX Font Info: ... okay on input line
|
150
|
+
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 40.
|
151
|
+
LaTeX Font Info: ... okay on input line 40.
|
152
|
+
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 40.
|
153
|
+
LaTeX Font Info: ... okay on input line 40.
|
154
|
+
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 40.
|
155
|
+
LaTeX Font Info: ... okay on input line 40.
|
156
|
+
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 40.
|
157
|
+
LaTeX Font Info: ... okay on input line 40.
|
158
|
+
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 40.
|
159
|
+
LaTeX Font Info: ... okay on input line 40.
|
160
|
+
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 40.
|
161
|
+
LaTeX Font Info: ... okay on input line 40.
|
162
|
+
LaTeX Font Info: Checking defaults for JY1/mc/m/n on input line 40.
|
163
|
+
LaTeX Font Info: ... okay on input line 40.
|
164
|
+
LaTeX Font Info: Checking defaults for JT1/mc/m/n on input line 40.
|
165
|
+
LaTeX Font Info: ... okay on input line 40.
|
162
166
|
\c@lstlisting=\count100
|
163
167
|
LaTeX Font Info: Font shape `JT1/mc/m/n' will be
|
164
|
-
(Font) scaled to size 16.60605pt on input line
|
168
|
+
(Font) scaled to size 16.60605pt on input line 46.
|
165
169
|
LaTeX Font Info: Font shape `JY1/mc/m/n' will be
|
166
|
-
(Font) scaled to size 16.60605pt on input line
|
170
|
+
(Font) scaled to size 16.60605pt on input line 46.
|
167
171
|
LaTeX Font Info: Font shape `JT1/mc/m/n' will be
|
168
|
-
(Font) scaled to size 11.53198pt on input line
|
172
|
+
(Font) scaled to size 11.53198pt on input line 46.
|
169
173
|
LaTeX Font Info: Font shape `JY1/mc/m/n' will be
|
170
|
-
(Font) scaled to size 11.53198pt on input line
|
174
|
+
(Font) scaled to size 11.53198pt on input line 46.
|
171
175
|
LaTeX Font Info: External font `cmex10' loaded for size
|
172
|
-
(Font) <12> on input line
|
176
|
+
(Font) <12> on input line 46.
|
173
177
|
LaTeX Font Info: External font `cmex10' loaded for size
|
174
|
-
(Font) <8> on input line
|
178
|
+
(Font) <8> on input line 46.
|
175
179
|
LaTeX Font Info: External font `cmex10' loaded for size
|
176
|
-
(Font) <6> on input line
|
180
|
+
(Font) <6> on input line 46.
|
177
181
|
LaTeX Font Info: Font shape `JY1/mc/m/n' will be
|
178
|
-
(Font) scaled to size 5.76599pt on input line
|
182
|
+
(Font) scaled to size 5.76599pt on input line 46.
|
179
183
|
LaTeX Font Info: Font shape `JT1/gt/m/n' will be
|
180
|
-
(Font) scaled to size 9.60999pt on input line
|
184
|
+
(Font) scaled to size 9.60999pt on input line 49.
|
181
185
|
LaTeX Font Info: Font shape `JY1/gt/m/n' will be
|
182
|
-
(Font) scaled to size 9.60999pt on input line
|
186
|
+
(Font) scaled to size 9.60999pt on input line 49.
|
183
187
|
LaTeX Font Info: Font shape `JT1/mc/m/n' will be
|
184
|
-
(Font) scaled to size 13.83836pt on input line
|
188
|
+
(Font) scaled to size 13.83836pt on input line 49.
|
185
189
|
LaTeX Font Info: Font shape `JY1/mc/m/n' will be
|
186
|
-
(Font) scaled to size 13.83836pt on input line
|
190
|
+
(Font) scaled to size 13.83836pt on input line 49.
|
187
191
|
LaTeX Font Info: Font shape `JT1/gt/m/n' will be
|
188
|
-
(Font) scaled to size 13.83836pt on input line
|
192
|
+
(Font) scaled to size 13.83836pt on input line 49.
|
189
193
|
LaTeX Font Info: Font shape `JY1/gt/m/n' will be
|
190
|
-
(Font) scaled to size 13.83836pt on input line
|
194
|
+
(Font) scaled to size 13.83836pt on input line 49.
|
191
195
|
(./hikiutils_yamane.toc [1
|
192
196
|
|
193
197
|
]
|
@@ -260,75 +264,67 @@ LaTeX Font Info: Font shape `OT1/cmtt/bx/n' in size <7> not available
|
|
260
264
|
]
|
261
265
|
[8] [9]
|
262
266
|
File: ../figs/./hikiutils_yamane.005.jpg Graphic file (type eps)
|
263
|
-
<../figs/./hikiutils_yamane.005.jpg> [10]
|
267
|
+
<../figs/./hikiutils_yamane.005.jpg> [10] [11]
|
264
268
|
File: ../figs/./hikiutils_yamane.007.jpg Graphic file (type eps)
|
265
269
|
|
266
|
-
<../figs/./hikiutils_yamane.007.jpg> [
|
270
|
+
<../figs/./hikiutils_yamane.007.jpg> [12] [13]) [14]
|
267
271
|
\openout2 = `results.aux'.
|
268
272
|
|
269
273
|
(./results.tex
|
270
274
|
File: ../figs/./hikiutils_yamane.002.jpg Graphic file (type eps)
|
271
275
|
|
272
276
|
<../figs/./hikiutils_yamane.002.jpg>
|
273
|
-
LaTeX Font Info: Try loading font information for OMS+cmr on input line
|
277
|
+
LaTeX Font Info: Try loading font information for OMS+cmr on input line 23.
|
274
278
|
|
275
279
|
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/omscmr.fd
|
276
280
|
File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
|
277
281
|
)
|
278
282
|
LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10> not available
|
279
|
-
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line
|
283
|
+
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 23.
|
280
284
|
[15
|
281
285
|
|
282
286
|
|
283
287
|
] [16]
|
284
288
|
[17]
|
285
289
|
File: ../figs/./hikiutils_yamane.003.jpg Graphic file (type eps)
|
286
|
-
<../figs/./hikiutils_yamane.003.jpg> [18]
|
290
|
+
<../figs/./hikiutils_yamane.003.jpg> [18] [19]
|
287
291
|
File: ../figs/./hikiutils_yamane.004.jpg Graphic file (type eps)
|
288
292
|
|
289
|
-
<../figs/./hikiutils_yamane.004.jpg> [
|
293
|
+
<../figs/./hikiutils_yamane.004.jpg> [20]
|
290
294
|
File: ../figs/./hikiutils_yamane.006.jpg Graphic file (type eps)
|
291
|
-
|
292
|
-
|
293
|
-
Overfull \hbox (3.95764pt too wide) in paragraph at lines 215--216
|
295
|
+
<../figs/./hikiutils_yamane.006.jpg>
|
296
|
+
Overfull \hbox (3.95764pt too wide) in paragraph at lines 223--224
|
294
297
|
\OT1/cmr/m/n/10 Thor \JY1/mc/m/n/10 では \OT1/cmr/m/n/10 start(ARGV) \JY1/mc/m/
|
295
298
|
n/10 を呼び出すことで \OT1/cmr/m/n/10 CLI \JY1/mc/m/n/10 を開始する . \OT1/cmr
|
296
299
|
/m/n/10 Hikithor::CLI.start(ARGV)
|
297
300
|
[]
|
298
301
|
|
299
|
-
[21]
|
302
|
+
[21] [22]) [23]
|
300
303
|
\openout2 = `discussion.aux'.
|
301
304
|
|
302
|
-
(./discussion.tex) [
|
305
|
+
(./discussion.tex) [24
|
303
306
|
|
304
307
|
|
305
308
|
]
|
306
|
-
Underfull \hbox (badness
|
307
|
-
[]\OT1/cmr/m/n/10 hikidoc,
|
308
|
-
|
309
|
+
Underfull \hbox (badness 1303) in paragraph at lines 57--58
|
310
|
+
[]\OT1/cmr/m/n/10 hikidoc, $\OT1/cmtt/m/n/10 https : / / rubygems . org / gems
|
311
|
+
/ hikidoc / versions / 0 . 1 . 0,[]$ $https : / /
|
309
312
|
[]
|
310
313
|
|
311
314
|
|
312
|
-
|
315
|
+
Underfull \hbox (badness 10000) in paragraph at lines 58--59
|
313
316
|
[]\JY1/mc/m/n/10 「\OT1/cmr/m/n/10 Thor \JY1/mc/m/n/10 の使い方まとめ 」 \OT1/c
|
314
|
-
mr/m/n/10
|
315
|
-
5b
|
316
|
-
[]
|
317
|
-
|
318
|
-
|
319
|
-
Underfull \hbox (badness 10000) in paragraph at lines 57--58
|
320
|
-
[]\JY1/mc/m/n/10 「\OT1/cmr/m/n/10 15.5. opt-parse - \JY1/mc/m/n/10 コマンドラ
|
321
|
-
インオプシ ョン解析器 」 \OT1/cmr/m/n/10 ,
|
317
|
+
mr/m/n/10 , $\OT1/cmtt/m/n/10 http : / / qiita . com / succi0303 / items /
|
322
318
|
[]
|
323
319
|
|
324
320
|
|
325
|
-
|
321
|
+
Underfull \hbox (badness 10000) in paragraph at lines 60--61
|
326
322
|
[]\JY1/mc/m/n/10 「\OT1/cmr/m/n/10 library opt-parse\JY1/mc/m/n/10 」 \OT1/cmr/
|
327
|
-
m/n/10 ,
|
328
|
-
|
323
|
+
m/n/10 , $\OT1/cmtt/m/n/10 https : / / docs . ruby-[]lang . org / ja / latest /
|
324
|
+
library /
|
329
325
|
[]
|
330
326
|
|
331
|
-
[
|
327
|
+
[25
|
332
328
|
|
333
329
|
] (./hikiutils_yamane.aux (./abstract.aux) (./introduction.aux)
|
334
330
|
(./method.aux) (./results.aux) (./discussion.aux))
|
@@ -337,12 +333,12 @@ LaTeX Warning: There were multiply-defined labels.
|
|
337
333
|
|
338
334
|
)
|
339
335
|
Here is how much of TeX's memory you used:
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
336
|
+
2693 strings out of 493683
|
337
|
+
36983 string characters out of 6149653
|
338
|
+
262086 words of memory out of 5000000
|
339
|
+
6223 multiletter control sequences out of 15000+600000
|
344
340
|
15673 words of font info for 72 fonts, out of 8000000 for 9000
|
345
341
|
934 hyphenation exceptions out of 8191
|
346
|
-
35i,9n,51p,777b,
|
342
|
+
35i,9n,51p,777b,1682s stack positions out of 5000i,500n,10000p,200000b,80000s
|
347
343
|
|
348
|
-
Output written on hikiutils_yamane.dvi (
|
344
|
+
Output written on hikiutils_yamane.dvi (25 pages, 96256 bytes).
|
Binary file
|
Binary file
|
@@ -1,7 +1,9 @@
|
|
1
1
|
\documentclass[12pt,a4paper]{jsarticle}
|
2
2
|
\usepackage[dvipdfmx]{graphicx}
|
3
3
|
\usepackage[dvipdfmx]{color}
|
4
|
-
\usepackage{
|
4
|
+
\usepackage{url}
|
5
|
+
\usepackage{listings,jlisting}
|
6
|
+
% to use japanese correctly, install jlistings.
|
5
7
|
\lstset{
|
6
8
|
basicstyle={\ttfamily},
|
7
9
|
identifierstyle={},
|
@@ -52,9 +54,9 @@
|
|
52
54
|
\include{results}
|
53
55
|
\include{discussion}
|
54
56
|
\begin{thebibliography}{99}
|
55
|
-
\bibitem{1-1} hikidoc, \
|
56
|
-
\bibitem{1-2} 「Thor
|
57
|
-
\bibitem{1-3} 「15.5. optparse - コマンドラインオプション解析器」, \
|
58
|
-
\bibitem{1-4} 「library optparse」, \
|
57
|
+
\bibitem{1-1} hikidoc, \url{https://rubygems.org/gems/hikidoc/versions/0.1.0,} \url{https://github.com/hiki/hikidoc,} 2017/1/30 アクセス.
|
58
|
+
\bibitem{1-2} 「Thorの使い方まとめ」, \url{http://qiita.com/succi0303/items/32560103190436c9435b} 2015/01/14更新, 2017/1/30 アクセス.
|
59
|
+
\bibitem{1-3} 「15.5. optparse - コマンドラインオプション解析器」, \url{http://docs.python.jp/2/library/optparse.html,} 2017/1/30 アクセス.
|
60
|
+
\bibitem{1-4} 「library optparse」, \url{https://docs.ruby-lang.org/ja/latest/library/optparse.html,} 2017/1/30 アクセス.
|
59
61
|
\end{thebibliography}
|
60
62
|
\end{document}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
\contentsline {section}{\numberline {1}概要}{4}
|
2
2
|
\contentsline {section}{\numberline {2}序論}{5}
|
3
3
|
\contentsline {section}{\numberline {3}方法}{7}
|
4
|
-
\contentsline {subsection}{\numberline {3.1}optparseと
|
4
|
+
\contentsline {subsection}{\numberline {3.1}optparseとThorの比較}{7}
|
5
5
|
\contentsline {subsubsection}{\numberline {3.1.1}Thor}{7}
|
6
6
|
\contentsline {paragraph}{fizzbuzzメソッド,versionメソッド}{8}
|
7
7
|
\contentsline {subsubsection}{\numberline {3.1.2}optparse}{8}
|
@@ -12,8 +12,8 @@
|
|
12
12
|
\contentsline {paragraph}{versionメソッド}{10}
|
13
13
|
\contentsline {subsection}{\numberline {3.2}既存のhikiutilsのコマンド解説}{10}
|
14
14
|
\contentsline {subsubsection}{\numberline {3.2.1}コマンドの登録と実行メソッド}{10}
|
15
|
-
\contentsline {subsubsection}{\numberline {3.2.2}CLIの実行プロセス}{
|
16
|
-
\contentsline {subsubsection}{\numberline {3.2.3}コード}{
|
15
|
+
\contentsline {subsubsection}{\numberline {3.2.2}CLIの実行プロセス}{12}
|
16
|
+
\contentsline {subsubsection}{\numberline {3.2.3}コード}{13}
|
17
17
|
\contentsline {section}{\numberline {4}結果}{15}
|
18
18
|
\contentsline {subsection}{\numberline {4.1}コマンドの命名原則}{15}
|
19
19
|
\contentsline {subsubsection}{\numberline {4.1.1}hikiutilsの想定利用形態}{15}
|
@@ -26,6 +26,6 @@
|
|
26
26
|
\contentsline {paragraph}{cd VAL}{18}
|
27
27
|
\contentsline {subsection}{\numberline {4.2}Thorによる実装}{18}
|
28
28
|
\contentsline {subsubsection}{\numberline {4.2.1}クラス初期化}{18}
|
29
|
-
\contentsline {subsubsection}{\numberline {4.2.2}コマンド定義}{
|
29
|
+
\contentsline {subsubsection}{\numberline {4.2.2}コマンド定義}{20}
|
30
30
|
\contentsline {subsubsection}{\numberline {4.2.3}CLIの実行プロセス}{21}
|
31
|
-
\contentsline {section}{\numberline {5}optparseからThorへの移行}{
|
31
|
+
\contentsline {section}{\numberline {5}optparseからThorへの移行}{24}
|
@@ -4,7 +4,7 @@ hikiは,hiki記法を用いたwiki cloneである.wikiはウォード・カ
|
|
4
4
|
hiki web systemの実際の基本動作は,hiki.cgiプログラムを介して行われている.こちらを便宜上hiki systemと呼ぶ.図\ref{fig:one}に従ってhiki systemの動作概要を説明する.hiki systemは,data/textに置かれた書かれたプレーンテキストをhtmlへ変換する.この変換はhikidoc\cite{1-1}というhikiフォーマットconverterを使っている.また,添付書類はcache/attachに,一度フォーマットしたhtmlはparserに置かれており,それらを参照してhtmlを表示する画面をhiki.cgiは作っている.さらにhiki systemでは検索機能,自動リンク作成などが提供されている
|
5
5
|
|
6
6
|
\begin{figure}[htbp]\begin{center}
|
7
|
-
\includegraphics[width=
|
7
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.001.jpg}
|
8
8
|
\caption{hiki web systemとhiki systemの対応関係.}
|
9
9
|
\label{fig:one}
|
10
10
|
\label{default}\end{center}\end{figure}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
\citation{1-2}
|
4
4
|
\citation{1-2}
|
5
5
|
\@writefile{toc}{\contentsline {section}{\numberline {3}方法}{7}}
|
6
|
-
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}optparseと
|
6
|
+
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}optparseとThorの比較}{7}}
|
7
7
|
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.1.1}Thor}{7}}
|
8
8
|
\citation{1-3}
|
9
9
|
\citation{1-4}
|
@@ -19,11 +19,11 @@
|
|
19
19
|
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces コマンドの登録と実行メソッドの対応.}}{10}}
|
20
20
|
\newlabel{fig:005}{{2}{10}}
|
21
21
|
\newlabel{default}{{2}{10}}
|
22
|
-
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.2}CLIの実行プロセス}{
|
22
|
+
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.2}CLIの実行プロセス}{12}}
|
23
23
|
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces CLIの実行プロセス.}}{12}}
|
24
24
|
\newlabel{fig:007}{{3}{12}}
|
25
25
|
\newlabel{default}{{3}{12}}
|
26
|
-
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.3}コード}{
|
26
|
+
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.3}コード}{13}}
|
27
27
|
\@setckpt{method}{
|
28
28
|
\setcounter{page}{15}
|
29
29
|
\setcounter{equation}{0}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
\section{方法}
|
3
|
-
\subsection{optparseと
|
3
|
+
\subsection{optparseとThorの比較}
|
4
4
|
今回の研究対象のhikiutilsは,optparseというコマンドライン解析ライブラリで実装されている.
|
5
5
|
本研究ではこの代替ライブラリとしてThorの採用を検討した.
|
6
6
|
本章の最初では,FizzBuzzという簡単なコードを例にoptparseとThorにより作成するコマンドライン解析コードの比較を行う.FizzBuzzはThorの使い方を解説した記事\cite{1-2}で紹介されている.比較しやすくするためoptparseでFizzBuzzを新たに実装した.
|
@@ -126,8 +126,10 @@ optparseの特徴は,「コマンドの登録,実行method」に分けて記
|
|
126
126
|
また,CLIの起動の仕方が特徴的である.この二つを取り出して,動作とコードを説明する.
|
127
127
|
|
128
128
|
\subsubsection{コマンドの登録と実行メソッド}
|
129
|
+
optparseのコマンド登録と実行メソッドの呼び出し関係は図\ref{fig:005}の通りである.
|
130
|
+
|
129
131
|
\begin{figure}[htbp]\begin{center}
|
130
|
-
\includegraphics[width=
|
132
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.005.jpg}
|
131
133
|
\caption{コマンドの登録と実行メソッドの対応.}
|
132
134
|
\label{fig:005}
|
133
135
|
\label{default}\end{center}\end{figure}
|
@@ -138,7 +140,7 @@ optparseでは以下の通り,コマンドの登録と実行が行われる.
|
|
138
140
|
\item optにコマンドを登録
|
139
141
|
\item 入力されたコマンドの処理のメソッドへ移動
|
140
142
|
\end{enumerate}
|
141
|
-
|
143
|
+
この実装コードは次の通りである.
|
142
144
|
\begin{lstlisting}[style=customRuby,basicstyle={\scriptsize\ttfamily}]
|
143
145
|
def execute
|
144
146
|
@argv << '--help' if @argv.size==0
|
@@ -175,13 +177,17 @@ optparseではOptionParserオブジェクトoptの生成を行い,コマンド
|
|
175
177
|
以下略
|
176
178
|
|
177
179
|
\end{lstlisting}
|
180
|
+
optparseではOptionParserオブジェクトoptの生成を行い,コマンドをoptに登録することでコマンドを作成することができる.しかし,これはコマンドを登録しているだけでコマンドの一覧ではこれを表示することができるが,コマンドの実行を行うためには実行を行うためのメソッドを作成する必要がある.optparseでのコマンドの実行はoptで登録されたコマンドが入力されることでそれぞれのコマンドの処理を行うメソッドに移動し処理を行う.しかし,このコマンド登録はハイフンを付けたコマンドしか登録ができず,ハイフンなしのコマンド登録はまた別の手段でやらなくてはいけない.
|
181
|
+
|
178
182
|
\subsubsection{CLIの実行プロセス}
|
183
|
+
optparseを用いた場合のCLIの実行プロセスは図\ref{fig:007}の通りとなる.
|
184
|
+
|
179
185
|
\begin{figure}[htbp]\begin{center}
|
180
|
-
\includegraphics[width=
|
186
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.007.jpg}
|
181
187
|
\caption{CLIの実行プロセス.}
|
182
188
|
\label{fig:007}
|
183
189
|
\label{default}\end{center}\end{figure}
|
184
|
-
|
190
|
+
CLIの実行プロセスは次の通りとなる.
|
185
191
|
|
186
192
|
\begin{enumerate}
|
187
193
|
\item HikiのHikiUtils::Command.run(ARGV)でhikiutils.rbのrunメソッドを呼ぶ
|
@@ -243,5 +249,5 @@ s)}
|
|
243
249
|
end
|
244
250
|
\end{lstlisting}
|
245
251
|
runメソッドでは「hikiutils: provide utilities for helping hiki editing.」を表示させ,executeメソッドを実行させる.
|
246
|
-
executeメソッドでは最初に「@argv
|
252
|
+
executeメソッドでは最初に「@argv << '--help' if @argv.size==0」と記述する.これはもしargv配列の中身が空であればargv配列に'--help'を代入する.「command\_parser = OptionParser.new do |opt|」ではOptionParserオブジェクトがoptを生成しコマンドを登録していき,command\_parserに代入する.そして,「command\_parser.parse!(@argv)」では@argvにある文字列をcommand\_parserでparseする.つまり,ここでは入力されたコマンドを解析し,登録されたコマンドと一致すればその処理が行われる.もし,一致しなければevalメソッドで表示する.
|
247
253
|
|
@@ -2,9 +2,9 @@
|
|
2
2
|
\@writefile{toc}{\contentsline {section}{\numberline {4}結果}{15}}
|
3
3
|
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}コマンドの命名原則}{15}}
|
4
4
|
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.1.1}hikiutilsの想定利用形態}{15}}
|
5
|
-
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces hikiutilsがあらかじめ想定している利用形態.}}{
|
6
|
-
\newlabel{fig:002}{{4}{
|
7
|
-
\newlabel{default}{{4}{
|
5
|
+
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces hikiutilsがあらかじめ想定している利用形態.}}{16}}
|
6
|
+
\newlabel{fig:002}{{4}{16}}
|
7
|
+
\newlabel{default}{{4}{16}}
|
8
8
|
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.1.2}コメンド名と振る舞いの詳細}{16}}
|
9
9
|
\@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces コマンドオプションとshellコマンドの対応.}}{17}}
|
10
10
|
\newlabel{table:ShellOption}{{1}{17}}
|
@@ -17,18 +17,19 @@
|
|
17
17
|
\@writefile{toc}{\contentsline {paragraph}{cd VAL}{18}}
|
18
18
|
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Thorによる実装}{18}}
|
19
19
|
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.1}クラス初期化}{18}}
|
20
|
-
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces Thorのinitialize
|
20
|
+
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces Thorのinitializeでのコード.}}{19}}
|
21
|
+
\newlabel{fig:003}{{5}{19}}
|
21
22
|
\newlabel{default}{{5}{19}}
|
22
|
-
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.2}コマンド定義}{
|
23
|
+
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.2}コマンド定義}{20}}
|
23
24
|
\@writefile{lof}{\contentsline {figure}{\numberline {6}{\ignorespaces Thorにおけるコマンド記述のひな形.}}{20}}
|
24
25
|
\newlabel{fig:004}{{6}{20}}
|
25
26
|
\newlabel{default}{{6}{20}}
|
26
27
|
\@writefile{toc}{\contentsline {subsubsection}{\numberline {4.2.3}CLIの実行プロセス}{21}}
|
27
|
-
\@writefile{lof}{\contentsline {figure}{\numberline {7}{\ignorespaces CLIの実行プロセス.}}{
|
28
|
-
\newlabel{fig:006}{{7}{
|
29
|
-
\newlabel{default}{{7}{
|
28
|
+
\@writefile{lof}{\contentsline {figure}{\numberline {7}{\ignorespaces CLIの実行プロセス.}}{22}}
|
29
|
+
\newlabel{fig:006}{{7}{22}}
|
30
|
+
\newlabel{default}{{7}{22}}
|
30
31
|
\@setckpt{results}{
|
31
|
-
\setcounter{page}{
|
32
|
+
\setcounter{page}{24}
|
32
33
|
\setcounter{equation}{0}
|
33
34
|
\setcounter{enumi}{2}
|
34
35
|
\setcounter{enumii}{0}
|
@@ -1,20 +1,19 @@
|
|
1
1
|
|
2
2
|
\section{結果}
|
3
3
|
\subsection{コマンドの命名原則}
|
4
|
-
|
4
|
+
機能ごとの動作はコマンドのオプションによって指定される.
|
5
5
|
このオプションにどのような名前をつけるかは,どれだけコマンドを覚えやすいかという
|
6
|
-
|
6
|
+
意味で重要である.コマンドの振る舞いを的確に表す名称をつける必要がある.
|
7
7
|
|
8
|
-
この振る舞いとしてもっとも受け入れやすいのがshell
|
9
|
-
pwd, ls, rm, touch, open
|
10
|
-
hikiutils
|
11
|
-
ようにします.
|
8
|
+
この振る舞いとしてもっとも受け入れやすいのがshellで用意されているコマンドである.
|
9
|
+
pwd, ls, rm, touch, openなどはもっとも直感的に動作がわかるコマンドである.
|
10
|
+
hikiutilsの振る舞いを予測できるシェルコマンドと同じ名前でオプションを提供する.
|
12
11
|
|
13
12
|
\subsubsection{hikiutilsの想定利用形態}
|
14
|
-
ここでhikiutils
|
13
|
+
ここでhikiutilsがあらかじめ想定している利用形態を解説する.
|
15
14
|
|
16
15
|
\begin{figure}[htbp]\begin{center}
|
17
|
-
\includegraphics[width=
|
16
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.002.jpg}
|
18
17
|
\caption{hikiutilsがあらかじめ想定している利用形態.}
|
19
18
|
\label{fig:002}
|
20
19
|
\label{default}\end{center}\end{figure}
|
@@ -24,11 +23,11 @@ hikiutilsは,
|
|
24
23
|
\item local PCとglobal serverとが用意されており,
|
25
24
|
\item それらのデータをrsyncで同期する
|
26
25
|
\end{itemize}
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
ことで動作することを想定される.これは,ネットに繋がっていないオフラインの状況でも
|
27
|
+
テキストなどの編集が可能で,さらに不用意な書き換えを防ぐための機構である.さらに,
|
28
|
+
どちらもが何かあった時のバックアップともなって,ミスによる手戻りを防いでいる.
|
30
29
|
|
31
|
-
これらの設定は,~/.hikircにyaml
|
30
|
+
これらの設定は,~/.hikircにyaml形式で記述・保存されている.
|
32
31
|
\begin{lstlisting}[style=,basicstyle={\scriptsize\ttfamily}]
|
33
32
|
bob% cat ~/.hikirc
|
34
33
|
:srcs:
|
@@ -44,7 +43,7 @@ bob% cat ~/.hikirc
|
|
44
43
|
:global_uri: http://nishitani0.kwansei.ac.jp/~bob/nishitani0/Internal
|
45
44
|
\end{lstlisting}
|
46
45
|
また,一般的に一人のユーザがいくつものまとまりとしてのlocal-globalペアを
|
47
|
-
|
46
|
+
保持して管理することが普通である.それぞれにnicke\_nameをつけて管理している.
|
48
47
|
\begin{lstlisting}[style=,basicstyle={\scriptsize\ttfamily}]
|
49
48
|
bob% hiki -s
|
50
49
|
hikiutils: provide utilities for helping hiki editing.
|
@@ -58,11 +57,11 @@ editor_command:open -a mi
|
|
58
57
|
2 | ist | /Users/bob/Sites/hiki-data/data | http://ist.ksc.k
|
59
58
|
3 | new_maple | /Users/bob/Sites/new_ist_data/maple_hiki_d| http://ist.ksc.k
|
60
59
|
\end{lstlisting}
|
61
|
-
とすると,それらの一覧と,いまtargetにしているnick\_name
|
60
|
+
とすると,それらの一覧と,いまtargetにしているnick\_nameディレクリが表示される.
|
62
61
|
|
63
62
|
\subsubsection{コメンド名と振る舞いの詳細}
|
64
|
-
検討の結果コマンドを以下の表\ref{table:ShellOption}
|
65
|
-
上部に記した,特によく使うコマンドに関しては,shell
|
63
|
+
検討の結果コマンドを以下の表\ref{table:ShellOption}のとおり書き換えることとする.
|
64
|
+
上部に記した,特によく使うコマンドに関しては,shellでよく使われるコマンド名と一致するにようにした.
|
66
65
|
|
67
66
|
\begin{table}[htbp]\begin{center}
|
68
67
|
\caption{コマンドオプションとshellコマンドの対応.}
|
@@ -92,7 +91,7 @@ version &-v &show program version \\
|
|
92
91
|
\end{center}\end{table}
|
93
92
|
%for inserting separate lines, use \hline, \cline{2-3} etc.
|
94
93
|
|
95
|
-
|
94
|
+
それぞれの意図を動作の解説として記述する.
|
96
95
|
|
97
96
|
\paragraph{open FILE}
|
98
97
|
ファイルを編集のためにeditorでopen.Editorは~/.hikircに
|
@@ -134,11 +133,14 @@ targetを変える,change directoryとのメタファ.ただし,いまの
|
|
134
133
|
について詳しく検討を行う.
|
135
134
|
|
136
135
|
\subsubsection{クラス初期化}
|
136
|
+
Thorのinitializeでのコードの呼び出し関係は図\ref{fig:003}の通りである.
|
137
|
+
|
137
138
|
\begin{figure}[htbp]\begin{center}
|
138
|
-
\includegraphics[width=
|
139
|
-
\caption{Thorのinitialize
|
139
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.003.jpg}
|
140
|
+
\caption{Thorのinitializeでのコード.}
|
141
|
+
\label{fig:003}
|
140
142
|
\label{default}\end{center}\end{figure}
|
141
|
-
|
143
|
+
この動きを順を追って説明すると
|
142
144
|
|
143
145
|
\begin{enumerate}
|
144
146
|
\item Hikithor::CLI.start(ARGV)が呼ばれる
|
@@ -146,7 +148,9 @@ Thorのinitializeでのコードはつぎの通りである.
|
|
146
148
|
\item これではThorのinitializeメソッドが呼ばれない
|
147
149
|
\item superを書くことでThorのinitializeメソッドが呼ばれる
|
148
150
|
\end{enumerate}
|
149
|
-
|
151
|
+
となる.
|
152
|
+
|
153
|
+
この実装コードは次の通りである.
|
150
154
|
\begin{lstlisting}[style=customRuby,basicstyle={\scriptsize\ttfamily}]
|
151
155
|
|
152
156
|
module Hikithor
|
@@ -164,29 +168,24 @@ module Hikithor
|
|
164
168
|
...以下略...
|
165
169
|
end
|
166
170
|
\end{lstlisting}
|
171
|
+
optparseではrequireでoptparseを呼びoptparseのinitializeを定義する必要はないが,Thorはinitializeを定義する必要がある.Thorの定義方法はrequireでThorを呼びCLIクラスで継承し,initializeメソッドにsuperを書くことでThorのinitializeが呼ばれる.initializeメソッド内ではThorの初期設定がされていないため,スーパークラスのメソッドを読み出してくれるsuperを書き加えることで図のようにinitializeメソッド内でThorのinitilalizeメソッドが呼ばれ定義される.
|
172
|
+
|
167
173
|
\subsubsection{コマンド定義}
|
168
|
-
Thorではoptparse
|
174
|
+
Thorではoptparseのような登録処理はない.コマンド記述のひな形は図\ref{fig:004}の通りである.
|
169
175
|
|
170
176
|
\begin{figure}[htbp]\begin{center}
|
171
|
-
\includegraphics[width=
|
177
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.004.jpg}
|
172
178
|
\caption{Thorにおけるコマンド記述のひな形.}
|
173
179
|
\label{fig:004}
|
174
180
|
\label{default}\end{center}\end{figure}
|
175
|
-
|
181
|
+
このひな形を順を追って説明する.
|
176
182
|
|
177
183
|
\begin{enumerate}
|
178
184
|
\item desc以降にコマンド名と,その説明が記述される.これらはコマンドhelpで一覧として表示させる
|
179
185
|
\item mapによって別のコマンド名でも実行できるように定義される.
|
180
186
|
\item defで定義されたメソッドの実行コード
|
181
187
|
\end{enumerate}
|
182
|
-
|
183
|
-
|
184
|
-
これに別名を与えるために利用されるキーワードがmapである.
|
185
|
-
\begin{quote}\begin{verbatim}
|
186
|
-
map A => B
|
187
|
-
\end{verbatim}\end{quote}
|
188
|
-
mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれるものである.
|
189
|
-
よって,これを使うことでコマンドの別名を指定することができる.
|
188
|
+
この実装コードは次の通りである.
|
190
189
|
\begin{lstlisting}[style=customRuby,basicstyle={\scriptsize\ttfamily}]
|
191
190
|
desc 'show,--show', 'show sources'
|
192
191
|
map "--show" => "show"
|
@@ -196,17 +195,26 @@ mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれる
|
|
196
195
|
,,,以下略...
|
197
196
|
end
|
198
197
|
\end{lstlisting}
|
198
|
+
Thorではdescで一覧を表示されるコマンド名,コマンドの説明を登録する.しかし,ここで記述したコマンドは単に一覧で表示させるためのものであり,実際に実行される時に呼び出すコマンド名は,defで定義された名前である.Thorでは処理実行を行うメソッド名がコマンド名となり,コマンド名1つが対応する.
|
199
|
+
|
200
|
+
これに別名を与えるために利用されるキーワードがmapである.
|
201
|
+
\begin{quote}\begin{verbatim}
|
202
|
+
map A => B
|
203
|
+
\end{verbatim}\end{quote}
|
204
|
+
mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれるものである.
|
205
|
+
よって,これを使うことでコマンドの別名を指定することができる.
|
206
|
+
|
199
207
|
以上より,Thorではコマンドの指定と処理にはdesc,map,処理メソッドだけで済む.optparseではコマンドを登録するためのメソッドと処理メソッドの両方が必要になっていた.一方Thorでは,処理メソッドが直接コマンド名となるため記述が簡潔になる.
|
200
208
|
|
201
209
|
\subsubsection{CLIの実行プロセス}
|
202
210
|
CLIの実行プロセスは図\ref{fig:006}の通りである.
|
203
211
|
|
204
212
|
\begin{figure}[htbp]\begin{center}
|
205
|
-
\includegraphics[width=
|
213
|
+
\includegraphics[width=12cm,bb= 0 0 937 753]{../figs/./hikiutils_yamane.006.jpg}
|
206
214
|
\caption{CLIの実行プロセス.}
|
207
215
|
\label{fig:006}
|
208
216
|
\label{default}\end{center}\end{figure}
|
209
|
-
Thorにおける
|
217
|
+
ThorにおけるCLIの実行プロセスは次の通りである.
|
210
218
|
|
211
219
|
\begin{enumerate}
|
212
220
|
\item hiki\_thorのHikithor::CLI.start(ARGV)でhikiutils\_thor.rbのCLIクラスを呼ぶ
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{{toc}}
|
2
2
|
!方法
|
3
|
-
!!optparseと
|
3
|
+
!!optparseとThorの比較
|
4
4
|
今回の研究対象のhikiutilsは,optparseというコマンドライン解析ライブラリで実装されている.
|
5
5
|
本研究ではこの代替ライブラリとしてThorの採用を検討した.
|
6
6
|
本章の最初では,FizzBuzzという簡単なコードを例にoptparseとThorにより作成するコマンドライン解析コードの比較を行う.FizzBuzzはThorの使い方を解説した記事{{cite(1-2)}}で紹介されている.比較しやすくするためoptparseでFizzBuzzを新たに実装した.
|
@@ -119,6 +119,7 @@ optparseの特徴は,「コマンドの登録,実行method」に分けて記
|
|
119
119
|
また,CLIの起動の仕方が特徴的である.この二つを取り出して,動作とコードを説明する.
|
120
120
|
|
121
121
|
!!!コマンドの登録と実行メソッド
|
122
|
+
optparseのコマンド登録と実行メソッドの呼び出し関係は図{{ref(fig:005)}}の通りである.
|
122
123
|
|
123
124
|
!!!!caption:(fig:005)コマンドの登録と実行メソッドの対応.
|
124
125
|
{{attach_view(hikiutils_yamane.005.jpg,hikiutils_yamane)}}
|
@@ -127,8 +128,8 @@ optparseでは以下の通り,コマンドの登録と実行が行われる.
|
|
127
128
|
#OptionParserオブジェクトoptを生成
|
128
129
|
#optにコマンドを登録
|
129
130
|
#入力されたコマンドの処理のメソッドへ移動
|
130
|
-
optparseではOptionParserオブジェクトoptの生成を行い,コマンドをoptに登録することでコマンドを作成することができる.しかし,これはコマンドを登録しているだけでコマンドの一覧ではこれを表示することができるが,コマンドの実行を行うためには実行を行うためのメソッドを作成する必要がある.optparseでのコマンドの実行はoptで登録されたコマンドが入力されることでそれぞれのコマンドの処理を行うメソッドに移動し処理を行う.しかし,このコマンド登録はハイフンを付けたコマンドしか登録ができず,ハイフンなしのコマンド登録はまた別の手段でやらなくてはいけない.
|
131
131
|
|
132
|
+
この実装コードは次の通りである.
|
132
133
|
<<< ruby
|
133
134
|
def execute
|
134
135
|
@argv << '--help' if @argv.size==0
|
@@ -165,12 +166,15 @@ optparseではOptionParserオブジェクトoptの生成を行い,コマンド
|
|
165
166
|
以下略
|
166
167
|
|
167
168
|
>>>
|
169
|
+
optparseではOptionParserオブジェクトoptの生成を行い,コマンドをoptに登録することでコマンドを作成することができる.しかし,これはコマンドを登録しているだけでコマンドの一覧ではこれを表示することができるが,コマンドの実行を行うためには実行を行うためのメソッドを作成する必要がある.optparseでのコマンドの実行はoptで登録されたコマンドが入力されることでそれぞれのコマンドの処理を行うメソッドに移動し処理を行う.しかし,このコマンド登録はハイフンを付けたコマンドしか登録ができず,ハイフンなしのコマンド登録はまた別の手段でやらなくてはいけない.
|
168
170
|
|
169
171
|
!!!CLIの実行プロセス
|
172
|
+
optparseを用いた場合のCLIの実行プロセスは図{{ref(fig:007)}}の通りとなる.
|
173
|
+
|
170
174
|
!!!!caption:(fig:007)CLIの実行プロセス.
|
171
175
|
{{attach_view(hikiutils_yamane.007.jpg,hikiutils_yamane)}}
|
172
176
|
|
173
|
-
|
177
|
+
CLIの実行プロセスは次の通りとなる.
|
174
178
|
#HikiのHikiUtils::Command.run(ARGV)でhikiutils.rbのrunメソッドを呼ぶ
|
175
179
|
#new(argv).executeでexecuteメソッドが実行される
|
176
180
|
|
@@ -2,18 +2,17 @@
|
|
2
2
|
!結果
|
3
3
|
!!コマンドの命名原則
|
4
4
|
|
5
|
-
|
5
|
+
機能ごとの動作はコマンドのオプションによって指定される.
|
6
6
|
このオプションにどのような名前をつけるかは,どれだけコマンドを覚えやすいかという
|
7
|
-
|
7
|
+
意味で重要である.コマンドの振る舞いを的確に表す名称をつける必要がある.
|
8
8
|
|
9
|
-
この振る舞いとしてもっとも受け入れやすいのがshell
|
10
|
-
pwd, ls, rm, touch, open
|
11
|
-
hikiutils
|
12
|
-
ようにします.
|
9
|
+
この振る舞いとしてもっとも受け入れやすいのがshellで用意されているコマンドである.
|
10
|
+
pwd, ls, rm, touch, openなどはもっとも直感的に動作がわかるコマンドである.
|
11
|
+
hikiutilsの振る舞いを予測できるシェルコマンドと同じ名前でオプションを提供する.
|
13
12
|
|
14
13
|
|
15
14
|
!!!hikiutilsの想定利用形態
|
16
|
-
ここでhikiutils
|
15
|
+
ここでhikiutilsがあらかじめ想定している利用形態を解説する.
|
17
16
|
|
18
17
|
!!!caption:(fig:002)hikiutilsがあらかじめ想定している利用形態.
|
19
18
|
{{attach_view(hikiutils_yamane.002.jpg,hikiutils_yamane)}}
|
@@ -21,11 +20,11 @@ hikiutilsの振る舞いを予測できるシェルコマンドと同じ名前
|
|
21
20
|
hikiutilsは,
|
22
21
|
*local PCとglobal serverとが用意されており,
|
23
22
|
*それらのデータをrsyncで同期する
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
ことで動作することを想定される.これは,ネットに繋がっていないオフラインの状況でも
|
24
|
+
テキストなどの編集が可能で,さらに不用意な書き換えを防ぐための機構である.さらに,
|
25
|
+
どちらもが何かあった時のバックアップともなって,ミスによる手戻りを防いでいる.
|
27
26
|
|
28
|
-
これらの設定は,~/.hikircにyaml
|
27
|
+
これらの設定は,~/.hikircにyaml形式で記述・保存されている.
|
29
28
|
<<< yaml
|
30
29
|
bob% cat ~/.hikirc
|
31
30
|
:srcs:
|
@@ -41,7 +40,7 @@ bob% cat ~/.hikirc
|
|
41
40
|
:global_uri: http://nishitani0.kwansei.ac.jp/~bob/nishitani0/Internal
|
42
41
|
>>>
|
43
42
|
また,一般的に一人のユーザがいくつものまとまりとしてのlocal-globalペアを
|
44
|
-
|
43
|
+
保持して管理することが普通である.それぞれにnicke_nameをつけて管理している.
|
45
44
|
<<< bash
|
46
45
|
bob% hiki -s
|
47
46
|
hikiutils: provide utilities for helping hiki editing.
|
@@ -55,12 +54,12 @@ editor_command:open -a mi
|
|
55
54
|
2 | ist | /Users/bob/Sites/hiki-data/data | http://ist.ksc.k
|
56
55
|
3 | new_maple | /Users/bob/Sites/new_ist_data/maple_hiki_d| http://ist.ksc.k
|
57
56
|
>>>
|
58
|
-
とすると,それらの一覧と,いまtargetにしているnick_name
|
57
|
+
とすると,それらの一覧と,いまtargetにしているnick_nameディレクリが表示される.
|
59
58
|
|
60
59
|
!!!コメンド名と振る舞いの詳細
|
61
60
|
|
62
|
-
検討の結果コマンドを以下の表{{ref(table:ShellOption)}}
|
63
|
-
上部に記した,特によく使うコマンドに関しては,shell
|
61
|
+
検討の結果コマンドを以下の表{{ref(table:ShellOption)}}のとおり書き換えることとする.
|
62
|
+
上部に記した,特によく使うコマンドに関しては,shellでよく使われるコマンド名と一致するにようにした.
|
64
63
|
|
65
64
|
!!!caption:(table:ShellOption)コマンドオプションとshellコマンドの対応.
|
66
65
|
||変更前||変更後||動作の解説
|
@@ -81,7 +80,7 @@ editor_command:open -a mi
|
|
81
80
|
||help [COMMAND] ||-h|| Describe available commands
|
82
81
|
||version ||-v|| show program version
|
83
82
|
|
84
|
-
|
83
|
+
それぞれの意図を動作の解説として記述する.
|
85
84
|
|
86
85
|
!!!! open FILE
|
87
86
|
ファイルを編集のためにeditorでopen.Editorは~/.hikircに
|
@@ -117,16 +116,19 @@ targetを変える,change directoryとのメタファ.ただし,いまの
|
|
117
116
|
について詳しく検討を行う.
|
118
117
|
|
119
118
|
!!!クラス初期化
|
120
|
-
|
119
|
+
Thorのinitializeでのコードの呼び出し関係は図{{ref(fig:003)}}の通りである.
|
120
|
+
|
121
|
+
!!!!caption:(fig:003)Thorのinitializeでのコード.
|
121
122
|
{{attach_view(hikiutils_yamane.003.jpg,hikiutils_yamane)}}
|
122
123
|
|
123
|
-
|
124
|
+
この動きを順を追って説明すると
|
124
125
|
#Hikithor::CLI.start(ARGV)が呼ばれる
|
125
126
|
#initializeメソッドが呼ばれる
|
126
127
|
#これではThorのinitializeメソッドが呼ばれない
|
127
128
|
#superを書くことでThorのinitializeメソッドが呼ばれる
|
128
|
-
|
129
|
+
となる.
|
129
130
|
|
131
|
+
この実装コードは次の通りである.
|
130
132
|
<<< ruby
|
131
133
|
|
132
134
|
module Hikithor
|
@@ -144,27 +146,20 @@ module Hikithor
|
|
144
146
|
...以下略...
|
145
147
|
end
|
146
148
|
>>>
|
149
|
+
optparseではrequireでoptparseを呼びoptparseのinitializeを定義する必要はないが,Thorはinitializeを定義する必要がある.Thorの定義方法はrequireでThorを呼びCLIクラスで継承し,initializeメソッドにsuperを書くことでThorのinitializeが呼ばれる.initializeメソッド内ではThorの初期設定がされていないため,スーパークラスのメソッドを読み出してくれるsuperを書き加えることで図のようにinitializeメソッド内でThorのinitilalizeメソッドが呼ばれ定義される.
|
147
150
|
|
148
151
|
!!!コマンド定義
|
149
|
-
Thorではoptparse
|
152
|
+
Thorではoptparseのような登録処理はない.コマンド記述のひな形は図{{ref(fig:004)}}の通りである.
|
150
153
|
|
151
154
|
!!!!caption:(fig:004)Thorにおけるコマンド記述のひな形.
|
152
155
|
{{attach_view(hikiutils_yamane.004.jpg,hikiutils_yamane)}}
|
153
156
|
|
154
|
-
|
157
|
+
このひな形を順を追って説明する.
|
155
158
|
#desc以降にコマンド名と,その説明が記述される.これらはコマンドhelpで一覧として表示させる
|
156
159
|
#mapによって別のコマンド名でも実行できるように定義される.
|
157
160
|
#defで定義されたメソッドの実行コード
|
158
161
|
|
159
|
-
|
160
|
-
|
161
|
-
これに別名を与えるために利用されるキーワードがmapである.
|
162
|
-
<<<
|
163
|
-
map A => B
|
164
|
-
>>>
|
165
|
-
mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれるものである.
|
166
|
-
よって,これを使うことでコマンドの別名を指定することができる.
|
167
|
-
|
162
|
+
この実装コードは次の通りである.
|
168
163
|
<<< ruby
|
169
164
|
desc 'show,--show', 'show sources'
|
170
165
|
map "--show" => "show"
|
@@ -174,6 +169,14 @@ mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれる
|
|
174
169
|
,,,以下略...
|
175
170
|
end
|
176
171
|
>>>
|
172
|
+
Thorではdescで一覧を表示されるコマンド名,コマンドの説明を登録する.しかし,ここで記述したコマンドは単に一覧で表示させるためのものであり,実際に実行される時に呼び出すコマンド名は,defで定義された名前である.Thorでは処理実行を行うメソッド名がコマンド名となり,コマンド名1つが対応する.
|
173
|
+
|
174
|
+
これに別名を与えるために利用されるキーワードがmapである.
|
175
|
+
<<<
|
176
|
+
map A => B
|
177
|
+
>>>
|
178
|
+
mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれるものである.
|
179
|
+
よって,これを使うことでコマンドの別名を指定することができる.
|
177
180
|
|
178
181
|
以上より,Thorではコマンドの指定と処理にはdesc,map,処理メソッドだけで済む.optparseではコマンドを登録するためのメソッドと処理メソッドの両方が必要になっていた.一方Thorでは,処理メソッドが直接コマンド名となるため記述が簡潔になる.
|
179
182
|
|
@@ -183,7 +186,7 @@ CLIの実行プロセスは図{{ref(fig:006)}}の通りである.
|
|
183
186
|
!!!!caption:(fig:006)CLIの実行プロセス.
|
184
187
|
{{attach_view(hikiutils_yamane.006.jpg,hikiutils_yamane)}}
|
185
188
|
|
186
|
-
Thorにおける
|
189
|
+
ThorにおけるCLIの実行プロセスは次の通りである.
|
187
190
|
#hiki_thorのHikithor::CLI.start(ARGV)でhikiutils_thor.rbのCLIクラスを呼ぶ
|
188
191
|
#hikiutils_thor.rbのCLIクラスのメソッドを順に実行していく
|
189
192
|
|
data/lib/hikiutils/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
|
2
3
|
# -*- coding: utf-8 -*-
|
3
4
|
require 'systemu'
|
@@ -210,7 +211,7 @@ task :latex_all do
|
|
210
211
|
line = ''
|
211
212
|
end
|
212
213
|
end
|
213
|
-
line ="\\usepackage{listings,jlisting}" if line.match(/\\usepackage{listings}/)
|
214
|
+
line ="\\usepackage{url}\n\\usepackage{listings,jlisting}\n" if line.match(/\\usepackage{listings}/)
|
214
215
|
if line.match(/section{(.+)}/)
|
215
216
|
if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
|
216
217
|
p m
|
@@ -277,7 +278,9 @@ def convert_to_latex(file_name, options={})
|
|
277
278
|
line = "\\end{thebibliography}\n"
|
278
279
|
end
|
279
280
|
if m=line.match(/\\item\[(.+)\](.+)/) and in_bib==true
|
280
|
-
|
281
|
+
tmp=m[2].gsub!(/\\verb\|(.*?)\|/){ "\\url{#{$1}}" }
|
282
|
+
line ="\\bibitem{#{m[1]}} #{tmp}"
|
283
|
+
puts line.blue
|
281
284
|
end
|
282
285
|
if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
|
283
286
|
p line="\\includegraphics\[width=#{$fig_width}cm,bb=#{$bounding_box}\]\{../figs/#{m[1]}\}\n"
|