milkode 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +14 -0
- data/Gemfile +1 -1
- data/HISTORY.ja.rdoc +17 -0
- data/HISTORY.rdoc +17 -0
- data/VERSION +1 -1
- data/bin/gmilk +1 -1
- data/bin/milk +1 -1
- data/lib/milkode/cdstk/cdstk.rb +17 -5
- data/lib/milkode/cdweb/app.rb +1 -1
- data/lib/milkode/cli.rb +3 -1
- data/lib/milkode/common/util.rb +21 -1
- data/lib/milkode/database/document_table.rb +14 -13
- data/lib/milkode/database/package_table.rb +6 -4
- data/lib/milkode/findgrep/findgrep.rb +2 -1
- data/lib/milkode/grep/cli_grep.rb +16 -4
- data/milkode.gemspec +6 -5
- data/test/test_cli.rb +5 -0
- data/test/test_package_table.rb +1 -1
- metadata +5 -12
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/HISTORY.ja.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 0.9.7 2012/01/29
|
2
|
+
|
3
|
+
* Support rroonga 2.1.x
|
4
|
+
|
5
|
+
* Support TravisCI
|
6
|
+
* https://travis-ci.org/ongaeshi/milkode
|
7
|
+
* Util#truncate_nsec を追加
|
8
|
+
|
9
|
+
* milk
|
10
|
+
* 'milk files -r' を追加
|
11
|
+
* 非データベースディレクトリでも'milk files'出来るように
|
12
|
+
* 'milk list -d' (ディレクトリのみ表示) を追加
|
13
|
+
|
14
|
+
* gmilk
|
15
|
+
* 一部の単語が正しくマッチするように修正 ('a-list'等)
|
16
|
+
* Windows環境でも日本語検索を可能に
|
17
|
+
|
1
18
|
=== 0.9.6 2012/12/28
|
2
19
|
|
3
20
|
* milk web
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 0.9.7 2012/01/29
|
2
|
+
|
3
|
+
* Support rroonga 2.1.x
|
4
|
+
|
5
|
+
* Support TravisCI
|
6
|
+
* https://travis-ci.org/ongaeshi/milkode
|
7
|
+
* Add Util#truncate_nsec
|
8
|
+
|
9
|
+
* milk
|
10
|
+
* Add 'milk files -r'
|
11
|
+
* Can run 'milk files' in non-database directory
|
12
|
+
* Add 'milk list -d' (Display directory)
|
13
|
+
|
14
|
+
* gmilk
|
15
|
+
* Fixed some words to match properly ('a-list' etc.)
|
16
|
+
* Can search non-ASCII characters in Windows environment
|
17
|
+
|
1
18
|
=== 0.9.6 2012/12/28
|
2
19
|
|
3
20
|
* milk web
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.7
|
data/bin/gmilk
CHANGED
data/bin/milk
CHANGED
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -407,6 +407,8 @@ module Milkode
|
|
407
407
|
h = File.exist?(p.directory) ? '' : '? '
|
408
408
|
if (options[:verbose])
|
409
409
|
"#{(h + p.name).ljust(max+2)} #{p.directory}"
|
410
|
+
elsif (options[:directory])
|
411
|
+
"#{p.directory}"
|
410
412
|
else
|
411
413
|
"#{h}#{p.name}"
|
412
414
|
end
|
@@ -414,7 +416,7 @@ module Milkode
|
|
414
416
|
|
415
417
|
@out.puts str
|
416
418
|
|
417
|
-
if Util.pipe?
|
419
|
+
if !options[:directory] && Util.pipe?($stdout)
|
418
420
|
if args.empty?
|
419
421
|
milkode_info
|
420
422
|
else
|
@@ -875,8 +877,12 @@ EOF
|
|
875
877
|
else
|
876
878
|
dir = File.expand_path('.')
|
877
879
|
r = @yaml.package_root(dir)
|
878
|
-
|
879
|
-
|
880
|
+
if r.nil?
|
881
|
+
@out.puts "Not registered '#{dir}'."
|
882
|
+
[]
|
883
|
+
else
|
884
|
+
[r]
|
885
|
+
end
|
880
886
|
end
|
881
887
|
end
|
882
888
|
|
@@ -935,15 +941,21 @@ EOF
|
|
935
941
|
end
|
936
942
|
end
|
937
943
|
|
938
|
-
def files(args)
|
944
|
+
def files(args, options)
|
939
945
|
packages = find_packages(args)
|
940
946
|
return if (packages.empty?)
|
941
947
|
|
942
948
|
db_open
|
949
|
+
|
950
|
+
basedir = File.expand_path('.') if options[:relative]
|
943
951
|
|
944
952
|
packages.each do |package|
|
945
953
|
package_records(package.name).each do |record|
|
946
|
-
|
954
|
+
if options[:relative]
|
955
|
+
@out.puts Util::relative_path(record.path, basedir)
|
956
|
+
else
|
957
|
+
@out.puts record.restpath
|
958
|
+
end
|
947
959
|
end
|
948
960
|
end
|
949
961
|
end
|
data/lib/milkode/cdweb/app.rb
CHANGED
@@ -22,7 +22,7 @@ set :haml, :format => :html5
|
|
22
22
|
|
23
23
|
get '/' do
|
24
24
|
@setting = WebSetting.new
|
25
|
-
@version = "0.9.
|
25
|
+
@version = "0.9.7"
|
26
26
|
@package_num = Database.instance.yaml_package_num
|
27
27
|
@file_num = Database.instance.totalRecords
|
28
28
|
@package_list = PackageList.new(Database.instance.grndb)
|
data/lib/milkode/cli.rb
CHANGED
@@ -71,6 +71,7 @@ EOF
|
|
71
71
|
|
72
72
|
desc "list [package1 package2 ...]", "List package"
|
73
73
|
option :verbose, :type => :boolean, :aliases => '-v', :desc => 'Be verbose.'
|
74
|
+
option :directory, :type => :boolean, :aliases => '-d', :desc => 'Display direcory.'
|
74
75
|
option :check, :type => :boolean, :aliases => '-c', :desc => "Check integrity 'yaml and database'"
|
75
76
|
def list(*args)
|
76
77
|
cdstk.list(args, options)
|
@@ -193,8 +194,9 @@ EOF
|
|
193
194
|
end
|
194
195
|
|
195
196
|
desc "files", "Display package files"
|
197
|
+
option :relative, :type => :boolean, :aliases => '-r', :desc => "Display relative path."
|
196
198
|
def files(*args)
|
197
|
-
cdstk.files(args)
|
199
|
+
cdstk.files(args, options)
|
198
200
|
end
|
199
201
|
|
200
202
|
# --------------------------------------------------------------------------
|
data/lib/milkode/common/util.rb
CHANGED
@@ -5,6 +5,7 @@ require 'milkode/common/archive-zip'
|
|
5
5
|
require 'fileutils'
|
6
6
|
require 'pathname'
|
7
7
|
require 'kconv'
|
8
|
+
require 'groonga'
|
8
9
|
|
9
10
|
module Milkode
|
10
11
|
module Util
|
@@ -205,7 +206,26 @@ module Milkode
|
|
205
206
|
str
|
206
207
|
end
|
207
208
|
end
|
208
|
-
|
209
|
+
|
210
|
+
# Timeからnsecを切り捨てる
|
211
|
+
# rroongaのTimeカラムはマイクロ秒までしか格納出来ない
|
212
|
+
def truncate_nsec(t)
|
213
|
+
Time.at(t.to_i, t.usec)
|
214
|
+
end
|
215
|
+
|
216
|
+
# gem_version_more?('rroonga', '2.1.0') #=> rroonga >= '2.1.0'
|
217
|
+
def gem_version_more?(name, version)
|
218
|
+
Gem.loaded_specs[name].version >= Gem::Version.new(version)
|
219
|
+
end
|
220
|
+
|
221
|
+
# 互換性保持のため
|
222
|
+
def groonga_table_sort(table, keys, options = {})
|
223
|
+
if gem_version_more?('rroonga', '2.1.0')
|
224
|
+
table.sort(keys, options).map{|r| r.value}
|
225
|
+
else
|
226
|
+
table.sort(keys, options)
|
227
|
+
end
|
228
|
+
end
|
209
229
|
end
|
210
230
|
end
|
211
231
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# @date 2012/05/29
|
7
7
|
|
8
8
|
require 'kconv'
|
9
|
-
require 'milkode/common/util
|
9
|
+
require 'milkode/common/util'
|
10
10
|
|
11
11
|
module Milkode
|
12
12
|
class DocumentTable
|
@@ -84,14 +84,14 @@ module Milkode
|
|
84
84
|
# @retval nil タイムスタンプ比較により更新無し
|
85
85
|
#
|
86
86
|
def add(package_dir, restpath, package_name = nil)
|
87
|
-
filename
|
88
|
-
filename
|
89
|
-
path
|
90
|
-
package
|
91
|
-
package
|
92
|
-
restpath
|
93
|
-
suffix
|
94
|
-
timestamp = File.mtime(filename) # OSへの問い合わせは変換前のファイル名で
|
87
|
+
filename = File.join(package_dir, restpath) # フルパスの作成
|
88
|
+
filename = File.expand_path(filename) # 絶対パスに変換
|
89
|
+
path = Util::filename_to_utf8(filename) # データベースに格納する時のファイル名はutf8
|
90
|
+
package = package_name || File.basename(package_dir)
|
91
|
+
package = Util::filename_to_utf8(package)
|
92
|
+
restpath = Util::filename_to_utf8(restpath)
|
93
|
+
suffix = File.extname(path).sub('.', "")
|
94
|
+
timestamp = Util::truncate_nsec(File.mtime(filename)) # OSへの問い合わせは変換前のファイル名で
|
95
95
|
|
96
96
|
record = @table[path]
|
97
97
|
|
@@ -287,10 +287,11 @@ module Milkode
|
|
287
287
|
# :limit => limit)
|
288
288
|
|
289
289
|
# ファイル名でソート
|
290
|
-
records =
|
291
|
-
|
292
|
-
|
293
|
-
|
290
|
+
records = Util.groonga_table_sort(result,
|
291
|
+
[{:key => "package", :order => "ascending"},
|
292
|
+
{:key => "restpath", :order => "ascending"}],
|
293
|
+
:offset => offset,
|
294
|
+
:limit => limit)
|
294
295
|
|
295
296
|
# 検索結果のレコード(limitの影響を受ける), 総マッチ数(limitの影響を受けない)
|
296
297
|
return records, result.size
|
@@ -5,6 +5,8 @@
|
|
5
5
|
# @author ongaeshi
|
6
6
|
# @date 2012/05/29
|
7
7
|
|
8
|
+
require 'milkode/common/util'
|
9
|
+
|
8
10
|
module Milkode
|
9
11
|
class PackageTable
|
10
12
|
include Enumerable
|
@@ -32,10 +34,10 @@ module Milkode
|
|
32
34
|
|
33
35
|
def add(name, directory, options)
|
34
36
|
@table.add(name,
|
35
|
-
:name
|
37
|
+
:name => name,
|
36
38
|
:directory => directory,
|
37
|
-
:addtime
|
38
|
-
:favtime
|
39
|
+
:addtime => Time.now,
|
40
|
+
:favtime => options[:fav] ? Time.now : Time.at(0))
|
39
41
|
end
|
40
42
|
|
41
43
|
def remove(name)
|
@@ -59,7 +61,7 @@ module Milkode
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def sort(kind, order = "descending")
|
62
|
-
@table
|
64
|
+
Util.groonga_table_sort(@table, [{:key => kind, :order => order}])
|
63
65
|
end
|
64
66
|
|
65
67
|
def dump
|
@@ -6,10 +6,16 @@ require 'milkode/common/dbdir'
|
|
6
6
|
require 'milkode/cdstk/cdstk'
|
7
7
|
require 'milkode/cdstk/yaml_file_wrapper'
|
8
8
|
require 'milkode/cdstk/package'
|
9
|
+
require 'kconv'
|
9
10
|
|
10
11
|
module Milkode
|
11
12
|
class CLI_Grep
|
12
13
|
def self.execute(stdout, arguments=[])
|
14
|
+
# 引数の文字コードをUTF-8に変換
|
15
|
+
if (Util::platform_win?)
|
16
|
+
arguments = arguments.map{|arg| Kconv.kconv(arg, Kconv::UTF8)}
|
17
|
+
end
|
18
|
+
|
13
19
|
option = FindGrep::FindGrep::DEFAULT_OPTION.dup
|
14
20
|
|
15
21
|
# default option
|
@@ -221,11 +227,17 @@ EOF
|
|
221
227
|
|
222
228
|
def prev
|
223
229
|
@arguments.map! do |v|
|
224
|
-
v
|
225
|
-
|
226
|
-
|
230
|
+
case v
|
231
|
+
when "-l"
|
232
|
+
":l"
|
233
|
+
when "-k"
|
234
|
+
":k"
|
235
|
+
when "-g"
|
236
|
+
":g"
|
237
|
+
else
|
238
|
+
v
|
239
|
+
end
|
227
240
|
end
|
228
|
-
|
229
241
|
end
|
230
242
|
|
231
243
|
def after
|
data/milkode.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{milkode}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ongaeshi"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2013-01-30}
|
13
13
|
s.description = %q{Line based local source code search engine & grep-command & web-app.}
|
14
14
|
s.email = %q{ongaeshi0621@gmail.com}
|
15
15
|
s.executables = ["gmilk", "milk"]
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
|
+
".travis.yml",
|
22
23
|
"Gemfile",
|
23
24
|
"HISTORY.ja.rdoc",
|
24
25
|
"HISTORY.rdoc",
|
@@ -194,7 +195,7 @@ Gem::Specification.new do |s|
|
|
194
195
|
|
195
196
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
196
197
|
s.add_runtime_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
197
|
-
s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0"
|
198
|
+
s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0"])
|
198
199
|
s.add_runtime_dependency(%q<rack>, [">= 1.3.4"])
|
199
200
|
s.add_runtime_dependency(%q<sinatra>, [">= 1.2.6"])
|
200
201
|
s.add_runtime_dependency(%q<launchy>, [">= 0.3.7"])
|
@@ -209,7 +210,7 @@ Gem::Specification.new do |s|
|
|
209
210
|
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
210
211
|
else
|
211
212
|
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
212
|
-
s.add_dependency(%q<rroonga>, [">= 1.1.0"
|
213
|
+
s.add_dependency(%q<rroonga>, [">= 1.1.0"])
|
213
214
|
s.add_dependency(%q<rack>, [">= 1.3.4"])
|
214
215
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
215
216
|
s.add_dependency(%q<launchy>, [">= 0.3.7"])
|
@@ -225,7 +226,7 @@ Gem::Specification.new do |s|
|
|
225
226
|
end
|
226
227
|
else
|
227
228
|
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
228
|
-
s.add_dependency(%q<rroonga>, [">= 1.1.0"
|
229
|
+
s.add_dependency(%q<rroonga>, [">= 1.1.0"])
|
229
230
|
s.add_dependency(%q<rack>, [">= 1.3.4"])
|
230
231
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
231
232
|
s.add_dependency(%q<launchy>, [">= 0.3.7"])
|
data/test/test_cli.rb
CHANGED
data/test/test_package_table.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: 53
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 7
|
10
|
+
version: 0.9.7
|
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:
|
18
|
+
date: 2013-01-30 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -57,14 +57,6 @@ dependencies:
|
|
57
57
|
- 1
|
58
58
|
- 0
|
59
59
|
version: 1.1.0
|
60
|
-
- - <
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
hash: 11
|
63
|
-
segments:
|
64
|
-
- 2
|
65
|
-
- 1
|
66
|
-
- 0
|
67
|
-
version: 2.1.0
|
68
60
|
requirement: *id002
|
69
61
|
- !ruby/object:Gem::Dependency
|
70
62
|
type: :runtime
|
@@ -264,6 +256,7 @@ extra_rdoc_files:
|
|
264
256
|
- README.rdoc
|
265
257
|
files:
|
266
258
|
- .document
|
259
|
+
- .travis.yml
|
267
260
|
- Gemfile
|
268
261
|
- HISTORY.ja.rdoc
|
269
262
|
- HISTORY.rdoc
|