tidtools 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -2
- data/Manifest.txt +1 -0
- data/bin/tidgrep +1 -1
- data/bin/twgrep +1 -1
- data/lib/tidgrep/cli.rb +7 -265
- data/lib/tidgrep/tidgrep.rb +281 -0
- data/lib/tidtools.rb +1 -1
- data/lib/tidtools/tiddle.rb +8 -0
- data/lib/twgrep/cli.rb +8 -4
- metadata +4 -3
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 0.0.9 2010/06/20
|
2
|
+
|
3
|
+
* デフォルトで検索する環境変数の名前を変更
|
4
|
+
* TIDGREP_PATH → TIDDLYWIKI_PATHS
|
5
|
+
|
6
|
+
* TiddlyWiki検索対象を複数個指定可能に
|
7
|
+
* -fオプション、環境変数TIDDLYWIKI_PATHS、どちらでも空白で複数のファイルをつなげることが出来るようになった
|
8
|
+
* -nオプションを使うことで、ファイルリストの中から一つを検索対象に絞り込むことも可能
|
9
|
+
|
10
|
+
* twgrepに-tオプションを追加、タイトルによる絞り込みを可能に
|
11
|
+
* デフォルトは "Tweet"
|
12
|
+
|
13
|
+
* 古いバージョンのTiddlyWiki(GTDStyleWiki等)で、改行コードが正しく認識されないバグを修正
|
14
|
+
|
1
15
|
=== 0.0.8 2010/05/19
|
2
16
|
|
3
17
|
* Manifest.txt更新忘れ
|
@@ -31,6 +45,5 @@
|
|
31
45
|
|
32
46
|
=== 0.0.1 2010-04-23
|
33
47
|
|
34
|
-
*
|
35
|
-
* Initial release
|
48
|
+
* ファーストリリース
|
36
49
|
|
data/Manifest.txt
CHANGED
data/bin/tidgrep
CHANGED
data/bin/twgrep
CHANGED
data/lib/tidgrep/cli.rb
CHANGED
@@ -1,272 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require File.join(File.dirname(__FILE__), '../
|
3
|
-
require File.join(File.dirname(__FILE__), '../tidtools/platform')
|
2
|
+
require File.join(File.dirname(__FILE__), '../tidgrep/tidgrep')
|
4
3
|
require 'optparse'
|
5
|
-
require 'kconv'
|
6
4
|
|
7
5
|
module Tidgrep
|
8
|
-
class Tidgrep
|
9
|
-
# 圧縮表示時のパラメータ
|
10
|
-
MATCH_LINE_COMP_NUM = 5
|
11
|
-
|
12
|
-
MATCH_ONLY_TITLE_COMP_NUM = 5
|
13
|
-
|
14
|
-
MATCH_TIDDLE_LINE_NUM = 3
|
15
|
-
MATCH_TIDDLE_COMP_NUM = 5
|
16
|
-
|
17
|
-
MATCH_TWEET_LINE_NUM = 3
|
18
|
-
MATCH_TWEET_COMP_NUM = 5
|
19
|
-
|
20
|
-
def initialize(stdout, file_name, title, regexp_option, report, match_rule, is_comp, keywords, kcode)
|
21
|
-
@stdout = stdout
|
22
|
-
@file_name = file_name
|
23
|
-
@title = title
|
24
|
-
@regexp_option = regexp_option
|
25
|
-
@report = report
|
26
|
-
@match_rule = match_rule
|
27
|
-
@is_comp = is_comp
|
28
|
-
@kcode = kcode
|
29
|
-
|
30
|
-
@title_regexp = @title && Regexp.new(@title, @regexp_option)
|
31
|
-
|
32
|
-
@content_regexps = []
|
33
|
-
keywords.each do |keyword|
|
34
|
-
@content_regexps << Regexp.new(kcode2utf(keyword), @regexp_option)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def validOption?
|
39
|
-
return false if !@file_name
|
40
|
-
return @title || @content_regexps.size > 0
|
41
|
-
end
|
42
|
-
|
43
|
-
def match?(target)
|
44
|
-
@content_regexps.each do |content_regexp|
|
45
|
-
return false if content_regexp !~ target
|
46
|
-
end
|
47
|
-
return true
|
48
|
-
end
|
49
|
-
|
50
|
-
def kcode2utf(str)
|
51
|
-
if (@kcode != Kconv::UTF8)
|
52
|
-
str.kconv(Kconv::UTF8, @kcode)
|
53
|
-
else
|
54
|
-
str
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def utf2kcode(str)
|
59
|
-
if (@kcode != Kconv::UTF8)
|
60
|
-
str.kconv(@kcode, Kconv::UTF8)
|
61
|
-
else
|
62
|
-
str
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def print(msg)
|
67
|
-
@stdout.print utf2kcode(msg)
|
68
|
-
end
|
69
|
-
|
70
|
-
def puts(msg)
|
71
|
-
@stdout.puts utf2kcode(msg)
|
72
|
-
end
|
73
|
-
|
74
|
-
def match_line
|
75
|
-
tiddles = Tiddle.parse_sort_modified(@file_name)
|
76
|
-
|
77
|
-
match_lines = 0
|
78
|
-
search_lines = 0
|
79
|
-
match_tiddles = 0
|
80
|
-
|
81
|
-
is_limit = false
|
82
|
-
|
83
|
-
tiddles.each do |tiddle|
|
84
|
-
next if (@title && tiddle.title !~ @title_regexp)
|
85
|
-
is_match_tiddle = false
|
86
|
-
line_no = 1
|
87
|
-
|
88
|
-
tiddle.content.each_line do |line|
|
89
|
-
if (match? line)
|
90
|
-
match_lines += 1
|
91
|
-
|
92
|
-
unless is_limit
|
93
|
-
puts "#{tiddle.title}:#{line_no}:#{line}"
|
94
|
-
|
95
|
-
if (@is_comp && match_lines >= MATCH_LINE_COMP_NUM)
|
96
|
-
is_limit = true
|
97
|
-
print ".\n.\n"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
unless is_match_tiddle
|
103
|
-
match_tiddles += 1
|
104
|
-
is_match_tiddle = true
|
105
|
-
end
|
106
|
-
end
|
107
|
-
line_no += 1
|
108
|
-
search_lines += 1
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
if (@report)
|
113
|
-
puts "------------------------------"
|
114
|
-
puts "search lines : #{search_lines}"
|
115
|
-
puts "match lines : #{match_lines}"
|
116
|
-
puts "total tiddles : #{tiddles.size}"
|
117
|
-
puts "match tiddles : #{match_tiddles}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def match_only_title
|
122
|
-
tiddles = Tiddle.parse_sort_modified(@file_name)
|
123
|
-
|
124
|
-
match_tiddles = 0
|
125
|
-
|
126
|
-
is_limit = false
|
127
|
-
|
128
|
-
tiddles.each do |tiddle|
|
129
|
-
next if (@title && tiddle.title !~ @title_regexp)
|
130
|
-
|
131
|
-
match_tiddles += 1
|
132
|
-
|
133
|
-
unless is_limit
|
134
|
-
puts tiddle.title
|
135
|
-
|
136
|
-
if (@is_comp && match_tiddles >= MATCH_ONLY_TITLE_COMP_NUM)
|
137
|
-
is_limit = true
|
138
|
-
print ".\n.\n"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
if (@report)
|
144
|
-
puts "------------------------------"
|
145
|
-
puts "total tiddles : #{tiddles.size}"
|
146
|
-
puts "match tiddles : #{match_tiddles}"
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
def match_tiddle
|
151
|
-
tiddles = Tiddle.parse_sort_modified(@file_name)
|
152
|
-
|
153
|
-
search_tiddles = 0
|
154
|
-
match_tiddles = 0
|
155
|
-
|
156
|
-
is_limit = false
|
157
|
-
|
158
|
-
tiddles.each do |tiddle|
|
159
|
-
next if (@title && tiddle.title !~ @title_regexp)
|
160
|
-
search_tiddles += 1
|
161
|
-
|
162
|
-
if (match? tiddle.content)
|
163
|
-
match_tiddles += 1
|
164
|
-
|
165
|
-
unless is_limit
|
166
|
-
puts "--- #{tiddle.title} --------------------"
|
167
|
-
|
168
|
-
unless @is_comp
|
169
|
-
puts tiddle.content
|
170
|
-
else
|
171
|
-
tiddle_a = tiddle.content.split(/\n/)
|
172
|
-
|
173
|
-
if (tiddle_a.size <= MATCH_TIDDLE_LINE_NUM)
|
174
|
-
print tiddle.content
|
175
|
-
else
|
176
|
-
print tiddle_a[0..(MATCH_TIDDLE_LINE_NUM - 1)].join("\n") + "\n.\n"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
if (@is_comp && match_tiddles >= MATCH_TIDDLE_COMP_NUM)
|
181
|
-
is_limit = true
|
182
|
-
print ".\n.\n"
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
if (@report)
|
189
|
-
puts "------------------------------"
|
190
|
-
puts "total tiddles : #{tiddles.size}"
|
191
|
-
puts "search tiddles : #{search_tiddles}"
|
192
|
-
puts "match tiddles : #{match_tiddles}"
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def match_tweet
|
197
|
-
tiddles = Tiddle.parse_sort_modified(@file_name)
|
198
|
-
|
199
|
-
search_tweets = 0
|
200
|
-
match_tweets = 0
|
201
|
-
|
202
|
-
is_limit = false
|
203
|
-
|
204
|
-
tiddles.each do |tiddle|
|
205
|
-
next if (@title && tiddle.title !~ @title_regexp)
|
206
|
-
is_match_tiddle = false
|
207
|
-
|
208
|
-
tweets = tiddle.content.split(/^----+\n/)
|
209
|
-
search_tweets += tweets.size
|
210
|
-
|
211
|
-
tweets.each do |tweet|
|
212
|
-
if (match? tweet)
|
213
|
-
match_tweets += 1
|
214
|
-
unless is_limit
|
215
|
-
unless is_match_tiddle
|
216
|
-
puts "--- #{tiddle.title} --------------------"
|
217
|
-
is_match_tiddle = true
|
218
|
-
else
|
219
|
-
puts "----\n"
|
220
|
-
end
|
221
|
-
|
222
|
-
unless @is_comp
|
223
|
-
print tweet
|
224
|
-
else
|
225
|
-
tweet_a = tweet.split(/\n/)
|
226
|
-
|
227
|
-
if (tweet_a.size <= MATCH_TWEET_LINE_NUM)
|
228
|
-
print tweet
|
229
|
-
else
|
230
|
-
print tweet_a[0..(MATCH_TWEET_LINE_NUM - 1)].join("\n") + "\n.\n"
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
if (@is_comp && match_tweets >= MATCH_TWEET_COMP_NUM)
|
235
|
-
is_limit = true
|
236
|
-
print ".\n.\n"
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
if (@report)
|
244
|
-
puts "------------------------------"
|
245
|
-
puts "search tweets : #{search_tweets}"
|
246
|
-
puts "match tweets : #{match_tweets}"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def execute
|
251
|
-
if (@content_regexps.size > 0)
|
252
|
-
case @match_rule
|
253
|
-
when "line"
|
254
|
-
match_line
|
255
|
-
when "tiddle"
|
256
|
-
match_tiddle
|
257
|
-
when "tweet"
|
258
|
-
match_tweet
|
259
|
-
end
|
260
|
-
else
|
261
|
-
match_only_title
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
end
|
266
|
-
|
267
6
|
class CLI
|
268
7
|
def self.execute(stdout, arguments=[])
|
269
|
-
|
8
|
+
file_names = ENV['TIDDLYWIKI_PATHS'].split
|
9
|
+
file_no = 0
|
270
10
|
title = nil
|
271
11
|
regexp_option = 0
|
272
12
|
report = false
|
@@ -275,7 +15,8 @@ module Tidgrep
|
|
275
15
|
kcode = Platform.get_shell_kcode
|
276
16
|
|
277
17
|
opt = OptionParser.new('tidgrep [option] keyword')
|
278
|
-
opt.on('-f
|
18
|
+
opt.on('-f TIDDLYWIKI_PATHS', '--filename TIDDLYWIKI_PATHS', 'TiddlyWiki path names') {|v| file_names = v.split }
|
19
|
+
opt.on('-n SELECT_NO', '--fileno SELECT_NO', 'file select number. (0 is all. 1,2,3,4.. is select only one.)') {|v| file_no = v.to_i }
|
279
20
|
opt.on('-t TITLE', '--title TITLE', 'match title') {|v| title = v }
|
280
21
|
opt.on('-i', '--ignore', 'ignore case') {|v| regexp_option |= Regexp::IGNORECASE }
|
281
22
|
opt.on('-r', '--report', 'disp report') {|v| report = true }
|
@@ -284,7 +25,8 @@ module Tidgrep
|
|
284
25
|
opt.parse!(arguments)
|
285
26
|
|
286
27
|
obj = Tidgrep.new(stdout,
|
287
|
-
|
28
|
+
file_names,
|
29
|
+
file_no,
|
288
30
|
title,
|
289
31
|
regexp_option,
|
290
32
|
report,
|
@@ -0,0 +1,281 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.dirname(__FILE__), '../tidtools/tiddle')
|
3
|
+
require File.join(File.dirname(__FILE__), '../tidtools/platform')
|
4
|
+
require 'kconv'
|
5
|
+
|
6
|
+
module Tidgrep
|
7
|
+
class Tidgrep
|
8
|
+
# 圧縮表示時のパラメータ
|
9
|
+
MATCH_LINE_COMP_NUM = 5
|
10
|
+
|
11
|
+
MATCH_ONLY_TITLE_COMP_NUM = 5
|
12
|
+
|
13
|
+
MATCH_TIDDLE_LINE_NUM = 3
|
14
|
+
MATCH_TIDDLE_COMP_NUM = 5
|
15
|
+
|
16
|
+
MATCH_TWEET_LINE_NUM = 3
|
17
|
+
MATCH_TWEET_COMP_NUM = 5
|
18
|
+
|
19
|
+
def initialize(stdout, file_names, file_no, title, regexp_option, report, match_rule, is_comp, keywords, kcode)
|
20
|
+
@stdout = stdout
|
21
|
+
@file_names = file_names
|
22
|
+
@file_no = file_no
|
23
|
+
@title = title
|
24
|
+
@regexp_option = regexp_option
|
25
|
+
@report = report
|
26
|
+
@match_rule = match_rule
|
27
|
+
@is_comp = is_comp
|
28
|
+
@kcode = kcode
|
29
|
+
|
30
|
+
@title_regexp = @title && Regexp.new(@title, @regexp_option)
|
31
|
+
|
32
|
+
@content_regexps = []
|
33
|
+
keywords.each do |keyword|
|
34
|
+
@content_regexps << Regexp.new(kcode2utf(keyword), @regexp_option)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def validOption?
|
39
|
+
return false if @file_names.empty?
|
40
|
+
return @title || @content_regexps.size > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
def match?(target)
|
44
|
+
@content_regexps.each do |content_regexp|
|
45
|
+
return false if content_regexp !~ target
|
46
|
+
end
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
|
50
|
+
def kcode2utf(str)
|
51
|
+
if (@kcode != Kconv::UTF8)
|
52
|
+
str.kconv(Kconv::UTF8, @kcode)
|
53
|
+
else
|
54
|
+
str
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def utf2kcode(str)
|
59
|
+
if (@kcode != Kconv::UTF8)
|
60
|
+
str.kconv(@kcode, Kconv::UTF8)
|
61
|
+
else
|
62
|
+
str
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def print(msg)
|
67
|
+
@stdout.print utf2kcode(msg)
|
68
|
+
end
|
69
|
+
|
70
|
+
def puts(msg)
|
71
|
+
@stdout.puts utf2kcode(msg)
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_tiddles
|
75
|
+
tiddles = []
|
76
|
+
|
77
|
+
if (@file_no <= 0)
|
78
|
+
@file_names.each do |file_name|
|
79
|
+
tiddles.concat Tiddle.parse_sort_modified(file_name)
|
80
|
+
end
|
81
|
+
elsif (@file_no <= @file_names.size)
|
82
|
+
tiddles.concat Tiddle.parse_sort_modified(@file_names[@file_no - 1])
|
83
|
+
end
|
84
|
+
|
85
|
+
tiddles
|
86
|
+
end
|
87
|
+
private :create_tiddles
|
88
|
+
|
89
|
+
def match_line
|
90
|
+
tiddles = create_tiddles
|
91
|
+
|
92
|
+
match_lines = 0
|
93
|
+
search_lines = 0
|
94
|
+
match_tiddles = 0
|
95
|
+
|
96
|
+
is_limit = false
|
97
|
+
|
98
|
+
tiddles.each do |tiddle|
|
99
|
+
next if (@title && tiddle.title !~ @title_regexp)
|
100
|
+
is_match_tiddle = false
|
101
|
+
line_no = 1
|
102
|
+
|
103
|
+
tiddle.content.each_line do |line|
|
104
|
+
if (match? line)
|
105
|
+
match_lines += 1
|
106
|
+
|
107
|
+
unless is_limit
|
108
|
+
puts "#{tiddle.title}:#{line_no}:#{line}"
|
109
|
+
|
110
|
+
if (@is_comp && match_lines >= MATCH_LINE_COMP_NUM)
|
111
|
+
is_limit = true
|
112
|
+
print ".\n.\n"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
unless is_match_tiddle
|
118
|
+
match_tiddles += 1
|
119
|
+
is_match_tiddle = true
|
120
|
+
end
|
121
|
+
end
|
122
|
+
line_no += 1
|
123
|
+
search_lines += 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
if (@report)
|
128
|
+
puts "------------------------------"
|
129
|
+
puts "search lines : #{search_lines}"
|
130
|
+
puts "match lines : #{match_lines}"
|
131
|
+
puts "total tiddles : #{tiddles.size}"
|
132
|
+
puts "match tiddles : #{match_tiddles}"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def match_only_title
|
137
|
+
tiddles = create_tiddles
|
138
|
+
|
139
|
+
match_tiddles = 0
|
140
|
+
|
141
|
+
is_limit = false
|
142
|
+
|
143
|
+
tiddles.each do |tiddle|
|
144
|
+
next if (@title && tiddle.title !~ @title_regexp)
|
145
|
+
|
146
|
+
match_tiddles += 1
|
147
|
+
|
148
|
+
unless is_limit
|
149
|
+
puts tiddle.title
|
150
|
+
|
151
|
+
if (@is_comp && match_tiddles >= MATCH_ONLY_TITLE_COMP_NUM)
|
152
|
+
is_limit = true
|
153
|
+
print ".\n.\n"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
if (@report)
|
159
|
+
puts "------------------------------"
|
160
|
+
puts "total tiddles : #{tiddles.size}"
|
161
|
+
puts "match tiddles : #{match_tiddles}"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def match_tiddle
|
166
|
+
tiddles = create_tiddles
|
167
|
+
|
168
|
+
search_tiddles = 0
|
169
|
+
match_tiddles = 0
|
170
|
+
|
171
|
+
is_limit = false
|
172
|
+
|
173
|
+
tiddles.each do |tiddle|
|
174
|
+
next if (@title && tiddle.title !~ @title_regexp)
|
175
|
+
search_tiddles += 1
|
176
|
+
|
177
|
+
if (match? tiddle.content)
|
178
|
+
match_tiddles += 1
|
179
|
+
|
180
|
+
unless is_limit
|
181
|
+
puts "--- #{tiddle.title} --------------------"
|
182
|
+
|
183
|
+
unless @is_comp
|
184
|
+
puts tiddle.content
|
185
|
+
else
|
186
|
+
tiddle_a = tiddle.content.split(/\n/)
|
187
|
+
|
188
|
+
if (tiddle_a.size <= MATCH_TIDDLE_LINE_NUM)
|
189
|
+
print tiddle.content
|
190
|
+
else
|
191
|
+
print tiddle_a[0..(MATCH_TIDDLE_LINE_NUM - 1)].join("\n") + "\n.\n"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
if (@is_comp && match_tiddles >= MATCH_TIDDLE_COMP_NUM)
|
196
|
+
is_limit = true
|
197
|
+
print ".\n.\n"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
if (@report)
|
204
|
+
puts "------------------------------"
|
205
|
+
puts "total tiddles : #{tiddles.size}"
|
206
|
+
puts "search tiddles : #{search_tiddles}"
|
207
|
+
puts "match tiddles : #{match_tiddles}"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def match_tweet
|
212
|
+
tiddles = create_tiddles
|
213
|
+
|
214
|
+
search_tweets = 0
|
215
|
+
match_tweets = 0
|
216
|
+
|
217
|
+
is_limit = false
|
218
|
+
|
219
|
+
tiddles.each do |tiddle|
|
220
|
+
next if (@title && tiddle.title !~ @title_regexp)
|
221
|
+
is_match_tiddle = false
|
222
|
+
|
223
|
+
tweets = tiddle.content.split(/^----+\n/)
|
224
|
+
search_tweets += tweets.size
|
225
|
+
|
226
|
+
tweets.each do |tweet|
|
227
|
+
if (match? tweet)
|
228
|
+
match_tweets += 1
|
229
|
+
unless is_limit
|
230
|
+
unless is_match_tiddle
|
231
|
+
puts "--- #{tiddle.title} --------------------"
|
232
|
+
is_match_tiddle = true
|
233
|
+
else
|
234
|
+
puts "----\n"
|
235
|
+
end
|
236
|
+
|
237
|
+
unless @is_comp
|
238
|
+
print tweet
|
239
|
+
else
|
240
|
+
tweet_a = tweet.split(/\n/)
|
241
|
+
|
242
|
+
if (tweet_a.size <= MATCH_TWEET_LINE_NUM)
|
243
|
+
print tweet
|
244
|
+
else
|
245
|
+
print tweet_a[0..(MATCH_TWEET_LINE_NUM - 1)].join("\n") + "\n.\n"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
if (@is_comp && match_tweets >= MATCH_TWEET_COMP_NUM)
|
250
|
+
is_limit = true
|
251
|
+
print ".\n.\n"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
if (@report)
|
259
|
+
puts "------------------------------"
|
260
|
+
puts "search tweets : #{search_tweets}"
|
261
|
+
puts "match tweets : #{match_tweets}"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def execute
|
266
|
+
if (@content_regexps.size > 0)
|
267
|
+
case @match_rule
|
268
|
+
when "line"
|
269
|
+
match_line
|
270
|
+
when "tiddle"
|
271
|
+
match_tiddle
|
272
|
+
when "tweet"
|
273
|
+
match_tweet
|
274
|
+
end
|
275
|
+
else
|
276
|
+
match_only_title
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
end
|
data/lib/tidtools.rb
CHANGED
data/lib/tidtools/tiddle.rb
CHANGED
@@ -59,6 +59,13 @@ class Tiddle
|
|
59
59
|
|
60
60
|
# tiddleの内容を取得
|
61
61
|
def self.content(tiddle)
|
62
|
+
data = content1(tiddle)
|
63
|
+
data.gsub!(/\\n/, "\n")
|
64
|
+
data
|
65
|
+
end
|
66
|
+
|
67
|
+
# tiddleの内容を取得(処理1 HTMLから取り出し)
|
68
|
+
def self.content1(tiddle)
|
62
69
|
pre = tiddle.search("pre")
|
63
70
|
|
64
71
|
if (pre.size > 0)
|
@@ -67,6 +74,7 @@ class Tiddle
|
|
67
74
|
tiddle.inner_html
|
68
75
|
end
|
69
76
|
end
|
77
|
+
private_class_method :content1
|
70
78
|
|
71
79
|
# 時刻に変換
|
72
80
|
def self.convtime(str)
|
data/lib/twgrep/cli.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require File.join(File.dirname(__FILE__), '../tidgrep/
|
2
|
+
require File.join(File.dirname(__FILE__), '../tidgrep/tidgrep')
|
3
3
|
require 'optparse'
|
4
4
|
|
5
5
|
module Twgrep
|
6
6
|
class CLI
|
7
7
|
def self.execute(stdout, arguments=[])
|
8
|
-
|
8
|
+
file_names = ENV['TIDDLYWIKI_PATHS'].split
|
9
|
+
file_no = 0
|
9
10
|
title = "Tweet"
|
10
11
|
regexp_option = 0
|
11
12
|
report = false
|
@@ -14,14 +15,17 @@ module Twgrep
|
|
14
15
|
kcode = Platform.get_shell_kcode
|
15
16
|
|
16
17
|
opt = OptionParser.new('twgrep [option] keyword')
|
17
|
-
opt.on('-f
|
18
|
+
opt.on('-f TIDDLYWIKI_PATHS', '--filename TIDDLYWIKI_PATHS', 'TiddlyWiki path names') {|v| file_names = v.split }
|
19
|
+
opt.on('-n SELECT_NO', '--fileno SELECT_NO', 'file select number. (0 is all. 1,2,3,4.. is select only one.)') {|v| file_no = v.to_i }
|
20
|
+
opt.on('-t TITLE', '--title TITLE', 'match title') {|v| title = v }
|
18
21
|
opt.on('-i', '--ignore', 'ignore case') {|v| regexp_option |= Regexp::IGNORECASE }
|
19
22
|
opt.on('-r', '--report', 'disp report') {|v| report = true }
|
20
23
|
opt.on('-c', '--comp', 'compression disp') {|v| is_comp = true; report = true }
|
21
24
|
opt.parse!(arguments)
|
22
25
|
|
23
26
|
obj = Tidgrep::Tidgrep.new(stdout,
|
24
|
-
|
27
|
+
file_names,
|
28
|
+
file_no,
|
25
29
|
title,
|
26
30
|
regexp_option,
|
27
31
|
report,
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ongaeshi
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-20 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- bin/twgrep
|
83
83
|
- bin/twmerge
|
84
84
|
- lib/tidgrep/cli.rb
|
85
|
+
- lib/tidgrep/tidgrep.rb
|
85
86
|
- lib/tidtools.rb
|
86
87
|
- lib/tidtools/platform.rb
|
87
88
|
- lib/tidtools/tiddle.rb
|