my_help 0.4.1 → 0.4.2

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: 30e9fbb25c42b30265ba6c9fa88f47db9ac984a7
4
- data.tar.gz: db31a83a6d0fe0a631ae2f9ca80f02dbe2a654bb
3
+ metadata.gz: aa420fa4ea82a71a6820c504a4d877a4b337cd73
4
+ data.tar.gz: 6c213383e6361373051e40abfc1d0f88bff5eb63
5
5
  SHA512:
6
- metadata.gz: 6326c44722969f0cbdf6969e044ca7603af7f46d56d91bedc1e479d240be542bc833e91299618a1101f96220e7045528f4f7fd9d3332498d316254044e10fe1a
7
- data.tar.gz: be884e7ee9e5c6f15e7f89a4b7312e5ebcd3c66270d5630519974246926c0c9df8180d90ee61c51a11efeee5488196b812743d7bc18b388c12ea053a728de2e3
6
+ metadata.gz: 28c61a91b148e02b0584979c08db0c5220d96f97a99c2cb1bb51a1748d1b8288fc7b456a917f1dc62cd8a227293c582b0380b258c1256aaf4528cf9a28abd27f
7
+ data.tar.gz: e8b8fad0b2306d93ac6d62f373709f12364001b0e61c2bbb2ffd598148e68cf5414e77159ac3ff61a27306c08bfb1d8981ae4a1868281d2ec8e20b89642e0a44
data/Rakefile CHANGED
@@ -47,7 +47,7 @@ task :clean_exe do
47
47
  files = Dir.entries('exe')
48
48
  files.each{|file|
49
49
  next if ["my_help",".","..",".DS_Store",
50
- "emacs_help","e_h","git_help"].include?(file)
50
+ "emacs_help","e_h","todo_help"].include?(file)
51
51
  FileUtils.rm(File.join('./exe',file), :verbose=>true)
52
52
  }
53
53
  end
@@ -16,27 +16,17 @@
16
16
  - "[sudo] gem uninstall my_help"
17
17
  - "自分[hogehoge]のgithubにある古いmy_helpをdelete"
18
18
  - "Fork from https://github.com/daddygongon/my_help"
19
+ - "[sudo] rm -rf my_help"
19
20
  - "git clone git@github.com:[hogehoge]/my_help.git"
20
21
  - "cd my_help"
22
+ - "rake to_yml"
21
23
  - "[sudo] bundle exec exe/my_help -c"
22
24
  - "[sudo] bundle exec exe/my_help -m"
23
25
  - "新しいterminalを開ける"
24
26
  - "my_help -l"
25
-
26
- :restart: #text here too
27
- :opts:
28
- :short: -r
29
- :long: --restart
30
- :desc: 新しいhelpをmake
31
- :title: "my_helpのinstall"
32
- :cont:
33
- - "[sudo] gem uninstall my_help"
34
- - "cd my_help"
35
- - "[sudo] bundle exec exe/my_help -c"
36
- - "[sudo] bundle exec exe/my_help -m"
37
- - "could not find expected ':' while scanning a ...がでたら"
38
- - "rm ~/.my_help/template_helpを試す"
39
- - "あるいはemacs ~/.my_help/template_helpでyamlを修正"
27
+ - "rake add_yml"
28
+ - "--editで編集画面を開けてみて,色が付いてなかったら,"
29
+ - "mv ~/.emacs ~/.emacs.d/init.elを試してみる"
40
30
 
41
31
  :make: #text here too
42
32
  :opts:
@@ -1,3 +1,3 @@
1
1
  module MyHelp
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/my_help.rb CHANGED
@@ -109,7 +109,7 @@ module MyHelp
109
109
 
110
110
  def clean_exe
111
111
  local_help_entries.each{|file|
112
- next if ['emacs_help','e_h','todo_help','git_help'].include?(file)
112
+ next if ['emacs_help','e_h','todo_help','todo_help'].include?(file)
113
113
  file = File.basename(file,'.yml')
114
114
  [file, short_name(file)].each{|name|
115
115
  p target=File.join('exe',name)
@@ -130,7 +130,7 @@ module MyHelp
130
130
 
131
131
  def edit_help(file)
132
132
  p target_help=File.join(@local_help_dir,file)
133
- system "emacs #{target_help}"
133
+ system "emacs #{target_help}.yml"
134
134
  end
135
135
 
136
136
  def local_help_entries
@@ -147,8 +147,16 @@ module MyHelp
147
147
  print "Specific help file:\n"
148
148
  local_help_entries.each{|file|
149
149
  file_path=File.join(@local_help_dir,file)
150
- help = YAML.load(File.read(file_path))
151
150
  file = File.basename(file,'.yml')
151
+ begin
152
+ help = YAML.load(File.read(file_path))
153
+ rescue=> eval
154
+ p eval
155
+ print "\n YAML load error in #{file}."
156
+ print " See the line shown above and revise by\n"
157
+ print " emacs #{file_path}\n"
158
+ exit
159
+ end
152
160
  print " #{file}\t:#{help[:head][0]}\n"
153
161
  }
154
162
  end
data/lib/specific_help.rb CHANGED
@@ -43,15 +43,33 @@ module SpecificHelp
43
43
  opt.on('--store [item]','store [item] in backfile'){|item| store(item)}
44
44
  opt.on('--remove [item]','remove [item] and store in backfile'){|item| remove(item) }
45
45
  opt.on('--add [item]','add new [item]'){|item| add(item) }
46
+ opt.on('--backup_list [val]','show last [val] backup list'){|val| backup_list(val)}
47
+ end
48
+ begin
49
+ command_parser.parse!(@argv)
50
+ rescue=> eval
51
+ p eval
46
52
  end
47
- # begin
48
- command_parser.parse!(@argv)
49
- # rescue=> eval
50
- # p eval
51
- # end
52
53
  exit
53
54
  end
54
55
 
56
+ def backup_list(val)
57
+ val = val || 10
58
+ print "\n ...showing last #{val} stored items in backup.\n"
59
+ backup=mk_backup_file(@source_file)
60
+ File.open(backup,'r'){|file|
61
+ backup_cont = YAML.load(File.read(backup))
62
+ backup_size = backup_cont.size
63
+ backup_size = backup_size>val.to_i ? val.to_i : backup_size
64
+ backup_keys = backup_cont.keys
65
+ backup_keys.reverse.each_with_index{|item,i|
66
+ break if i>=backup_size
67
+ line = item.to_s.split('_')
68
+ printf("%10s : %8s%8s\n",line[0],line[1],line[2])
69
+ }
70
+ }
71
+ end
72
+
55
73
  def mk_backup_file(file)
56
74
  path = File.dirname(file)
57
75
  base = File.basename(file)
@@ -61,14 +79,24 @@ module SpecificHelp
61
79
  end
62
80
 
63
81
  def store(item)
82
+ print "Trying to store #{item}\n"
64
83
  backup=mk_backup_file(@source_file)
65
- store_item = @help_cont[item.to_sym]
84
+ unless store_item = @help_cont[item.to_sym] then
85
+ print "No #{item} in this help. The items are following...\n"
86
+ keys = @help_cont.keys
87
+ keys.each{|key|
88
+ p key
89
+ }
90
+ exit
91
+ end
66
92
  p store_name = item+"_"+Time.now.strftime("%Y%m%d_%H%M%S")
67
- cont = {store_name.to_sym => store_item}
68
- File.open(backup,'a'){|file| file.print(YAML.dump(cont))}
93
+ backup_cont=YAML.load(File.read(backup)) || {}
94
+ backup_cont[store_name.to_sym]=store_item
95
+ File.open(backup,'w'){|file| file.print(YAML.dump(backup_cont))}
69
96
  end
70
97
 
71
98
  def add(item='new_item')
99
+ print "Trying to add #{item}\n"
72
100
  new_item={:opts=>{:short=>'-'+item[0], :long=>'--'+item, :desc=>item},
73
101
  :title=>item, :cont=> [item]}
74
102
  @help_cont[item.to_sym]=new_item
@@ -76,6 +104,7 @@ module SpecificHelp
76
104
  end
77
105
 
78
106
  def remove(item)
107
+ print "Trying to remove #{item}\n"
79
108
  store(item)
80
109
  @help_cont.delete(item.to_sym)
81
110
  File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
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.4.1
4
+ version: 0.4.2
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-11-20 00:00:00.000000000 Z
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,7 +128,6 @@ email:
128
128
  executables:
129
129
  - e_h
130
130
  - emacs_help
131
- - git_help
132
131
  - my_help
133
132
  extensions: []
134
133
  extra_rdoc_files: []
@@ -146,7 +145,6 @@ files:
146
145
  - bin/setup
147
146
  - exe/e_h
148
147
  - exe/emacs_help
149
- - exe/git_help
150
148
  - exe/my_help
151
149
  - hikis/README_en.hiki
152
150
  - hikis/README_ja.hiki
data/exe/git_help DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','git_help.yml')
4
- SpecificHelp::Command.run(help_file, ARGV)