helpline 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +2 -1
- data/exe/helpline +8 -5
- data/lib/helpline/generate.rb +1 -0
- data/lib/helpline/update.rb +23 -20
- 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: c2ec697caa86da979b533f2002d7fa313b1fec88eb31e8f89a8b3176e09cccb5
|
4
|
+
data.tar.gz: 74d191374b68cda1545ac70f1e4ca4abea2fd0a867cb66c72fc66d29c8fab7e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4ff55951f5f64ffec395028f4069c74c3251409850d3e7200738bb03a461b2677eef60b1e17f385cf3a3f7511b00405636466e1e759d622dcd4bfeefcb8eab
|
7
|
+
data.tar.gz: 3801b7240aea007585935c50bcc3c74b6fd06410a4801a0f909b9852a301c4ced1e963ef0957e60e56f82420d4601620f8a96cd235ed6c4c1a82ccc942bbfea7
|
data/Makefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
.PHONY: test
|
1
2
|
#
|
2
3
|
# Gem版
|
3
4
|
#
|
@@ -8,7 +9,7 @@ update:
|
|
8
9
|
helpline --update
|
9
10
|
|
10
11
|
update-local:
|
11
|
-
helpline --update
|
12
|
+
helpline --update ~/ScrapboxData/HelpLine.json ~/ScrapboxData/masui-helpline.json
|
12
13
|
|
13
14
|
#
|
14
15
|
# テスト
|
data/exe/helpline
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
|
+
#
|
4
|
+
# HelpLineのメインプログラム
|
5
|
+
#
|
3
6
|
|
4
7
|
require 'optparse'
|
5
8
|
|
@@ -21,20 +24,20 @@ helpline = HelpLine.new
|
|
21
24
|
|
22
25
|
options = ARGV.getopts('utds:','update','test','source:','debug')
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
#
|
27
|
+
debug = options['d'] || options['debug']
|
28
|
+
|
29
|
+
# データ更新
|
27
30
|
if options['u'] || options['update'] # ~/.helpline.json更新
|
28
31
|
sources = (ARGV.length > 0 ? ARGV : ['HelpLine'])
|
29
32
|
helpline.update sources
|
30
33
|
exit
|
31
34
|
end
|
32
35
|
|
36
|
+
# テスト
|
33
37
|
if options['t'] || options['test'] # テスト
|
34
|
-
puts helpline.generate " #{ARGV.join(' ')} "
|
38
|
+
puts helpline.generate " #{ARGV.join(' ')} ", debug
|
35
39
|
exit
|
36
40
|
end
|
37
41
|
|
38
|
-
debug = options['d'] || options['debug']
|
39
42
|
query = " #{ARGV.join(' ').sub(/\[/,'').sub(/\]/,'')} "
|
40
43
|
helpline.run query, debug
|
data/lib/helpline/generate.rb
CHANGED
@@ -36,6 +36,7 @@ class HelpLine
|
|
36
36
|
desc = eval('"' + l + '"')
|
37
37
|
f.puts "desc: #{desc}"
|
38
38
|
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
39
|
+
# puts "g.add(\"#{desc.force_encoding('utf-8')}\",\"#{cmd.force_encoding('utf-8')}\")"
|
39
40
|
}
|
40
41
|
f.puts "cmd: #{cmd}"
|
41
42
|
entries = []
|
data/lib/helpline/update.rb
CHANGED
@@ -15,9 +15,11 @@ class HelpLine
|
|
15
15
|
|
16
16
|
sources.each { |source|
|
17
17
|
pagedata = {}
|
18
|
+
projectname = ''
|
18
19
|
if File.exist?(source)
|
19
20
|
puts "-----------------ページデータをJSONデータ(#{source})から取得"
|
20
21
|
data = JSON.parse(File.read(source))
|
22
|
+
projectname = data['name']
|
21
23
|
data['pages'].each { |page|
|
22
24
|
title = page['title']
|
23
25
|
puts "...#{title}"
|
@@ -25,6 +27,7 @@ class HelpLine
|
|
25
27
|
}
|
26
28
|
elsif source =~ /^[a-zA-Z\-]+$/ # たぶんHelpLineプロジェクト
|
27
29
|
puts "-----------------ページデータをScrapbox(#{source})から取得"
|
30
|
+
projectname = source
|
28
31
|
project = Scrapbox::Project.new(source)
|
29
32
|
project.pages.each { |title,page|
|
30
33
|
puts "...#{title}"
|
@@ -71,36 +74,36 @@ class HelpLine
|
|
71
74
|
end
|
72
75
|
}
|
73
76
|
puts "-----------------HelpLineデータを検出"
|
74
|
-
pagedata.each { |title,
|
77
|
+
pagedata.each { |title,data|
|
75
78
|
# puts "...#{title}"
|
76
79
|
dumpdata['pages'] << title
|
77
80
|
processing_defs = false
|
78
|
-
|
79
|
-
|
80
|
-
if
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
if $1.length < codeindent + 1
|
88
|
-
codeindent = nil
|
89
|
-
else
|
90
|
-
next
|
91
|
-
end
|
92
|
-
end
|
93
|
-
if line =~ /^[\$\%\?]/
|
94
|
-
if line =~ /^\%/ && !processing_defs
|
95
|
-
puts "'$'で始まる用例定義なしでコマンドを定義しようとしています"
|
81
|
+
cmd_defined = false
|
82
|
+
data.each { |line|
|
83
|
+
if line =~ /^[\$\?]/
|
84
|
+
dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
|
85
|
+
cmd_defined = false
|
86
|
+
processing_defs = true
|
87
|
+
elsif line =~ /^\%/
|
88
|
+
if !processing_defs
|
89
|
+
puts "'$'で始まる用例定義なしでコマンドを定義しようとしています (#{title})"
|
96
90
|
exit
|
97
91
|
end
|
98
92
|
dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
|
99
|
-
|
93
|
+
cmd_defined = true
|
94
|
+
processing_defs = false
|
95
|
+
elsif processing_defs && !cmd_defined
|
96
|
+
dumpdata['defs'] << "% open 'https://Scrapbox.io/#{projectname}/#{title}' {#{dumpdata['pages'].length-1}}"
|
97
|
+
cmd_defined = false
|
98
|
+
processing_defs = false
|
100
99
|
else
|
100
|
+
cmd_defined = false
|
101
101
|
processing_defs = false
|
102
102
|
end
|
103
103
|
}
|
104
|
+
if processing_defs && !cmd_defined
|
105
|
+
dumpdata['defs'] << "% open 'https://Scrapbox.io/#{projectname}/#{title}' {#{dumpdata['pages'].length-1}}"
|
106
|
+
end
|
104
107
|
}
|
105
108
|
}
|
106
109
|
|
data/lib/helpline/version.rb
CHANGED