hikiutils 0.2.3.13 → 0.2.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/hikiutils.gemspec +2 -1
  3. data/hikiutils_bob/Rakefile +30 -16
  4. data/hikiutils_bob/code.hiki +9 -30
  5. data/hikiutils_bob/figs/hikiutils_bob.002.jpeg +0 -0
  6. data/hikiutils_bob/figs/hikiutils_bob.007.jpeg +0 -0
  7. data/hikiutils_bob/figs/hikiutils_bob.pdf +0 -0
  8. data/hikiutils_bob/hikiutils_bob/hikiutils_bob.002.jpeg +0 -0
  9. data/hikiutils_bob/hikiutils_bob/hikiutils_bob.007.jpeg +0 -0
  10. data/hikiutils_bob/hikiutils_bob.key +0 -0
  11. data/hikiutils_bob/latex_all.hiki +33 -8
  12. data/hikiutils_bob/latex_dir/code.aux +7 -14
  13. data/hikiutils_bob/latex_dir/code.log +28 -0
  14. data/hikiutils_bob/latex_dir/code.tex +13 -31
  15. data/hikiutils_bob/latex_dir/hikiutils_bob.log +59 -50
  16. data/hikiutils_bob/latex_dir/hikiutils_bob.pdf +0 -0
  17. data/hikiutils_bob/latex_dir/hikiutils_bob.synctex.gz +0 -0
  18. data/hikiutils_bob/latex_dir/hikiutils_bob.toc +29 -29
  19. data/hikiutils_bob/latex_dir/latex_all.aux +19 -16
  20. data/hikiutils_bob/latex_dir/latex_all.log +28 -0
  21. data/hikiutils_bob/latex_dir/latex_all.tex +34 -9
  22. data/hikiutils_bob/latex_dir/sync.aux +16 -16
  23. data/hikiutils_bob/latex_dir/sync.tex +4 -4
  24. data/hikiutils_yamane/Rakefile +14 -2
  25. data/hikiutils_yamane/abstract.hiki +3 -3
  26. data/hikiutils_yamane/discussion.hiki +9 -0
  27. data/hikiutils_yamane/hikiutils_yamane.hiki +8 -10
  28. data/hikiutils_yamane/introduction.hiki +1 -1
  29. data/hikiutils_yamane/latex_dir/abstract.tex +3 -3
  30. data/hikiutils_yamane/latex_dir/{%CA%FD/313/241.aux → discussion.aux} +8 -7
  31. data/hikiutils_yamane/latex_dir/discussion.tex +9 -0
  32. data/hikiutils_yamane/latex_dir/hikiutils_yamane.aux +3 -6
  33. data/hikiutils_yamane/latex_dir/hikiutils_yamane.log +50 -59
  34. data/hikiutils_yamane/latex_dir/hikiutils_yamane.pdf +0 -0
  35. data/hikiutils_yamane/latex_dir/hikiutils_yamane.synctex.gz +0 -0
  36. data/hikiutils_yamane/latex_dir/hikiutils_yamane.tex +4 -7
  37. data/hikiutils_yamane/latex_dir/hikiutils_yamane.toc +21 -21
  38. data/hikiutils_yamane/latex_dir/introduction.tex +1 -1
  39. data/hikiutils_yamane/latex_dir/method.aux +46 -0
  40. data/hikiutils_yamane/latex_dir/method.tex +247 -0
  41. data/hikiutils_yamane/latex_dir/results.aux +49 -0
  42. data/hikiutils_yamane/latex_dir/results.tex +249 -0
  43. data/hikiutils_yamane/method.hiki +234 -0
  44. data/hikiutils_yamane/results.hiki +225 -0
  45. data/hikiutils_yamane/toc.hiki +0 -1
  46. data/lib/hikiutils/version.rb +1 -1
  47. data/lib/hikiutils_thor.rb~ +37 -37
  48. data/lib/templates/Rakefile_hiki_sync +32 -17
  49. data/lib/templates/mi_key_bind_setting +1 -0
  50. metadata +33 -19
  51. data/hikiutils_yamane/Rakefile~ +0 -477
  52. data/hikiutils_yamane/command.hiki +0 -111
  53. data/hikiutils_yamane/compare.hiki +0 -116
  54. data/hikiutils_yamane/latex_dir/command.aux +0 -35
  55. data/hikiutils_yamane/latex_dir/command.log +0 -0
  56. data/hikiutils_yamane/latex_dir/command.tex +0 -123
  57. data/hikiutils_yamane/latex_dir/compare.aux +0 -30
  58. data/hikiutils_yamane/latex_dir/compare.tex +0 -123
  59. data/hikiutils_yamane/latex_dir/optparse.aux +0 -31
  60. data/hikiutils_yamane/latex_dir/optparse.tex +0 -119
  61. data/hikiutils_yamane/latex_dir/thor.aux +0 -32
  62. data/hikiutils_yamane/latex_dir/thor.tex +0 -110
  63. data/hikiutils_yamane/optparse.hiki +0 -114
  64. data/hikiutils_yamane/thor.hiki +0 -107
@@ -0,0 +1,225 @@
1
+ {{toc}}
2
+ !結果
3
+ !!コマンドの命名原則
4
+
5
+ 機能ごとの動作はコマンドのオプションによって指定されます.
6
+ このオプションにどのような名前をつけるかは,どれだけコマンドを覚えやすいかという
7
+ 意味で重要です.コマンドの振る舞いを的確に表す名称をつける必要があります.
8
+
9
+ この振る舞いとしてもっとも受け入れやすいのがshellで用意されているコマンドです.
10
+ pwd, ls, rm, touch, openなどはもっとも直感的に動作がわかるコマンドです.
11
+ hikiutilsの振る舞いを予測できるシェルコマンドと同じ名前でオプションを提供する
12
+ ようにします.
13
+
14
+
15
+ !!!hikiutilsの想定利用形態
16
+ ここでhikiutilsがあらかじめ想定している利用形態を解説しておきます.
17
+
18
+ !!!caption:(fig:002)hikiutilsがあらかじめ想定している利用形態.
19
+ {{attach_view(hikiutils_yamane.002.jpg,hikiutils_yamane)}}
20
+
21
+ hikiutilsは,
22
+ *local PCとglobal serverとが用意されており,
23
+ *それらのデータをrsyncで同期する
24
+ ことで動作することを想定しています.これは,ネットに繋がっていないオフラインの状況でも
25
+ テキストなどの編集が可能で,さらに不用意な書き換えを防ぐための機構です.さらに,
26
+ どちらもが何かあった時のバックアップともなって,ミスによる手戻りを防いでいます.
27
+
28
+ これらの設定は,~/.hikircにyaml形式で記述・保存されています.
29
+ <<< yaml
30
+ bob% cat ~/.hikirc
31
+ :srcs:
32
+ - :nick_name: new_ist
33
+ :local_dir: "/Users/bob/Sites/new_ist_data/ist_data"
34
+ :local_uri: http://localhost/ist
35
+ :global_dir: nishitani@ist.ksc.kwansei.ac.jp:/home/nishitani/new_ist_data/ist_data
36
+ :global_uri: http://ist.ksc.kwansei.ac.jp/~nishitani/
37
+ - :nick_name: dmz0
38
+ :local_dir: "/Users/bob/Sites/nishitani0/Internal/data"
39
+ :local_uri: http://localhost/~bob/nishitani0/Internal
40
+ :global_dir: bob@dmz0:/Users/bob/Sites/nishitani0/Internal/data
41
+ :global_uri: http://nishitani0.kwansei.ac.jp/~bob/nishitani0/Internal
42
+ >>>
43
+ また,一般的に一人のユーザがいくつものまとまりとしてのlocal-globalペアを
44
+ 保持して管理することが普通です.それぞれにnicke_nameをつけて管理しています.
45
+ <<< bash
46
+ bob% hiki -s
47
+ hikiutils: provide utilities for helping hiki editing.
48
+ "open -a mi"
49
+ target_no:1
50
+ editor_command:open -a mi
51
+ id | name | local directory | global uri
52
+ -----------------------------------------------------------------------------
53
+ 0 | new_ist | /Users/bob/Sites/new_ist_data/ist_data | http://ist.ksc.k
54
+ *1 | dmz0 | /Users/bob/Sites/nishitani0/Internal/data | http://nishitani
55
+ 2 | ist | /Users/bob/Sites/hiki-data/data | http://ist.ksc.k
56
+ 3 | new_maple | /Users/bob/Sites/new_ist_data/maple_hiki_d| http://ist.ksc.k
57
+ >>>
58
+ とすると,それらの一覧と,いまtargetにしているnick_nameディレクリが表示されます.
59
+
60
+ !!!コメンド名と振る舞いの詳細
61
+
62
+ 検討の結果コマンドを以下の表{{ref(table:ShellOption)}}のとおり書き換えることとします.
63
+ 上部に記した,特によく使うコマンドに関しては,shellでよく使われるコマンド名と一致するにようにしました.
64
+
65
+ !!!caption:(table:ShellOption)コマンドオプションとshellコマンドの対応.
66
+ ||変更前||変更後||動作の解説
67
+ ||edit FILE ||open|| open file
68
+ ||list [FILE] ||ls|| list files
69
+ ||rsync ||rsync|| rsync files
70
+ ||update FILE ||touch|| update file
71
+ ||show ||pwd|| show nick_names
72
+ ||target VAL ||cd|| targetを変える,cdとのメタファ
73
+ || || ||
74
+ ||move [FILE] ||mv|| move file
75
+ ||remove [FILE] ||rm|| remove files
76
+ ||add || || add sources info
77
+ ||checkdb || || check database file
78
+ ||datebase FILE ||db|| read datebase file
79
+ ||display FILE ||show|| display converted hikifile
80
+ ||euc FILE || || translate file to euc
81
+ ||help [COMMAND] ||-h|| Describe available commands
82
+ ||version ||-v|| show program version
83
+
84
+ それぞれの意図を動作の解説として記述しています.
85
+
86
+ !!!! open FILE
87
+ ファイルを編集のためにeditorでopen.Editorは~/.hikircに
88
+ :editor_command: open -a mi
89
+ として保存されている.open -a miをemacsなどに適宜変更して使用.
90
+
91
+ !!!! ls [FILE]
92
+ local_dirにあるファイル名を[FILE*]として表示.例えば,hikiutils_yamane以下の拡張子が
93
+ ついたファイルを表示.hikiシステムではtextディレクトリーは階層構造を取ることができない.
94
+ 西谷研ではdirectoryの代わりにスネーク表記で階層構造を表している.
95
+
96
+ !!!! rsync
97
+ local_dirの内容をglobal_dirにrsyncする.逆方向は同期に誤差が生じたり,permissionが
98
+ おかしくなるので,現在のところ一方向の同期のみとしている.したがって,作業手順としては
99
+ テキストの変更はlocal_dirで読み行うようにしている.
100
+
101
+ !!!! touch FILE
102
+ loccal_dirで書き換えたFILEの内容をlocal_uriに反映させ,ブラウザで表示.シェルコマンドの
103
+ touchによって,変更時間を現在に変え,最新状態とするのに似せてコマンド名をtouchとしている.
104
+
105
+ !!!! pwd
106
+ nick_nameの一覧とtargetを表示,current targetをcurrent dirとみなして,
107
+ コマンド名をpwdとした.
108
+
109
+ !!!! cd VAL
110
+ targetを変える,change directoryとのメタファ.ただし,いまのところnick_nameでは
111
+ 対応しておらず,nick_nameの番号をVAL入力することで変更する.
112
+ !!Thorによる実装
113
+ 手法のところで概観した通り,Thorを用いることで記述の簡略化が期待できる.ここでは,実際に書き換える前後,すなわちoptparse版とThor版の対応するコードを比較することで,以下の具体的な違い
114
+ *クラス初期化
115
+ *コマンド定義
116
+ *CLIの実行プロセス
117
+ について詳しく検討を行う.
118
+
119
+ !!!クラス初期化
120
+ !!!!caption:Thorのinitializeでのコード
121
+ {{attach_view(hikiutils_yamane.003.jpg,hikiutils_yamane)}}
122
+
123
+ Thorのinitializeでのコードはつぎの通りである.
124
+ #Hikithor::CLI.start(ARGV)が呼ばれる
125
+ #initializeメソッドが呼ばれる
126
+ #これではThorのinitializeメソッドが呼ばれない
127
+ #superを書くことでThorのinitializeメソッドが呼ばれる
128
+ optparseではrequireでoptparseを呼びoptparseのinitializeを定義する必要はないが,Thorはinitializeを定義する必要がある.Thorの定義方法はrequireでThorを呼びCLIクラスで継承し,initializeメソッドにsuperを書くことでThorのinitializeが呼ばれる.initializeメソッド内ではThorの初期設定がされていないため,スーパークラスのメソッドを読み出してくれるsuperを書き加えることで図のようにinitializeメソッド内でThorのinitilalizeメソッドが呼ばれ定義される.
129
+
130
+ <<< ruby
131
+
132
+ module Hikithor
133
+
134
+ DATA_FILE=File.join(ENV['HOME'],'.hikirc')
135
+ attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
136
+
137
+ class CLI < Thor
138
+ def initialize(*args)
139
+ super
140
+ @data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
141
+ data_path = File.join(ENV['HOME'], '.hikirc')
142
+ DataFiles.prepare(data_path)
143
+
144
+ ...以下略...
145
+ end
146
+ >>>
147
+
148
+ !!!コマンド定義
149
+ Thorではoptparseのような登録処理はない.図{{ref(fig:004)}}にある通りにコマンドが記述される.
150
+
151
+ !!!!caption:(fig:004)Thorにおけるコマンド記述のひな形.
152
+ {{attach_view(hikiutils_yamane.004.jpg,hikiutils_yamane)}}
153
+
154
+ それらは以下のように構成される.
155
+ #desc以降にコマンド名と,その説明が記述される.これらはコマンドhelpで一覧として表示させる
156
+ #mapによって別のコマンド名でも実行できるように定義される.
157
+ #defで定義されたメソッドの実行コード
158
+
159
+ Thorではdescで一覧を表示されるコマンド名,コマンドの説明を登録する.しかし,ここで記述したコマンドは単に一覧で表示させるためのものであり,実際に実行される時に呼び出すコマンド名は,defで定義された名前である.Thorでは処理実行を行うメソッド名がコマンド名となり,コマンド名1つが対応する.
160
+
161
+ これに別名を与えるために利用されるキーワードがmapである.
162
+ <<<
163
+ map A => B
164
+ >>>
165
+ mapとはBと呼ばれるメソッドをAでも呼べるようにしてくれるものである.
166
+ よって,これを使うことでコマンドの別名を指定することができる.
167
+
168
+ <<< ruby
169
+ desc 'show,--show', 'show sources'
170
+ map "--show" => "show"
171
+ def show
172
+ printf("target_no:%i\n",@src[:target])
173
+ printf("editor_command:%s\n",@src[:editor_command])
174
+ ,,,以下略...
175
+ end
176
+ >>>
177
+
178
+ 以上より,Thorではコマンドの指定と処理にはdesc,map,処理メソッドだけで済む.optparseではコマンドを登録するためのメソッドと処理メソッドの両方が必要になっていた.一方Thorでは,処理メソッドが直接コマンド名となるため記述が簡潔になる.
179
+
180
+ !!!CLIの実行プロセス
181
+ CLIの実行プロセスは図{{ref(fig:006)}}の通りである.
182
+
183
+ !!!!caption:(fig:006)CLIの実行プロセス.
184
+ {{attach_view(hikiutils_yamane.006.jpg,hikiutils_yamane)}}
185
+
186
+ Thorにおけるcliの実行プロセスは次の通りである.
187
+ #hiki_thorのHikithor::CLI.start(ARGV)でhikiutils_thor.rbのCLIクラスを呼ぶ
188
+ #hikiutils_thor.rbのCLIクラスのメソッドを順に実行していく
189
+
190
+ Thorではstart(ARGV)を呼び出すことでCLIを開始する.Hikithor::CLI.start(ARGV)を実行されることによりrequireで呼ばれているhikiutils_thor.rbのCLIコマンドを順に実行する.そして,入力されたコマンドと一致するメソッドを探し,そのコマンドの処理が実行される.
191
+
192
+ exe/hiki_thorの具体的な記述は次の通りである.
193
+ <<< ruby
194
+ #!/usr/bin/env ruby
195
+
196
+ require "hikiutils_thor"
197
+
198
+ Hikithor::CLI.start(ARGV)
199
+ >>>
200
+ hikiutilsのoptparseバージョンと同様に「require "hikituils_thor"」ではlib/hikiutils_thor.rbを読み出してくることを期待している.
201
+ ここでもgemspecファイルでlibへのロードパスの記述がされているため,hikiutils_thor.rbを参照することができる.
202
+ 「Hikithor::CLI.start(ARGV)」ではlib/hikiutils_thor.rbのHikithorモジュールCommandクラスを実行する記述が成されている.
203
+
204
+ 呼び出される側のlib/hikiutils_thor.rbの具体的な記述は次の通りである.
205
+ <<< ruby
206
+
207
+ module Hikithor
208
+
209
+ DATA_FILE=File.join(ENV['HOME'],'.hikirc')
210
+ attr_accessor :src, :target, :editor_command, :browser, :data_name, :l_dir
211
+
212
+ class CLI < Thor
213
+ def initialize(*args)
214
+ super
215
+ @data_name=['nick_name','local_dir','local_uri','global_dir','global_uri']
216
+ data_path = File.join(ENV['HOME'], '.hikirc')
217
+ DataFiles.prepare(data_path)
218
+ ...以下略...
219
+ >>>
220
+
221
+ 通常のclass呼び出しで生成されるようになっている.
222
+ rubyにおいても通常のclassからの実行では,newした後にexeする.
223
+ しかし,Thorにおいてはstartという関数名で初期化・実行される.
224
+ これは,rubyに付属しているRakefileの実行方法とよく似た構文となっている.
225
+
@@ -17,4 +17,3 @@
17
17
  !!!4.2.2:コマンド定義
