my_help 0.8.6 → 1.1a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/'../test'/.my_help/.my_help_conf.yml +2 -0
  3. data/'../test'/.my_help/emacs.org +50 -0
  4. data/{lib/templates → '../test'/.my_help}/org.org +0 -0
  5. data/{lib/templates → '../test'/.my_help}/todo.org +0 -0
  6. data/.gitignore +8 -0
  7. data/.my_help/example2.org +9 -0
  8. data/.rspec +1 -2
  9. data/.rspec_status +13 -0
  10. data/.yardoc/checksums +3 -3
  11. data/.yardoc/object_types +0 -0
  12. data/.yardoc/objects/root.dat +0 -0
  13. data/Gemfile +10 -5
  14. data/Gemfile.lock +61 -88
  15. data/README.org +35 -47
  16. data/Rakefile +25 -14
  17. data/doc/MyHelp/Control.html +443 -221
  18. data/doc/MyHelp.html +7 -7
  19. data/doc/OrgToYaml.html +12 -10
  20. data/doc/_index.html +7 -7
  21. data/doc/class_list.html +2 -2
  22. data/doc/css/style.css +3 -2
  23. data/doc/file.README.html +29 -29
  24. data/doc/file_list.html +2 -2
  25. data/doc/frames.html +2 -2
  26. data/doc/index.html +29 -29
  27. data/doc/js/app.js +14 -3
  28. data/doc/method_list.html +24 -8
  29. data/doc/top-level-namespace.html +6 -6
  30. data/docs/README.html +218 -0
  31. data/docs/README.org +202 -0
  32. data/docs/old_docs/16b_nasu.pdf +0 -0
  33. data/docs/old_docs/17b_oyagi.pdf +0 -0
  34. data/docs/old_docs/19b_okabata.pdf +0 -0
  35. data/docs/old_docs/19b_yamaguchi.pdf +0 -0
  36. data/docs/old_docs/features/delete.feature +7 -0
  37. data/docs/old_docs/features/edit.feature +7 -0
  38. data/docs/old_docs/features/list.feature +6 -0
  39. data/docs/old_docs/features/new.feature +7 -0
  40. data/docs/old_docs/features/step_definitions/delete_spec.rb +12 -0
  41. data/docs/old_docs/features/step_definitions/edit_spec.rb +14 -0
  42. data/docs/old_docs/features/step_definitions/list_spec.rb +10 -0
  43. data/docs/old_docs/features/step_definitions/new_spec.rb +12 -0
  44. data/docs/old_docs/features/support/env.rb +3 -0
  45. data/docs/old_docs/fukumori_symp/18_human_interface_fukumori_workshop.pdf +0 -0
  46. data/docs/old_docs/fukumori_symp/memo_perp_magician.pdf +0 -0
  47. data/docs/old_docs/fukumori_symp//347/237/245/350/255/230/343/201/256/347/233/264/344/272/244/350/243/234/347/251/272/351/226/223.png +0 -0
  48. data/exe/my_help +1 -142
  49. data/lib/my_help/cli.rb +106 -0
  50. data/lib/my_help/config.rb +70 -0
  51. data/lib/my_help/git_cli.rb +40 -0
  52. data/lib/my_help/init.rb +28 -0
  53. data/lib/my_help/list.rb +76 -0
  54. data/lib/my_help/md2hash.rb +54 -0
  55. data/lib/my_help/modify.rb +33 -0
  56. data/lib/my_help/org2hash.rb +45 -0
  57. data/lib/my_help/org2yml.rb +14 -14
  58. data/lib/my_help/version.rb +3 -1
  59. data/lib/my_help.rb +23 -7
  60. data/lib/templates/emacs.org +13 -14
  61. data/lib/templates/example.md +17 -0
  62. data/lib/templates/example.org +9 -0
  63. data/my_help.gemspec +27 -22
  64. data/tmp.txt +14 -0
  65. metadata +52 -26
  66. data/README.html +0 -443
  67. data/README.rdoc +0 -6
  68. data/bin/my_help_thor +0 -66
  69. data/exe/my_help_gli +0 -82
  70. data/lib/my_help/my_help_controll.rb +0 -222
  71. data/lib/my_help/tomo_help_controll.rb +0 -0
  72. data/lib/templates/help_template.org +0 -8
