my_help 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +2 -0
  5. data/Gemfile +1 -0
  6. data/README.md +1 -1
  7. data/Rakefile +35 -12
  8. data/exe/{todo_help → my_todo} +1 -1
  9. data/hikis/diff_against_org-mode.hiki +34 -0
  10. data/hikis/tmp.org +20 -0
  11. data/lib/.emacs_help.rb.swp +0 -0
  12. data/lib/daddygongon/my_todo.yml +31 -0
  13. data/lib/emacs_help.rb +15 -0
  14. data/lib/emacs_help.rb~ +137 -0
  15. data/lib/my_help/test.rb +3 -0
  16. data/lib/my_help/version.rb +1 -1
  17. data/lib/my_help.rb +1 -1
  18. data/lib/my_todo/my_todo.rb +7 -0
  19. data/lib/my_todo/my_todo.rb~ +7 -0
  20. data/lib/specific_help.rb +42 -11
  21. data/lib/specific_help.rb~ +193 -0
  22. data/lib/todo.rb +1 -0
  23. data/lib/todo.rb~ +1 -0
  24. data/lor +0 -0
  25. data/my_help.gemspec +4 -2
  26. data/my_help.wiki/Home.md +1 -1
  27. data/my_help.wiki/README_ja.md +1 -1
  28. data/my_help_nasu/.DS_Store +0 -0
  29. data/my_help_nasu/.gitignore +1 -0
  30. data/my_help_nasu/Rakefile +422 -0
  31. data/my_help_nasu/code.hiki +285 -0
  32. data/my_help_nasu/consideration.hiki +8 -0
  33. data/my_help_nasu/features.hiki +185 -0
  34. data/my_help_nasu/figs/my_help_nasu.001.jpeg +0 -0
  35. data/my_help_nasu/figs/my_help_nasu.001.jpg +0 -0
  36. data/my_help_nasu/figs/my_help_nasu1.001.jpg +0 -0
  37. data/my_help_nasu/head2.tex +9 -0
  38. data/my_help_nasu/hiki_help.yml +53 -0
  39. data/my_help_nasu/introduction.hiki +29 -0
  40. data/my_help_nasu/key_bind_mi +1 -0
  41. data/my_help_nasu/latex_dir/.gitignore +1 -0
  42. data/my_help_nasu/latex_dir/Rakefile +420 -0
  43. data/my_help_nasu/latex_dir/code.aux +25 -0
  44. data/my_help_nasu/latex_dir/code.tex +271 -0
  45. data/my_help_nasu/latex_dir/consideration.aux +22 -0
  46. data/my_help_nasu/latex_dir/consideration.tex +9 -0
  47. data/my_help_nasu/latex_dir/features.aux +31 -0
  48. data/my_help_nasu/latex_dir/features.tex +173 -0
  49. data/my_help_nasu/latex_dir/head.tex +9 -0
  50. data/my_help_nasu/latex_dir/hiki_help.yml +53 -0
  51. data/my_help_nasu/latex_dir/introduction.aux +22 -0
  52. data/my_help_nasu/latex_dir/introduction.tex +23 -0
  53. data/my_help_nasu/latex_dir/jlisting.sty +216 -0
  54. data/my_help_nasu/latex_dir/jlisting.tex +216 -0
  55. data/my_help_nasu/latex_dir/latex_dir/head.tex +9 -0
  56. data/my_help_nasu/latex_dir/latex_dir/jlisting.tex +216 -0
  57. data/my_help_nasu/latex_dir/latex_dir/pre.tex +36 -0
  58. data/my_help_nasu/latex_dir/method_bdd.aux +26 -0
  59. data/my_help_nasu/latex_dir/method_bdd.tex +28 -0
  60. data/my_help_nasu/latex_dir/method_cucumber.aux +28 -0
  61. data/my_help_nasu/latex_dir/method_cucumber.log +28 -0
  62. data/my_help_nasu/latex_dir/method_cucumber.tex +205 -0
  63. data/my_help_nasu/latex_dir/method_usage.aux +28 -0
  64. data/my_help_nasu/latex_dir/method_usage.tex +76 -0
  65. data/my_help_nasu/latex_dir/my_help_nasu.aux +12 -0
  66. data/my_help_nasu/latex_dir/my_help_nasu.log +328 -0
  67. data/my_help_nasu/latex_dir/my_help_nasu.pdf +0 -0
  68. data/my_help_nasu/latex_dir/my_help_nasu.synctex.gz +0 -0
  69. data/my_help_nasu/latex_dir/my_help_nasu.tex +74 -0
  70. data/my_help_nasu/latex_dir/my_help_nasu.toc +32 -0
  71. data/my_help_nasu/latex_dir/overview.aux +21 -0
  72. data/my_help_nasu/latex_dir/overview.tex +12 -0
  73. data/my_help_nasu/latex_dir/pre.tex +36 -0
  74. data/my_help_nasu/method_bdd.hiki +24 -0
  75. data/my_help_nasu/method_cucumber.hiki +184 -0
  76. data/my_help_nasu/method_usage.hiki +69 -0
  77. data/my_help_nasu/my_help_nasu/.DS_Store +0 -0
  78. data/my_help_nasu/my_help_nasu/my_help_nasu.001.jpeg +0 -0
  79. data/my_help_nasu/my_help_nasu.hiki +32 -0
  80. data/my_help_nasu/my_help_nasu.key +0 -0
  81. data/my_help_nasu/overview.hiki +11 -0
  82. data/tmp.txt +2 -0
  83. metadata +104 -10
  84. data/lib/daddygongon/git_help.yml +0 -30
  85. data/lib/daddygongon/todo_help.yml +0 -58