18
18
  !!!4.2.3:CLIの実行プロセス
19
19
  !!!4.2.4:optparseとの全体的な比較
20
- !5:参考文献
@@ -1,3 +1,3 @@
1
1
  module HikiUtils
2
- VERSION = "0.2.3.13"
2
+ VERSION = "0.2.3.14"
3
3
  end
@@ -78,16 +78,16 @@ EOS
78
78
  }
79
79
  end
80
80
 
81
- desc 'version,--version,-v', 'show program version'
82
- map "--version" => "version"
83
- map "-v" => "version"
81
+ desc '-v', 'show program version'
82
+ # map "--version" => "version"
83
+ map "バージョン" => "version"
84
84
  def version
85
85
  puts HikiUtils::VERSION
86
86
  end
87
87
 
88
- desc 'add,--add', 'add sources info'
89
- map "--add" => "add"
90
- option :add
88
+ desc 'add', 'add sources info'
89
+ # map "--add" => "add"
90
+ # option :add
91
91
  def add
92
92
  cont = {}
93
93
  @data_name.each{|name|
@@ -99,16 +99,16 @@ EOS
99
99
  show
100
100
  end
101
101
 
102
- desc 'target VAL,--target VAL', 'set target id'
103
- map "--target" => "target"
104
- def target(val)
102
+ desc 'cd VAL', 'set target id'
103
+ # map "--target" => "target"
104
+ def cd(val)
105
105
  @src[:target] = val.to_i
106
106
  show
107
107
  end
108
108
 
109
- desc 'edit FILE,--edit FILE', 'open file'
110
- map "--edit" => "edit"
111
- def edit(file)
109
+ desc 'open', 'open file'
110
+ # map "--edit" => "edit"
111
+ def open(file)
112
112
  t_file=File.join(@l_dir,'text',file)
113
113
  if !File.exist?(t_file) then
114
114
  file=File.open(t_file,'w')
@@ -119,18 +119,18 @@ EOS
119
119
  system command
120
120
  end
121
121
 
122
- desc 'list [FILE],--list [FILE]', 'list files'
123
- map "--list" => "list"
124
- def list(file)
122
+ desc 'ls [FILE]', 'list files'
123
+ # map "--list" => "list"
124
+ def ls(file)
125
125
  file ='' if file==nil
126
126
  t_file=File.join(@l_dir,'text')
127
127
  print "target_dir : "+t_file+"\n"
128
128
  print `cd #{t_file} ; ls -lt #{file}*`
129
129
  end
130
130
 
131
- desc 'update FILE,--update FILE', 'update file'
132
- map "--update" => "update"
133
- def update(file0)
131
+ desc 'touch', 'update file'
132
+ # map "--update" => "update"
133
+ def touch(file0)
134
134
  file = (file0==nil) ? 'FrontPage' : file0
135
135
  t_file=File.join(@l_dir,'cache/parser',file)
136
136
  FileUtils.rm(t_file,:verbose=>true)
@@ -143,9 +143,9 @@ EOS
143
143
  p "If you get 整形式になっていません, try login as a valid user."
144
144
  end
145
145
 
146
- desc 'rsync,--rsync', 'rsync files'
147
- map "--rsync" => "rsync"
148
- option :rsync
146
+ desc 'rsync', 'rsync files'
147
+ # map "--rsync" => "rsync"
148
+ # option :rsync
149
149
  def rsync
150
150
  p local = @l_dir
151
151
  p global = @src[:srcs][@target][:global_dir]
@@ -153,16 +153,16 @@ EOS
153
153
  system command
154
154
  end
155
155
 
156
- desc 'datebase FILE,--database FILE', 'read datebase file'
157
- map "--database" => "database"
158
- def database(file_name)
156
+ desc 'db FILE', 'read datebase file'
157
+ # map "--database" => "database"
158
+ def db(file_name)
159
159
  info=InfoDB.new(@l_dir)
160
160
  p info.show(file_name)
161
161
  end
162
162
 
163
- desc 'display FILE,--display FILE', 'display converted hikifile'
164
- map "--display" => "display"
165
- def display(file)
163
+ desc 'show FILE', 'display converted hikifile'
164
+ # map "--display" => "display"
165
+ def show(file)
166
166
  body = HikiDoc.to_html(File.read(file))
167
167
  source = HTML_TEMPLATE
168
168
  title = File.basename(file)
@@ -173,16 +173,16 @@ EOS
173
173
  system "open #{t.path}"
174
174
  end
175
175
 
176
- desc 'checkdb,--checkdb', 'check database file'
177
- map "--checkdb" => "checkdb"
176
+ desc 'checkdb', 'check database file'
177
+ # map "--checkdb" => "checkdb"
178
178
  def checkdb
179
179
  result= InfoDB.new(@l_dir).show_inconsist
180
180
  print (result=='') ? "db agrees with text dir.\n" : result
181
181
  end
182
182
 
183
- desc 'remove [FILE],--remove [FILE]', 'remove files'
184
- map "--remove" => "remove"
185
- def remove(file_name)
183
+ desc 'rm [FILE]', 'remove files'
184
+ # map "--remove" => "remove"
185
+ def rm(file_name)
186
186
  p text_path = File.join(@l_dir,'text',file_name)
187
187
  p attach_path = File.join(@l_dir,'cache/attach',file_name)
188
188
  begin
@@ -203,9 +203,9 @@ EOS
203
203
  info.dump
204
204
  end
205
205
 
206
- desc 'move [FILE],--move [FILE]', 'move file'
207
- map "--move" => "move"
208
- def move(files)
206
+ desc 'mv [FILE]', 'move file'
207
+ # map "--move" => "move"
208
+ def mv(files)
209
209
  begin
210
210
  p file1_path = File.join(@l_dir,'text',files[0])
211
211
  p file2_path = File.join(@l_dir,'text',files[1])
@@ -266,8 +266,8 @@ EOS
266
266
  info.dump
267
267
  end
268
268
 
269
- desc 'euc FILE,--euc FILE', 'translate file to euc'
270
- map "--euc" => "euc"
269
+ desc 'euc FILE', 'translate file to euc'
270
+ # map "--euc" => "euc"
271
271
  def euc(file)
272
272
  p file_path = File.join(@l_dir,'text',file)
273
273
  cont = File.readlines(file_path)
@@ -2,6 +2,8 @@
2
2
  require 'systemu'
3
3
  require 'tempfile'
4
4
  require 'colorize'
5
+ require 'coderay'
6
+
5
7
  # -*- coding: utf-8 -*-
6
8
  begin
7
9
  $hiki_dir = File.readlines('./.hikirc')[0].chomp
@@ -36,7 +38,7 @@ task :reset_hiki do
36
38
  }
