tidtools 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/lib/tidgrep/cli.rb +33 -11
- data/lib/tidtools/platform.rb +16 -0
- data/lib/tidtools.rb +1 -1
- data/lib/twgrep/cli.rb +3 -1
- metadata +4 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/lib/tidgrep/cli.rb
CHANGED
@@ -1,33 +1,37 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require File.join(File.dirname(__FILE__), '../tidtools/tiddle')
|
3
|
+
require File.join(File.dirname(__FILE__), '../tidtools/platform')
|
3
4
|
require 'optparse'
|
5
|
+
require 'kconv'
|
4
6
|
|
5
7
|
module Tidgrep
|
6
|
-
|
7
|
-
|
8
|
+
class Tidgrep
|
9
|
+
# 圧縮表示時のパラメータ
|
10
|
+
MATCH_LINE_COMP_NUM = 5
|
8
11
|
|
9
|
-
|
12
|
+
MATCH_ONLY_TITLE_COMP_NUM = 5
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
MATCH_TIDDLE_LINE_NUM = 3
|
15
|
+
MATCH_TIDDLE_COMP_NUM = 5
|
13
16
|
|
14
|
-
|
15
|
-
|
17
|
+
MATCH_TWEET_LINE_NUM = 3
|
18
|
+
MATCH_TWEET_COMP_NUM = 5
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
def initialize(stdout, file_name, title, regexp_option, report, match_rule, is_comp, keywords, kcode)
|
21
|
+
@stdout = stdout
|
19
22
|
@file_name = file_name
|
20
23
|
@title = title
|
21
24
|
@regexp_option = regexp_option
|
22
25
|
@report = report
|
23
26
|
@match_rule = match_rule
|
24
27
|
@is_comp = is_comp
|
28
|
+
@kcode = kcode
|
25
29
|
|
26
30
|
@title_regexp = @title && Regexp.new(@title, @regexp_option)
|
27
31
|
|
28
32
|
@content_regexps = []
|
29
33
|
keywords.each do |keyword|
|
30
|
-
@content_regexps << Regexp.new(keyword, @regexp_option)
|
34
|
+
@content_regexps << Regexp.new(self.kconv(keyword), @regexp_option)
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -43,6 +47,22 @@ module Tidgrep
|
|
43
47
|
return true
|
44
48
|
end
|
45
49
|
|
50
|
+
def kconv(str)
|
51
|
+
if (@kcode != Kconv::UTF8)
|
52
|
+
str.kconv(@kconv, Kconv::UTF8)
|
53
|
+
else
|
54
|
+
str
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def print(msg)
|
59
|
+
@stdout.print self.kconv msg
|
60
|
+
end
|
61
|
+
|
62
|
+
def puts(msg)
|
63
|
+
@stdout.puts self.kconv msg
|
64
|
+
end
|
65
|
+
|
46
66
|
def match_line
|
47
67
|
tiddles = Tiddle.parse_sort_modified(@file_name)
|
48
68
|
|
@@ -244,6 +264,7 @@ module Tidgrep
|
|
244
264
|
report = false
|
245
265
|
match_rule = "line"
|
246
266
|
is_comp = false
|
267
|
+
kcode = Platform.get_shell_kcode
|
247
268
|
|
248
269
|
opt = OptionParser.new('tidgrep [option] keyword')
|
249
270
|
opt.on('-f FILE_NAME', '--filename FILE_NAME', 'TiddlyWiki file name') {|v| file_name = v }
|
@@ -261,7 +282,8 @@ module Tidgrep
|
|
261
282
|
report,
|
262
283
|
match_rule,
|
263
284
|
is_comp,
|
264
|
-
arguments
|
285
|
+
arguments,
|
286
|
+
kcode)
|
265
287
|
|
266
288
|
unless obj.validOption?
|
267
289
|
puts opt.help
|
data/lib/tidtools.rb
CHANGED
data/lib/twgrep/cli.rb
CHANGED
@@ -11,6 +11,7 @@ module Twgrep
|
|
11
11
|
report = false
|
12
12
|
match_rule = "tweet"
|
13
13
|
is_comp = false
|
14
|
+
kcode = Platform.get_shell_kcode
|
14
15
|
|
15
16
|
opt = OptionParser.new('twgrep [option] keyword')
|
16
17
|
opt.on('-f FILE_NAME', '--filename FILE_NAME', 'TiddlyWiki file name') {|v| file_name = v }
|
@@ -26,7 +27,8 @@ module Twgrep
|
|
26
27
|
report,
|
27
28
|
match_rule,
|
28
29
|
is_comp,
|
29
|
-
arguments
|
30
|
+
arguments,
|
31
|
+
kcode)
|
30
32
|
|
31
33
|
unless obj.validOption? && arguments.size > 0
|
32
34
|
puts opt.help
|
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
|
+
- 5
|
9
|
+
version: 0.0.5
|
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-04-
|
17
|
+
date: 2010-04-28 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- bin/twgrep
|
82
82
|
- lib/tidgrep/cli.rb
|
83
83
|
- lib/tidtools.rb
|
84
|
+
- lib/tidtools/platform.rb
|
84
85
|
- lib/tidtools/tiddle.rb
|
85
86
|
- lib/twgrep/cli.rb
|
86
87
|
- script/console
|