my_help 1.2.5 → 1.2.7

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
  SHA256:
3
- metadata.gz: 7fbe3cc902e69de5a60eaeaa7d14dd022d9e62762c8a49614a196e1ee5140e7b
4
- data.tar.gz: 007a657cf27a611ff2283ad3d06646663623f87a42c4aff01386652b347efbcf
3
+ metadata.gz: cb657df4836581b1f682cf5cffabdb89215f4f6f51a5836aa2dfdb7d86d11a20
4
+ data.tar.gz: 8e2d7673d363db127caeba1323837a7a2a1ef989f25461ec0dd28ee33f594d7c
5
5
  SHA512:
6
- metadata.gz: 29765172ae78544814be3103168a972456dbaf7db01a53b0587db7c90e6d9cf5352f3be5dd7a064b94e5c9450b55bab2dd5f988c8c50d2fe1eca5462c11e6582
7
- data.tar.gz: 45abc775d1b7099f640e52123ff6f851f338e8cb47b5a3645eb67a4ba059284238dc51cad0d371c6a2da875ed8a17dcf034fe74341b45925e4d7a7284de04e6d
6
+ metadata.gz: 41f84a96ab9e2b1794805587c13c14489e3e85f849d756875e0f1a0bf0fe780db5e009adebbac32efa0b85ce1209e21d8b4d54d4ebe546c2edfd590b4d789f49
7
+ data.tar.gz: 3309a3cfd356061482fae41107396fb9a319e0b9a6bc4dd2e98fa88048ed044f2f2c29a37aadfc3ed9f8e9acb32cba2724e29cff09f3eedbd6d33af7702ec661
data/lib/my_help/cli.rb CHANGED
@@ -15,8 +15,6 @@ module MyHelp
15
15
 
16
16
  package_name 'my_help'
17
17
  map "-v" => :version
18
- map "--version" => :version
19
-
20
18
  desc "version", "show version"
21
19
 
22
20
  def version
@@ -31,13 +29,6 @@ module MyHelp
31
29
  def add_defaults
32
30
  puts "Adding defaults org files in .my_help"
33
31
  config = get_config
34
- if config[:template_dir] !=
35
- File.expand_path("../templates", __dir__)
36
- puts "inconsistency for :template_dir"
37
- config.configure(:template_dir=>
38
- File.expand_path("../templates", __dir__))
39
- config.save_config
40
- end
41
32
  help_dir = options["help_dir"] || config[:local_help_dir]
42
33
  p current_orgs = Dir.glob(File.join(help_dir, "*.org")).
43
34
  map!{|f| File.basename(f)}
@@ -103,7 +94,7 @@ module MyHelp
103
94
  end
104
95
 
105
96
  desc "new [HELP]", "mk new HELP"
106
-
97
+ map "-n" => :new
107
98
  def new(*args)
108
99
  c = get_config
109
100
  help_name = args[0]
@@ -112,6 +103,21 @@ module MyHelp
112
103
  # puts res.stdout
113
104
  end
114
105
 
106
+ desc "place [TEMPLATE]", "place template on cwd"
107
+ map "-p" => :place
108
+ def place(*args)
109
+ config = get_config
110
+ p help_name = File.basename( (args[0] || 'template.org'),
111
+ '.org')
112
+ t_file = File.join('.', help_name+".org")
113
+ if File.exist?(t_file)
114
+ puts "File #{t_file} exists, set file_name."
115
+ else
116
+ FileUtils.cp(File.join(config[:template_dir],'template.org'),
117
+ t_file, verbose: true)
118
+ end
119
+ end
120
+
115
121
  desc "delete [HELP]", "delete HELP"
116
122
 
117
123
  def delete(*args)
@@ -21,8 +21,19 @@ module MyHelp
21
21
  configure_with(@config[:conf_file])
22
22
  # YAML.dump(@config, File.open(@config[:conf_file], 'w'))
23
23
  # no good for multiple testers.
24
+ check_template_dir
24
25
  end
25
26
 
27
+
28
+ def check_template_dir
29
+ temp_path = File.expand_path("../templates", __dir__)
30
+
31
+ if config[:template_dir] != temp_path
32
+ puts "inconsistency for :template_dir"
33
+ config[:template_dir]= temp_path
34
+ save_config
35
+ end
36
+ end
26
37
  # Configure through hash
27
38
  def configure(opts = nil)
28
39
  return if opts == nil
@@ -3,6 +3,7 @@ module MyHelp
3
3
  def get_config #(args)
4
4
  parent_help_dir = options["help_dir"] || ""
5
5
  parent_help_dir = ENV["HOME"] unless File.exist?(parent_help_dir)
6
+ # Forget necessity of these
6
7
  return Config.new(parent_help_dir)
7
8
  end
8
9
  end
data/lib/my_help/list.rb CHANGED
@@ -16,7 +16,7 @@ module MyHelp
16
16
  if item == nil && name == nil
17
17
  list_helps()
18
18
  else
19
- path = File.exists?(name + @ext) ? name + @ext :
19
+ path = File.exist?(name + @ext) ? name + @ext :
20
20
  File.join(@path, name + @ext)
21
21
  list_help_with(path, name, item)
22
22
  end
@@ -32,15 +32,27 @@ module MyHelp
32
32
  def list_helps()
33
33
  files = File.join(@path, "*#{@ext}")
34
34
  Dir.glob(files).inject("") do |out, file|