37
39
  r_files = files.reverse[0..-4]
38
40
  r_files.each{|file|
39
- print "remove #{file}? [ynqlA] ".red
41
+ print "remove #{file}[ynqlA]? ".red
40
42
  input=STDIN.gets.chomp
41
43
  case input
42
44
  when 'y'
@@ -49,7 +51,7 @@ task :reset_hiki do
49
51
  when 'q'
50
52
  exit
51
53
  when 'A'
52
- print "\nAre you sure? [Yn] ".magenta
54
+ print "\nAre you sure[Yn]? ".magenta
53
55
  input2 = STDIN.gets.chomp
54
56
  case input2
55
57
  when 'Y'
@@ -66,9 +68,11 @@ end
66
68
  desc "latex_dirのゴミを掃除"
67
69
  task :reset_latex_dir do
68
70
  system "mv latex_dir/head.tex ."
71
+ system "mv latex_dir/jlisting.sty ."
69
72
  system "rm -rf latex_dir"
70
73
  system "mkdir latex_dir"
71
74
  system "mv head.tex latex_dir/"
75
+ system "mv jlisting.sty latex_dir/"
72
76
  system "rake latex_all"
73
77
  end
74
78
 
@@ -80,14 +84,10 @@ task :mk_toc do
80
84
  if m=line.match(/\\contentsline \{(.+)\}\{\\numberline \{([\d|\.]+)\}(.+)\}\{\d+\}/)
81
85
  layer,sec_no,title=m[1],m[2],m[3]
82
86
  d = case m[1]
83
- when 'section'
84
- 1
85
- when 'subsection'
86
- 2
87
- when 'subsubsection'
88
- 3
89
- else
90
- 4
87
+ when 'section'; 1
88
+ when 'subsection'; 2
89
+ when 'subsubsection'; 3
90
+ else; 4
91
91
  end
92
92
  layer = "!"*d
93
93
  title.gsub!('\_','_')
@@ -101,7 +101,8 @@ end
101
101
  desc "FILE.hikiあるいはhikiファイルすべてを最新状態に更新"
102
102
  task :touch do
103
103
  if file=ARGV[1]
104
- p target = $basename+"_"+file.split('.')[0]
104
+ file_split=file.split(".")
105
+ p target = $basename==file_split[0] ? $basename : $basename+"_"+file_split[0]
105
106
  system "hiki -u #{target}"
106
107
  else
107
108
  p target = File.join($hiki_dir,'cache','attach',$basename)
@@ -109,7 +110,6 @@ task :touch do
109
110
  Dir.entries('.').each{|file|
110
111
  file_split=file.split(".")
111
112
  if file_split[1]=='hiki'
112
- next if file_split[0]==$basename
113
113
  p target = $basename==file_split[0] ? $basename : $basename+"_"+file_split[0]
114
114
  system "hiki -u #{target}"
115
115
  end
@@ -120,7 +120,8 @@ end
120
120
 
121
121
  desc "FILE.hikiあるいはhikiファイルをedtiorで開く"
122
122
  task :open do
123
- if file=ARGV[1]
123
+ if file=ARGV[1]
124
+ file += '.hiki' if file.split(".")[1]==nil
124
125
  system "open -a mi #{file}"
125
126
  else
126
127
  Dir.entries('.').each{|file|
@@ -144,6 +145,7 @@ task :latex_wrap => [:latex_base, :change_wrap] do
144
145
  end
145
146
 
146
147
  def latex_loop(entries,opts={})
148
+ check_bounding_box
147
149
  main_file=""
148
150
  entries.each{|file|
149
151
  options={:latex_all=>true}
@@ -189,7 +191,6 @@ end
189
191
 
190
192
  desc "すべてのhikiファイルをlatex変換"
191
193
  task :latex_all do
192
- check_bounding_box
193
194
  p entries=Dir.entries('.')
194
195
  main_file = latex_loop(entries,opts={:main=>true})
195
196
  latex_loop(entries)
@@ -197,7 +198,14 @@ task :latex_all do
197
198
  p reg_exp = Regexp.new("#{$basename}_(.+)")
198
199
  toc = false
199
200
  File.readlines(File.join($latex_dir,"#{main_file}.tex")).each{|line|
200
- line, toc = "", true if line.match(/\\tableofcontents/) and toc == true #only one
201
+ # line, toc = "", true if line.match(/\\tableofcontents/) and toc == true #only one
202
+ if line.match(/\\tableofcontents/)
203
+ if toc == false #only one
204
+ toc = true
205
+ else
206
+ line = ''
207
+ end
208
+ end
201
209
  line ="\\usepackage{listings,jlisting}" if line.match(/\\usepackage{listings}/)
202
210
  if line.match(/section{(.+)}/)
203
211
  if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
@@ -285,7 +293,7 @@ def latex_cite_ref(line)
285
293
  while m=line.match(r_pair[1])
286
294
  line.sub!(r_pair[1],"\\ref\{#{m[1]}\}")
287
295
  end
288
- puts line.chomp.blue
296
+ # puts line.chomp.blue
289
297
  return line
290
298
  end
291
299
 
@@ -440,7 +448,14 @@ task :self_copy do
440
448
  cp_files.each{|files|
441
449
  p source = files[0]
442
450
  p target = File.join('/Users/bob/Github/hikiutils/lib/templates/',files[1])
443
- FileUtils.cp(source,target,:verbose=>true)
451
+ command = "diff #{source} #{target}"
452
+ status, stdout, stderr=systemu command
453
+ if stdout!=''
454
+ puts command.red
455
+ puts CodeRay.scan(stdout, :Diff).term
456
+ print " Are you sure to save #{source}? [Yn] ".red
457
+ FileUtils.cp(source,target,:verbose=>true) if STDIN.gets.chomp=='Y'
458
+ end
444
459
  }
445
460
  end
446
461
 
@@ -0,0 +1 @@
1
+ ***control+A:<<<MOVECARET-STARTOFLINE>>>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hikiutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3.13
4
+ version: 0.2.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishitani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.9.12.1
131
+ version: 0.9.17
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.9.12.1
138
+ version: 0.9.17
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: systemu
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: coderay
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  description: "."
196
210
  email:
197
211
  - shigeto_nishitani@me.com
@@ -326,6 +340,7 @@ files:
326
340
  - hikiutils_bob/figs/hikiutils_bob.004.jpeg
327
341
  - hikiutils_bob/figs/hikiutils_bob.005.jpeg
328
342
  - hikiutils_bob/figs/hikiutils_bob.006.jpeg
343
+ - hikiutils_bob/figs/hikiutils_bob.007.jpeg
329
344
  - hikiutils_bob/figs/hikiutils_bob.pdf
330
345
  - hikiutils_bob/figs/sync.pdf
331
346
  - hikiutils_bob/hiki_help.yml
@@ -338,13 +353,16 @@ files:
338
353
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.004.jpeg
339
354
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.005.jpeg
340
355
  - hikiutils_bob/hikiutils_bob/hikiutils_bob.006.jpeg
356
+ - hikiutils_bob/hikiutils_bob/hikiutils_bob.007.jpeg
341
357
  - hikiutils_bob/latex_all.hiki
342
358
  - hikiutils_bob/latex_dir/code.aux
359
+ - hikiutils_bob/latex_dir/code.log
343
360
  - hikiutils_bob/latex_dir/code.tex
344
361
  - hikiutils_bob/latex_dir/head.tex
345
362
  - hikiutils_bob/latex_dir/hikiutils_bob.aux
346
363
  - hikiutils_bob/latex_dir/hikiutils_bob.log
347
364
  - hikiutils_bob/latex_dir/hikiutils_bob.pdf
365
+ - hikiutils_bob/latex_dir/hikiutils_bob.synctex.gz
348
366
  - hikiutils_bob/latex_dir/hikiutils_bob.tex
349
367
  - hikiutils_bob/latex_dir/hikiutils_bob.toc
350
368
  - hikiutils_bob/latex_dir/jlisting.sty
@@ -352,6 +370,7 @@ files:
352
370
  - hikiutils_bob/latex_dir/latex2hiki.aux
353
371
  - hikiutils_bob/latex_dir/latex2hiki.tex
354
372
  - hikiutils_bob/latex_dir/latex_all.aux
373
+ - hikiutils_bob/latex_dir/latex_all.log
355
374
  - hikiutils_bob/latex_dir/latex_all.tex
356
375
  - hikiutils_bob/latex_dir/pre.tex
357
376
  - hikiutils_bob/latex_dir/references.tex
@@ -363,7 +382,6 @@ files:
363
382
  - hikiutils_bob/toc.hiki
364
383
  - hikiutils_yamane/.gitignore
365
384
  - hikiutils_yamane/Rakefile
366
- - hikiutils_yamane/Rakefile~
367
385
  - hikiutils_yamane/abstract.hiki
368
386
  - hikiutils_yamane/backup/hikiutils%28optparse%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%29
369
387
  - hikiutils_yamane/backup/hikiutils%28thor%E3%83%90%E3%83%BC%E3%82%B8%E3%83%A7%E3%83%B3%29
@@ -372,8 +390,7 @@ files:
372
390
  - hikiutils_yamane/backup/hikiutils_yamane_#hikiutils_yamane
373
391
  - hikiutils_yamane/backup/hikiutils_yamane_command_table
374
392
  - hikiutils_yamane/backup/hikiutils_yamane_introduction
375
- - hikiutils_yamane/command.hiki
376
- - hikiutils_yamane/compare.hiki
393
+ - hikiutils_yamane/discussion.hiki
377
394
  - hikiutils_yamane/figs/hikiutils_yamane.001.jpg
378
395
  - hikiutils_yamane/figs/hikiutils_yamane.002.bb
379
396
  - hikiutils_yamane/figs/hikiutils_yamane.002.jpg
@@ -428,14 +445,10 @@ files:
428
445
  - hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.006.jpeg
429
446
  - hikiutils_yamane/hikiutils_yamane/hikiutils_yamane.007.jpeg
430
447
  - hikiutils_yamane/introduction.hiki
431
- - hikiutils_yamane/latex_dir/%CA%FDˡ.aux
432
448
  - hikiutils_yamane/latex_dir/abstract.aux
433
449
  - hikiutils_yamane/latex_dir/abstract.tex
434
- - hikiutils_yamane/latex_dir/command.aux
435
- - hikiutils_yamane/latex_dir/command.log
436
- - hikiutils_yamane/latex_dir/command.tex
437
- - hikiutils_yamane/latex_dir/compare.aux
438
- - hikiutils_yamane/latex_dir/compare.tex
450
+ - hikiutils_yamane/latex_dir/discussion.aux
451
+ - hikiutils_yamane/latex_dir/discussion.tex
439
452
  - hikiutils_yamane/latex_dir/head.tex
440
453
  - hikiutils_yamane/latex_dir/hikiutils_yamane.aux
441
454
  - hikiutils_yamane/latex_dir/hikiutils_yamane.log
@@ -446,14 +459,14 @@ files:
446
459
  - hikiutils_yamane/latex_dir/introduction.aux
447
460
  - hikiutils_yamane/latex_dir/introduction.tex
448
461
  - hikiutils_yamane/latex_dir/jlisting.sty
449
- - hikiutils_yamane/latex_dir/optparse.aux
450
- - hikiutils_yamane/latex_dir/optparse.tex
462
+ - hikiutils_yamane/latex_dir/method.aux
463
+ - hikiutils_yamane/latex_dir/method.tex
451
464
  - hikiutils_yamane/latex_dir/pre.tex
452
- - hikiutils_yamane/latex_dir/thor.aux
453
- - hikiutils_yamane/latex_dir/thor.tex
454
- - hikiutils_yamane/optparse.hiki
465
+ - hikiutils_yamane/latex_dir/results.aux
466
+ - hikiutils_yamane/latex_dir/results.tex
467
+ - hikiutils_yamane/method.hiki
468
+ - hikiutils_yamane/results.hiki
455
469
  - hikiutils_yamane/test.rb
456
- - hikiutils_yamane/thor.hiki
457
470
  - hikiutils_yamane/toc.hiki
458
471
  - lib/hikiutils.rb
459
472
  - lib/hikiutils.rb~
@@ -467,6 +480,7 @@ files:
467
480
  - lib/templates/head.tex
468
481
  - lib/templates/hiki_help.yml
469
482
  - lib/templates/jlisting.sty
483
+ - lib/templates/mi_key_bind_setting
470
484
  - lib/templates/pre.tex
471
485
  homepage: http://github.org/daddygongon/hikiutils
472
486
  licenses: