my_help 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +0 -3
- data/Gemfile.lock +10 -9
- data/README.html +362 -0
- data/README.org +58 -157
- data/README.rdoc +6 -0
- data/README_en.org +131 -0
- data/Rakefile_gli +44 -0
- data/bin/my_help +67 -0
- data/lib/my_help.rb +5 -204
- data/lib/my_help/my_help_controll.rb +139 -0
- data/lib/my_help/org2yml.rb +8 -2
- data/lib/my_help/version.rb +1 -1
- data/lib/templates/org_help.org +18 -15
- data/my_help.gemspec +23 -33
- data/my_help.rdoc +5 -0
- metadata +85 -55
- data/Dockerfile.template +0 -13
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/docs/README_en.org +0 -164
- data/docs/diff_against_org_mode.org +0 -38
- data/docs/path_setting.org +0 -47
- data/exe/e_h +0 -4
- data/exe/emacs_help +0 -4
- data/exe/m_t +0 -4
- data/exe/my_help +0 -6
- data/exe/my_todo +0 -4
- data/exe/o_h +0 -4
- data/exe/org_help +0 -4
- data/lib/emacs_help.rb +0 -137
- data/lib/my_help/test.rb +0 -29
- data/lib/my_help/yml2org.rb +0 -34
- data/lib/my_help_thor.rb +0 -170
- data/lib/specific_help.rb +0 -171
- data/lib/specific_help_bu.rb +0 -233
- data/lib/specific_help_opt.rb +0 -71
- data/lib/specific_help_thor.rb +0 -172
- data/make_docker.sh +0 -5
data/lib/specific_help_thor.rb
DELETED
@@ -1,172 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "optparse"
|
3
|
-
require "yaml"
|
4
|
-
require "my_help/version"
|
5
|
-
require 'fileutils'
|
6
|
-
require "coderay"
|
7
|
-
require 'colorize'
|
8
|
-
require "thor"
|
9
|
-
|
10
|
-
module SpecificHelp
|
11
|
-
class Command < Thor
|
12
|
-
# def self.start(file,*args)
|
13
|
-
# new(file,*args).execute
|
14
|
-
# end
|
15
|
-
def initialize(*args)
|
16
|
-
super
|
17
|
-
# p ENV['HELP_NAME']
|
18
|
-
file=File.join(ENV['HOME'],'.my_help',"#{ENV['HELP_NAME']}.yml")
|
19
|
-
puts "@initialize\n"
|
20
|
-
|
21
|
-
@source_file = file
|
22
|
-
@help_cont = YAML.load(File.read(@source_file))
|
23
|
-
@help_cont[:head].each{|line| print line.chomp+"\n" } if @help_cont[:head] != nil
|
24
|
-
@help_cont[:license].each{|line| print "#{line.chomp}\n" } if @help_cont[:license] != nil
|
25
|
-
@argv = *args
|
26
|
-
end
|
27
|
-
|
28
|
-
desc 'backup NAME, --backup NAME','backup NAME help'
|
29
|
-
map "--backup" => "backup"
|
30
|
-
def backup(val)
|
31
|
-
val = val || 10
|
32
|
-
print "\n ...showing last #{val} stored items in backup.\n"
|
33
|
-
backup=mk_backup_file(@source_file)
|
34
|
-
File.open(backup,'r'){|file|
|
35
|
-
backup_cont = YAML.load(File.read(backup))
|
36
|
-
backup_size = backup_cont.size
|
37
|
-
backup_size = backup_size>val.to_i ? val.to_i : backup_size
|
38
|
-
backup_keys = backup_cont.keys
|
39
|
-
backup_keys.reverse.each_with_index{|item,i|
|
40
|
-
break if i>=backup_size
|
41
|
-
line = item.to_s.split('_')
|
42
|
-
printf("%10s : %8s%8s\n",line[0],line[1],line[2])
|
43
|
-
}
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
desc 'store NAME, --store','store NAME help'
|
48
|
-
map "--store" => "store"
|
49
|
-
def store(item)
|
50
|
-
if item==nil
|
51
|
-
print "spcify --store [item].\n"
|
52
|
-
exit
|
53
|
-
else
|
54
|
-
print "Trying to store #{item}\n"
|
55
|
-
end
|
56
|
-
backup=mk_backup_file(@source_file)
|
57
|
-
unless store_item = @help_cont[item.to_sym] then
|
58
|
-
print "No #{item} in this help. The items are following...\n"
|
59
|
-
keys = @help_cont.keys
|
60
|
-
keys.each{|key|
|
61
|
-
p key
|
62
|
-
}
|
63
|
-
exit
|
64
|
-
end
|
65
|
-
p store_name = item+"_"+Time.now.strftime("%Y%m%d_%H%M%S")
|
66
|
-
cont = {store_name.to_sym => store_item}
|
67
|
-
backup_cont=YAML.load(File.read(backup)) || {}
|
68
|
-
backup_cont[store_name.to_sym]=store_item
|
69
|
-
File.open(backup,'w'){|file| file.print(YAML.dump(backup_cont))}
|
70
|
-
end
|
71
|
-
|
72
|
-
desc 'add NAME, --add NAME','add NAME help'
|
73
|
-
map "--add" => "add"
|
74
|
-
def add(item='new_item')
|
75
|
-
print "Trying to add #{item}\n"
|
76
|
-
new_item={:opts=>{:short=>'-'+item[0], :long=>'--'+item, :desc=>item},
|
77
|
-
:title=>item, :cont=> [item]}
|
78
|
-
@help_cont[item.to_sym]=new_item
|
79
|
-
File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
|
80
|
-
end
|
81
|
-
|
82
|
-
desc 'remove NAME, --remove NAME','remove NAME help'
|
83
|
-
map "--remove" => "remove"
|
84
|
-
def remove(item)
|
85
|
-
print "Trying to remove #{item}\n"
|
86
|
-
store(item)
|
87
|
-
@help_cont.delete(item.to_sym)
|
88
|
-
File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
|
89
|
-
end
|
90
|
-
|
91
|
-
desc 'edit, --edit','edit help'
|
92
|
-
map "--edit" => "edit"
|
93
|
-
def edit
|
94
|
-
puts "@edit\n"
|
95
|
-
p help_file =@source_file
|
96
|
-
begin
|
97
|
-
p command= "emacs #{help_file}"
|
98
|
-
exec command
|
99
|
-
rescue => e
|
100
|
-
print "\nOption edit is not executable on windows. \n"
|
101
|
-
print "Type the following shell command;\n\n"
|
102
|
-
print "emacs /home/#{ENV['USER']}/.my_help/#{File.basename(@source_file)}\n\n"
|
103
|
-
print "M-x ruby-mode should be good for edit.\n"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
desc 'hiki, --hiki','hiki help'
|
108
|
-
map "--hiki" => "hiki"
|
109
|
-
def hiki
|
110
|
-
@help_cont.each_pair{|key,val|
|
111
|
-
if key==:head or key==:license
|
112
|
-
hiki_disp(val)
|
113
|
-
else
|
114
|
-
hiki_help(key)
|
115
|
-
end
|
116
|
-
}
|
117
|
-
end
|
118
|
-
|
119
|
-
desc 'all, --all','all help'
|
120
|
-
map "--all" => "all"
|
121
|
-
def all
|
122
|
-
@help_cont.each_pair{|key,val|
|
123
|
-
if key==:head or key==:license
|
124
|
-
val[0]+=":"
|
125
|
-
disp(val)
|
126
|
-
else
|
127
|
-
disp_help(key)
|
128
|
-
end
|
129
|
-
}
|
130
|
-
end
|
131
|
-
|
132
|
-
no_commands do
|
133
|
-
|
134
|
-
def mk_backup_file(file)
|
135
|
-
path = File.dirname(file)
|
136
|
-
base = File.basename(file)
|
137
|
-
backup= File.join(path,"."+base)
|
138
|
-
FileUtils.touch(backup) unless File.exists?(backup)
|
139
|
-
return backup
|
140
|
-
end
|
141
|
-
|
142
|
-
def hiki_help(key_word)
|
143
|
-
items =@help_cont[key_word]
|
144
|
-
puts "\n!!"+items[:title]+"\n"
|
145
|
-
hiki_disp(items[:cont])
|
146
|
-
end
|
147
|
-
|
148
|
-
def hiki_disp(lines)
|
149
|
-
lines.each{|line| puts "*#{line}"} if lines != nil
|
150
|
-
end
|
151
|
-
|
152
|
-
def disp_help(key_word)
|
153
|
-
print_separater
|
154
|
-
items =@help_cont[key_word]
|
155
|
-
puts items[:title].magenta
|
156
|
-
# puts CodeRay.scan("-#{items[:title]}:", :Taskpaper).term
|
157
|
-
disp(items[:cont])
|
158
|
-
print_separater
|
159
|
-
end
|
160
|
-
|
161
|
-
def disp(lines)
|
162
|
-
# lines.each{|line| puts " +#{line}"} if lines != nil
|
163
|
-
lines.each{|line| puts "*#{line}".blue}
|
164
|
-
# lines.each{|line| puts CodeRay.scan("+#{line}", :Taskpaper).term}
|
165
|
-
end
|
166
|
-
|
167
|
-
def print_separater
|
168
|
-
print "---\n"
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|