helpline 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/helpline +122 -87
- data/lib/helpline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b2bc48034db45fc57d3f69b5d992dc7ab045e7acf82d48fe0f225398ee6fdb9
|
4
|
+
data.tar.gz: f2f1cfcfb59fd2c7cbafd8ac650cf569caac793d3ebf3821b8032a9529370acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c646c3edc7b3c5ca9120db0802e446ffdae29e76e475d228feb23fcc5a43568a7f237be646f2f8e1ff1399d6b43dbe69e0d186324d4c3ad6456528cfda4a19a
|
7
|
+
data.tar.gz: 791d893b90bc215c7ee063db030d17f7b0549af829683d59d59a7af54e3a4bc4650462a1854f261681e39211d17695af2b3f940039ce19682f035a8dfb13ef5f
|
data/exe/helpline
CHANGED
@@ -20,74 +20,100 @@ class HelpLine
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def initialize
|
23
|
-
@pagedata = {}
|
24
|
-
@project = Scrapbox::Project.new("HelpLine")
|
23
|
+
# @pagedata = {}
|
24
|
+
# @project = Scrapbox::Project.new("HelpLine")
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
#
|
29
|
-
# ページデータ取得
|
30
|
-
#
|
31
|
-
puts "-----------------ページデータを取得"
|
32
|
-
@project.pages.each { |title,page|
|
33
|
-
puts "...#{title}"
|
34
|
-
@pagedata[title] = page.text.split(/\n/)
|
35
|
-
}
|
36
|
-
|
27
|
+
def update(sources) # sources = ['HelpLine', '~/ScrapboxData/masui.json', ...]
|
37
28
|
dumpdata = {}
|
38
29
|
dumpdata['codes'] = []
|
39
30
|
dumpdata['defs'] = []
|
40
31
|
dumpdata['pages'] = []
|
41
32
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
33
|
+
sources.each { |source|
|
34
|
+
pagedata = {}
|
35
|
+
source = File.expand_path(source)
|
36
|
+
if File.exist?(source)
|
37
|
+
puts "-----------------ページデータをJSONデータ(#{source})から取得"
|
38
|
+
data = JSON.parse(File.read(source))
|
39
|
+
data['pages'].each { |page|
|
40
|
+
title = page['title']
|
41
|
+
puts "...#{title}"
|
42
|
+
pagedata[title] = page['lines']
|
43
|
+
}
|
44
|
+
elsif source =~ /^[a-zA-Z\-]+$/ # たぶんHelpLineプロジェクト
|
45
|
+
puts "-----------------ページデータをScrapbox(#{source})から取得"
|
46
|
+
project = Scrapbox::Project.new(source)
|
47
|
+
project.pages.each { |title,page|
|
48
|
+
puts "...#{title}"
|
49
|
+
pagedata[title] = page.text.split(/\n/)
|
50
|
+
}
|
51
|
+
else
|
52
|
+
next
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# 関数/定数を評価"
|
57
|
+
#
|
58
|
+
puts "-----------------関数/定数を取得"
|
59
|
+
src = nil
|
60
|
+
indent = ''
|
61
|
+
code = []
|
62
|
+
pagedata.each { |title,lines|
|
63
|
+
puts "...#{title}"
|
64
|
+
lines.each { |line|
|
65
|
+
if src && line =~ /^#{indent}\s+/ then
|
66
|
+
code << line
|
67
|
+
elsif line =~ /^code:(.*\.rb)$/ then
|
68
|
+
src = $2
|
69
|
+
indent = $1
|
70
|
+
code = []
|
71
|
+
elsif src then
|
72
|
+
dumpdata['codes'] << code.join("\n")
|
73
|
+
src = nil
|
74
|
+
indent = ''
|
75
|
+
code = []
|
76
|
+
else
|
77
|
+
end
|
78
|
+
}
|
79
|
+
if code.length > 0
|
80
|
+
dumpdata['codes'] << code.join("\n")
|
54
81
|
end
|
55
82
|
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
69
|
-
else
|
70
|
-
line =~ /^(\s*)/
|
71
|
-
if line.length < codeindent
|
72
|
-
codeindent = nil
|
83
|
+
puts "-----------------HelpLineデータを検出"
|
84
|
+
pagedata.each { |title,pagedata|
|
85
|
+
puts "...#{title}"
|
86
|
+
dumpdata['pages'] << title
|
87
|
+
processing_defs = false
|
88
|
+
codeindent = nil
|
89
|
+
pagedata.each { |line|
|
90
|
+
if !codeindent
|
91
|
+
if line =~ /^code:/
|
92
|
+
codeindent = $1.length
|
93
|
+
next
|
94
|
+
end
|
73
95
|
else
|
74
|
-
|
96
|
+
line =~ /^(\s*)/
|
97
|
+
if line.length < codeindent
|
98
|
+
codeindent = nil
|
99
|
+
else
|
100
|
+
next
|
101
|
+
end
|
75
102
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
103
|
+
if line =~ /^\s*[\$\%\?]/
|
104
|
+
if line =~ /^\%/ && !processing_defs
|
105
|
+
puts "'$'で始まる用例定義なしでコマンドを定義しようとしています"
|
106
|
+
exit
|
107
|
+
end
|
108
|
+
dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
|
109
|
+
processing_defs = true
|
110
|
+
else
|
111
|
+
processing_defs = false
|
82
112
|
end
|
83
|
-
|
84
|
-
processing_defs = true
|
85
|
-
else
|
86
|
-
processing_defs = false
|
87
|
-
end
|
113
|
+
}
|
88
114
|
}
|
89
115
|
}
|
90
|
-
|
116
|
+
|
91
117
|
File.open(datafile,"w"){ |f|
|
92
118
|
f.puts dumpdata.to_json
|
93
119
|
}
|
@@ -109,14 +135,12 @@ class HelpLine
|
|
109
135
|
Curses.print " % " + list[i][1]
|
110
136
|
}
|
111
137
|
Curses.move(sel*2,0)
|
112
|
-
# Curses.down
|
113
|
-
# Curses.tol
|
114
138
|
end
|
115
139
|
|
116
|
-
def helpline(
|
140
|
+
def helpline(sources,test=nil,debug=nil)
|
117
141
|
data = JSON.parse(File.read(datafile))
|
118
142
|
unless data['pages'] # データ型式変換があったので
|
119
|
-
|
143
|
+
update sources
|
120
144
|
data = JSON.parse(File.read(datafile))
|
121
145
|
end
|
122
146
|
|
@@ -133,23 +157,24 @@ class HelpLine
|
|
133
157
|
# HelpLineエントリ
|
134
158
|
#
|
135
159
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
logfile = (debug ? "/tmp/helpline-defs" : "/dev/null")
|
161
|
+
File.open(logfile,"w"){ |f| # ログを残す場合
|
162
|
+
entries = []
|
163
|
+
data['defs'].each { |line|
|
164
|
+
if line =~ /^\s*[\$\?]\s*(.*)$/ # $....
|
165
|
+
entries << $1
|
166
|
+
elsif line =~ /^\s*\%\s*(.*)$/ # %....
|
167
|
+
cmd = $1
|
168
|
+
entries.each { |l|
|
169
|
+
desc = eval('"' + l + '"')
|
170
|
+
f.puts "desc: #{desc}"
|
171
|
+
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
172
|
+
}
|
173
|
+
f.puts "cmd: #{cmd}"
|
174
|
+
entries = []
|
175
|
+
end
|
176
|
+
}
|
151
177
|
}
|
152
|
-
# }
|
153
178
|
|
154
179
|
res = g.generate " #{ARGV.join(' ').sub(/\[/,'').sub(/\]/,'')} "
|
155
180
|
|
@@ -179,7 +204,8 @@ class HelpLine
|
|
179
204
|
end
|
180
205
|
}
|
181
206
|
|
182
|
-
if options['t'] then
|
207
|
+
# if options['t'] || options['test'] then
|
208
|
+
if test
|
183
209
|
puts list
|
184
210
|
exit
|
185
211
|
end
|
@@ -253,23 +279,32 @@ class HelpLine
|
|
253
279
|
end
|
254
280
|
end
|
255
281
|
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
|
262
|
-
|
282
|
+
# アップデート
|
283
|
+
# % helpline -u
|
284
|
+
# データを指定してアップデート
|
285
|
+
# % helpline -u -s HelpLine,/Users/masui/ScrapboxData/masui-HelpLine.json
|
286
|
+
# テスト
|
287
|
+
# % helpline -t
|
288
|
+
#
|
263
289
|
|
264
290
|
helpline = HelpLine.new
|
265
291
|
|
266
|
-
|
292
|
+
options = ARGV.getopts('utds:','update','test','source:','debug')
|
293
|
+
update = options['u'] || options['update']
|
294
|
+
test = options['t'] || options['test']
|
295
|
+
debug = options['d'] || options['debug']
|
296
|
+
sources = ['HelpLine']
|
297
|
+
if options['s'] || options['source']
|
298
|
+
sources = (options['s'] || options['source']).split(/,/)
|
299
|
+
end
|
300
|
+
|
301
|
+
if !File.exist?(helpline.datafile) && !update
|
267
302
|
puts "#{helpline.datafile}を作成します..."
|
268
|
-
helpline.
|
303
|
+
helpline.update sources
|
269
304
|
end
|
270
305
|
|
271
|
-
if
|
272
|
-
helpline.
|
306
|
+
if update then
|
307
|
+
helpline.update sources
|
273
308
|
else
|
274
|
-
helpline.helpline
|
309
|
+
helpline.helpline sources, test, debug
|
275
310
|
end
|
data/lib/helpline/version.rb
CHANGED