milkode 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/milkode/cdstk/cdstk.rb +2 -2
- data/lib/milkode/cdstk/milkode_yaml.rb +5 -0
- data/lib/milkode/cdstk/yaml_file_wrapper.rb +4 -0
- data/lib/milkode/cdweb/lib/database.rb +33 -21
- data/lib/milkode/cdweb/lib/search_contents.rb +1 -3
- data/lib/milkode/cdweb/lib/search_files.rb +2 -5
- data/lib/milkode/cdweb/views/search_form.haml +3 -3
- data/lib/milkode/common/util.rb +1 -1
- data/test/test_cdstk.rb +2 -0
- data/test/test_database.rb +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -636,12 +636,12 @@ EOF
|
|
636
636
|
end
|
637
637
|
|
638
638
|
# データベースからも削除
|
639
|
-
dir = File.expand_path(dir)
|
639
|
+
# dir = File.expand_path(dir)
|
640
640
|
|
641
641
|
alert("rm_package", dir)
|
642
642
|
@package_count += 1
|
643
643
|
|
644
|
-
Database.instance.
|
644
|
+
Database.instance.remove_fpath(dir) do |record|
|
645
645
|
alert_info("rm_record", record.path)
|
646
646
|
@file_count += 1
|
647
647
|
end
|
@@ -59,6 +59,11 @@ EOF
|
|
59
59
|
@contents.find {|v| v.same_name?(name)}
|
60
60
|
end
|
61
61
|
|
62
|
+
# 指定キーワードにマッチする全てのパッケージを返す
|
63
|
+
def match_all(keyword)
|
64
|
+
@contents.find_all {|p| p.name.include? keyword }
|
65
|
+
end
|
66
|
+
|
62
67
|
# ディレクトリ名が同じパッケージを検索
|
63
68
|
def find_dir(directory)
|
64
69
|
@contents.find {|v| v.directory == directory}
|
@@ -52,7 +52,18 @@ module Milkode
|
|
52
52
|
return table.records[0]
|
53
53
|
end
|
54
54
|
|
55
|
-
def search(patterns, packages, fpaths, suffixs, offset = 0, limit = -1)
|
55
|
+
def search(patterns, packages, current_path, fpaths, suffixs, offset = 0, limit = -1)
|
56
|
+
# パッケージ名から絶対パスに変換
|
57
|
+
unless packages.empty?
|
58
|
+
packages = convert_packages(packages)
|
59
|
+
|
60
|
+
# キーワードがパッケージ名にマッチしなければ検索しない
|
61
|
+
return [], 0 if packages.empty?
|
62
|
+
else
|
63
|
+
# パッケージ名未指定の時は現在位置もfpathsに含める
|
64
|
+
fpaths << current_path + "/" unless current_path == ""
|
65
|
+
end
|
66
|
+
|
56
67
|
# @todo fpathを厳密に検索するには、検索結果からさらに先頭からのパスではないものを除外する
|
57
68
|
records, total_records = searchMain(patterns, packages, fpaths, suffixs, offset, limit)
|
58
69
|
end
|
@@ -131,14 +142,13 @@ module Milkode
|
|
131
142
|
paths
|
132
143
|
end
|
133
144
|
|
134
|
-
#
|
135
|
-
|
136
|
-
def remove(packages)
|
145
|
+
# 指定したfpathにマッチするレコードを削除する
|
146
|
+
def remove_fpath(fpath)
|
137
147
|
# データベースを開き直す
|
138
148
|
reopen_patch
|
139
149
|
|
140
|
-
#
|
141
|
-
records, total_records =
|
150
|
+
# 削除したいコンテンツを検索
|
151
|
+
records, total_records = searchMain([], [], [fpath], [], 0, -1)
|
142
152
|
|
143
153
|
# 検索結果はHashのレコードなので、これを直接deleteしても駄目
|
144
154
|
# 1. Record#record_idを使って主キー(Groonga#Arrayのレコード)を取り出し
|
@@ -222,23 +232,15 @@ module Milkode
|
|
222
232
|
end
|
223
233
|
|
224
234
|
# スコアとタイムスタンプでソート
|
225
|
-
records = table.sort([{:key => "_score", :order => "descending"},
|
226
|
-
|
227
|
-
:offset => offset,
|
228
|
-
:limit => limit)
|
229
|
-
|
230
|
-
# ファイル名でソート
|
231
|
-
# @todo 本当はこっちが望ましいが、パッケージ検索を正確にしないことには出来ない
|
232
|
-
# records = table.sort([{:key => "shortpath", :order => "ascending"}],
|
235
|
+
# records = table.sort([{:key => "_score", :order => "descending"},
|
236
|
+
# {:key => "timestamp", :order => "descending"}],
|
233
237
|
# :offset => offset,
|
234
238
|
# :limit => limit)
|
235
|
-
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
end
|
241
|
-
end
|
239
|
+
|
240
|
+
# ファイル名でソート
|
241
|
+
records = table.sort([{:key => "shortpath", :order => "ascending"}],
|
242
|
+
:offset => offset,
|
243
|
+
:limit => limit)
|
242
244
|
|
243
245
|
# マッチ数
|
244
246
|
total_records = table.size
|
@@ -281,5 +283,15 @@ module Milkode
|
|
281
283
|
end
|
282
284
|
private :suffix_expression
|
283
285
|
|
286
|
+
def convert_packages(packages)
|
287
|
+
packages.inject([]) {|r, p| r += expand_packages(p)}
|
288
|
+
end
|
289
|
+
|
290
|
+
def expand_packages(keyword)
|
291
|
+
@yaml.match_all(keyword).map{|p| p.directory}
|
292
|
+
end
|
293
|
+
|
294
|
+
# --- error ---
|
295
|
+
class NotFoundPackage < RuntimeError ; end
|
284
296
|
end
|
285
297
|
end
|
@@ -34,9 +34,7 @@ module Milkode
|
|
34
34
|
@offset = params[:offset].to_i
|
35
35
|
@line = params[:line].to_i
|
36
36
|
@is_onematch = params[:onematch]
|
37
|
-
|
38
|
-
fpaths << path + "/" unless path == ""
|
39
|
-
@records, @total_records, @elapsed = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, LIMIT_NUM)
|
37
|
+
@records, @total_records, @elapsed = Database.instance.search(@q.keywords, @q.packages, path, @q.fpaths, @q.suffixs, @offset, LIMIT_NUM)
|
40
38
|
grep_contents
|
41
39
|
end
|
42
40
|
|
@@ -23,13 +23,10 @@ module Milkode
|
|
23
23
|
|
24
24
|
@offset = params[:offset].to_i
|
25
25
|
|
26
|
-
|
27
|
-
fpaths << path + "/" unless path == ""
|
28
|
-
|
29
|
-
if (fpaths.include?("*"))
|
26
|
+
if (@q.fpaths.include?("*"))
|
30
27
|
@records, @total_records = Database.instance.selectAll(@offset, DISP_NUM)
|
31
28
|
else
|
32
|
-
@records, @total_records = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, DISP_NUM)
|
29
|
+
@records, @total_records = Database.instance.search(@q.keywords, @q.packages, path, @q.fpaths, @q.suffixs, @offset, DISP_NUM)
|
33
30
|
end
|
34
31
|
end
|
35
32
|
|
@@ -10,13 +10,13 @@
|
|
10
10
|
%br
|
11
11
|
%label
|
12
12
|
= create_radio('all', params[:shead])
|
13
|
-
|
13
|
+
全て
|
14
14
|
%label
|
15
15
|
= create_radio('package', params[:shead])
|
16
|
-
|
16
|
+
パッケージ(おすすめ)
|
17
17
|
%label
|
18
18
|
= create_radio('directory', params[:shead])
|
19
|
-
|
19
|
+
ディレクトリ
|
20
20
|
%label
|
21
21
|
= create_checkbox('onematch', params[:onematch])
|
22
22
|
= '1ファイル1マッチ'
|
data/lib/milkode/common/util.rb
CHANGED
data/test/test_cdstk.rb
CHANGED
data/test/test_database.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milkode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ongaeshi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-17 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|