my_help 1.2.7 → 1.2.9

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: cb657df4836581b1f682cf5cffabdb89215f4f6f51a5836aa2dfdb7d86d11a20
4
- data.tar.gz: 8e2d7673d363db127caeba1323837a7a2a1ef989f25461ec0dd28ee33f594d7c
3
+ metadata.gz: ef3b53ff5f6f90cf1458dc5cd60ee98cc13daebe346bc124c01d4dac72aab3fb
4
+ data.tar.gz: 2d0ada2b498a2df1b2fe295b4155bb641382ecff7e86ca317d44f0bb4c33bdd8
5
5
  SHA512:
6
- metadata.gz: 41f84a96ab9e2b1794805587c13c14489e3e85f849d756875e0f1a0bf0fe780db5e009adebbac32efa0b85ce1209e21d8b4d54d4ebe546c2edfd590b4d789f49
7
- data.tar.gz: 3309a3cfd356061482fae41107396fb9a319e0b9a6bc4dd2e98fa88048ed044f2f2c29a37aadfc3ed9f8e9acb32cba2724e29cff09f3eedbd6d33af7702ec661
6
+ metadata.gz: e47417728172f3816c0c7c8dbfdcbfb652b9331dfeea896c81638bb9d6ada6825bdbd8ad6058dbc916809c2e744b86d24fb5aefbc044233585cae7c6c9a83709
7
+ data.tar.gz: b85b56f45a05bf6a987c434221ec33ac45d30f3b6a34d9af690eddcd05606cbea7355e24fbd293e44c1dc64a49f55dacf96d79f4ffd885c6c4a4f3529e5d11b8
@@ -29,7 +29,7 @@ module MyHelp
29
29
  temp_path = File.expand_path("../templates", __dir__)
30
30
 
31
31
  if config[:template_dir] != temp_path
32
- puts "inconsistency for :template_dir"
32
+ puts "adjust inconsistency of template_dir.\n"
33
33
  config[:template_dir]= temp_path
34
34
  save_config
35
35
  end
data/lib/my_help/list.rb CHANGED
@@ -36,35 +36,38 @@ module MyHelp
36
36
  help_info = read_help(file)
37
37
  head = help_info[:items]["head"] ?
38
38
  help_info[:items]["head"].split("\n")[0] : ''
39
- # "head "ではだめ...やれやれ<24/10/02> revised
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]
39
+ # out << "%10s: %s\n" % [help_info[:name], head]
40
+ out << "%s: %s\n" %
41
+ [pad_multi_bytes(help_info[:name],20), head]
43
42
  end
44
43
  end
45
44
 
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
45
+ def pad_multi_bytes(str, length, padstr=" ")
46
+ str_bytes = str.each_char.map do |c|
47
+ c.bytesize == 1 ? 1 : 2
48
+ end.reduce(0, &:+)
49
+ # p [str, length, str_bytes]
50
+ if str_bytes<length
51
+ pad = padstr * (length - str_bytes)
52
+ return pad + str
53
+ else
54
+ return str
55
+ end
53
56
  end
54
57
 
55
58
 
56
- # defaultで@path/name.@extのヘルプを読み込んで,itemを表示
57
- #
58
59
  def list_help_with(path, name, item)
59
60
  @help_info = read_help(path)
60
- output = ColorizedString["my_help called with name : #{name}, item : #{item}\n"].colorize(:cyan)
61
+ output = ColorizedString[
62
+ "my_help called with name : #{name},item : #{item}\n"
63
+ ].colorize(:cyan)
61
64
 
62
65
  if item == nil
63
66
  @help_info[:items].each_pair do |item, val|
64
67
  item, desc = item.split(":")
65
68
  desc ||= ""
66
- output << "- %20s : %s\n" % [item, desc]
67
- # output << "%s: %s\n" % [pad_with_bytes(item, 40), desc]
69
+ output << "%s: %s\n" %
70
+ [pad_multi_bytes(item, 20), desc]
68
71
  end
69
72
  else
70
73
  output << find_near(item)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MyHelp
4
- VERSION = "1.2.7"
4
+ VERSION = "1.2.9"
5
5
  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.7
4
+ version: 1.2.9
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-10-03 00:00:00.000000000 Z
11
+ date: 2024-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec