my_help 0.8.5 → 1.1

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 -1
  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 +63 -56
  15. data/README.org +35 -29
  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 -92
  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 +15 -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 +26 -24
  64. data/tmp.txt +14 -0
  65. metadata +51 -25
  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 -220
  71. data/lib/my_help/tomo_help_controll.rb +0 -0
  72. data/lib/templates/help_template.org +0 -8
data/bin/my_help_thor DELETED
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'thor'
3
- require 'my_help'
4
- require 'colorize'
5
- class MyCLI < Thor
6
- desc('setup', 'set up the test database')
7
- def setup(*args)
8
- $control = MyHelp::Control.new()
9
- end
10
-
11
- desc "list", "list all helps, specific HELP, or item"
12
- def list(*args)
13
- invoke :setup
14
- file = args[0]
15
- item = args[1]
16
- if file.nil?
17
- puts $control.list_all # list []
18
- elsif item.nil?
19
- begin
20
- puts $control.list_help(file) # list [file]
21
- rescue => e
22
- puts e.to_s.red
23
- end
24
- else
25
- begin
26
- puts $control.show_item(file, item) # list [file] [item]
27
- rescue => e
28
- puts e.to_s.red
29
- end
30
- end
31
- end
32
-
33
- desc "edit {help_name}", "edit HELP_NAME"
34
- def edit(help_name)
35
- invoke :setup
36
- $control.edit_help(help_name)
37
- end
38
-
39
- desc "new {help_name}", "make new HELP_NAME"
40
- def new(help_name)
41
- invoke :setup
42
- $control.init_help(help_name)
43
- end
44
-
45
- desc "delete {help_name}", "delete HELP_NAME"
46
- def delete(help_name)
47
- invoke :setup
48
- $control.delete_help(help_name)
49
- end
50
-
51
- desc "tomo_upload {help_name}", "tomo_upload HELP_NAME"
52
- def tomo_upload(help_name)
53
- invoke :setup
54
- $control.upload_help(help_name)
55
- end
56
-
57
- desc "search {find_char}", "search FIND_CHAR"
58
- def search(find_char)
59
- invoke :setup
60
- $control.search_help(find_char)
61
- end
62
- end
63
-
64
- MyCLI.start(ARGV)
65
-
66
-
data/exe/my_help_gli DELETED
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'gli'
3
- require 'my_help'
4
-
5
- include GLI::App
6
-
7
- program_desc 'make own help and list.'
8
-
9
- version MyHelp::VERSION
10
-
11
- subcommand_option_handling :normal
12
- arguments :strict
13
-
14
- desc 'list all helps, specific HELP, or item'
15
- arg_name 'HELP_NAME, ITEM'
16
- command :list do |c|
17
- c.action do |global_options,options,args|
18
- file, item = args
19
- if file.nil?
20
- $control.list_all
21
- elsif item.nil?
22
- $control.list_help(file)
23
- else
24
- $control.show_item(file, item)
25
- end
26
- end
27
- end
28
-
29
- desc 'edit HELP_NAME help'
30
- arg_name 'HELP_NAME'
31
- command :edit do |c|
32
- c.action do |global_options,options,args|
33
- $control.edit_help(args[0])
34
- end
35
- end
36
-
37
- desc 'make new HELP_NAME help'
38
- arg_name 'HELP_NAME'
39
- command :new do |c|
40
- c.action do |global_options,options,args|
41
- $control.init_help(args[0])
42
- end
43
- end
44
-
45
- desc 'delete HELP_NAME help'
46
- arg_name 'HELP_NAME'
47
- command :delete do |c|
48
- c.action do |global_options,options,args|
49
- $control.delete_help(args[0])
50
- end
51
- end
52
-
53
- desc 'tomo_upload HELP_NAME help'
54
- arg_name 'HELP_NAME'
55
- command :tomo_upload do |c|
56
- c.action do |global_options,options,args|
57
- $control.upload_help(args[0])
58
- end
59
- end
60
-
61
- desc 'search FIND_CHAR'
62
- arg_name = 'FIND_CHAR'
63
- command :search do |c|
64
- c.action do |global_options,options,args|
65
- $control.search_help(args[0])
66
- end
67
- end
68
-
69
-
70
- pre do |global,command,options,args|
71
- $control = MyHelp::Control.new()
72
- true
73
- end
74
-
75
- post do |global,command,options,args|
76
- end
77
-
78
- on_error do |exception|
79
- true
80
- end
81
-
82
- exit run(ARGV)
@@ -1,220 +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 = '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
-
145
- def delete_help(file)
146
- file = File.join(@local_help_dir,file+'.org')
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
- end
160
-
161
- def search_help(word)
162
- p find_char = word
163
- system "ls #{@local_help_dir} | grep #{find_char}"
164
- end
165
-
166
- private
167
- def select_item(help, item)
168
- o_key = nil
169
- help.each_pair do |key, cont|
170
- next if key==:license or key==:head
171
- if cont[:opts][:short] == item or cont[:opts][:long] == item
172
- o_key = key
173
- break
174
- end
175
- end
176
- o_key
177
- end
178
-
179
- def disp_opts( conts )
180
- output = ''
181
- col = 0
182
- conts.each_pair do |key, item|
183
- col_length = case col
184
- when 0; output << item.rjust(5)+", "
185
- when 1; output << item.ljust(15)+": "
186
- else; output << item
187
- end
188
- col += 1
189
- end
190
- output << "\n"
191
- end
192
-
193
- def local_help_entries
194
- entries= []
195
- Dir.entries(@local_help_dir).each{|file|
196
- # next unless file.include?('_')
197
- next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
198
- # next if file.match(/(.+)_e\.org/) # OK?
199
- # next if file.match(/(.+)\.html/)
200
- if file.match(/(.+)\.org$/) # OK?
201
- entries << file
202
- end
203
- }
204
- return entries
205
- end
206
-
207
- def auto_load(file_path)
208
- case File.extname(file_path)
209
- # when '.yml'
210
- # cont = YAML.load(File.read(file_path))
211
- when '.org'
212
- cont = OrgToYaml.new(file_path).help_cont
213
- else
214
- puts "Not handling file types of #{file_path}"
215
- cont = nil
216
- end
217
- cont
218
- end
219
- end
220
- 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の例