my_help 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7748831520dc7c031ae3a9896b230b3cac6ad2b
4
+ data.tar.gz: 84cd874af8c122770dfc8b05a340893769a920a1
5
+ SHA512:
6
+ metadata.gz: 0f37baeda38f155012232fdef59801bee91af8f1ba07e90813a35745a6c226a60a0d0569f0a83fa96220aba97358f39819f3bed8fa22d1f8dd126b4285f0cb52
7
+ data.tar.gz: 3397b6059109407b2b24a6b7ed77d0d7d3462e814eff019d2a78f201f6e378efbd04ded5a940e6af6750775d34c19f462a90899b438a99c0ad83dba4e38944c9
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ -
2
+ **/*.md
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at shigeto_nishitani@me.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in my_help.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Shigeto R. Nishitani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # 名前
2
+
3
+ petit_help, general_help, my_help, ...
4
+
5
+ # 概要
6
+
7
+ CUI(CLI)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
8
+
9
+ # 問題点
10
+ CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
11
+ commandや文法を覚えるのに苦労します.少しのkey(とっかかり)があると
12
+ 思い出すんですが,うろ覚えでは間違えて路頭に迷います.問題点は,
13
+ - manは基本的に英語
14
+ - manualでは重たい
15
+ - いつもおなじことをwebで検索して
16
+ - 同じとこ見ている
17
+ - memoしても,どこへ置いたか忘れる
18
+
19
+ などです.
20
+
21
+ # 特徴
22
+ これらをgem環境として提供しようというのが,このgemの目的です.
23
+ 仕様としては,
24
+ - userが自分にあったmanを作成
25
+ - 雛形を提供
26
+ - おなじformat, looks, 操作, 階層構造
27
+ - すぐに手が届く
28
+ - それらを追加・修正・削除できる
29
+
30
+ hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
+ かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
+ key(記憶のとっかかり)を提供することが目的です.
33
+
34
+ # userの独自helpの達成方法
35
+ exe中のファイルをrakeで自動生成.
36
+ ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
+ exe中に実行ファイルを自動生成させている.
38
+ ```
39
+ lib/daddygongon/
40
+ └── emacs_help
41
+
42
+ exe
43
+ ├── e_h
44
+ └── emacs_help
45
+ ```
46
+ ということ.これは,
47
+ ```
48
+ rake my_help
49
+ ```
50
+ で実行される.これを
51
+ ```
52
+ rake install:local
53
+ ```
54
+ すれば必要とするhelpがlocalな環境で表示される.
55
+
56
+ たくさんの実行ファイルを/usr/loca/binに置くことになるので,
57
+ ```
58
+ gem uninstall my_help
59
+ gem uninstall emacs_help
60
+ ```
61
+ でそこをcleanにしておくことが望ましい.
62
+ ```ruby
63
+ desc "make own help from lib/daddygongon/files"
64
+ task :my_help do
65
+ exe_cont="#!/usr/bin/env ruby\n"
66
+ user_name = 'daddygongon'
67
+ p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
68
+ entries.each{|file|
69
+ p file
70
+ p file_name=file.split('_')
71
+ 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"
76
+ target_files.each{|name|
77
+ p target=File.join('exe',name)
78
+ File.open(target,'w'){|file|
79
+ file.print exe_cont
80
+ }
81
+ FileUtils.chmod('a+x', target, :verbose => true)
82
+ }
83
+ }
84
+ end
85
+ ```
86
+
87
+ この後の実装方法は,emacs_helpに
88
+
89
+ 1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
+ 1. hush形式でdataをいれ,それをrequireして使う
91
+
92
+ かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
93
+
94
+ # どちらがいいか
95
+ Rubyで日本語が使えるから,optionsを日本語にしてみた.
96
+ ```
97
+ Usage: eh [options]
98
+ -v, --version show program Version.
99
+ -c, --カーソル Cursor移動
100
+ -p, --ページ Page移動
101
+ -f, --ファイル File操作
102
+ -e, --編集 Edit操作
103
+ -w, --ウィンドウ Window操作
104
+ -b, --バッファ Buffer操作
105
+ -q, --終了 終了操作
106
+ ```
107
+ 半角,全角がoptparseでは適切に判断できない様で,表示があまり揃っていない.
108
+ しかし,初心者の振る舞いを見ているとわざわざ日本語に切り替えて打ち込むことは稀であり,
109
+ key wordをhelpで参照してshort optionで入力している.そこで,
110
+ ```
111
+ Usage: eh [options]
112
+ -v, --version show program Version.
113
+ -c, --cursor カーソル移動
114
+ -p, --page ページ移動
115
+ -f, --file ファイル操作
116
+ -e, --edit 編集操作
117
+ -w, --window ウィンドウ操作
118
+ -b, --buffer バッファ操作
119
+ -q, --quit 終了操作
120
+ ```
121
+ としたほうがいいと提案する.アンケートを実施してみてほしい.
data/Rakefile ADDED
@@ -0,0 +1,74 @@
1
+ require "bundler/gem_tasks"
2
+ require 'yard'
3
+ require "rake/testtask"
4
+ require 'fileutils'
5
+ p base_path = File.expand_path('..', __FILE__)
6
+ p basename = File.basename(base_path)
7
+
8
+ task :default do
9
+ system 'rake -T'
10
+ end
11
+
12
+ desc "make documents by yard"
13
+ task :yard => [:hiki2md] do
14
+ YARD::Rake::YardocTask.new
15
+ end
16
+
17
+ desc "transfer hikis/*.hiki to wiki"
18
+ task :hiki2md do
19
+ files = Dir.entries('hikis')
20
+ files.each{|file|
21
+ name=file.split('.')
22
+ case name[1]
23
+ when 'hiki'
24
+ p command="hiki2md hikis/#{name[0]}.hiki > #{basename}.wiki/#{name[0]}.md"
25
+ system command
26
+ when 'gif','png','pdf'
27
+ p command="cp hikis/#{file} #{basename}.wiki/#{file}"
28
+ # system command
29
+ FileUtils.cp("hikis/#{file}","#{basename}.wiki/#{file}",:verbose=>true)
30
+ FileUtils.cp("hikis/#{file}","doc/#{file}",:verbose=>true)
31
+ end
32
+ }
33
+ readme_en="#{basename}.wiki/README_en.md"
34
+ readme_ja="#{basename}.wiki/README_ja.md"
35
+ if File.exists?(readme_en)
36
+ FileUtils.cp(readme_en,"./README.md",:verbose=>true)
37
+ elsif File.exists?(readme_ja)
38
+ FileUtils.cp(readme_ja,"./README.md",:verbose=>true)
39
+ FileUtils.cp(readme_ja,"#{basename}.wiki/Home.md",:verbose=>true)
40
+ end
41
+ end
42
+
43
+ desc "transfer hikis/*.hiki to latex"
44
+ task :latex do
45
+ target = 'handout_sample'
46
+ command = "hiki2latex --pre latexes/handout_pre.tex hikis/#{target}.hiki > latexes/#{target}.tex"
47
+ system command
48
+ command = "open latexes/#{target}.tex"
49
+ system command
50
+ end
51
+
52
+
53
+ desc "make own help from lib/daddygongon/files"
54
+ task :my_help do
55
+ exe_cont="#!/usr/bin/env ruby\n"
56
+ user_name = 'daddygongon'
57
+ p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
58
+ entries.each{|file|
59
+ p file
60
+ p file_name=file.split('_')
61
+ target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
62
+ p cont_name = File.join(user_name,file)
63
+ # exe_cont << "require '#{cont_name}'\n"
64
+ exe_cont << "require 'my_help'\n"
65
+ exe_cont << "EmacsHelp::Command.run(ARGV)\n"
66
+ target_files.each{|name|
67
+ p target=File.join('exe',name)
68
+ File.open(target,'w'){|file|
69
+ file.print exe_cont
70
+ }
71
+ FileUtils.chmod('a+x', target, :verbose => true)
72
+ }
73
+ }
74
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "my_help"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/e_h ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'my_help'
3
+ EmacsHelp::Command.run(ARGV)
data/exe/emacs_help ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'my_help'
3
+ EmacsHelp::Command.run(ARGV)
data/exe/my_help ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "my_help"
@@ -0,0 +1,116 @@
1
+ !名前
2
+
3
+ petit_help, general_help, my_help, ...
4
+
5
+ !概要
6
+
7
+ CUI(CLI)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
8
+
9
+ !問題点
10
+ CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
11
+ commandや文法を覚えるのに苦労します.少しのkey(とっかかり)があると
12
+ 思い出すんですが,うろ覚えでは間違えて路頭に迷います.問題点は,
13
+ * manは基本的に英語
14
+ * manualでは重たい
15
+ * いつもおなじことをwebで検索して
16
+ * 同じとこ見ている
17
+ * memoしても,どこへ置いたか忘れる
18
+
19
+ などです.
20
+
21
+ !特徴
22
+ これらをgem環境として提供しようというのが,このgemの目的です.
23
+ 仕様としては,
24
+ * userが自分にあったmanを作成
25
+ * 雛形を提供
26
+ ** おなじformat, looks, 操作, 階層構造
27
+ * すぐに手が届く
28
+ * それらを追加・修正・削除できる
29
+
30
+ hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
+ かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
+ key(記憶のとっかかり)を提供することが目的です.
33
+
34
+ !userの独自helpの達成方法
35
+ exe中のファイルをrakeで自動生成.
36
+ ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
+ exe中に実行ファイルを自動生成させている.
38
+ <<<
39
+ lib/daddygongon/
40
+ └── emacs_help
41
+
42
+ exe
43
+ ├── e_h
44
+ └── emacs_help
45
+ >>>
46
+ ということ.これは,
47
+ rake my_help
48
+ で実行される.これを
49
+ rake install:local
50
+ すれば必要とするhelpがlocalな環境で表示される.
51
+
52
+ たくさんの実行ファイルを/usr/loca/binに置くことになるので,
53
+ gem uninstall my_help
54
+ gem uninstall emacs_help
55
+ でそこをcleanにしておくことが望ましい.
56
+ <<< ruby
57
+ desc "make own help from lib/daddygongon/files"
58
+ task :my_help do
59
+ exe_cont="#!/usr/bin/env ruby\n"
60
+ user_name = 'daddygongon'
61
+ p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
62
+ entries.each{|file|
63
+ p file
64
+ p file_name=file.split('_')
65
+ 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"
68
+ exe_cont << "require 'my_help'\n"
69
+ exe_cont << "EmacsHelp::Command.run(ARGV)\n"
70
+ target_files.each{|name|
71
+ p target=File.join('exe',name)
72
+ File.open(target,'w'){|file|
73
+ file.print exe_cont
74
+ }
75
+ FileUtils.chmod('a+x', target, :verbose => true)
76
+ }
77
+ }
78
+ end
79
+ >>>
80
+
81
+ この後の実装方法は,emacs_helpに
82
+
83
+ # yaml形式でdataを入れ,command.runの入力ファイルとする
84
+ # hush形式でdataをいれ,それをrequireして使う
85
+
86
+ かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
87
+
88
+ !どちらがいいか
89
+ Rubyで日本語が使えるから,optionsを日本語にしてみた.
90
+ <<<
91
+ Usage: eh [options]
92
+ -v, --version show program Version.
93
+ -c, --カーソル Cursor移動
94
+ -p, --ページ Page移動
95
+ -f, --ファイル File操作
96
+ -e, --編集 Edit操作
97
+ -w, --ウィンドウ Window操作
98
+ -b, --バッファ Buffer操作
99
+ -q, --終了 終了操作
100
+ >>>
101
+ 半角,全角がoptparseでは適切に判断できない様で,表示があまり揃っていない.
102
+ しかし,初心者の振る舞いを見ているとわざわざ日本語に切り替えて打ち込むことは稀であり,
103
+ key wordをhelpで参照してshort optionで入力している.そこで,
104
+ <<<
105
+ Usage: eh [options]
106
+ -v, --version show program Version.
107
+ -c, --cursor カーソル移動
108
+ -p, --page ページ移動
109
+ -f, --file ファイル操作
110
+ -e, --edit 編集操作
111
+ -w, --window ウィンドウ操作
112
+ -b, --buffer バッファ操作
113
+ -q, --quit 終了操作
114
+ >>>
115
+ としたほうがいいと提案する.アンケートを実施してみてほしい.
116
+
@@ -0,0 +1,11 @@
1
+ \documentclass[10pt,a4j,twocolumn]{jsarticle}
2
+
3
+ \usepackage[dvipdfmx]{graphicx}
4
+
5
+ \setlength{\textheight}{275mm}
6
+ \headheight 5mm
7
+ \topmargin -30mm
8
+ \textwidth 185mm
9
+ \oddsidemargin -15mm
10
+ \evensidemargin -15mm
11
+ \pagestyle{empty}
File without changes
@@ -0,0 +1,3 @@
1
+ module EmacsHelp
2
+ VERSION = "0.1.2"
3
+ end
data/lib/emacs_help.rb ADDED
@@ -0,0 +1,122 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "optparse"
3
+ require "emacs_help/version"
4
+
5
+ module EmacsHelp
6
+ class Command
7
+ def self.run(argv=[])
8
+ print "\n特殊キー操作"
9
+ print "\tc-f, controlキーを押しながら 'f'\n"
10
+ print "\t\tM-f, escキーを押した後一度離して'f'\n"
11
+ print "\t操作の中断c-g, 操作の取り消し(Undo) c-x u \n"
12
+ new(argv).execute
13
+ end
14
+
15
+ def initialize(argv=[])
16
+ @argv = argv
17
+ data_path = File.join(ENV['HOME'], '.hikirc')
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 = EmacsHelp::VERSION
25
+ puts opt.ver
26
+ }
27
+ opt.on('-c','--カーソル','Cursor移動') {cursor_move}
28
+ opt.on('-p','--ページ','Page移動') {page_move}
29
+ opt.on('-f','--ファイル','File操作') {file}
30
+ opt.on('-e','--編集','Edit操作') {edit}
31
+ opt.on('-w','--ウィンドウ','Window操作') {window}
32
+ opt.on('-b','--バッファ','Buffer操作') {buffer}
33
+ opt.on('-q','--終了','終了操作') {quit}
34
+ end
35
+ begin
36
+ command_parser.parse!(@argv)
37
+ rescue=> eval
38
+ p eval
39
+ end
40
+ exit
41
+ end
42
+
43
+ def disp(lines)
44
+ lines.each{|line|
45
+ if line.include?(',')
46
+ show line
47
+ else
48
+ puts " #{line}"
49
+ end
50
+ }
51
+ end
52
+ def show(line)
53
+ puts " #{line}"
54
+ end
55
+
56
+ def quit
57
+ puts "\n終了操作quit"
58
+ cont = ["c-x c-c, Quit emacs, ファイルを保存して終了",
59
+ "c-z, suspend emacs, 一時停止,fgで復活"]
60
+ disp(cont)
61
+ end
62
+
63
+ def window
64
+ puts "\nウィンドウ操作window"
65
+ cont=["c-x 2, 2 windows, 二つに分割",
66
+ "c-x 1, 1 windows, 一つに戻す",
67
+ "c-x 3, 3rd window sep,縦線分割",
68
+ "c-x o, Other windows, 次の画面へ移動"]
69
+ disp(cont)
70
+ end
71
+
72
+ def buffer
73
+ puts "\nバッファー操作buffer"
74
+ cont =[ "c-x b, show Buffer, バッファのリスト",
75
+ "c-x c-b, next Buffer, 次のバッファへ移動"]
76
+ disp(cont)
77
+ end
78
+
79
+ def edit
80
+ puts "\n編集操作editor"
81
+ cont = ["c-d, Delete char, 一字削除",
82
+ "c-k, Kill line, 一行抹消,カット",
83
+ "c-y, Yank, ペースト",
84
+ "c-w, Kill region, 領域抹消,カット",
85
+ "領域選択は,先頭or最後尾でc-spaceした後,最後尾or先頭へカーソル移動",
86
+ "c-s, forward incremental Search WORD, 前へWORDを検索",
87
+ "c-r, Reverse incremental search WORD, 後へWORDを検索",
88
+ "M-x query-replace WORD1 <ret> WORD2:対話的置換(y or nで可否選択)"]
89
+ disp(cont)
90
+ end
91
+
92
+ def file
93
+ puts "\nファイル操作file"
94
+ cont =[ "c-x c-f, Find file, ファイルを開く",
95
+ "c-x c-s, Save file, ファイルを保存",
96
+ "c-x c-w, Write file NAME, ファイルを別名で書き込む"]
97
+ disp(cont)
98
+ end
99
+
100
+ def page_move
101
+ puts "\nページ移動page"
102
+ cont = ["c-v, move Vertical, 次のページへ",
103
+ "M-v, move reversive Vertical,前のページへ",
104
+ "c-l, centerise Line, 現在行を中心に",
105
+ "M-<, move Top of file, ファイルの先頭へ",
106
+ "M->, move Bottom of file, ファイルの最後尾へ"]
107
+ disp(cont)
108
+ end
109
+
110
+ def cursor_move
111
+ puts "\nカーソル移動cursor"
112
+ cont = ["c-f, move Forwrard, 前or右へ",
113
+ "c-b, move Backwrard, 後or左へ",
114
+ "c-a, go Ahead of line, 行頭へ",
115
+ "c-e, go End of line, 行末へ",
116
+ "c-n, move Next line, 次行へ",
117
+ "c-p, move Previous line, 前行へ"]
118
+ disp(cont)
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,3 @@
1
+ module MyHelp
2
+ VERSION = "0.1.0"
3
+ end
data/lib/my_help.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "my_help/version"
2
+ require "emacs_help"
3
+
4
+ module MyHelp
5
+ # Your code goes here...
6
+ end
data/my_help.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'my_help/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "my_help"
8
+ spec.version = MyHelp::VERSION
9
+ spec.authors = ["Shigeto R. Nishitani"]
10
+ spec.email = ["shigeto_nishitani@me.com"]
11
+
12
+ spec.summary = %q{display emacs key bindings in Japanese.}
13
+ spec.description = %q{Emulating CUI(CLI) help, user make and display his own help.}
14
+ spec.homepage = "https://github.com/daddygongon/my_help"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = 'http://rubygems.org'
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "minitest", "~> 5.0"
33
+ spec.add_development_dependency "yard"
34
+ spec.add_development_dependency "hiki2md"
35
+ spec.add_development_dependency "mathjax-yard"
36
+ spec.add_development_dependency "hiki2latex"
37
+ end
@@ -0,0 +1,121 @@
1
+ # 名前
2
+
3
+ petit_help, general_help, my_help, ...
4
+
5
+ # 概要
6
+
7
+ CUI(CLI)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
8
+
9
+ # 問題点
10
+ CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
11
+ commandや文法を覚えるのに苦労します.少しのkey(とっかかり)があると
12
+ 思い出すんですが,うろ覚えでは間違えて路頭に迷います.問題点は,
13
+ - manは基本的に英語
14
+ - manualでは重たい
15
+ - いつもおなじことをwebで検索して
16
+ - 同じとこ見ている
17
+ - memoしても,どこへ置いたか忘れる
18
+
19
+ などです.
20
+
21
+ # 特徴
22
+ これらをgem環境として提供しようというのが,このgemの目的です.
23
+ 仕様としては,
24
+ - userが自分にあったmanを作成
25
+ - 雛形を提供
26
+ - おなじformat, looks, 操作, 階層構造
27
+ - すぐに手が届く
28
+ - それらを追加・修正・削除できる
29
+
30
+ hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
+ かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
+ key(記憶のとっかかり)を提供することが目的です.
33
+
34
+ # userの独自helpの達成方法
35
+ exe中のファイルをrakeで自動生成.
36
+ ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
+ exe中に実行ファイルを自動生成させている.
38
+ ```
39
+ lib/daddygongon/
40
+ └── emacs_help
41
+
42
+ exe
43
+ ├── e_h
44
+ └── emacs_help
45
+ ```
46
+ ということ.これは,
47
+ ```
48
+ rake my_help
49
+ ```
50
+ で実行される.これを
51
+ ```
52
+ rake install:local
53
+ ```
54
+ すれば必要とするhelpがlocalな環境で表示される.
55
+
56
+ たくさんの実行ファイルを/usr/loca/binに置くことになるので,
57
+ ```
58
+ gem uninstall my_help
59
+ gem uninstall emacs_help
60
+ ```
61
+ でそこをcleanにしておくことが望ましい.
62
+ ```ruby
63
+ desc "make own help from lib/daddygongon/files"
64
+ task :my_help do
65
+ exe_cont="#!/usr/bin/env ruby\n"
66
+ user_name = 'daddygongon'
67
+ p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
68
+ entries.each{|file|
69
+ p file
70
+ p file_name=file.split('_')
71
+ 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"
76
+ target_files.each{|name|
77
+ p target=File.join('exe',name)
78
+ File.open(target,'w'){|file|
79
+ file.print exe_cont
80
+ }
81
+ FileUtils.chmod('a+x', target, :verbose => true)
82
+ }
83
+ }
84
+ end
85
+ ```
86
+
87
+ この後の実装方法は,emacs_helpに
88
+
89
+ 1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
+ 1. hush形式でdataをいれ,それをrequireして使う
91
+
92
+ かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
93
+
94
+ # どちらがいいか
95
+ Rubyで日本語が使えるから,optionsを日本語にしてみた.
96
+ ```
97
+ Usage: eh [options]
98
+ -v, --version show program Version.
99
+ -c, --カーソル Cursor移動
100
+ -p, --ページ Page移動
101
+ -f, --ファイル File操作
102
+ -e, --編集 Edit操作
103
+ -w, --ウィンドウ Window操作
104
+ -b, --バッファ Buffer操作
105
+ -q, --終了 終了操作
106
+ ```
107
+ 半角,全角がoptparseでは適切に判断できない様で,表示があまり揃っていない.
108
+ しかし,初心者の振る舞いを見ているとわざわざ日本語に切り替えて打ち込むことは稀であり,
109
+ key wordをhelpで参照してshort optionで入力している.そこで,
110
+ ```
111
+ Usage: eh [options]
112
+ -v, --version show program Version.
113
+ -c, --cursor カーソル移動
114
+ -p, --page ページ移動
115
+ -f, --file ファイル操作
116
+ -e, --edit 編集操作
117
+ -w, --window ウィンドウ操作
118
+ -b, --buffer バッファ操作
119
+ -q, --quit 終了操作
120
+ ```
121
+ としたほうがいいと提案する.アンケートを実施してみてほしい.
@@ -0,0 +1,121 @@
1
+ # 名前
2
+
3
+ petit_help, general_help, my_help, ...
4
+
5
+ # 概要
6
+
7
+ CUI(CLI)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
8
+
9
+ # 問題点
10
+ CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
11
+ commandや文法を覚えるのに苦労します.少しのkey(とっかかり)があると
12
+ 思い出すんですが,うろ覚えでは間違えて路頭に迷います.問題点は,
13
+ - manは基本的に英語
14
+ - manualでは重たい
15
+ - いつもおなじことをwebで検索して
16
+ - 同じとこ見ている
17
+ - memoしても,どこへ置いたか忘れる
18
+
19
+ などです.
20
+
21
+ # 特徴
22
+ これらをgem環境として提供しようというのが,このgemの目的です.
23
+ 仕様としては,
24
+ - userが自分にあったmanを作成
25
+ - 雛形を提供
26
+ - おなじformat, looks, 操作, 階層構造
27
+ - すぐに手が届く
28
+ - それらを追加・修正・削除できる
29
+
30
+ hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
+ かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
+ key(記憶のとっかかり)を提供することが目的です.
33
+
34
+ # userの独自helpの達成方法
35
+ exe中のファイルをrakeで自動生成.
36
+ ./lib/daddygongon/にそれらのdataを保存.以下ではその名前から
37
+ exe中に実行ファイルを自動生成させている.
38
+ ```
39
+ lib/daddygongon/
40
+ └── emacs_help
41
+
42
+ exe
43
+ ├── e_h
44
+ └── emacs_help
45
+ ```
46
+ ということ.これは,
47
+ ```
48
+ rake my_help
49
+ ```
50
+ で実行される.これを
51
+ ```
52
+ rake install:local
53
+ ```
54
+ すれば必要とするhelpがlocalな環境で表示される.
55
+
56
+ たくさんの実行ファイルを/usr/loca/binに置くことになるので,
57
+ ```
58
+ gem uninstall my_help
59
+ gem uninstall emacs_help
60
+ ```
61
+ でそこをcleanにしておくことが望ましい.
62
+ ```ruby
63
+ desc "make own help from lib/daddygongon/files"
64
+ task :my_help do
65
+ exe_cont="#!/usr/bin/env ruby\n"
66
+ user_name = 'daddygongon'
67
+ p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
68
+ entries.each{|file|
69
+ p file
70
+ p file_name=file.split('_')
71
+ 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"
76
+ target_files.each{|name|
77
+ p target=File.join('exe',name)
78
+ File.open(target,'w'){|file|
79
+ file.print exe_cont
80
+ }
81
+ FileUtils.chmod('a+x', target, :verbose => true)
82
+ }
83
+ }
84
+ end
85
+ ```
86
+
87
+ この後の実装方法は,emacs_helpに
88
+
89
+ 1. yaml形式でdataを入れ,command.runの入力ファイルとする
90
+ 1. hush形式でdataをいれ,それをrequireして使う
91
+
92
+ かのどちらかで実装.speedとかdebugを比較・検証する必要あり.
93
+
94
+ # どちらがいいか
95
+ Rubyで日本語が使えるから,optionsを日本語にしてみた.
96
+ ```
97
+ Usage: eh [options]
98
+ -v, --version show program Version.
99
+ -c, --カーソル Cursor移動
100
+ -p, --ページ Page移動
101
+ -f, --ファイル File操作
102
+ -e, --編集 Edit操作
103
+ -w, --ウィンドウ Window操作
104
+ -b, --バッファ Buffer操作
105
+ -q, --終了 終了操作
106
+ ```
107
+ 半角,全角がoptparseでは適切に判断できない様で,表示があまり揃っていない.
108
+ しかし,初心者の振る舞いを見ているとわざわざ日本語に切り替えて打ち込むことは稀であり,
109
+ key wordをhelpで参照してshort optionで入力している.そこで,
110
+ ```
111
+ Usage: eh [options]
112
+ -v, --version show program Version.
113
+ -c, --cursor カーソル移動
114
+ -p, --page ページ移動
115
+ -f, --file ファイル操作
116
+ -e, --edit 編集操作
117
+ -w, --window ウィンドウ操作
118
+ -b, --buffer バッファ操作
119
+ -q, --quit 終了操作
120
+ ```
121
+ としたほうがいいと提案する.アンケートを実施してみてほしい.
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: my_help
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shigeto R. Nishitani
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hiki2md
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mathjax-yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hiki2latex
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Emulating CUI(CLI) help, user make and display his own help.
112
+ email:
113
+ - shigeto_nishitani@me.com
114
+ executables:
115
+ - e_h
116
+ - emacs_help
117
+ - my_help
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - ".gitignore"
122
+ - ".travis.yml"
123
+ - ".yardopts"
124
+ - CODE_OF_CONDUCT.md
125
+ - Gemfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - exe/e_h
132
+ - exe/emacs_help
133
+ - exe/my_help
134
+ - hikis/README_ja.hiki
135
+ - latexes/handout_pre.tex
136
+ - lib/daddygongon/emacs_help
137
+ - lib/emacs_help.rb
138
+ - lib/emacs_help/version.rb
139
+ - lib/my_help.rb
140
+ - lib/my_help/version.rb
141
+ - my_help.gemspec
142
+ - my_help.wiki/Home.md
143
+ - my_help.wiki/README_ja.md
144
+ homepage: https://github.com/daddygongon/my_help
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.5.1
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: display emacs key bindings in Japanese.
168
+ test_files: []