my_help 1.2 → 1.2.3

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.yardoc/checksums +4 -4
  3. data/.yardoc/objects/root.dat +0 -0
  4. data/Gemfile.lock +1 -1
  5. data/README.org +84 -117
  6. data/README_j.org +143 -0
  7. data/Rakefile +20 -1
  8. data/development_memo.org +242 -0
  9. data/lib/my_help/cli.rb +7 -1
  10. data/lib/my_help/config.rb +1 -1
  11. data/lib/my_help/list.rb +5 -3
  12. data/lib/my_help/version.rb +1 -1
  13. data/lib/templates/example.org +3 -5
  14. metadata +4 -37
  15. data/README_en.org +0 -131
  16. data/doc/MyHelp/CLI.html +0 -749
  17. data/doc/MyHelp/Config.html +0 -693
  18. data/doc/MyHelp/Control.html +0 -1127
  19. data/doc/MyHelp/Error.html +0 -124
  20. data/doc/MyHelp/GetConfig.html +0 -196
  21. data/doc/MyHelp/Git.html +0 -291
  22. data/doc/MyHelp/Init.html +0 -449
  23. data/doc/MyHelp/List.html +0 -577
  24. data/doc/MyHelp/Md2Hash.html +0 -632
  25. data/doc/MyHelp/Modify.html +0 -393
  26. data/doc/MyHelp/Org2Hash.html +0 -542
  27. data/doc/MyHelp.html +0 -135
  28. data/doc/Org2Yaml.html +0 -497
  29. data/doc/OrgToYaml.html +0 -497
  30. data/doc/_index.html +0 -230
  31. data/doc/class_list.html +0 -51
  32. data/doc/css/common.css +0 -1
  33. data/doc/css/full_list.css +0 -58
  34. data/doc/css/style.css +0 -497
  35. data/doc/file.README.html +0 -181
  36. data/doc/file_list.html +0 -56
  37. data/doc/frames.html +0 -17
  38. data/doc/index.html +0 -181
  39. data/doc/js/app.js +0 -314
  40. data/doc/js/full_list.js +0 -216
  41. data/doc/js/jquery.js +0 -4
  42. data/doc/method_list.html +0 -451
  43. data/doc/top-level-namespace.html +0 -112
  44. data/pkg/my_help-0.8.6.gem +0 -0
  45. data/pkg/my_help-0.9.0.gem +0 -0
  46. data/pkg/my_help-1.0b.gem +0 -0
  47. data/pkg/my_help-1.0c.gem +0 -0
  48. data/pkg/my_help-1.1.gem +0 -0
  49. data/pkg/my_help-1.1a.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73b21875275f91d6aaa1b7a2a274a2319e1eb86df4e843913cf3a9e818fc211b
4
- data.tar.gz: 7472056b4622cead820d9e69c3da7350cda7d06746c89797c2dcddba34baad35
3
+ metadata.gz: d4a86f6d2f3dabef582a9c43dca24554b1dda2f5d773d0f7f8c9907c1dd205f8
4
+ data.tar.gz: 7010d97c58171b9606db261705a93deb7d6f23e546baeb32d25869e99ec1bfc7
5
5
  SHA512:
6
- metadata.gz: 87585a0384723ea7f1ff5d623593413ba1d33e6d7c4564fcf97756c883b8f40bfbf74d0b4d4412b87b491956fe51781dcbd4c82afbc40cf71a17b7efc084ae87
7
- data.tar.gz: 82e066659953bc7a72e3a1638769c7de01c70e24853e2dffd9635c657689339aa9aa07d69867d88d79dfd9dddd1f65b59d616301eb75daf71e9afbef2d28a448
6
+ metadata.gz: 1e0aaf779bb22e17ebd06d6d4277e323619b054120cb56ba8eab1e33c33d1ab2f8df9b71245f769276ce3c2de7d7c99804c5fd55710164cbef20eb063d8f235e
7
+ data.tar.gz: ec825103b28a678f0dcc7f2c94ec9afdfc836f69deae5b763279b61bb38ace3295a4be45f04956d87b118f95ce8af964cf89c629f5288ea9bc6cc42164228f90
data/.yardoc/checksums CHANGED
@@ -1,11 +1,11 @@
1
1
  lib/my_help.rb 7539f0f58056d44d38352f868bfea4d6fb63a9ee