35
- # p [out, file]
35
+ # p [out, file]
36
36
  help_info = read_help(file)
37
37
  head = help_info[:items]["head"] ?
38
- help_info[:items]["head"].split("\n")[0] :
39
- ''
38
+ help_info[:items]["head"].split("\n")[0] : ''
39
+ # "head "ではだめ...やれやれ<24/10/02> revised
40
40
  out << "%10s: %s\n" % [help_info[:name], head]
41
+ # out << "%s: %s\n" % [help_info[:name], head]
42
+ # out << "%20s: %s\n" % [pad_with_bytes(help_info[:name],20), head]
41
43
  end
42
44
  end
43
45
 
46
+ def pad_with_bytes(str, length, padstr=" ")
47
+ p str="日本語"
48
+ p str_bytes = str.bytesize
49
+ p pad_bytes = length - str_bytes
50
+ p pad = padstr * (pad_bytes / padstr.bytesize)
51
+ exit
52
+ return pad + str
53
+ end
54
+
55
+
44
56
  # defaultで@path/name.@extのヘルプを読み込んで,itemを表示
45
57
  #
46
58
  def list_help_with(path, name, item)
@@ -52,6 +64,7 @@ module MyHelp
52
64
  item, desc = item.split(":")
53
65
  desc ||= ""
54
66
  output << "- %20s : %s\n" % [item, desc]
67
+ # output << "%s: %s\n" % [pad_with_bytes(item, 40), desc]
55
68
  end
56
69
  else
57
70
  output << find_near(item)
@@ -40,7 +40,12 @@ module MyHelp
40
40
 
41
41
  def read_item(line)
42
42
  m = line.match(/\* (.+)/)
43
- return m ? m[1] : nil
43
+ item = if m
44
+ m[1].match(/head\s*/) ? "head" : m[1]
45
+ else
46
+ nil
47
+ end
48
+ return item
44
49
  end
45
50
  end
46
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyHelp
4
- VERSION = "1.2.5"
4
+ VERSION = "1.2.7"
5
5
  end
@@ -9,33 +9,6 @@
9
9
   - c-g,操作を中断する
10
10
   - c-x u, 直前に行った操作を取り消す
11
11
  * license: cc by Kaede Ogawa & Shigeto R. Nishitani, 2024
12
- * basic
13
- ** 初期
14
- - emacs [FILE]
15
- ** 終了操作
16
- - c-x c-c, ファイルを保存して、Emacsを終了する
17
- - c-z, Emacsを一時停止する, fgで再開する
18
- ** カーソル移動
19
- - c-f, カーソルを1文字前に移動
20
- - c-b, カーソルを1文字後ろに移動
21
- - c-a, 行の先頭に移動
22
- - c-e, 行の末尾に移動
23
- - c-n, 次の行に移動
24
- - c-p, 前の行に移動
25
- - c-v, 次のページに移動
26
- - M-v, 前のページに移動
27
- - c-l, カーソル行を画面の中央に移動(2回目は画面の上端に、3回目は画面の下端に移動する)
28
- - M-<, ファイルの先頭に移動
29
- - M->, ファイルの末尾に移動
30
- ** 編集操作
31
- - c-d, カーソルの右側の1文字を削除
32
- - c-k, カーソル位置から行の末尾までの文字を削除
33
- - c-y, 直前に削除した文字を貼り付け
34
- - c-w, 選択された領域を削除
35
- - 領域選択は、先頭 or 最後尾で c-space した後、最後尾 or 先頭へカーソル移動
36
- - c-s, 前へ WORD を検索
37
- - c-r, 後へ WORD を検索
38
- - M-x query-replace WORD1 <ret> WORD2, 文字列の置換(y or n で可否選択)
39
12
  * カーソル移動
40
13
  - c-f, カーソルを1文字前に移動
41
14
  - c-b, カーソルを1文字後ろに移動
@@ -0,0 +1,9 @@
1
+ #+OPTIONS: ^:{}
2
+ #+STARTUP: indent nolineimages overview num
3
+ #+TITLE: template for org-file
4
+ #+AUTHOR: Shigeto R. Nishitani
5
+ #+EMAIL: (concat "shigeto_nishitani@mac.com")
6
+ #+LANGUAGE: jp
7
+ #+OPTIONS: H:4 toc:t num:2
8
+ #+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
9
+
data/my_help.gemspec CHANGED
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_runtime_dependency "thor"
24
24
  spec.add_runtime_dependency "command_line"
25
25
  spec.add_runtime_dependency "colorize"
26
- spec.add_development_dependency "aruba"
26
+ # spec.add_development_dependency "aruba"
27
+ spec.add_development_dependency "yard"
28
+ spec.add_development_dependency "rubocop"
27
29
  # For more information and examples about making a new gem, checkout our
28
30
  # guide at: https://bundler.io/guides/creating_gem.html
29
31
  end
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: 1.2.5
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeto R. Nishiani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-26 00:00:00.000000000 Z
11
+ date: 2024-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -67,7 +67,21 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: aruba
70
+ name: yard
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: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -151,6 +165,7 @@ files:
151
165
  - lib/templates/example.org
152
166
  - lib/templates/my_help_j.org
153
167
  - lib/templates/org_j.org
168
+ - lib/templates/template.org
154
169
  - my_help.gemspec
155
170
  - my_help_install.org
156
171
  homepage: https://github.com/daddygongon/my_help