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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b1990a34e246aa29e6f04d43d72541dc2dea4a1a9051f96541ce4d1b161006b
4
- data.tar.gz: c09e2c0ab0e5ad4d3848c7a4b1a6ab37913e8990f96bc0f260b2e8cfd719aac8
3
+ metadata.gz: c2ec697caa86da979b533f2002d7fa313b1fec88eb31e8f89a8b3176e09cccb5
4
+ data.tar.gz: 74d191374b68cda1545ac70f1e4ca4abea2fd0a867cb66c72fc66d29c8fab7e7
5
5
  SHA512:
6
- metadata.gz: 58cdbfd97c3030da1ef9f496ccd85efc5429693b276d87e95a61059a7a0edbcabee793fd9b6ae0f278e4a8f36de707853e071c4846998d64b90199e1c5d92e1a
7
- data.tar.gz: 04f66e3949c0d9aa0a9e96b83fc68da053825f1ad5ec25d3c177f8f8c180aa4fbcc059bda63350f70c5838111407f5b22cced14e1df1cbe1cd1b986cf747c6ba
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 --debug --source ~/ScrapboxData/HelpLine.json,~/ScrapboxData/masui-helpline.json
12
+ helpline --update ~/ScrapboxData/HelpLine.json ~/ScrapboxData/masui-helpline.json
12
13
 
13
14
  #
14
15
  # テスト
@@ -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
- # update
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
@@ -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 = []
@@ -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,pagedata|
77
+ pagedata.each { |title,data|
75
78
  # puts "...#{title}"
76
79
  dumpdata['pages'] << title
77
80
  processing_defs = false
78
- codeindent = nil
79
- pagedata.each { |line|
80
- if !codeindent
81
- if line =~ /^code:/
82
- codeindent = 0
83
- next
84
- end
85
- else
86
- line =~ /^(\s*)/
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
- processing_defs = true
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
 
@@ -1,3 +1,3 @@
1
1
  module Helpline
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Masui