2
- lib/my_help/cli.rb 8cd7468e74ef89e8a9ee83e5e780b70b6e2874c4
2
+ lib/my_help/cli.rb c2a482691a6e9183e393110da8a552d477cf856e
3
3
  lib/my_help/init.rb ac83b0cbfd9394278da8e7bf83b089cb84e132e4
4
- lib/my_help/list.rb 30d4be2eb41e623abeeb6914ab9907ced97ed722
5
- lib/my_help/config.rb d7162fbe953828fc7e6a5aac89adf8678131068f
4
+ lib/my_help/list.rb a63c0f1366a7c162d2c5e16e70f37f7ebb32cf8e
5
+ lib/my_help/config.rb be52fb39c0656febb6d230aa50e7b7a6804c7cc4
6
6
  lib/my_help/modify.rb 17a00a9f1b4126d9c067a320b47639e5a5fec845
7
7
  lib/my_help/git_cli.rb bb04396f0b9d54ecb13100fe5cde029f7dbb0ea7
8
8
  lib/my_help/md2hash.rb 35ebd32d3f545b40cd9ebb1972dc60d53b58b22a
9
9
  lib/my_help/org2yml.rb 334d0a7b648dc75b1d9504ec6d68937c70e96343
10
- lib/my_help/version.rb e82ec18cc8f885ee6c9b6846c3813e1eb96981a9
10
+ lib/my_help/version.rb 618ac9ac5ac451afc28fc6bae7bd657fc71a915a
11
11
  lib/my_help/org2hash.rb 939fea903abb5247959d74e18afc8db30fb5f6c8
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_help (1.0c)
4
+ my_help (1.2.3)
5
5
  colorize
6
6
  command_line
7
7
  thor
data/README.org CHANGED
@@ -1,96 +1,80 @@
1
- # my_help
2
- #+AUTHOR: Shigeto R. Nishitani
3
- #+EMAIL: (concat "nishitani@kwansei.ac.jp")
4
- #+LANGUAGE: jp
5
- #+OPTIONS: H:4 toc:t num:2
6
- #+SETUPFILE: /Users/bob/.emacs.d/org-mode/theme-readtheorg.setup
7
- #+STARTUP: indent nolineimages
1
+ #+STARTUP: indent nolineimages content
8
2
  #+OPTIONS: ^:{}