@@ -0,0 +1,420 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'systemu'
3
+ require 'tempfile'
4
+ # -*- coding: utf-8 -*-
5
+ begin
6
+ $hiki_dir = File.readlines('./.hikirc')[0].chomp
7
+ rescue => e
8
+ puts e
9
+ exit
10
+ end
11
+ dirnames=Dir.pwd.split('/')
12
+ $basename = (dirnames[-1]=='hikis')? dirnames[-2] : dirnames[-1]
13
+ $latex_dir= 'latex_dir'
14
+ $section_layer = {}
15
+
16
+ task :default do
17
+ system 'rake -T'
18
+ end
19
+
20
+ desc "Githubのdirをsafariでopen"
21
+ task :github do
22
+ status, stdout, stderr = systemu %q( git remote -v |grep origin )
23
+ p github_dir=stdout.match(/(.+):(.+) \(push\)/)[2]
24
+ system "open https://github.com/#{github_dir}"
25
+ end
26
+
27
+ desc "hikiシステムにあるゴミファイルを掃除する"
28
+ task :reset_hiki do
29
+ status, stdout, stderr = systemu "hiki -l #{$basename}"
30
+ print stdout
31
+ files=[]
32
+ stdout.split("\n").each{|line|
33
+ files << line.split(/\s+/)[-1]
34
+ }
35
+ p r_files = files.reverse[0..-4]
36
+ r_files.each{|file|
37
+ print "remove #{file}[ynqlA]?"
38
+ input=STDIN.gets.chomp
39
+ case input
40
+ when 'y'
41
+ p command="hiki --remove #{file}"
42
+ system command
43
+ when 'n'
44
+ when 'l'
45
+ p command="hiki -l #{$basename}"
46
+ system command
47
+ when 'q'
48
+ exit
49
+ when 'A'
50
+ print "\nAre you sure?[Yn]"
51
+ input2 = STDIN.gets.chomp
52
+ case input2
53
+ when 'Y'
54
+ r_files.each{|file| system "hiki --remove #{file}"}
55
+ p target = File.join($hiki_dir,'cache','attach',$basename)
56
+ exit
57
+ when 'n'
58
+ exit
59
+ end
60
+ end
61
+ }
62
+ end
63
+
64
+ desc "latex_dirのゴミを掃除"
65
+ task :reset_latex_dir do
66
+ system "mv latex_dir/head.tex ."
67
+ system "rm -rf latex_dir"
68
+ system "mkdir latex_dir"
69
+ system "mv head.tex latex_dir/"
70
+ system "rake latex_all"
71
+ end
72
+
73
+ desc "toc.hikiの作成"
74
+ task :mk_toc do
75
+ p target = $basename+'.toc'
76
+ cont=""
77
+ File.readlines(File.join('latex_dir',target)).each{|line|
78
+ if m=line.match(/\\contentsline \{(.+)\}\{\\numberline \{([\d|\.]+)\}(.+)\}\{\d+\}/)
79
+ layer,sec_no,title=m[1],m[2],m[3]
80
+ d = case m[1]
81
+ when 'section'
82
+ 1
83
+ when 'subsection'
84
+ 2
85
+ when 'subsubsection'
86
+ 3
87
+ else
88
+ 4
89
+ end
90
+ layer = "!"*d
91
+ title.gsub!('\_','_')
92
+ cont << "#{layer}#{sec_no}:#{title}\n"
93
+ end
94
+ }
95
+ print cont
96
+ File.open("toc.hiki",'w'){|file| file.print cont}
97
+ end
98
+
99
+ desc "FILE.hikiあるいはhikiファイルすべてを最新状態に更新"
100
+ task :touch do
101
+ if file=ARGV[1]
102
+ p target = $basename+"_"+file.split('.')[0]
103
+ system "hiki -u #{target}"
104
+ else
105
+ p target = File.join($hiki_dir,'cache','attach',$basename)
106
+ system "touch #{target}/*"
107
+ Dir.entries('.').each{|file|
108
+ file_split=file.split(".")
109
+ if file_split[1]=='hiki'
110
+ next if file_split[0]==$basename
111
+ p target = $basename+"_"+file_split[0]
112
+ system "hiki -u #{target}"
113
+ end
114
+ }
115
+ end
116
+ end
117
+
118
+ desc "FILE.hikiあるいはhikiファイルをedtiorで開く"
119
+ task :open do
120
+ if file=ARGV[1]
121
+ system "open -a mi #{file}"
122
+ else
123
+ Dir.entries('.').each{|file|
124
+ file_split=file.split(".")
125
+ if file_split[1]=='hiki'
126
+ p target = file_split[0]
127
+ system "open -a mi #{target}"
128
+ end
129
+ }
130
+ end
131
+ end
132
+
133
+ desc "FILE1をlatexに変換"
134
+ task :latex => [:latex_base] do
135
+ exit
136
+ end
137
+
138
+ desc "FILE1をwrap formatでlatexに変換"
139
+ task :latex_wrap => [:latex_base, :change_wrap] do
140
+ exit
141
+ end
142
+
143
+ def latex_loop(entries,opts={})
144
+ main_file=""
145
+ entries.each{|file|
146
+ options={:latex_all=>true}
147
+ next unless file.split('.')[1]=='hiki'
148
+ next if file=='toc.hiki'
149
+ next if file.include?('.hikirc')
150
+ f_name =File.basename(file,'.hiki')
151
+ if opts[:main]
152
+ if f_name==$basename
153
+ options[:latex]="--listings --head latex_dir/head.tex -p "
154
+ options[:main]=true
155
+ main_file=f_name
156
+ convert_to_latex(file, options)
157
+ end
158
+ else
159
+ if f_name!=$basename
160
+ p level = $section_layer[f_name] || 1
161
+ options[:latex]="-l #{level} --listings -b "
162
+ convert_to_latex(file, options)
163
+ end
164
+ end
165
+ }
166
+ return main_file
167
+ end
168
+
169
+ def check_section_layers(lines)
170
+ p reg_exp = Regexp.new("#{$basename}_(.+)")
171
+ lines.each{|line|
172
+ p line
173
+ if m=line.match(/(!+)\[\[(.+)\]\]/)
174
+ p count = m[1].count('!')
175
+ p file_name=m[2].match(reg_exp)[1]
176
+ $section_layer[file_name]=count
177
+ end
178
+ }
179
+ p $section_layer
180
+ end
181
+
182
+ def check_bounding_box
183
+ # $bounding_box="0 0 442 432"
184
+ $bounding_box=" 0 0 737 453"
185
+ end
186
+
187
+ desc "すべてのhikiファイルをlatex変換"
188
+ task :latex_all do
189
+ p entries=Dir.entries('.')
190
+ check_bounding_box
191
+ main_file = latex_loop(entries,opts={:main=>true})
192
+ latex_loop(entries)
193
+ cont=""
194
+ p reg_exp = Regexp.new("#{$basename}_(.+)")
195
+ toc = false
196
+ File.readlines(File.join($latex_dir,"#{main_file}.tex")).each{|line|
197
+ line, toc = "", true if line.match(/\\tableofcontents/) and toc == true #only one
198
+ line ="\\usepackage{listings,jlisting}" if line.match(/\\usepackage{listings}/)
199
+ if line.match(/section{(.+)}/)
200
+ if m=line.match(/\\verb\|(.+)\((.+)\)\|/)
201
+ p m
202
+ p m_t=m[2].match(reg_exp)[1]
203
+ line = "\\include{#{m_t}}\n"
204
+ elsif m=line.match(/section{\\verb\|(.+)\|}/)
205
+ p m
206
+ p m_t=m[1].match(reg_exp)[1]
207
+ line = "\\include{#{m_t}}\n"
208
+ else
209
+ # line = ""
210
+ end
211
+ end
212
+ cont << line
213
+ }
214
+ File.open(File.join($latex_dir,"#{main_file}.tex"),'w'){|file| file.print cont}
215
+ system "open latex_dir/#{main_file}.tex"
216
+ exit
217
+ end
218
+
219
+ task :latex_base do
220
+ Dir.mkdir($latex_dir) unless Dir.exist?($latex_dir)
221
+ convert_to_latex(ARGV[1])
222
+ system("open #{$save_name}")
223
+ end
224
+
225
+ def convert_to_latex(file_name, options={})
226
+ p file_name = file_name.include?('.hiki')? file_name : file_name+'.hiki'
227
+ p tex_name = File.basename(file_name,'.hiki')+'.tex'
228
+ p $save_name = ARGV[2] || File.join($latex_dir,tex_name)
229
+ pre_name = File.join($latex_dir,'pre.tex')
230
+ p pre_command = File.exist?(pre_name) ? '--pre '+pre_name : nil
231
+ lines = File.readlines(file_name)
232
+ check_section_layers(lines) if options[:main]
233
+ cont = ""
234
+ lines.each_with_index{|line,i|
235
+ if m=line.match(/\{\{attach_view\((.*),(.*)\)\}\}/)
236
+ p line="\{\{attach_view\(#{m[1]}\)\}\}\n"
237
+ elsif options[:latex_all] and i<5
238
+ line="" if line.match(/^!title:|^!author:|^!date:/)
239
+ end
240
+ cont << line
241
+ }
242
+ tf1,tf2='tmp1.txt','tmp2.txt'
243
+ File.open(tf1,'w'){|file| file.print cont}
244
+ system "hiki2latex #{pre_command} #{options[:latex]} #{tf1} > #{tf2}"
245
+ lines = File.readlines(tf2)
246
+ system "rm #{tf1} #{tf2}"
247
+ cont = ""
248
+ lines.each{|line|
249
+ if m=line.match(/\\includegraphics\[width=6cm\]\{(.+)\}/)
250
+ p line="\\includegraphics\[width=10cm,bb=#{$bounding_box}\]\{../figs/#{m[1]}\}\n"
251
+ cont << line
252
+ else
253
+ cont << line
254
+ end
255
+ }
256
+ File.open($save_name,'w'){|file| file.print cont }
257
+ end
258
+
259
+ task :change_wrap do
260
+ lines = File.readlines($save_name)
261
+
262
+ cont = ""
263
+ lines.each{|line|
264
+ if line.include?('\begin{figure}[htbp]\begin{center}')
265
+ p line
266
+ cont << '\begin{wrapfigure}{r}{8cm}'+"\n"
267
+ cont << '\vspace{-2\baselineskip}'+"\n"
268
+ cont << '\begin{center}'+"\n"
269
+ elsif line.include?('\label{default}\end{center}\end{figure}')
270
+ p line
271
+ cont << '\end{center}'+"\n"
272
+ cont << '\vspace{2\baselineskip}'+"\n"
273
+ cont << '\end{wrapfigure}'+"\n"
274
+ else
275
+ cont << line
276
+ end
277
+ }
278
+ File.open($save_name,'w'){|file| file.print cont }
279
+
280
+ system("open #{$save_name}")
281
+ exit
282
+ end
283
+
284
+
285
+ desc "increment fig NUBERS in FILE"
286
+ task :increment do
287
+ number=ARGV[1]
288
+ file = ARGV[2]
289
+ dir = ARGV[3] || nil
290
+ lines = File.readlines(file)
291
+ cont = ""
292
+ lines.each{|line|
293
+ if m=line.match(/\{\{attach_view\((\w+|_).(\d+).jpeg\)\}\}/)
294
+ new_num=sprintf("%03d",m[2].to_i+number.to_i)
295
+ line="\{\{attach_view\(#{m[1]}.#{new_num}.jpeg,#{dir}\)\}\}\n"
296
+ cont << line
297
+ else
298
+ cont << line
299
+ end
300
+ }
301
+ print cont
302
+ exit
303
+ end
304
+
305
+ desc "numbering figs from the NUBER in FILE"
306
+ task :number do
307
+ number=ARGV[1].to_i
308
+ file = ARGV[2]
309
+ dir = ARGV[3] || nil
310
+ lines = File.readlines(file)
311
+ cont = ""
312
+ lines.each{|line|
313
+ if m=line.match(/\{\{attach_view\((\w+|_).(\d+).jpeg,(\w+)\)\}\}/)
314
+ new_num=sprintf("%03d",number)
315
+ line="\{\{attach_view\(#{m[1]}.#{new_num}.jpeg,#{m[3]}\)\}\}\n"
316
+ cont << line
317
+ number += 1
318
+ else
319
+ cont << line
320
+ end
321
+ }
322
+ print cont
323
+ exit
324
+ end
325
+
326
+ desc "convert fig size SCALE TARGET_DIR"
327
+ task :convert do
328
+ scale = ARGV[1]
329
+ target_dir=ARGV[2]
330
+ Dir.entries(target_dir)[2..-1].each{|file|
331
+ p file
332
+ source = File.join(target_dir,file)
333
+ target = File.join('figs',file)
334
+ p command = "convert #{source} -resize #{scale}\% #{target}"
335
+ system command
336
+ }
337
+ exit
338
+ end
339
+
340
+ desc "hikiの同期"
341
+ task :sync => [:check_previous,:sync0]
342
+
343
+
344
+ desc "hikiの強制同期"
345
+ task :force_sync => [:sync0]
346
+
347
+ task :sync0 do
348
+ entries=Dir.entries('.')
349
+ entries[2..-1].each{|source| #cp *.hiki
350
+ next unless source.split('.')[1]=='hiki'
351
+ next if source.include?('.hikirc')
352
+ p base = source.split('.')[0]
353
+ name = (base==$basename)? base : $basename+'_'+base
354
+ p target = File.join($hiki_dir,'text',name)
355
+ FileUtils.cp(source,target,:verbose=>true)
356
+ }
357
+ p entries=Dir.entries('./figs') #cp files in figs
358
+ p target = File.join($hiki_dir,'cache','attach',$basename)
359
+ FileUtils.mkdir_p(target,:verbose=>true) unless File.exists?(target)
360
+ entries[2..-1].each{|file|
361
+ p source = File.join('./figs',file)
362
+ FileUtils.cp(source,target,:verbose=>true)
363
+ }
364
+
365
+ File.open('./.hikirc','w'){|file|
366
+ status, stdout, stderr =systemu "hiki -l #{$basename}*"
367
+ file.print($hiki_dir+"\n")
368
+ stdout.split("\n")[3..-1].each{|line|
369
+ file.print line+"\n"
370
+ }
371
+ }
372
+ exit
373
+ end
374
+
375
+ desc "For hiki Errno::ENOENT, Errno::EACCES"
376
+ task :chenv do
377
+ p user = ENV['USER']
378
+ system("sudo chmod -R a+w #{$hiki_dir}")
379
+ # system("sudo chown -R #{user} #{$hiki_dir}")
380
+ end
381
+
382
+ desc "self copy to hikiutils template directory"
383
+ task :self_copy do
384
+ p cp_files=[[File.join(Dir.pwd,'Rakefile'),'Rakefile_hiki_sync'],
385
+ [File.join(ENV['HOME'],'.my_help','hiki_help.yml'),'hiki_help.yml']]
386
+ cp_files.each{|files|
387
+ p source = files[0]
388
+ p target = File.join('/Users/bob/Github/hikiutils/lib/templates/',files[1])
389
+ FileUtils.cp(source,target,:verbose=>true)
390
+ }
391
+ end
392
+
393
+ task :check_previous do
394
+ current={}
395
+ print "current hiki dir\n"
396
+ status, stdout, stderr = systemu("hiki -l #{$basename}*")
397
+ stdout.split("\n")[3..-1].each{|line|
398
+ p line
399
+ file= line.split(/\s+/)[-1]
400
+ current[file]=line
401
+ }
402
+ previous={}
403
+ print "previous sync\n"
404
+ File.readlines('.hikirc')[1..-1].each{|line|
405
+ p line.chomp
406
+ file= line.split(/\s+/)[-1]
407
+ previous[file]=line.chomp
408
+ }
409
+ changed = []
410
+ current.each_pair{|key,val|
411
+ if !previous.include?(key) or previous[key]!=val
412
+ changed << val+"\n"
413
+ end
414
+ }
415
+ if changed.size != 0
416
+ print("hiki dirで変更が発生しています.\n")
417
+ changed.each{|line| print line+"\n"}
418
+ exit
419
+ end
420
+ end
@@ -0,0 +1,25 @@
1
+ \relax
2
+ \@writefile{toc}{\contentsline {section}{\numberline {3}結果}{17}}
3
+ \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}todoの更新マニュアル}{17}}
4
+ \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Cucumber}{17}}
5
+ \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}RSpec}{21}}
6
+ \@setckpt{code}{
7
+ \setcounter{page}{23}
8
+ \setcounter{equation}{0}
9
+ \setcounter{enumi}{5}
10
+ \setcounter{enumii}{0}
11
+ \setcounter{enumiii}{0}
12
+ \setcounter{enumiv}{0}
13
+ \setcounter{footnote}{0}
14
+ \setcounter{mpfootnote}{0}
15
+ \setcounter{part}{0}
16
+ \setcounter{section}{3}
17
+ \setcounter{subsection}{3}
18
+ \setcounter{subsubsection}{0}
19
+ \setcounter{paragraph}{0}
20
+ \setcounter{subparagraph}{0}
21
+ \setcounter{figure}{2}
22
+ \setcounter{table}{1}
23
+ \setcounter{lstnumber}{18}
24
+ \setcounter{lstlisting}{0}
25
+ }