githelp 0.3.4 → 0.3.5

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/githelp +24 -5
  3. data/lib/githelp/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2399358a578fc4982f40df664fa591f07be16622a7557213ca3ff949870c7ba9
4
- data.tar.gz: d6bb36c95bd36c6bf61a7daa8da22d0ec17299550dd5138505a3aa52d8a77871
3
+ metadata.gz: 0dfa9adad7bd2f69ed8ea736bd211e3709ccf32a86e1a98fa10677620c6ef4e4
4
+ data.tar.gz: b44b567936f41913773977f3331dbbeff6a462f5932ebd51a5f2d7aeffe83300
5
5
  SHA512:
6
- metadata.gz: 979c3fc27e26ef71241263d29a9dbd76370d5d3e7d5b28be9f507f31674e829ecd01bb2380afb5e7c1de864ac78b0b1f7de42f70486acc5b39c05a86a02b144e
7
- data.tar.gz: 8595537506f2f4e8e53b84aedc68c9a22e13c30e606d3a1c10c56f4df251c6d759cee6561696ea4b6e8765e6fbe0703fd0846bd05ed900fcecf987102b659080
6
+ metadata.gz: a58961c4276d2d0082de92a82e1a06e5a3d368bc53bbd4f1384b4f8b4067d6a863856b757df2c51a93112c8eb19b64634e08ab12431116b7e0523fe264c822eb
7
+ data.tar.gz: e90623ed545071fc6a3f4f691f3bd1dc83a4989d649bdcc1c106357e29076e33e12f95eb0d3d38ef2177531360eb6ec761b6a18f7efc4684059a910280da2bc5
@@ -33,6 +33,7 @@ class GitHelp
33
33
  dumpdata = {}
34
34
  dumpdata['codes'] = []
35
35
  dumpdata['defs'] = []
36
+ dumpdata['pages'] = []
36
37
 
37
38
  #
38
39
  # 関数/定数を評価"
@@ -52,6 +53,7 @@ class GitHelp
52
53
  puts "-----------------GitHelpデータを検出"
53
54
  @pagedata.each { |title,pagedata|
54
55
  puts "...#{title}"
56
+ dumpdata['pages'] << title
55
57
  processing_defs = false
56
58
  codeindent = nil
57
59
  pagedata.each { |line|
@@ -74,7 +76,7 @@ class GitHelp
74
76
  puts "'$'で始まる用例定義なしでコマンドを定義しようとしています"
75
77
  exit
76
78
  end
77
- dumpdata['defs'] << line
79
+ dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
78
80
  processing_defs = true
79
81
  else
80
82
  processing_defs = false
@@ -89,6 +91,10 @@ class GitHelp
89
91
 
90
92
  def githelp(pager)
91
93
  data = JSON.parse(File.read(datafile))
94
+ unless data['pages'] # データ型式変換があったので
95
+ getdata
96
+ data = JSON.parse(File.read(datafile))
97
+ end
92
98
 
93
99
  #
94
100
  # 関数定義などをeval
@@ -129,21 +135,34 @@ class GitHelp
129
135
  }
130
136
 
131
137
  if pager == 'peco' then
138
+ no = {}
132
139
  res = IO.popen(pager, "r+") {|io|
133
140
  list.each_with_index { |entry,ind|
134
- io.puts "#[#{ind}] #{entry[0]}"
141
+ entry[0].sub!(/\s*{(\d*)}$/,'')
142
+ entry[1].sub!(/\s*{(\d*)}$/,'')
143
+ no[entry[0]] = $1.to_i
144
+ io.puts "[#{ind}] #{entry[0]}"
135
145
  io.puts " #{entry[1]}"
136
146
  }
137
147
  io.close_write
138
148
  io.gets
139
149
  }
140
150
  if res
141
- if res =~ /^\#\[(\d+)\]/
151
+ if res =~ /^\[(\d+)\]/
152
+ desc = list[$1.to_i][0]
142
153
  cmd = list[$1.to_i][1]
143
154
  else
155
+ desc = ''
156
+ list.each { |entry|
157
+ desc = entry[0] if entry[1].sub(/^\s*/,'') == res.chomp.sub(/^\s*/,'')
158
+ }
144
159
  cmd = res.sub(/^\s*/,'')
145
160
  end
146
- print "「#{cmd.chomp}」 を実行しますか? "
161
+
162
+ puts "データ: http://scrapbox.io/GitHelp/#{data['pages'][no[desc]]}"
163
+ puts
164
+ puts "#{desc} ために"
165
+ print "コマンド「#{cmd.chomp}」 を実行しますか? (Y) "
147
166
  ans = STDIN.gets
148
167
  if ans =~ /^y/i || ans == "\n"
149
168
  system cmd
@@ -152,7 +171,7 @@ class GitHelp
152
171
  else
153
172
  res = IO.popen(pager, "w") {|io|
154
173
  list.each_with_index { |entry,ind|
155
- io.puts "#[#{ind}] #{entry[0]}"
174
+ io.puts "[#{ind}] #{entry[0]}"
156
175
  io.puts " #{entry[1]}"
157
176
  }
158
177
  }
@@ -1,3 +1,3 @@
1
1
  module GitHelp
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githelp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Masui