9
-
10
- * 概要
11
- :PROPERTIES:
12
- :CUSTOM_ID: 概要
13
- :END:
14
-
15
- CUI(CLA)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
16
-
17
-
18
- * (my_helpで解決しようとする)問題点
19
- :PROPERTIES:
20
- :CUSTOM_ID: my_helpで解決しようとする問題点
21
- :END:
22
-
23
- CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
24
- commandや文法を覚えるのに苦労します.
25
- 少しのkey(とっかかり)があると思い出すんですが,
26
- うろ覚えでは間違えて路頭に迷います.
27
- 問題点は,
28
- + manは基本的に英語
29
- + manualでは重たい
30
- + いつもおなじことをwebで検索して
31
- + 同じとこ見ている
32
- + memoしても,どこへ置いたか忘れる
33
- などです.
34
-
35
- * 特徴
36
- :PROPERTIES:
37
- :CUSTOM_ID: 特徴
38
- :END:
39
-
40
- これらをCLAとして提供しようというのが,このgemの目的です.
41
- 仕様としては,
42
- - userが自分にあったmanを作成
43
- - 雛形を提供
44
- - おなじformat, looks, 操作, 階層構造
45
- - すぐに手が届く
46
- - それらを追加・修正・削除できる
47
-
48
- memoソフトでは,検索が必要となりますが,my_help
49
- key(記憶のとっかかり)を提供することが目的です.
50
- RPGでレベル上げとかアイテムを貯めるようにして,
51
- プログラミングでスキルを発展させてください.
52
-
53
- VSCodeやGithub Copilotではcodeの候補を挙げてくれますが,
54
- 物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
55
-
56
- * 使用法
57
- :PROPERTIES:
58
- :CUSTOM_ID: 使用法
59
- :END:
60
- ** インストール
61
-
62
- : > gem install my_help
63
- です.
64
-
65
- ** 簡単な使用法
66
- :PROPERTIES:
67
- :CUSTOM_ID: 簡単な使用法
68
- :END:
69
-
70
- まずは,
71
- #+begin_src bash
3
+ * Name
4
+ - my_help :: manual like help for each user
5
+
6
+ * Summary
7
+ This gem makes and supplies user specific helps, emulating CUI(CLI) help
8
+ usage.
9
+
10
+ * Target
11
+ A very novice of learning a specific operation,
12
+ such as CUI, shell, or emacs,
13
+ has a difficulty in remembering commands and grammers.
14
+ Some simple `key' reminds all, but no key brings nothing.
15
+ Especially a non-English-native has a strong difficulty
16
+ on the key remembering.
17
+ The problems are,
18
+ - a man(ual) is in English
19
+ - a man is heavily documented
20
+ - On web, searching the same key word,
21
+ - and reading the same URI repeatedly
22
+ - but a memo goes away somewhere...
23
+
24
+ * Specs
25
+ This gem aims to supply own help by gem environment.
26
+ Specs are,
27
+ - user makes his own help
28
+ - supplies a template
29
+ - a same format, looks, operation, and hierarchy
30
+ - easily see, read
31
+ - supplies editing and install commands.
32
+
33
+ Wiki targets the whole engineer, my_help targets a specific person.
34
+ Half of the wiki aim should be covered by my_help.
35
+ Making own manual is one of the best practices for remembering operations.
36
+ Memo applications are good, if you remember the key word.
37
+ my_help supplies the key for remembering the word.
38
+
39
+ * Usage
40
+ ** Install
41
+
42
+ : $ gem install my_help
43
+
44
+ ** Simple Usage
45
+ At first, you can see the commands supplied by my_help.
46
+ #+begin_example
72
47
  > my_help
73
- Commands:
74
- my_help delete HELP # delete HELP
75
- my_help edit HELP # edit HELP
76
- my_help help [COMMAND] # Describe available commands or one specific command
77
- my_help list [HELP] [ITEM] # list all helps, specific HELP, or ITEM
78
- my_help new HELP # make new HELP
79
- my_help set_editor EDITOR_NAME # set editor to EDITOR_NAME
80
- my_help setup # set up the test database
81
- my_help version # show version
82
- #+end_src
83
- としてください.このlistにNAMEやITEMを加えて行くとわかると思います.
84
-
85
- #+begin_src bash
86
- > my_help list
87
- > my_help list emacs
88
- > my_help list emacs -f
89
- > my_help list emacs file
90
- #+end_src
91
- として動かしてみてください.
92
-
93
- #+begin_src bash
48
+ NAME
49
+ my_help - make own help and list.
50
+
51
+ SYNOPSIS
52
+ my_help [global options] command [command options] [arguments...]
53
+
54
+ VERSION
55
+ 0.7.0
56
+
57
+ GLOBAL OPTIONS
58
+ --help - Show this message
59
+ --version - Display the program version
60
+
61
+ COMMANDS
62
+ delete - delete HELP_NAME help
63
+ edit - edit HELP_NAME help
64
+ help - Shows a list of commands or help for one command
65
+ list - list all helps, specific HELP, or item
66
+ new - make new HELP_NAME
67
+ #+end_example
68
+
69
+ When you add HELP_NAME and item (-o)wo'
70
+
71
+ : my_help list
72
+ : my_help list emacs_help
73
+ : my_help list emacs_help -f
74
+ : my_help list emacs_help file
75
+
76
+
77
+ #+BEGIN_EXAMPLE
94
78
  - emacsのキーバインド
95
79
  -
96
80
  特殊キー操作
@@ -111,33 +95,16 @@ Commands:
111
95
  , query_replace : query_replace
112
96
  -r, ruby-mode : ruby-mode
113
97
  -d, dired : ファイラとして使う
114
- #+end_src
115
-
116
- ** my_helpがやっていること
117
- my_helpの個々のヘルプファイルは'~/.my_help'に置かれています.
118
- ヘルプファイルのフォーマットはEmacsのorg-modeです.
119
- これをEditorで叩いて編集したり,
120
- そこから情報を取り出したりしています.
121
- 単にファイル操作を集約しているだけなのですが,
122
- これが面倒で...
123
-
124
-
125
- ** 独自のhelpを作る方法
126
- 独自のhelpを作る方法です.まずは,
127
-
128
- : $ my_help new new_help
98
+ #+END_EXAMPLE
129
99
 
130
- で,new_helpというtemplateが用意されます.
131
- : $ my_help edit new_help
132
- で編集してください. Emacs org形式で,格納されています.
100
+ ** Make your own help
101
+ For making your new help, you can do tha as follows:
102
+ : my_help new new_help
133
103
 
134
- : $ my_help delete new_help
104
+ A templeate is compied, then you can edit as
105
+ : my_help edit new_help
106
+ The file is stored in emacs org mode.
135
107
 
136
- すると消されます.
137
- ** editorの変更
138
- : $ my_help set_editor vim
139
- でeditorを変更できます.codeとかは確認していますが,
140
- それ以外で動いたり,動かなかったりを報告してください.
108
+ You can delete if as follows:
109
+ : my_help delete new_help
141
110
 
142
- OS Xで'emacs'とした時にGUI版が立ち上がって嫌だという場合は,
143
- 'emacs -nw'として下さい.
data/README_j.org ADDED
@@ -0,0 +1,143 @@
1
+ # my_help
2
+ #+AUTHOR: Shigeto R. Nishitani
3
+ #+EMAIL: (concat "nishitani@kwansei.ac.jp")
4
+ #+LANGUAGE: jp
5
+ #+OPTIONS: H:4 toc:t num:2
6
+ #+SETUPFILE: /Users/bob/.emacs.d/org-mode/theme-readtheorg.setup
7
+ #+STARTUP: indent nolineimages
8
+ #+OPTIONS: ^:{}
9
+
10
+ * 概要
11
+ :PROPERTIES:
12
+ :CUSTOM_ID: 概要
13
+ :END:
14
+
15
+ CUI(CLA)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
16
+
17
+
18
+ * (my_helpで解決しようとする)問題点
19
+ :PROPERTIES:
20
+ :CUSTOM_ID: my_helpで解決しようとする問題点
21
+ :END:
22
+
23
+ CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
24
+ commandや文法を覚えるのに苦労します.
25
+ 少しのkey(とっかかり)があると思い出すんですが,
26
+ うろ覚えでは間違えて路頭に迷います.
27
+ 問題点は,
28
+ + manは基本的に英語
29
+ + manualでは重たい
30
+ + いつもおなじことをwebで検索して
31
+ + 同じとこ見ている
32
+ + memoしても,どこへ置いたか忘れる
33
+ などです.
34
+
35
+ * 特徴
36
+ :PROPERTIES:
37
+ :CUSTOM_ID: 特徴
38
+ :END:
39
+
40
+ これらをCLAとして提供しようというのが,このgemの目的です.
41
+ 仕様としては,
42
+ - userが自分にあったmanを作成
43
+ - 雛形を提供
44
+ - おなじformat, looks, 操作, 階層構造
45
+ - すぐに手が届く
46
+ - それらを追加・修正・削除できる
47
+
48
+ memoソフトでは,検索が必要となりますが,my_helpは
49
+ key(記憶のとっかかり)を提供することが目的です.
50
+ RPGでレベル上げとかアイテムを貯めるようにして,
51
+ プログラミングでスキルを発展させてください.
52
+
53
+ VSCodeやGithub Copilotではcodeの候補を挙げてくれますが,
54
+ 物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
55
+
56
+ * 使用法
57
+ :PROPERTIES:
58
+ :CUSTOM_ID: 使用法
59
+ :END:
60
+ ** インストール
61
+
62
+ : > gem install my_help
63
+ です.
64
+
65
+ ** 簡単な使用法
66
+ :PROPERTIES:
67
+ :CUSTOM_ID: 簡単な使用法
68
+ :END:
69
+
70
+ まずは,
71
+ #+begin_src bash
72
+ > my_help
73
+ Commands:
74
+ my_help delete HELP # delete HELP
75
+ my_help edit HELP # edit HELP
76
+ my_help help [COMMAND] # Describe available commands or one specific command
77
+ my_help list [HELP] [ITEM] # list all helps, specific HELP, or ITEM
78
+ my_help new HELP # make new HELP
79
+ my_help set_editor EDITOR_NAME # set editor to EDITOR_NAME
80
+ my_help setup # set up the test database
81
+ my_help version # show version
82
+ #+end_src
83
+ としてください.このlistにNAMEやITEMを加えて行くとわかると思います.
84
+
85
+ #+begin_src bash
86
+ > my_help list
87
+ > my_help list emacs
88
+ > my_help list emacs -f
89
+ > my_help list emacs file
90
+ #+end_src
91
+ として動かしてみてください.
92
+
93
+ #+begin_src bash
94
+ - emacsのキーバインド
95
+ -
96
+ 特殊キー操作
97
+ - C-f, controlキーを押しながら 'f'
98
+ - M-f, escキーを押した後一度離して'f'
99
+ - 操作の中断C-g, 操作の取り消し(Undo) C-x u
100
+ , head : head
101
+ , license : license
102
+ -c, cursor : cursor
103
+ -e, edit : edit
104
+ -s, short_cut : short_cut
105
+ -f, file : file
106
+ -q, quit : quit
107
+ -p, page : page
108
+ -w, window : window
109
+ -b, buffer : buffer
110
+ -m, mode : mode
111
+ , query_replace : query_replace
112
+ -r, ruby-mode : ruby-mode
113
+ -d, dired : ファイラとして使う
114
+ #+end_src
115
+
116
+ ** my_helpがやっていること
117
+ my_helpの個々のヘルプファイルは'~/.my_help'に置かれています.
118
+ ヘルプファイルのフォーマットはEmacsのorg-modeです.
119
+ これをEditorで叩いて編集したり,
120
+ そこから情報を取り出したりしています.
121
+ 単にファイル操作を集約しているだけなのですが,
122
+ これが面倒で...
123
+
124
+
125
+ ** 独自のhelpを作る方法
126
+ 独自のhelpを作る方法です.まずは,
127
+
128
+ : $ my_help new new_help
129
+
130
+ で,new_helpというtemplateが用意されます.
131
+ : $ my_help edit new_help
132
+ で編集してください. Emacs org形式で,格納されています.
133
+
134
+ : $ my_help delete new_help
135
+
136
+ すると消されます.
137
+ ** editorの変更
138
+ : $ my_help set_editor vim
139
+ でeditorを変更できます.codeとかは確認していますが,
140
+ それ以外で動いたり,動かなかったりを報告してください.
141
+
142
+ OS Xで'emacs'とした時にGUI版が立ち上がって嫌だという場合は,
143
+ 'emacs -nw'として下さい.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
-
2
+ require 'yard'
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
5
 
@@ -30,3 +30,22 @@ RuboCop::RakeTask.new
30
30
  task :default do
31
31
  system "rake -T"
32
32
  end
33
+
34
+ require "colorize"
35
+ require 'command_line/global'
36
+
37
+ desc 'git auto'
38
+ task :git_auto do
39
+ print "Input comments: "
40
+ comment = STDIN.gets.chomp
41
+ comment = comment == "" ? "auto pull and push" : comment.gsub("\'", "\\'")
42
+ ["git add -A",
43
+ "git commit -m '#{comment}'",
44
+ "git pull origin main",
45
+ "git push origin main"].each do |comm|
46
+ puts comm.cyan
47
+ res = command_line comm
48
+ puts res.stdout.green
49
+ end
50
+ end
51
+
@@ -0,0 +1,242 @@
1
+ #+qiita_teams: 5e172c4b5167abe35a3e
2
+ #+qiita_private: 6487b0b54e4eda26e9f6
3
+ #+OPTIONS: ^:{}
4
+ #+STARTUP: indent nolineimages
5
+ #+TITLE: my_help 開発メモ
6
+ #+AUTHOR: Shigeto R. Nishitani
7
+ #+EMAIL: (concat "shigeto_nishitani@mac.com")
8
+ #+LANGUAGE: jp
9
+ #+OPTIONS: H:4 toc:t num:2
10
+ # +OPTIONS: toc:nil
11
+ #+TAG: ruby, test, my_help
12
+ #+TWITTER: off
13
+ #+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
14
+
15
+ * <2023-01-07 Sat> Thor
16
+ いくつかのaliasをThorで実現したい
17
+ - my_help -v
18
+ - my_help --version
19
+ という標準的なoption期待に答える.
20
+
21
+ - [[https://marsbased.com/blog/2020/04/27/building-ruby-cli-thor/][author token, aliases sample]]
22
+ - [[https://stackoverflow.com/questions/28504373/command-aliasing-in-thor][map]]
23
+ なんかの記述があったが,
24
+ - https://github.com/rails/thor/wiki
25
+ で解決.やっぱり原典ね.
26
+
27
+ あと,その後ろの方に,例文の引き方があって,
28
+ - https://gist.github.com/search?l=ruby&q=.thor
29
+ が便利なんがわかった.これは,使える.
30
+
31
+
32
+ * <2023-01-06 Fri> get_configの置き場所
33
+ Thorのsubcommandを使ってclassを分けたが,共通で利用する
34
+ get_configメソッドをどこに置くかで悩んだ.
35
+
36
+ 結局,
37
+ #+begin_src ruby
38
+ # git_cli.rb
39
+ Module MyHelp
40
+ Module GetConfig
41
+ Class Git < Thor
42
+ include GetConfig
43
+ ...
44
+ end
45
+ # cli.rb
46
+ Module MyHelp
47
+ Class CLI < Thor
48
+ include GetConfig
49
+ ...
50
+ end
51
+ # my_help.rb
52
+ require_relative "my_help/git_cli"
53
+ require_relative "my_help/cli"
54
+ #+end_src
55
+ としている.
56
+ 専用のModuleを作成して,includeするという方法.
57
+ * <2023-01-05 Thu> cli directory指定
58
+ ** directory指定
59
+ テスト環境と本番環境でのhelp_dirあるいはconfig_dir指定の
60
+ 差異の吸収メモ.
61
+ - --help_dirでcliはhelp_dirを指定できる.
62
+ - 全て変更したはず.
63
+ - configが混乱しやすい...config[:ext]なんかを自動で返すといいが.
64
+ - rspec/unitでは
65
+ - config_spec.rb, modify_spec.rbではtmp_confをtemp_dirに作成
66
+ - list_spec.rbではtemplates_pathを絶対パスで参照
67
+
68
+ ** Thorでのdirectory指定の変更
69
+ Thorのdirectory指定をしっかりやってみる.
70
+
71
+ #+begin_src bash
72
+ bundle exec rspec --format documentation -e list spec/cli_spec.rb --help_dir='./tmp/.my_Help'
73
+ invalid option: --help_dir=./tmp/.my_Help
74
+
75
+ Please use --help for a listing of valid options
76
+ #+end_src
77
+ これはだめ.なぜなら,--help_dirはmy_helpのlistのoptionであって,
78
+ rspecは解釈してくれない.
79
+
80
+ ここは,cli_spec.rbで
81
+ #+begin_src ruby
82
+ temp_dir = Dir.pwd
83
+ let(:help_name) { "example" }
84
+ let(:help_dir) { File.join(temp_dir, "lib", "templates") }
85
+
86
+ it "list with name" do
87
+ run_command("my_help list #{help_name} a_item --help_dir=#{help_dir}")
88
+ stop_all_commands
89
+ expect(last_command_started).to have_output(/a_item/)
90
+ end
91
+ #+end_src
92
+ とすべき.
93
+
94
+ そうすると
95
+ #+begin_src bash
96
+ bundle exec exe/my_help list --help_dir='/Users/bob/git_hub/my_help/lib/templates'
97
+ #+end_src
98
+ でも動く.
99
+ そうしておいて,optionsを移動.
100
+
101
+ 今は,
102
+ #+begin_src bash
103
+ > bundle exec exe/my_help help list
104
+ Usage:
105
+ my_help list [HELP] [ITEM]
106
+
107
+ Options:
108
+ [--help-dir=HELP_DIR]
109
+ [--layer=N]
110
+
111
+ list helps
112
+ #+end_src
113
+ となっていたが,
114
+
115
+ #+begin_src bash
116
+ bundle exec exe/my_help
117
+ Commands:
118
+ my_help delete [HELP] # delete HELP
119
+ my_help edit [HELP] # edit help
120
+ ...
121
+ Options:
122
+ [--help-dir=HELP_DIR]
123
+ #+end_src
124
+ とclass_optionとすることで,共通して指定できるように変更.
125
+
126
+ * <2022-12-15 Thu> subcommand and options
127
+ - [[https://hawksnowlog.blogspot.com/2020/09/ruby-thor-tutorial.html#hello-thor][Ruby thor で CLI ツールの開発に入門してみる]]
128
+
129
+ * <2022-12-15 Thu> rspecでerror
130
+ Arubaでrspecするとpwd directoryが/tmp/arubaになる?
131
+ そうすると今のままではrspecが通らなくなる.
132
+ example2.orgの置き場が不定.
133
+ spec側で強引に作るか...
134
+
135
+ それもsmartにしたいよね.
136
+ newでは後ろにoptionがあって,#{temp_dir}での作成とできるが,
137
+ これをその他のoptionsでやるのは難しそう.
138
+
139
+ ** 解決!!
140
+ Arubaだけの問題なので,テストの時用にhelp_dirを
141
+ Thorのoptionとして引けるようにした.
142
+ #+begin_src ruby -n
143
+ desc "list [HELP] [ITEM]", "list helps"
144
+ option :help_dir, :type => :string
145
+ # use method_options [[https://github.com/rails/thor/wiki/Method-Options]]
146
+ def list(*args)
147
+ config = get_config(args).config
148
+ help_dir = options["help_dir"] || config[:local_help_dir]
149
+ puts List.new(help_dir,
150
+ config[:ext]).list(*args.join(" "))
151
+ end
152
+ ...
153
+ context "list command" do
154
+ temp_dir = Dir.pwd
155
+ let(:help_name) { "example" }
156
+ let(:help_dir) { File.join(temp_dir, "lib", "templates") }
157
+
158
+ it "list with name" do
159
+ run_command("my_help list #{help_name} a_item --help_dir=#{help_dir}")
160
+ stop_all_commands
161
+ expect(last_command_started).to have_output(/a_item/)
162
+ end
163
+ end
164
+
165
+ #+end_src
166
+
167
+ * <2021-10-18 月> conf_pathの追加
168
+ my_help.confの場所を指定するconf_pathをnewで指定できるようにする.
169
+
170
+ #+begin_src diff -n -i
171
+ > git diff
172
+ --- a/lib/my_help/my_help_controll.rb
173
+ +++ b/lib/my_help/my_help_controll.rb
174
+ @@ -5,13 +5,14 @@ require 'yaml'
175
+ module MyHelp
176
+ class Control
177
+ attr_accessor :local_help_dir, :editor
178
+ - def initialize()
179
+ + def initialize(conf_path=nil)
180
+ # for configuration setups
181
+ # see https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
182
+ -
183
+ + @conf_path = conf_path || ENV['HOME']
184
+ @template_dir = File.expand_path("../../templates", __FILE__)
185
+ @exe_dir = File.expand_path("../../exe", __FILE__)
186
+ - @local_help_dir = File.join(ENV['HOME'],'.my_help')
187
+ + @local_help_dir = File.join(@conf_path, '.my_help')
188
+ + @conf_file = File.join(@local_help_dir, '.my_help_conf.yml')
189
+ @editor = ENV['EDITOR'] || 'emacs' #'code', 'emacs' #'vim' #default editor
190
+ # @mini_account = File
191
+ set_help_dir_if_not_exists
192
+ @@ -28,9 +29,6 @@ module MyHelp
193
+ end
194
+
195
+ def load_conf
196
+ - file_name = '.my_help_conf.yml'
197
+ - # @conf_file = File.join(Dir.pwd, file_name)
198
+ - @conf_file = File.join(@local_help_dir, file_name)
199
+ begin
200
+ conf = YAML.load_file(@conf_file)
201
+ @editor = conf[:editor]
202
+ #+end_src
203
+
204
+ 変更箇所は次の通り.
205
+ - initializeはconf_pathを受け取るが,指定されてない時はnil
206
+ - これを@conf_pathに受け渡すが,defaultをENV['HOME']に指定
207
+ - これでデフォルトのconfigurationを変更していく
208
+ やり方は,
209
+ [[https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem][Where to place/access config file in gem?]]
210
+ を参照する.
211
+
212
+ これによってTest::unitでのtest環境独自のmy_help環境を構築することが
213
+ できる.
214
+
215
+ * <2021-11-08 月> conf_pathをactivate
216
+ testが進んできたので,conf_pathをactivateした.
217
+ そのためのテストが必要かも.
218
+
219
+ 1. ENV['HOME']で指定した時と...
220
+ 1. pwdで何もない時のoptionsがどうなっている?
221
+
222
+ #+begin_src yaml
223
+ config:
224
+ :template_dir: "/Users/bob/git_hub/my_help/lib/templates"
225
+ :local_help_dir: "/Users/bob/git_hub/my_help/test/.my_help"
226
+ :conf_file: "/Users/bob/git_hub/my_help/test/.my_help/.my_help_conf.yml"
227
+ :editor: emacs
228
+ #+end_src
229
+
230
+ * <2021-11-08 月> bundle exec exe/my_help editでエラー
231
+ #+begin_src shell
232
+ Could not find ffi-1.15.4 in any of the sources
233
+ Run `bundle install` to install missing gems.
234
+ #+end_src
235
+ とのエラー.
236
+ なんだろう.
237
+
238
+ さらに,command_lineで呼ぶと,
239
+ : emacs: standard input is not a tty
240
+ というエラーが出る.これまたなんだろう???
241
+
242
+