my_help 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c300a6cf8118a5de14ad9a499ae09097da533f87
4
- data.tar.gz: 213c929710cf37f80acf50a27a51a6932b5ce83f
3
+ metadata.gz: dab861c2fa7bc1ecda68c901e2419bda4dbd86ec
4
+ data.tar.gz: f6d7d0ecccb112139bd7605dc73335a3decd6528
5
5
  SHA512:
6
- metadata.gz: 8cf6f08dade31756b7155ed9eff41114b7aa868a8e9fe6725b7452835a8766c25e7ce8294ff5ff939080c521480a0f73ba44818ea2ff0f74fd2b8ea51feab696
7
- data.tar.gz: 18daf94f375d54a5b10e956991248ac8bce6afda0a0071246e1d7cc988050b2e0f51b98a375bf06f0ec10e22f4cfb41fe450d35c370e0eabc1d8024a35025d08
6
+ metadata.gz: e0c4409ac355238a38874800ea637acd67daddbb545ff213aeefa09799dbd0413d6fec8a9adb28c46f7f10643cb284895016ba54b758710633e6878136d95435
7
+ data.tar.gz: 09d47076171690f6d21d5086d500ff5a35c2874edeb4e4f8d407b73728cbe38723a2eeb93a5c8ba04e04bd20d1bc3c2edf73e80492fca118a29447966e6f5581
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 名前
2
2
 
3
- petit_help, general_help, my_help, ...
3
+ my_help
4
4
 
5
5
  # 概要
6
6
 
@@ -31,7 +31,62 @@ hikiでやろうとしていることの半分くらいはこのあたりのこ
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
33
 
34
+ # 使用法
35
+ ## インストール
36
+ インストールですが,gemの標準とは違ったやり方になります.GithubからForkしてcloneします.
37
+ ```
38
+ git clone git@github.com:daddygongon/my_help.git
39
+ ```
40
+ あとの作業はbundleを使って行います.これは,最後のrake install:localをコマンドから実行する方法がわからんかったからですが...helpファイルのpush共有とかも考えるとこれがいいのかも.
41
+
42
+ 用意されているコマンドは,
43
+
44
+ ```
45
+ bob% bundle exec exe/my_help
46
+ Usage: my_help [options]
47
+ -v, --version show program Version.
48
+ -l, --list 個別(specific)ヘルプのList表示.
49
+ -e, --edit NAME NAME(例:test_help)をEdit編集.
50
+ -i, --init NAME NAME(例:test_help)のtemplateを作成.
51
+ -m, --make make and install:local all helps.
52
+ ```
53
+ です.まず,-lでdefaultで入っているリストを見てください.
54
+
55
+ ```
56
+ bob% bundle exec exe/my_help -l
57
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
58
+ ["-l"]
59
+ Specific help file:
60
+ emacs_help
61
+ test_help
62
+ ```
63
+ これで,CUIでemacs_help, e_h, test_help, t_hが用意されています.少し振る舞いに慣れてください.
64
+
65
+ ## 独自のhelpを作る方法
66
+ さて,独自のhelpを作る方法です.まずは,
67
+
68
+ ```
69
+ bob% bundle exec exe/my_help -i new_help
70
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
71
+ ["-i", "new_help"]
72
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help"
73
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help"
74
+ cp /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help
75
+ /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help
76
+ ```
77
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
78
+
79
+ そのあと,my_helpのdirectoryで
80
+ ```
81
+ git add -A
82
+ git commit -m 'add new help'
83
+ rake install:local
84
+ ```
85
+ してください.
86
+
34
87
  # userの独自helpの達成方法
88
+ (rake my_helpでやっていたが,今は,my_help -mに移行)
89
+
35
90
  exe中のファイルをrakeで自動生成.
36
91
  ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
92
  exe中に実行ファイルを自動生成させている.
@@ -59,6 +114,12 @@ gem uninstall my_help
59
114
  gem uninstall emacs_help
60
115
  ```
61
116
  でそこをcleanにしておくことが望ましい.
117
+
118
+ Rakefileの中身は以下の通り.
119
+ ```
120
+ in Rakefile
121
+ ```
122
+
62
123
  ```ruby
63
124
  desc "make own help from lib/daddygongon/files"
64
125
  task :my_help do
@@ -69,13 +130,15 @@ task :my_help do
69
130
  p file
70
131
  p file_name=file.split('_')
71
132
  target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
72
- p cont_name = File.join(user_name,file)
73
- # exe_cont << "require '#{cont_name}'\n"
74
- exe_cont << "require 'emacs_help'\n"
75
- exe_cont << "EmacsHelp::Command.run(ARGV)\n"
133
+ p cont_name = File.join('lib',user_name,file)
134
+ exe_cont << "require 'my_help'\n"
135
+ exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
136
+ exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
76
137
  target_files.each{|name|
138
+ p ''
77
139
  p target=File.join('exe',name)
78
140
  File.open(target,'w'){|file|
141
+ print exe_cont
79
142
  file.print exe_cont
80
143
  }
81
144
  FileUtils.chmod('a+x', target, :verbose => true)
@@ -84,12 +147,27 @@ task :my_help do
84
147
  end
85
148
  ```
86
149
 
87
- この後の実装方法は,emacs_helpに
150
+ 実装方法は,emacs_helpに
88
151
 
89
152
  1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
153
  1. hush形式でdataをいれ,それをrequireして使う
91
154
 
92
155
  かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
156
+ 今の所,No.1の方を実装.No.2のためのhushデータは,
157
+
158
+ ```ruby
159
+ require 'yaml'
160
+ require 'pp'
161
+
162
+ pp YAML.load(File.read(ARGV[0]))
163
+ ```
164
+
165
+ ```
166
+ ruby test.rb lib/daddygongon/emacs_help
167
+ ```
168
+
169
+ で構築できる.実装してみて.
170
+
93
171
 
94
172
  # どちらがいいか
95
173
  Rubyで日本語が使えるから,optionsを日本語にしてみた.
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ task :hiki2md do
33
33
  readme_en="#{basename}.wiki/README_en.md"
34
34
  readme_ja="#{basename}.wiki/README_ja.md"
35
35
  if File.exists?(readme_en)
36
- FileUtils.cp(readme_en,"./README.md",:verbose=>true)
36
+ FileUtils.cp(readme_en,"./README.md",:verbose=>true)
37
37
  elsif File.exists?(readme_ja)
38
38
  FileUtils.cp(readme_ja,"./README.md",:verbose=>true)
39
39
  FileUtils.cp(readme_ja,"#{basename}.wiki/Home.md",:verbose=>true)
@@ -52,18 +52,20 @@ end
52
52
 
53
53
  desc "make own help from lib/daddygongon/files"
54
54
  task :my_help do
55
- exe_cont="#!/usr/bin/env ruby\n"
56
55
  user_name = 'daddygongon'
57
56
  p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
58
57
  entries.each{|file|
59
58
  p file
59
+ next if file[0]=='#' or file[-1]=='~'
60
+ exe_cont="#!/usr/bin/env ruby\n"
60
61
  p file_name=file.split('_')
61
62
  target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
62
63
  p cont_name = File.join('lib',user_name,file)
63
- exe_cont << "require 'my_help'\n"
64
- exe_cont << "MyHelp::Command.run('#{cont_name}', ARGV)\n"
64
+ exe_cont << "require 'specific_help'\n"
65
+ exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
66
+ exe_cont << "SpecificHelp::Command.run(help_file, ARGV)\n"
65
67
  target_files.each{|name|
66
- p ''
68
+ print "\n"
67
69
  p target=File.join('exe',name)
68
70
  File.open(target,'w'){|file|
69
71
  print exe_cont
data/exe/#my_help# ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "my_help"
4
+
data/exe/e_h CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'my_help'
3
- MyHelp::Command.run('lib/daddygongon/emacs_help', ARGV)
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/emacs_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/emacs_help CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'my_help'
3
- MyHelp::Command.run('lib/daddygongon/emacs_help', ARGV)
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/emacs_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/my_help CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "my_help"
4
+ MyHelp::Command.run(ARGV)
data/exe/n_h ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/new_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/new_help ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/new_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/t_h ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/test_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/test_help ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = '/Users/bob/Github/my_help/lib/daddygongon/test_help'
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/hikis/README_ja.hiki CHANGED
@@ -1,6 +1,6 @@
1
1
  !名前
2
2
 
3
- petit_help, general_help, my_help, ...
3
+ my_help
4
4
 
5
5
  !概要
6
6
 
@@ -31,7 +31,60 @@ hikiでやろうとしていることの半分くらいはこのあたりのこ
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
33
 
34
+ !使用法
35
+ !!インストール
36
+ インストールですが,gemの標準とは違ったやり方になります.GithubからForkしてcloneします.
37
+ git clone git@github.com:daddygongon/my_help.git
38
+ あとの作業はbundleを使って行います.これは,最後のrake install:localをコマンドから実行する方法がわからんかったからですが...helpファイルのpush共有とかも考えるとこれがいいのかも.
39
+
40
+ 用意されているコマンドは,
41
+
42
+ <<<
43
+ bob% bundle exec exe/my_help
44
+ Usage: my_help [options]
45
+ -v, --version show program Version.
46
+ -l, --list 個別(specific)ヘルプのList表示.
47
+ -e, --edit NAME NAME(例:test_help)をEdit編集.
48
+ -i, --init NAME NAME(例:test_help)のtemplateを作成.
49
+ -m, --make make and install:local all helps.
50
+ >>>
51
+ です.まず,-lでdefaultで入っているリストを見てください.
52
+
53
+ <<<
54
+ bob% bundle exec exe/my_help -l
55
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
56
+ ["-l"]
57
+ Specific help file:
58
+ emacs_help
59
+ test_help
60
+ >>>
61
+ これで,CUIでemacs_help, e_h, test_help, t_hが用意されています.少し振る舞いに慣れてください.
62
+
63
+ !!独自のhelpを作る方法
64
+ さて,独自のhelpを作る方法です.まずは,
65
+
66
+ <<<
67
+ bob% bundle exec exe/my_help -i new_help
68
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
69
+ ["-i", "new_help"]
70
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help"
71
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help"
72
+ cp /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help
73
+ /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help
74
+ >>>
75
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
76
+
77
+ そのあと,my_helpのdirectoryで
78
+ <<<
79
+ git add -A
80
+ git commit -m 'add new help'
81
+ rake install:local
82
+ >>>
83
+ してください.
84
+
34
85
  !userの独自helpの達成方法
86
+ (rake my_helpでやっていたが,今は,my_help -mに移行)
87
+
35
88
  exe中のファイルをrakeで自動生成.
36
89
  ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
90
  exe中に実行ファイルを自動生成させている.
@@ -53,6 +106,10 @@ exe
53
106
  gem uninstall my_help
54
107
  gem uninstall emacs_help
55
108
  でそこをcleanにしておくことが望ましい.
109
+
110
+ Rakefileの中身は以下の通り.
111
+ in Rakefile
112
+
56
113
  <<< ruby
57
114
  desc "make own help from lib/daddygongon/files"
58
115
  task :my_help do
@@ -63,13 +120,15 @@ task :my_help do
63
120
  p file
64
121
  p file_name=file.split('_')
65
122
  target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
66
- p cont_name = File.join(user_name,file)
67
- # exe_cont << "require '#{cont_name}'\n"
123
+ p cont_name = File.join('lib',user_name,file)
68
124
  exe_cont << "require 'my_help'\n"
69
- exe_cont << "EmacsHelp::Command.run(ARGV)\n"
125
+ exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
126
+ exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
70
127
  target_files.each{|name|
128
+ p ''
71
129
  p target=File.join('exe',name)
72
130
  File.open(target,'w'){|file|
131
+ print exe_cont
73
132
  file.print exe_cont
74
133
  }
75
134
  FileUtils.chmod('a+x', target, :verbose => true)
@@ -78,12 +137,25 @@ task :my_help do
78
137
  end
79
138
  >>>
80
139
 
81
- この後の実装方法は,emacs_helpに
140
+ 実装方法は,emacs_helpに
82
141
 
83
142
  # yaml形式でdataを入れ,command.runの入力ファイルとする
84
143
  # hush形式でdataをいれ,それをrequireして使う
85
144
 
86
145
  かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
146
+ 今の所,No.1の方を実装.No.2のためのhushデータは,
147
+
148
+ <<< ruby
149
+ require 'yaml'
150
+ require 'pp'
151
+
152
+ pp YAML.load(File.read(ARGV[0]))
153
+ >>>
154
+
155
+ ruby test.rb lib/daddygongon/emacs_help
156
+
157
+ で構築できる.実装してみて.
158
+
87
159
 
88
160
  !どちらがいいか
89
161
  Rubyで日本語が使えるから,optionsを日本語にしてみた.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  :head:
3
- - "\n 特殊キー操作\n"
4
- - "\tc-f, controlキーを押しながら 'f'\n"
5
- - "\t\tM-f, escキーを押した後一度離して'f'\n"
6
- - "\t操作の中断c-g, 操作の取り消し(Undo) c-x u \n"
3
+ - "\n特殊キー操作\n"
4
+ - " c-f, controlキーを押しながら 'f'\n"
5
+ - " M-f, escキーを押した後一度離して'f'\n"
6
+ - " 操作の中断c-g, 操作の取り消し(Undo) c-x u \n"
7
7
  :cursor:
8
8
  :opts:
9
9
  :short: "-c"
@@ -0,0 +1,24 @@
1
+ ---
2
+ :head:
3
+ - "TODO: ヘルプ内容の概略.\n"
4
+ - " 常に表示される内容を記述.\n"
5
+ - " 下を参照して変更してください.\n"
6
+ :item:
7
+ :opts:
8
+ :short: "-i"
9
+ :long: "--item"
10
+ :desc: 単元(item)
11
+ :title: "\n単元\n"
12
+ :cont:
13
+ - c-f, move Forwrard, 前or右へ
14
+ - フォーマットは自由です. ','があるときは2文字下げ,ないときは4文字下げ
15
+ :item2:
16
+ :opts:
17
+ :short: "-j"
18
+ :long: "--item2"
19
+ :desc: 単元2(item2)
20
+ :title: "\n単元2\n"
21
+ :cont:
22
+ - c-f, move Forwrard, 前or右へ
23
+ - フォーマットは自由です.
24
+
@@ -0,0 +1,24 @@
1
+ ---
2
+ :head:
3
+ - "TODO: ヘルプ内容の概略.\n"
4
+ - " 常に表示される内容を記述.\n"
5
+ - " 下を参照して変更してください.\n"
6
+ :item:
7
+ :opts:
8
+ :short: "-i"
9
+ :long: "--item"
10
+ :desc: 単元(item)
11
+ :title: "\n単元\n"
12
+ :cont:
13
+ - c-f, move Forwrard, 前or右へ
14
+ - フォーマットは自由です. ','があるときは2文字下げ,ないときは4文字下げ
15
+ :item2:
16
+ :opts:
17
+ :short: "-j"
18
+ :long: "--item2"
19
+ :desc: 単元2(item2)
20
+ :title: "\n単元2\n"
21
+ :cont:
22
+ - c-f, move Forwrard, 前or右へ
23
+ - フォーマットは自由です.
24
+
@@ -0,0 +1,24 @@
1
+ ---
2
+ :head:
3
+ - "TODO: ヘルプ内容の概略.\n"
4
+ - " 常に表示される内容を記述.\n"
5
+ - " 下を参照して変更してください.\n"
6
+ :item:
7
+ :opts:
8
+ :short: "-i"
9
+ :long: "--item"
10
+ :desc: 単元(item)
11
+ :title: "\n単元\n"
12
+ :cont:
13
+ - c-f, move Forwrard, 前or右へ
14
+ - フォーマットは自由です. ','があるときは2文字下げ,ないときは4文字下げ
15
+ :item2:
16
+ :opts:
17
+ :short: "-j"
18
+ :long: "--item2"
19
+ :desc: 単元2(item2)
20
+ :title: "\n単元2\n"
21
+ :cont:
22
+ - c-f, move Forwrard, 前or右へ
23
+ - フォーマットは自由です.
24
+
@@ -1,3 +1,3 @@
1
1
  module MyHelp
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/my_help.rb CHANGED
@@ -1,36 +1,35 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "optparse"
3
3
  require "yaml"
4
- require "emacs_help/version"
4
+ require "fileutils"
5
+ #require "emacs_help/version"
5
6
  require "my_help/version"
6
- require "emacs_help"
7
+ #require "emacs_help"
7
8
 
8
9
  module MyHelp
9
10
  class Command
10
11
 
11
- def self.run(file,argv=[])
12
- new(file, argv).execute
12
+ def self.run(argv=[])
13
+ new(argv).execute
13
14
  end
14
15
 
15
- def initialize(file,argv=[])
16
- @help_cont = YAML.load(File.read(file))
17
- # @help_cont = YAML.load(File.read('lib/daddygongon/emacs_help'))
18
- @help_cont[:head].each{|line| print line }
16
+ def initialize(argv=[])
19
17
  @argv = argv
18
+ p @target_dir = File.expand_path("../../lib/daddygongon", __FILE__)
19
+ p @argv
20
20
  end
21
21
 
22
22
  def execute
23
23
  @argv << '--help' if @argv.size==0
24
24
  command_parser = OptionParser.new do |opt|
25
25
  opt.on('-v', '--version','show program Version.') { |v|
26
- opt.version = EmacsHelp::VERSION
26
+ opt.version = MyHelp::VERSION
27
27
  puts opt.ver
28
28
  }
29
- @help_cont.each_pair{|key,val|
30
- next if key==:head
31
- opts = val[:opts]
32
- opt.on(opts[:short],opts[:long],opts[:desc]) {disp_from_help_cont(key)}
33
- }
29
+ opt.on('-l', '--list', '個別(specific)ヘルプのList表示.'){list_helps}
30
+ opt.on('-e NAME', '--edit NAME', 'NAME(例:test_help)をEdit編集.'){|file| edit_help(file)}
31
+ opt.on('-i NAME', '--init NAME', 'NAME(例:test_help)のtemplateを作成.'){|file| init_help(file)}
32
+ opt.on('-m', '--make', 'make and install:local all helps.'){make_help}
34
33
  end
35
34
  begin
36
35
  command_parser.parse!(@argv)
@@ -40,21 +39,45 @@ module MyHelp
40
39
  exit
41
40
  end
42
41
 
43
- def disp(lines)
44
- lines.each{|line|
45
- if line.include?(',')
46
- puts " #{line}"
47
- else
48
- puts " #{line}"
49
- end
42
+ def make_help
43
+ p entries=Dir.entries(@target_dir)[2..-1]
44
+ entries.each{|file|
45
+ p file
46
+ next if file[0]=='#' or file[-1]=='~'
47
+ exe_cont="#!/usr/bin/env ruby\nrequire 'specific_help'\n"
48
+ p file_name=file.split('_')
49
+ target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
50
+ target = File.join(@target_dir,file)
51
+ exe_cont << "help_file = '#{target}'\n"
52
+ exe_cont << "SpecificHelp::Command.run(help_file, ARGV)\n"
53
+ target_files.each{|name|
54
+ print "\n"
55
+ p target=File.join('exe',name)
56
+ File.open(target,'w'){|file|
57
+ print exe_cont
58
+ file.print exe_cont
59
+ }
60
+ FileUtils.chmod('a+x', target, :verbose => true)
61
+ }
50
62
  }
51
63
  end
52
64
 
53
- def disp_from_help_cont(key_word)
54
- items =@help_cont[key_word]
55
- puts items[:title]
56
- disp(items[:cont])
65
+ def init_help(file)
66
+ p target_help=File.join(@target_dir,file)
67
+ p template = File.join(File.dirname(@target_dir),'my_help','template_help')
68
+ FileUtils::Verbose.cp(template,target_help)
69
+ end
70
+
71
+ def edit_help(file)
72
+ p target_help=File.join(@target_dir,file)
73
+ system "emacs #{target_help}"
57
74
  end
58
- end
59
75
 
76
+ def list_helps
77
+ print "Specific help file:\n"
78
+ Dir.entries(@target_dir)[2..-1].each{|file|
79
+ print " "+file+"\n"
80
+ }
81
+ end
82
+ end
60
83
  end
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "optparse"
3
+ require "yaml"
4
+ require "my_help/version"
5
+
6
+
7
+ module SpecificHelp
8
+ class Command
9
+
10
+ def self.run(file,argv=[])
11
+ new(file, argv).execute
12
+ end
13
+
14
+ def initialize(file,argv=[])
15
+ @help_cont = YAML.load(File.read(file))
16
+ @help_cont[:head].each{|line| print line }
17
+ @argv = argv
18
+ end
19
+
20
+ def execute
21
+ @argv << '--help' if @argv.size==0
22
+ command_parser = OptionParser.new do |opt|
23
+ opt.on('-v', '--version','show program Version.') { |v|
24
+ opt.version = MyHelp::VERSION
25
+ puts opt.ver
26
+ }
27
+ @help_cont.each_pair{|key,val|
28
+ next if key==:head
29
+ opts = val[:opts]
30
+ opt.on(opts[:short],opts[:long],opts[:desc]) {disp_from_help_cont(key)}
31
+ }
32
+ end
33
+ begin
34
+ command_parser.parse!(@argv)
35
+ rescue=> eval
36
+ p eval
37
+ end
38
+ exit
39
+ end
40
+
41
+ def disp(lines)
42
+ lines.each{|line|
43
+ if line.include?(',')
44
+ puts " #{line}"
45
+ else
46
+ puts " #{line}"
47
+ end
48
+ }
49
+ end
50
+
51
+ def disp_from_help_cont(key_word)
52
+ items =@help_cont[key_word]
53
+ puts items[:title]
54
+ disp(items[:cont])
55
+ end
56
+ end
57
+ end
data/my_help.wiki/Home.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 名前
2
2
 
3
- petit_help, general_help, my_help, ...
3
+ my_help
4
4
 
5
5
  # 概要
6
6
 
@@ -31,7 +31,62 @@ hikiでやろうとしていることの半分くらいはこのあたりのこ
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
33
 
34
+ # 使用法
35
+ ## インストール
36
+ インストールですが,gemの標準とは違ったやり方になります.GithubからForkしてcloneします.
37
+ ```
38
+ git clone git@github.com:daddygongon/my_help.git
39
+ ```
40
+ あとの作業はbundleを使って行います.これは,最後のrake install:localをコマンドから実行する方法がわからんかったからですが...helpファイルのpush共有とかも考えるとこれがいいのかも.
41
+
42
+ 用意されているコマンドは,
43
+
44
+ ```
45
+ bob% bundle exec exe/my_help
46
+ Usage: my_help [options]
47
+ -v, --version show program Version.
48
+ -l, --list 個別(specific)ヘルプのList表示.
49
+ -e, --edit NAME NAME(例:test_help)をEdit編集.
50
+ -i, --init NAME NAME(例:test_help)のtemplateを作成.
51
+ -m, --make make and install:local all helps.
52
+ ```
53
+ です.まず,-lでdefaultで入っているリストを見てください.
54
+
55
+ ```
56
+ bob% bundle exec exe/my_help -l
57
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
58
+ ["-l"]
59
+ Specific help file:
60
+ emacs_help
61
+ test_help
62
+ ```
63
+ これで,CUIでemacs_help, e_h, test_help, t_hが用意されています.少し振る舞いに慣れてください.
64
+
65
+ ## 独自のhelpを作る方法
66
+ さて,独自のhelpを作る方法です.まずは,
67
+
68
+ ```
69
+ bob% bundle exec exe/my_help -i new_help
70
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
71
+ ["-i", "new_help"]
72
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help"
73
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help"
74
+ cp /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help
75
+ /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help
76
+ ```
77
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
78
+
79
+ そのあと,my_helpのdirectoryで
80
+ ```
81
+ git add -A
82
+ git commit -m 'add new help'
83
+ rake install:local
84
+ ```
85
+ してください.
86
+
34
87
  # userの独自helpの達成方法
88
+ (rake my_helpでやっていたが,今は,my_help -mに移行)
89
+
35
90
  exe中のファイルをrakeで自動生成.
36
91
  ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
92
  exe中に実行ファイルを自動生成させている.
@@ -59,6 +114,12 @@ gem uninstall my_help
59
114
  gem uninstall emacs_help
60
115
  ```
61
116
  でそこをcleanにしておくことが望ましい.
117
+
118
+ Rakefileの中身は以下の通り.
119
+ ```
120
+ in Rakefile
121
+ ```
122
+
62
123
  ```ruby
63
124
  desc "make own help from lib/daddygongon/files"
64
125
  task :my_help do
@@ -69,13 +130,15 @@ task :my_help do
69
130
  p file
70
131
  p file_name=file.split('_')
71
132
  target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
72
- p cont_name = File.join(user_name,file)
73
- # exe_cont << "require '#{cont_name}'\n"
74
- exe_cont << "require 'emacs_help'\n"
75
- exe_cont << "EmacsHelp::Command.run(ARGV)\n"
133
+ p cont_name = File.join('lib',user_name,file)
134
+ exe_cont << "require 'my_help'\n"
135
+ exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
136
+ exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
76
137
  target_files.each{|name|
138
+ p ''
77
139
  p target=File.join('exe',name)
78
140
  File.open(target,'w'){|file|
141
+ print exe_cont
79
142
  file.print exe_cont
80
143
  }
81
144
  FileUtils.chmod('a+x', target, :verbose => true)
@@ -84,12 +147,27 @@ task :my_help do
84
147
  end
85
148
  ```
86
149
 
87
- この後の実装方法は,emacs_helpに
150
+ 実装方法は,emacs_helpに
88
151
 
89
152
  1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
153
  1. hush形式でdataをいれ,それをrequireして使う
91
154
 
92
155
  かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
156
+ 今の所,No.1の方を実装.No.2のためのhushデータは,
157
+
158
+ ```ruby
159
+ require 'yaml'
160
+ require 'pp'
161
+
162
+ pp YAML.load(File.read(ARGV[0]))
163
+ ```
164
+
165
+ ```
166
+ ruby test.rb lib/daddygongon/emacs_help
167
+ ```
168
+
169
+ で構築できる.実装してみて.
170
+
93
171
 
94
172
  # どちらがいいか
95
173
  Rubyで日本語が使えるから,optionsを日本語にしてみた.
@@ -1,6 +1,6 @@
1
1
  # 名前
2
2
 
3
- petit_help, general_help, my_help, ...
3
+ my_help
4
4
 
5
5
  # 概要
6
6
 
@@ -31,7 +31,62 @@ hikiでやろうとしていることの半分くらいはこのあたりのこ
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
33
 
34
+ # 使用法
35
+ ## インストール
36
+ インストールですが,gemの標準とは違ったやり方になります.GithubからForkしてcloneします.
37
+ ```
38
+ git clone git@github.com:daddygongon/my_help.git
39
+ ```
40
+ あとの作業はbundleを使って行います.これは,最後のrake install:localをコマンドから実行する方法がわからんかったからですが...helpファイルのpush共有とかも考えるとこれがいいのかも.
41
+
42
+ 用意されているコマンドは,
43
+
44
+ ```
45
+ bob% bundle exec exe/my_help
46
+ Usage: my_help [options]
47
+ -v, --version show program Version.
48
+ -l, --list 個別(specific)ヘルプのList表示.
49
+ -e, --edit NAME NAME(例:test_help)をEdit編集.
50
+ -i, --init NAME NAME(例:test_help)のtemplateを作成.
51
+ -m, --make make and install:local all helps.
52
+ ```
53
+ です.まず,-lでdefaultで入っているリストを見てください.
54
+
55
+ ```
56
+ bob% bundle exec exe/my_help -l
57
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
58
+ ["-l"]
59
+ Specific help file:
60
+ emacs_help
61
+ test_help
62
+ ```
63
+ これで,CUIでemacs_help, e_h, test_help, t_hが用意されています.少し振る舞いに慣れてください.
64
+
65
+ ## 独自のhelpを作る方法
66
+ さて,独自のhelpを作る方法です.まずは,
67
+
68
+ ```
69
+ bob% bundle exec exe/my_help -i new_help
70
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon"
71
+ ["-i", "new_help"]
72
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help"
73
+ "/usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help"
74
+ cp /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/my_help/template_help
75
+ /usr/local/lib/ruby/gems/2.2.0/gems/my_help-0.2.1/lib/daddygongon/new_help
76
+ ```
77
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
78
+
79
+ そのあと,my_helpのdirectoryで
80
+ ```
81
+ git add -A
82
+ git commit -m 'add new help'
83
+ rake install:local
84
+ ```
85
+ してください.
86
+
34
87
  # userの独自helpの達成方法
88
+ (rake my_helpでやっていたが,今は,my_help -mに移行)
89
+
35
90
  exe中のファイルをrakeで自動生成.
36
91
  ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
92
  exe中に実行ファイルを自動生成させている.
@@ -59,6 +114,12 @@ gem uninstall my_help
59
114
  gem uninstall emacs_help
60
115
  ```
61
116
  でそこをcleanにしておくことが望ましい.
117
+
118
+ Rakefileの中身は以下の通り.
119
+ ```
120
+ in Rakefile
121
+ ```
122
+
62
123
  ```ruby
63
124
  desc "make own help from lib/daddygongon/files"
64
125
  task :my_help do
@@ -69,13 +130,15 @@ task :my_help do
69
130
  p file
70
131
  p file_name=file.split('_')
71
132
  target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
72
- p cont_name = File.join(user_name,file)
73
- # exe_cont << "require '#{cont_name}'\n"
74
- exe_cont << "require 'emacs_help'\n"
75
- exe_cont << "EmacsHelp::Command.run(ARGV)\n"
133
+ p cont_name = File.join('lib',user_name,file)
134
+ exe_cont << "require 'my_help'\n"
135
+ exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
136
+ exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
76
137
  target_files.each{|name|
138
+ p ''
77
139
  p target=File.join('exe',name)
78
140
  File.open(target,'w'){|file|
141
+ print exe_cont
79
142
  file.print exe_cont
80
143
  }
81
144
  FileUtils.chmod('a+x', target, :verbose => true)
@@ -84,12 +147,27 @@ task :my_help do
84
147
  end
85
148
  ```
86
149
 
87
- この後の実装方法は,emacs_helpに
150
+ 実装方法は,emacs_helpに
88
151
 
89
152
  1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
153
  1. hush形式でdataをいれ,それをrequireして使う
91
154
 
92
155
  かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
156
+ 今の所,No.1の方を実装.No.2のためのhushデータは,
157
+
158
+ ```ruby
159
+ require 'yaml'
160
+ require 'pp'
161
+
162
+ pp YAML.load(File.read(ARGV[0]))
163
+ ```
164
+
165
+ ```
166
+ ruby test.rb lib/daddygongon/emacs_help
167
+ ```
168
+
169
+ で構築できる.実装してみて.
170
+
93
171
 
94
172
  # どちらがいいか
95
173
  Rubyで日本語が使えるから,optionsを日本語にしてみた.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_help
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
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: 2016-10-27 00:00:00.000000000 Z
11
+ date: 2016-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,9 +112,14 @@ description: Emulating CUI(CLI) help, an user makes and displays his own helps.
112
112
  email:
113
113
  - shigeto_nishitani@me.com
114
114
  executables:
115
+ - "#my_help#"
115
116
  - e_h
116
117
  - emacs_help
117
118
  - my_help
119
+ - n_h
120
+ - new_help
121
+ - t_h
122
+ - test_help
118
123
  extensions: []
119
124
  extra_rdoc_files: []
120
125
  files:
@@ -128,16 +133,24 @@ files:
128
133
  - Rakefile
129
134
  - bin/console
130
135
  - bin/setup
136
+ - exe/#my_help#
131
137
  - exe/e_h
132
138
  - exe/emacs_help
133
139
  - exe/my_help
140
+ - exe/n_h
141
+ - exe/new_help
142
+ - exe/t_h
143
+ - exe/test_help
134
144
  - hikis/README_ja.hiki
135
145
  - latexes/handout_pre.tex
136
146
  - lib/daddygongon/emacs_help
147
+ - lib/daddygongon/new_help
148
+ - lib/daddygongon/test_help
137
149
  - lib/emacs_help.rb
138
- - lib/emacs_help/version.rb
139
150
  - lib/my_help.rb
151
+ - lib/my_help/template_help
140
152
  - lib/my_help/version.rb
153
+ - lib/specific_help.rb
141
154
  - my_help.gemspec
142
155
  - my_help.wiki/Home.md
143
156
  - my_help.wiki/README_ja.md
@@ -1,3 +0,0 @@
1
- module EmacsHelp
2
- VERSION = "0.1.2"
3
- end