@@ -1,222 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'fileutils'
3
- require 'yaml'
4
-
5
- module MyHelp
6
- class Control
7
- attr_accessor :local_help_dir, :editor
8
- def initialize()
9
- # for configuration setups
10
- # see https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
11
-
12
- @template_dir = File.expand_path("../../templates", __FILE__)
13
- @exe_dir = File.expand_path("../../exe", __FILE__)
14
- @local_help_dir = File.join(ENV['HOME'],'.my_help')
15
- @editor = ENV['EDITOR'] || 'emacs' #'code', 'emacs' #'vim' #default editor
16
- # @mini_account = File
17
- set_help_dir_if_not_exists
18
- load_conf
19
- end
20
-
21
- def set_editor(editor)
22
- @editor = editor
23
- file_name = '.my_help_conf.yml'
24
- @conf_file = File.join(@local_help_dir, file_name)
25
- conf = {editor: editor}
26
- File.open(@conf_file, 'w'){|f| YAML.dump(conf, f)}
27
- puts "set editor '#{@editor}'"
28
- end
29
-
30
- def load_conf
31
- file_name = '.my_help_conf.yml'
32
- # @conf_file = File.join(Dir.pwd, file_name)
33
- @conf_file = File.join(@local_help_dir, file_name)
34
- begin
35
- conf = YAML.load_file(@conf_file)
36
- @editor = conf[:editor]
37
- rescue => e
38
- puts e.to_s.red
39
- puts 'make .my_help_conf.yml'.green
40
- set_editor(@editor)
41
- end
42
- end
43
-
44
- def set_help_dir_if_not_exists
45
- return if File::exist?(@local_help_dir)
46
- FileUtils.mkdir_p(@local_help_dir, :verbose=>true)
47
- Dir.entries(@template_dir).each{|file|
48
- next if file=='help_template.org'
49
- file_path=File.join(@local_help_dir,file)
50
- next if File::exists?(file_path)
51
- FileUtils.cp((File.join(@template_dir,file)),@local_help_dir,:verbose=>true)
52
- }
53
- end
54
-
55
- def list_all
56
- output = "\nList all helps\n"
57
- local_help_entries.each do |file|
58
- file_path=File.join(@local_help_dir,file)
59
- title = file.split('.')[0]
60
- help = auto_load(file_path)
61
- next if help.nil?
62
- begin
63
- desc = help[:head][:cont].split("\n")[0]
64
- rescue => e
65
- puts e
66
- puts "No head in #{file_path}".red
67
- next
68
- end
69
- output << title.rjust(10)
70
- output << ": #{desc}\n"
71
- end
72
- output
73
- end
74
-
75
- WrongFileName = Class.new(RuntimeError)
76
- def list_help(file)
77
- output = ''
78
- file_path=File.join(@local_help_dir,file+'.org')
79
- begin
80
- help = auto_load(file_path)
81
- rescue => e
82
- raise WrongFileName, "No help named '#{file}' in the directory '#{local_help_dir}'."
83
- end
84
- help.each_pair do |key, conts|
85
- output << conts[:cont] if key==:head
86
- output << disp_opts( conts[:opts] )
87
- end
88
- output
89
- end
90
-
91
- WrongItemName = Class.new(RuntimeError)
92
- def show_item(file, item)
93
- output = ''
94
- file_path=File.join(@local_help_dir,file+'.org')
95
- help = auto_load(file_path)
96
- select = select_item(help, item)
97
- output << help[:head][:cont]
98
- unless select then
99
- raise WrongItemName, "No item entry: #{item}"
100
- end
101
- output << '-'*5+"\n"+select.to_s.green+"\n"
102
- output << help[select][:cont]
103
- end
104
-
105
- def edit_help(file)
106
- p target_help = File.join(@local_help_dir,file+'.org')
107
- if local_help_entries.member?(file+'.org')
108
- system "#{@editor} #{target_help}"
109
- else
110
- puts "file #{target_help} does not exits in #{@local_help_dir}."
111
- puts "init #{file} first."
112
- end
113
- end
114
-
115
- def init_help(file)
116
- if file.nil?
117
- puts "specify NAME".red
118
- exit
119
- end
120
- p target_help=File.join(@local_help_dir,file+'.org')
121
- if File::exists?(target_help)
122
- puts "File exists. delete it first to initialize it."
123
- exit
124
- end
125
- p template = File.join(@template_dir,'help_template.org')
126
- FileUtils::Verbose.cp(template,target_help)
127
- end
128
-
129
- =begin
130
- def delete_help(file)
131
- file = File.join(@local_help_dir,file+'.org')
132
- print "Are you sure to delete "+file.blue+"?[Ynq] ".red
133
- case STDIN.gets.chomp
134
- when 'Y'
135
- begin
136
- FileUtils.rm(file,:verbose=>true)
137
- rescue => error
138
- puts error.to_s.red
139
- end
140
- when 'n', 'q' ; exit
141
- end
142
- end
143
- =end
144
- def delete_help(file)
145
- file = File.join(@local_help_dir,file+'.org')
146
- if File.exist?(file) == true
147
- print "Are you sure to delete "+file.blue+"?[Yn] ".red
148
- case STDIN.gets.chomp
149
- when 'Y'
150
- begin
151
- FileUtils.rm(file,:verbose=>true)
152
- return 0
153
- rescue => error
154
- puts error.to_s.red
155
- return 1
156
- end
157
- when 'n', 'q' ; return 0
158
- end
159
- else
160
- print file + " is a non-existent file"
161
- end
162
- end
163
-
164
- def search_help(word)
165
- p find_char = word
166
- system "ls #{@local_help_dir} | grep #{find_char}"
167
- end
168
-
169
- private
170
- def select_item(help, item)
171
- o_key = nil
172
- help.each_pair do |key, cont|
173
- next if key==:license or key==:head
174
- if cont[:opts][:short] == item or cont[:opts][:long] == item
175
- o_key = key
176
- break
177
- end
178
- end
179
- o_key
180
- end
181
-
182
- def disp_opts( conts )
183
- output = ''
184
- col = 0
185
- conts.each_pair do |key, item|
186
- col_length = case col
187
- when 0; output << item.rjust(5)+", "
188
- when 1; output << item.ljust(15)+": "
189
- else; output << item
190
- end
191
- col += 1
192
- end
193
- output << "\n"
194
- end
195
- def local_help_entries
196
- entries= []
197
- Dir.entries(@local_help_dir).each{|file|
198
- # next unless file.include?('_')
199
- next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
200
- # next if file.match(/(.+)_e\.org/) # OK?
201
- # next if file.match(/(.+)\.html/)
202
- if file.match(/(.+)\.org$/) # OK?
203
- entries << file
204
- end
205
- }
206
- return entries
207
- end
208
-
209
- def auto_load(file_path)
210
- case File.extname(file_path)
211
- # when '.yml'
212
- # cont = YAML.load(File.read(file_path))
213
- when '.org'
214
- cont = OrgToYaml.new(file_path).help_cont
215
- else
216
- puts "Not handling file types of #{file_path}"
217
- cont = nil
218
- end
219
- cont
220
- end
221
- end
222
- end
File without changes
@@ -1,8 +0,0 @@
1
- #+STARTUP: indent nolineimages
2
- * head
3
- - ヘルプのサンプル雛形
4
- - headに常に表示される内容を記述
5
- * license
6
- - cc by Shigeto R. Nishitani, 2016
7
- * item_example
8
- - itemの例