my_help 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.org +7 -0
- data/exe/my_help +35 -17
- data/lib/my_help/my_help_controll.rb +104 -74
- data/lib/my_help/version.rb +1 -1
- data/my_help.gemspec +2 -2
- metadata +5 -23
- data/.ruby-version +0 -1
- data/Rakefile_gli +0 -44
- data/my_help.rdoc +0 -5
- data/tmp.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13b91f6abff32e7684a29cc6ed379336cec60491
|
4
|
+
data.tar.gz: 4a4615b5241da57e266de134b904b68cf030cb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eed8e764d4d4a8cca12016807e1792886c297e347fd1c722e6466eaf4ec1043dad5b408090eaefd9d1b4f9bbd6fb6381ad3be98852584fa7a7fd09cc68f68aa3
|
7
|
+
data.tar.gz: 7518cd00a767a2d0c63ec0b514a0d39d9fb6eda53a2ee77c40e7db508d4de0ef2f281dcba2f7b200648bd42337f81cf81ed57a3247a132112f6b44c6f4126fc1
|
data/Gemfile.lock
CHANGED
data/README.org
CHANGED
@@ -135,3 +135,10 @@ COMMANDS
|
|
135
135
|
: my_help delete new_help
|
136
136
|
|
137
137
|
すると消されます.
|
138
|
+
* test
|
139
|
+
testは[[/Users/bob/github/ruby_docs/testing_frameworks/test_unit/README.org]]
|
140
|
+
にあるのに従って書いている.
|
141
|
+
|
142
|
+
「Rubyベストプラクティス」にあるmustを使ったextension
|
143
|
+
を組み込んで,DSLにしている.
|
144
|
+
[[https://github.com/practicingruby/rbp/blob/master/testing/test_unit_extensions.rb]]
|
data/exe/my_help
CHANGED
@@ -1,50 +1,68 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'thor'
|
3
3
|
require 'my_help'
|
4
|
-
|
4
|
+
require 'colorize'
|
5
5
|
class MyCLI < Thor
|
6
|
-
desc
|
7
|
-
def
|
6
|
+
desc('setup', 'set up the test database')
|
7
|
+
def setup(*args)
|
8
8
|
$control = MyHelp::Control.new()
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "list", "list helps, specific HELP, or item"
|
12
|
+
def list(*args)
|
13
|
+
invoke :setup
|
9
14
|
file = args[0]
|
10
15
|
item = args[1]
|
11
16
|
if file.nil?
|
12
|
-
$control.list_all
|
17
|
+
puts $control.list_all.blue # list []
|
13
18
|
elsif item.nil?
|
14
|
-
|
19
|
+
begin
|
20
|
+
puts $control.list_help(file) # list [file]
|
21
|
+
rescue => e
|
22
|
+
puts e.to_s.red
|
23
|
+
end
|
15
24
|
else
|
16
|
-
|
25
|
+
begin
|
26
|
+
puts $control.show_item(file, item) # list [file] [item]
|
27
|
+
rescue => e
|
28
|
+
puts e.to_s.red
|
29
|
+
end
|
17
30
|
end
|
18
31
|
end
|
19
32
|
|
33
|
+
desc "version", "show version"
|
34
|
+
def version
|
35
|
+
invoke :setup
|
36
|
+
puts MyHelp::VERSION
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "editor {editor_name}", "set editor"
|
40
|
+
def editor(editor_name)
|
41
|
+
invoke :setup
|
42
|
+
$control.set_editor(editor_name)
|
43
|
+
end
|
44
|
+
|
20
45
|
desc "edit {help_name}", "edit HELP_NAME"
|
21
46
|
def edit(help_name)
|
22
|
-
|
47
|
+
invoke :setup
|
23
48
|
$control.edit_help(help_name)
|
24
49
|
end
|
25
50
|
|
26
51
|
desc "new {help_name}", "make new HELP_NAME"
|
27
52
|
def new(help_name)
|
28
|
-
|
53
|
+
invoke :setup
|
29
54
|
$control.init_help(help_name)
|
30
55
|
end
|
31
56
|
|
32
57
|
desc "delete {help_name}", "delete HELP_NAME"
|
33
58
|
def delete(help_name)
|
34
|
-
|
59
|
+
invoke :setup
|
35
60
|
$control.delete_help(help_name)
|
36
61
|
end
|
37
62
|
|
38
|
-
|
39
|
-
desc "tomo_upload {help_name}", "tomo_upload HELP_NAME"
|
40
|
-
def tomo_upload(help_name)
|
41
|
-
$control = MyHelp::Control.new()
|
42
|
-
$control.upload_help(help_name)
|
43
|
-
end
|
44
|
-
|
45
63
|
desc "search {find_char}", "search FIND_CHAR"
|
46
64
|
def search(find_char)
|
47
|
-
|
65
|
+
invoke :setup
|
48
66
|
$control.search_help(find_char)
|
49
67
|
end
|
50
68
|
end
|
@@ -1,16 +1,47 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
|
+
require 'fileutils'
|
3
|
+
require 'yaml'
|
4
|
+
|
2
5
|
module MyHelp
|
3
|
-
class Control
|
6
|
+
class Control
|
7
|
+
attr_accessor :local_help_dir, :editor
|
4
8
|
def initialize()
|
9
|
+
# for configuration setups
|
10
|
+
# see https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
|
11
|
+
|
5
12
|
@template_dir = File.expand_path("../../templates", __FILE__)
|
6
13
|
@exe_dir = File.expand_path("../../exe", __FILE__)
|
7
14
|
@local_help_dir = File.join(ENV['HOME'],'.my_help')
|
8
|
-
|
15
|
+
@editor = 'code' #'emacs' #'vim'
|
16
|
+
# @mini_account = File
|
9
17
|
set_help_dir_if_not_exists
|
18
|
+
load_conf
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_editor(editor)
|
22
|
+
@editor = editor
|
23
|
+
file_name = '.my_help_conf.yml'
|
24
|
+
# @conf_file = File.join(Dir.pwd, file_name)
|
25
|
+
@conf_file = File.join(@local_help_dir, file_name)
|
26
|
+
conf = {editor: editor}
|
27
|
+
File.open(@conf_file, 'w'){|f| YAML.dump(conf, f)}
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_conf
|
31
|
+
file_name = '.my_help_conf.yml'
|
32
|
+
# @conf_file = File.join(Dir.pwd, file_name)
|
33
|
+
@conf_file = File.join(@local_help_dir, file_name)
|
34
|
+
begin
|
35
|
+
conf = YAML.load_file(@conf_file)
|
36
|
+
@editor = conf[:editor]
|
37
|
+
rescue => e
|
38
|
+
p e
|
39
|
+
set_editor('code')
|
40
|
+
end
|
10
41
|
end
|
11
42
|
|
12
43
|
def set_help_dir_if_not_exists
|
13
|
-
return if File::
|
44
|
+
return if File::exist?(@local_help_dir)
|
14
45
|
FileUtils.mkdir_p(@local_help_dir, :verbose=>true)
|
15
46
|
Dir.entries(@template_dir).each{|file|
|
16
47
|
next if file=='help_template.org'
|
@@ -20,66 +51,60 @@ module MyHelp
|
|
20
51
|
}
|
21
52
|
end
|
22
53
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if cont[:opts][:short] == item or cont[:opts][:long] == item
|
37
|
-
o_key = key
|
38
|
-
break
|
54
|
+
def list_all
|
55
|
+
output = "\nList all helps\n"
|
56
|
+
local_help_entries.each do |file|
|
57
|
+
file_path=File.join(@local_help_dir,file)
|
58
|
+
title = file.split('.')[0]
|
59
|
+
help = auto_load(file_path)
|
60
|
+
next if help.nil?
|
61
|
+
begin
|
62
|
+
desc = help[:head][:cont].split("\n")[0]
|
63
|
+
rescue => e
|
64
|
+
puts e
|
65
|
+
puts "No head in #{file_path}".red
|
66
|
+
next
|
39
67
|
end
|
68
|
+
output << title.rjust(10)
|
69
|
+
output << ": #{desc}\n"
|
40
70
|
end
|
41
|
-
|
71
|
+
output
|
42
72
|
end
|
43
73
|
|
74
|
+
WrongFileName = Class.new(RuntimeError)
|
44
75
|
def list_help(file)
|
76
|
+
output = ''
|
45
77
|
file_path=File.join(@local_help_dir,file+'.org')
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
78
|
+
begin
|
79
|
+
help = auto_load(file_path)
|
80
|
+
rescue => e
|
81
|
+
raise WrongFileName, "No help named '#{file}' in the directory '#{local_help_dir}'."
|
50
82
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
col = 0
|
55
|
-
conts.each_pair do |key, item|
|
56
|
-
col_length = case col
|
57
|
-
when 0; print item.rjust(5)+", "
|
58
|
-
when 1; print item.ljust(15)+": "
|
59
|
-
else; print item
|
60
|
-
end
|
61
|
-
col += 1
|
83
|
+
help.each_pair do |key, conts|
|
84
|
+
output << conts[:cont] if key==:head
|
85
|
+
output << disp_opts( conts[:opts] )
|
62
86
|
end
|
63
|
-
|
87
|
+
output
|
64
88
|
end
|
65
89
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
print ": #{desc}\n".blue
|
90
|
+
WrongItemName = Class.new(RuntimeError)
|
91
|
+
def show_item(file, item)
|
92
|
+
output = ''
|
93
|
+
file_path=File.join(@local_help_dir,file+'.org')
|
94
|
+
help = auto_load(file_path)
|
95
|
+
select = select_item(help, item)
|
96
|
+
output << help[:head][:cont]
|
97
|
+
unless select then
|
98
|
+
raise WrongItemName, "No item entry: #{item}"
|
76
99
|
end
|
100
|
+
output << '-'*5+"\n"+select.to_s.green+"\n"
|
101
|
+
output << help[select][:cont]
|
77
102
|
end
|
78
103
|
|
79
104
|
def edit_help(file)
|
80
105
|
p target_help = File.join(@local_help_dir,file+'.org')
|
81
106
|
if local_help_entries.member?(file+'.org')
|
82
|
-
system "
|
107
|
+
system "#{@editor} #{target_help}"
|
83
108
|
else
|
84
109
|
puts "file #{target_help} does not exits in #{@local_help_dir}."
|
85
110
|
puts "init #{file} first."
|
@@ -114,39 +139,44 @@ module MyHelp
|
|
114
139
|
end
|
115
140
|
end
|
116
141
|
|
117
|
-
def
|
118
|
-
p
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
puts "file #{target_help} does not exits in #{@local_help_dir}."
|
132
|
-
puts "init #{file} first."
|
142
|
+
def search_help(word)
|
143
|
+
p find_char = word
|
144
|
+
system "ls #{@local_help_dir} | grep #{find_char}"
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
def select_item(help, item)
|
149
|
+
o_key = nil
|
150
|
+
help.each_pair do |key, cont|
|
151
|
+
next if key==:license or key==:head
|
152
|
+
if cont[:opts][:short] == item or cont[:opts][:long] == item
|
153
|
+
o_key = key
|
154
|
+
break
|
155
|
+
end
|
133
156
|
end
|
157
|
+
o_key
|
134
158
|
end
|
135
159
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
160
|
+
def disp_opts( conts )
|
161
|
+
output = ''
|
162
|
+
col = 0
|
163
|
+
conts.each_pair do |key, item|
|
164
|
+
col_length = case col
|
165
|
+
when 0; output << item.rjust(5)+", "
|
166
|
+
when 1; output << item.ljust(15)+": "
|
167
|
+
else; output << item
|
168
|
+
end
|
169
|
+
col += 1
|
170
|
+
end
|
171
|
+
output << "\n"
|
140
172
|
end
|
141
|
-
=end
|
142
173
|
|
143
|
-
private
|
144
174
|
def local_help_entries
|
145
175
|
entries= []
|
146
176
|
Dir.entries(@local_help_dir).each{|file|
|
147
|
-
# next unless file.include?('_')
|
177
|
+
# next unless file.include?('_')
|
148
178
|
next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
|
149
|
-
# next if file.match(/(.+)_e\.org/) # OK?
|
179
|
+
# next if file.match(/(.+)_e\.org/) # OK?
|
150
180
|
# next if file.match(/(.+)\.html/)
|
151
181
|
if file.match(/(.+)\.org$/) # OK?
|
152
182
|
entries << file
|
@@ -157,8 +187,8 @@ module MyHelp
|
|
157
187
|
|
158
188
|
def auto_load(file_path)
|
159
189
|
case File.extname(file_path)
|
160
|
-
# when '.yml'
|
161
|
-
# cont = YAML.load(File.read(file_path))
|
190
|
+
# when '.yml'
|
191
|
+
# cont = YAML.load(File.read(file_path))
|
162
192
|
when '.org'
|
163
193
|
cont = OrgToYaml.new(file_path).help_cont
|
164
194
|
else
|
data/lib/my_help/version.rb
CHANGED
data/my_help.gemspec
CHANGED
@@ -18,8 +18,8 @@ spec = Gem::Specification.new do |s|
|
|
18
18
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
s.add_development_dependency('rake')
|
20
20
|
s.add_development_dependency('rdoc')
|
21
|
-
s.add_development_dependency('thor')
|
22
21
|
s.add_development_dependency('rspec')
|
23
|
-
s.add_runtime_dependency('
|
22
|
+
s.add_runtime_dependency('thor')
|
23
|
+
# s.add_runtime_dependency('gli','2.17.1')
|
24
24
|
s.add_runtime_dependency "colorize"
|
25
25
|
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: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shigeot R. Nishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,33 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: thor
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: gli
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.17.1
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.17.1
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: colorize
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +91,6 @@ files:
|
|
105
91
|
- ".dockerignore"
|
106
92
|
- ".gitignore"
|
107
93
|
- ".rspec"
|
108
|
-
- ".ruby-version"
|
109
94
|
- ".travis.yml"
|
110
95
|
- ".yardoc/checksums"
|
111
96
|
- ".yardoc/complete"
|
@@ -120,7 +105,6 @@ files:
|
|
120
105
|
- README.rdoc
|
121
106
|
- README_en.org
|
122
107
|
- Rakefile
|
123
|
-
- Rakefile_gli
|
124
108
|
- doc/MyHelp.html
|
125
109
|
- doc/MyHelp/Control.html
|
126
110
|
- doc/OrgToYaml.html
|
@@ -150,8 +134,6 @@ files:
|
|
150
134
|
- lib/templates/org.org
|
151
135
|
- lib/templates/todo.org
|
152
136
|
- my_help.gemspec
|
153
|
-
- my_help.rdoc
|
154
|
-
- tmp.rb
|
155
137
|
homepage: https://github.com/daddygongon/my_help
|
156
138
|
licenses:
|
157
139
|
- MIT
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.3
|
data/Rakefile_gli
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'rake/clean'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rubygems/package_task'
|
4
|
-
require 'rdoc/task'
|
5
|
-
require 'cucumber'
|
6
|
-
require 'cucumber/rake/task'
|
7
|
-
Rake::RDocTask.new do |rd|
|
8
|
-
rd.main = "README.rdoc"
|
9
|
-
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
-
rd.title = 'Your application title'
|
11
|
-
end
|
12
|
-
|
13
|
-
spec = eval(File.read('my_help.gemspec'))
|
14
|
-
|
15
|
-
Gem::PackageTask.new(spec) do |pkg|
|
16
|
-
end
|
17
|
-
CUKE_RESULTS = 'results.html'
|
18
|
-
CLEAN << CUKE_RESULTS
|
19
|
-
desc 'Run features'
|
20
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
-
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
-
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
-
t.cucumber_opts = opts
|
24
|
-
t.fork = false
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
-
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
-
tag_opts = ' --tags ~@pending'
|
30
|
-
tag_opts = ' --tags @wip'
|
31
|
-
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
-
t.fork = false
|
33
|
-
end
|
34
|
-
|
35
|
-
task :cucumber => :features
|
36
|
-
task 'cucumber:wip' => 'features:wip'
|
37
|
-
task :wip => 'features:wip'
|
38
|
-
require 'rake/testtask'
|
39
|
-
Rake::TestTask.new do |t|
|
40
|
-
t.libs << "test"
|
41
|
-
t.test_files = FileList['test/*_test.rb']
|
42
|
-
end
|
43
|
-
|
44
|
-
task :default => [:test,:features]
|
data/my_help.rdoc
DELETED