milkode 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/HISTORY.ja.rdoc +17 -0
- data/HISTORY.rdoc +17 -0
- data/README.md +21 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/gmilk +1 -1
- data/bin/milk +1 -1
- data/lib/milkode/cdstk/cdstk.rb +9 -9
- data/lib/milkode/cdstk/milkode_yaml.rb +1 -1
- data/lib/milkode/cdstk/package.rb +2 -2
- data/lib/milkode/cdweb/app.rb +3 -3
- data/lib/milkode/cdweb/lib/coderay_html2.rb +1 -1
- data/lib/milkode/cdweb/lib/command.rb +4 -4
- data/lib/milkode/cdweb/lib/database.rb +2 -2
- data/lib/milkode/cdweb/lib/grep.rb +1 -1
- data/lib/milkode/cdweb/lib/search_contents.rb +7 -7
- data/lib/milkode/cdweb/lib/search_files.rb +2 -2
- data/lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb +2 -2
- data/lib/milkode/cdweb/lib/search_gotoline.rb +2 -2
- data/lib/milkode/common/util.rb +11 -6
- data/lib/milkode/database/document_table.rb +7 -7
- data/lib/milkode/database/updater.rb +11 -9
- data/lib/milkode/grep/cli_grep.rb +18 -7
- data/lib/milkode/grep/fast_gotoline.rb +2 -2
- data/lib/milkode/grep/findgrep.rb +8 -8
- data/milkode.gemspec +12 -9
- data/test/test_cli.rb +3 -3
- data/test/test_ignore_setting.rb +1 -1
- data/test/test_milkode_yaml.rb +8 -8
- data/test/test_package_table.rb +1 -1
- data/test/test_util.rb +59 -59
- metadata +30 -6
- data/README.rdoc +0 -6
data/Gemfile
CHANGED
@@ -10,12 +10,13 @@ gem 'rack' , '>= 1.5.2'
|
|
10
10
|
gem 'sinatra' , '>= 1.2.6'
|
11
11
|
gem 'launchy' , '>= 0.3.7'
|
12
12
|
gem 'coderay' , '>= 1.0.5'
|
13
|
-
gem 'thin' , '>= 1.2.10'
|
13
|
+
gem 'thin' , '>= 1.2.10', '< 2.0.0'
|
14
14
|
gem 'archive-zip' , '>= 0.4.0'
|
15
15
|
gem 'haml' , '>= 3.1.2'
|
16
16
|
gem 'sass' , '>= 3.1.3'
|
17
17
|
gem 'thor' , '>= 0.18.1'
|
18
18
|
gem 'i18n' , '~> 0.6.5'
|
19
|
+
gem 'whichr' , '~> 0.3'
|
19
20
|
|
20
21
|
# Add dependencies to develop your gem here.
|
21
22
|
# Include everything needed to run rake, tests, features, etc.
|
data/HISTORY.ja.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 1.6.0 2014/04/13
|
2
|
+
|
3
|
+
* milk
|
4
|
+
* #57 Use "rescue Error::EACCESS" instead of FileTest.readable? for Windows (thanks kazuna)
|
5
|
+
* #58 Use whichr in Util.exist_command? (thanks kazuna)
|
6
|
+
|
7
|
+
* gmilk
|
8
|
+
* #61 Without displaying stacktrace when pressed Ctrl+C on gmilk (thanks msmhrt)
|
9
|
+
* Support ENV['GMILK_OPTIONS']
|
10
|
+
|
11
|
+
* etc
|
12
|
+
* #64 thin < 2.0.0 in Gemfile (thanks MaskedW)
|
13
|
+
* Add TravisCI Button
|
14
|
+
* README.rdoc -> README.md
|
15
|
+
* Util::func -> Util.func
|
16
|
+
* Rewrite summary and description
|
17
|
+
|
1
18
|
=== 1.5.0 2014/02/08
|
2
19
|
|
3
20
|
* milk web
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 1.6.0 2014/04/13
|
2
|
+
|
3
|
+
* milk
|
4
|
+
* #57 Use "rescue Error::EACCESS" instead of FileTest.readable? for Windows (thanks kazuna)
|
5
|
+
* #58 Use whichr in Util.exist_command? (thanks kazuna)
|
6
|
+
|
7
|
+
* gmilk
|
8
|
+
* #61 Without displaying stacktrace when pressed Ctrl+C on gmilk (thanks msmhrt)
|
9
|
+
* Support ENV['GMILK_OPTIONS']
|
10
|
+
|
11
|
+
* etc
|
12
|
+
* #64 thin < 2.0.0 in Gemfile (thanks MaskedW)
|
13
|
+
* Add TravisCI Button
|
14
|
+
* README.rdoc -> README.md
|
15
|
+
* Util::func -> Util.func
|
16
|
+
* Rewrite summary and description
|
17
|
+
|
1
18
|
=== 1.5.0 2014/02/08
|
2
19
|
|
3
20
|
* milk web
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Milkode
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/ongaeshi/milkode.svg?branch=develop)](https://travis-ci.org/ongaeshi/milkode)
|
4
|
+
|
5
|
+
Milkode is "Line Based" local source code search engine written by Ruby. It have command line interface and web application. It will accelerate the code reading of your life.
|
6
|
+
|
7
|
+
Milkode is "見るコード". "See a code" is meaning.
|
8
|
+
|
9
|
+
[Honyomi](https://github.com/ongaeshi/honyomi) are brothers.
|
10
|
+
|
11
|
+
![milk-web-01.jpg](http://milkode.ongaeshi.me/images/milk-web-01.jpg)
|
12
|
+
|
13
|
+
## DOCUMENTS
|
14
|
+
|
15
|
+
* [Milkode - line based local source code search engine](http://milkode.ongaeshi.me/)
|
16
|
+
|
17
|
+
## HISTORY
|
18
|
+
|
19
|
+
* [History.rdoc](https://github.com/ongaeshi/milkode/blob/master/HISTORY.rdoc)
|
20
|
+
* [更新履歴](https://github.com/ongaeshi/milkode/blob/master/HISTORY.ja.rdoc)
|
21
|
+
|
data/Rakefile
CHANGED
@@ -16,8 +16,8 @@ Jeweler::Tasks.new do |gem|
|
|
16
16
|
gem.name = "milkode"
|
17
17
|
gem.homepage = "http://github.com/ongaeshi/milkode"
|
18
18
|
gem.license = "MIT"
|
19
|
-
gem.summary = %Q{Line based local source code search engine
|
20
|
-
gem.description = %Q{
|
19
|
+
gem.summary = %Q{Line based local source code search engine.}
|
20
|
+
gem.description = %Q{Milkode is line based local source code search engine. It have command line interface and web application. It will accelerate the code reading of your life.}
|
21
21
|
gem.email = "ongaeshi0621@gmail.com"
|
22
22
|
gem.authors = ["ongaeshi"]
|
23
23
|
# Dependencies move to 'Gemfile'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.6.0
|
data/bin/gmilk
CHANGED
data/bin/milk
CHANGED
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -255,7 +255,7 @@ module Milkode
|
|
255
255
|
when '.zip', '.xpi'
|
256
256
|
alert("extract", "#{src}")
|
257
257
|
zip_dir = File.join(@db_dir, "packages/#{ext.sub(".", "")}")
|
258
|
-
result = File.join(zip_dir, Util
|
258
|
+
result = File.join(zip_dir, Util.zip_extract(src, zip_dir))
|
259
259
|
else
|
260
260
|
src
|
261
261
|
end
|
@@ -989,7 +989,7 @@ EOF
|
|
989
989
|
if options[:package]
|
990
990
|
add_ignore = args.map {|v| v.sub(/^.\//, "") }
|
991
991
|
else
|
992
|
-
path = Util
|
992
|
+
path = Util.relative_path(File.expand_path('.'), package.directory).to_s
|
993
993
|
add_ignore = args.map {|v| File.join(path, v).sub(/^.\//, "") }
|
994
994
|
end
|
995
995
|
|
@@ -1025,7 +1025,7 @@ EOF
|
|
1025
1025
|
packages.each do |package|
|
1026
1026
|
package_records(package.name).each do |record|
|
1027
1027
|
if options[:relative]
|
1028
|
-
@out.puts Util
|
1028
|
+
@out.puts Util.relative_path(record.path, basedir)
|
1029
1029
|
else
|
1030
1030
|
if options[:all]
|
1031
1031
|
@out.puts record.path
|
@@ -1099,11 +1099,11 @@ EOF
|
|
1099
1099
|
private
|
1100
1100
|
|
1101
1101
|
def git_protocol?(options, src)
|
1102
|
-
options[:protocol] == 'git' || Util
|
1102
|
+
options[:protocol] == 'git' || Util.git_url?(src)
|
1103
1103
|
end
|
1104
1104
|
|
1105
1105
|
def svn_protocol?(options, src)
|
1106
|
-
options[:protocol] == 'svn' || Util
|
1106
|
+
options[:protocol] == 'svn' || Util.svn_url?(src)
|
1107
1107
|
end
|
1108
1108
|
|
1109
1109
|
def db_file
|
@@ -1154,8 +1154,8 @@ EOF
|
|
1154
1154
|
updater.exec
|
1155
1155
|
|
1156
1156
|
# Is github repository ?
|
1157
|
-
if Util
|
1158
|
-
repo_name = Dir.chdir(package.directory) { Util
|
1157
|
+
if Util.exist_command?('git') && File.exist?(File.join(package.directory, ".git"))
|
1158
|
+
repo_name = Dir.chdir(package.directory) { Util.github_repo(`git config --get remote.origin.url`) }
|
1159
1159
|
|
1160
1160
|
if repo_name && repo_name != package.options[:github]
|
1161
1161
|
dst = package.options
|
@@ -1220,7 +1220,7 @@ EOF
|
|
1220
1220
|
r << "#{@file_count} records" if @file_count > 0
|
1221
1221
|
r << "#{@add_count} add" if @add_count > 0
|
1222
1222
|
r << "#{@update_count} update" if @update_count > 0
|
1223
|
-
alert('result', "#{r.join(', ')}. (#{Gren::Util
|
1223
|
+
alert('result', "#{r.join(', ')}. (#{Gren::Util.time_s(time)})")
|
1224
1224
|
end
|
1225
1225
|
|
1226
1226
|
def milkode_info
|
@@ -1265,7 +1265,7 @@ EOF
|
|
1265
1265
|
end
|
1266
1266
|
|
1267
1267
|
def alert(title, msg)
|
1268
|
-
if (Util
|
1268
|
+
if (Util.platform_win?)
|
1269
1269
|
@out.puts "#{title.ljust(10)} : #{Kconv.kconv(msg, Kconv::SJIS)}"
|
1270
1270
|
else
|
1271
1271
|
@out.puts "#{title.ljust(10)} : #{msg}"
|
data/lib/milkode/cdweb/app.rb
CHANGED
@@ -43,7 +43,7 @@ end
|
|
43
43
|
get '/' do
|
44
44
|
if Database.validate?
|
45
45
|
@setting = WebSetting.new
|
46
|
-
@version = "1.
|
46
|
+
@version = "1.6.0"
|
47
47
|
|
48
48
|
@package_num = Database.instance.yaml_package_num
|
49
49
|
@file_num = Database.instance.totalRecords
|
@@ -82,8 +82,8 @@ post '/search*' do
|
|
82
82
|
|
83
83
|
query = Query.new(params[:query])
|
84
84
|
# gotolineモードで1つだけ渡された時は直接ジャンプ
|
85
|
-
if query.keywords.size == 1 && Milkode::Util
|
86
|
-
gotoline = Milkode::Util
|
85
|
+
if query.keywords.size == 1 && Milkode::Util.gotoline_keyword?(query.keywords[0])
|
86
|
+
gotoline = Milkode::Util.parse_gotoline(query.keywords)[0]
|
87
87
|
path2 = File.join(url_for('/home'), gotoline[0][0])
|
88
88
|
redirect Mkurl.new(path2, params).inherit_query_shead + "#n#{gotoline[1]}"
|
89
89
|
else
|
@@ -65,7 +65,7 @@ module Encoders
|
|
65
65
|
r << "class=\"highlight-line\"" if is_highlight
|
66
66
|
attr = r.join(" ")
|
67
67
|
|
68
|
-
line = Milkode::Util
|
68
|
+
line = Milkode::Util.highlight_keywords(line, options[:keywords], 'highlight-filename') if is_highlight
|
69
69
|
|
70
70
|
"<span #{attr}>#{line}</span>"
|
71
71
|
end
|
@@ -23,9 +23,9 @@ module Milkode
|
|
23
23
|
|
24
24
|
q = params[:query] && Query.new(params[:query])
|
25
25
|
|
26
|
-
if (Util
|
27
|
-
if Util
|
28
|
-
gotolines = Util
|
26
|
+
if (Util.larger_than_oneline(record.content) && q && !q.keywords.empty?)
|
27
|
+
if Util.gotoline_keyword?(q.keywords[0])
|
28
|
+
gotolines = Util.parse_gotoline(q.keywords)
|
29
29
|
match_lines = []
|
30
30
|
gotolines.each do |v|
|
31
31
|
if v[0][0][1..-1] == record.shortpath
|
@@ -70,7 +70,7 @@ module Milkode
|
|
70
70
|
end
|
71
71
|
|
72
72
|
elsif (query.keywords.size > 0)
|
73
|
-
if Util
|
73
|
+
if Util.gotoline_keyword?(query.keywords[0])
|
74
74
|
searcher = SearchGotoLine.new(path, params, query, suburl)
|
75
75
|
else
|
76
76
|
searcher = SearchContents.new(path, params, query, suburl, locale)
|
@@ -66,7 +66,7 @@ module Milkode
|
|
66
66
|
|
67
67
|
# パッケージ名未指定の時は現在位置を検索条件に追加
|
68
68
|
if packages.empty? && current_path != ''
|
69
|
-
package, restpath = Util
|
69
|
+
package, restpath = Util.divide_shortpath(current_path)
|
70
70
|
|
71
71
|
grn_package = @grndb.packages[package]
|
72
72
|
if grn_package
|
@@ -183,7 +183,7 @@ module Milkode
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def touch_viewtime(path)
|
186
|
-
package, restpath = Util
|
186
|
+
package, restpath = Util.divide_shortpath(path)
|
187
187
|
@grndb.packages.touch_if(package, :viewtime) if package
|
188
188
|
end
|
189
189
|
|
@@ -117,7 +117,7 @@ module Milkode
|
|
117
117
|
return [] if files.size > FILTER_BY_DIRECTORIES_FILES
|
118
118
|
|
119
119
|
files.map {|v|
|
120
|
-
Util
|
120
|
+
Util.relative_path(v[1], @path.split("/")[1..-1].join("/")).to_s # 'path/to/file' -> 'to/file' (@path == 'path')
|
121
121
|
}.find_all {|v|
|
122
122
|
v.include?("/") # Extract directory
|
123
123
|
}.map {|v|
|
@@ -189,7 +189,7 @@ EOF
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def recommended_fuzzy_gotoline?
|
192
|
-
@q.keywords.size == 1 && @q.only_keywords && Util
|
192
|
+
@q.keywords.size == 1 && @q.only_keywords && Util.fuzzy_gotoline_keyword?(@q.keywords[0])
|
193
193
|
end
|
194
194
|
|
195
195
|
def recommended_wide_match_range?
|
@@ -296,7 +296,7 @@ EOF
|
|
296
296
|
@next_line = nil
|
297
297
|
|
298
298
|
@records.each_with_index do |record, index|
|
299
|
-
if (Util
|
299
|
+
if (Util.larger_than_oneline(record.content))
|
300
300
|
if grep_match_lines_stopover(record, index, keywords, wide_match_range)
|
301
301
|
break
|
302
302
|
end
|
@@ -353,7 +353,7 @@ EOF
|
|
353
353
|
|
354
354
|
url = @homeurl + record_link(record)
|
355
355
|
|
356
|
-
path = Util
|
356
|
+
path = Util.relative_path(record.shortpath, @path)
|
357
357
|
|
358
358
|
if path != @prev
|
359
359
|
# dt = <<EOS
|
@@ -388,8 +388,8 @@ EOS
|
|
388
388
|
end
|
389
389
|
|
390
390
|
def result_record(record)
|
391
|
-
filename = Util
|
392
|
-
filename = Util
|
391
|
+
filename = Util.relative_path(record.shortpath, @path).to_s
|
392
|
+
filename = Util.highlight_keywords(filename, @q.keywords, 'highlight-filename')
|
393
393
|
|
394
394
|
<<EOS
|
395
395
|
<dt class='result-file'>#{file_or_dirimg(true, @suburl)}<a href='#{@homeurl + record_link(record)}'>#{filename}</a></dt>
|
@@ -417,7 +417,7 @@ EOS
|
|
417
417
|
refinements << "<a href='#{refinement_suffix(record.suffix)}'>.#{record.suffix}</a>" if record.suffix
|
418
418
|
|
419
419
|
# ディレクトリで絞り込み
|
420
|
-
path = Util
|
420
|
+
path = Util.relative_path(record.shortpath, @path)
|
421
421
|
dirname = path.to_s.split('/')[-2]
|
422
422
|
refinements << "<a href='#{refinement_directory(record.shortpath + '/..')}'>#{dirname}/</a>" if dirname
|
423
423
|
|
@@ -78,8 +78,8 @@ EOF
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def result_record(record)
|
81
|
-
filename = Util
|
82
|
-
filename = Util
|
81
|
+
filename = Util.relative_path(record.shortpath, @path).to_s
|
82
|
+
filename = Util.highlight_keywords(filename, @q.fpaths + @q.fpath_or_packages, 'highlight-filename')
|
83
83
|
|
84
84
|
<<EOS
|
85
85
|
<dt class='result-file'>#{file_or_dirimg(true, @suburl)}<a href='#{@homeurl + record_link(record)}'>#{filename}</a></dt>
|
@@ -32,7 +32,7 @@ module Milkode
|
|
32
32
|
@homeurl = @suburl + "/home/"
|
33
33
|
|
34
34
|
# 検索クエリを解析
|
35
|
-
gotolines = Util
|
35
|
+
gotolines = Util.parse_gotoline(@q.gotolines + @q.keywords)
|
36
36
|
@gotoline = gotolines[0]
|
37
37
|
|
38
38
|
# 検索
|
@@ -129,7 +129,7 @@ EOF
|
|
129
129
|
url = @homeurl + record_link(record)
|
130
130
|
|
131
131
|
<<EOS
|
132
|
-
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util
|
132
|
+
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util.relative_path record.shortpath, @path}</a></dt>
|
133
133
|
<dd>
|
134
134
|
#{coderay.to_html_anchorlink(url)}
|
135
135
|
</dd>
|
@@ -33,7 +33,7 @@ module Milkode
|
|
33
33
|
@homeurl = @suburl + "/home/"
|
34
34
|
|
35
35
|
# 検索クエリを解析
|
36
|
-
@gotolines = Util
|
36
|
+
@gotolines = Util.parse_gotoline(@q.keywords)
|
37
37
|
|
38
38
|
# レコードをピックアップ
|
39
39
|
@records = []
|
@@ -118,7 +118,7 @@ EOF
|
|
118
118
|
url = @homeurl + record_link(record)
|
119
119
|
|
120
120
|
<<EOS
|
121
|
-
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util
|
121
|
+
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util.relative_path record.shortpath, @path}</a></dt>
|
122
122
|
<dd>
|
123
123
|
#{coderay.to_html_anchorlink(url)}
|
124
124
|
</dd>
|
data/lib/milkode/common/util.rb
CHANGED
@@ -6,6 +6,7 @@ require 'pathname'
|
|
6
6
|
require 'kconv'
|
7
7
|
require 'open3'
|
8
8
|
require 'strscan'
|
9
|
+
require 'whichr'
|
9
10
|
|
10
11
|
module Milkode
|
11
12
|
module Util
|
@@ -116,7 +117,7 @@ module Milkode
|
|
116
117
|
end
|
117
118
|
|
118
119
|
def ignore_case?(pattens, is_sensitive)
|
119
|
-
!is_sensitive && (pattens.all? {|v| Util
|
120
|
+
!is_sensitive && (pattens.all? {|v| Util.downcase? v})
|
120
121
|
end
|
121
122
|
|
122
123
|
def gotoline_keyword?(keyword)
|
@@ -235,11 +236,15 @@ module Milkode
|
|
235
236
|
|
236
237
|
# 指定したコマンドが存在するか?
|
237
238
|
def exist_command?(command)
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
239
|
+
# open3 : Not working on Pure Windows
|
240
|
+
# begin
|
241
|
+
# Open3.capture3('type', command)[2].exited?
|
242
|
+
# rescue Errno::ENOENT
|
243
|
+
# false
|
244
|
+
# end
|
245
|
+
|
246
|
+
# whichr
|
247
|
+
!(RubyWhich.new.which(command).empty?)
|
243
248
|
end
|
244
249
|
|
245
250
|
def highlight_keywords(src, keywords, css_class)
|
@@ -124,12 +124,12 @@ EOF
|
|
124
124
|
def add(package_dir, restpath, package_name = nil)
|
125
125
|
filename = File.join(package_dir, restpath) # フルパスの作成
|
126
126
|
filename = File.expand_path(filename) # 絶対パスに変換
|
127
|
-
path = Util
|
127
|
+
path = Util.filename_to_utf8(filename) # データベースに格納する時のファイル名はutf8
|
128
128
|
package = package_name || File.basename(package_dir)
|
129
|
-
package = Util
|
130
|
-
restpath = Util
|
129
|
+
package = Util.filename_to_utf8(package)
|
130
|
+
restpath = Util.filename_to_utf8(restpath)
|
131
131
|
suffix = File.extname(path).sub('.', "")
|
132
|
-
timestamp = Util
|
132
|
+
timestamp = Util.truncate_nsec(File.mtime(filename)) # OSへの問い合わせは変換前のファイル名で
|
133
133
|
|
134
134
|
record = @table[path]
|
135
135
|
|
@@ -173,7 +173,7 @@ EOF
|
|
173
173
|
|
174
174
|
# shortpathの一致するレコードを取得
|
175
175
|
def find_shortpath(shortpath)
|
176
|
-
package, restpath = Util
|
176
|
+
package, restpath = Util.divide_shortpath(shortpath)
|
177
177
|
result = @table.select { |record| (record.package == package) & (record.restpath == restpath) }
|
178
178
|
return result.records[0]
|
179
179
|
end
|
@@ -183,7 +183,7 @@ EOF
|
|
183
183
|
if (shortpath.nil? || shortpath.empty?)
|
184
184
|
@table.select.records
|
185
185
|
else
|
186
|
-
package, restpath = Util
|
186
|
+
package, restpath = Util.divide_shortpath(shortpath)
|
187
187
|
|
188
188
|
if (restpath.nil? || restpath.empty?)
|
189
189
|
@table.select { |record| record.package == package }.to_a
|
@@ -406,7 +406,7 @@ EOF
|
|
406
406
|
private
|
407
407
|
|
408
408
|
def load_content(filename)
|
409
|
-
Util
|
409
|
+
Util.load_content($stdout, filename)
|
410
410
|
end
|
411
411
|
|
412
412
|
def package_expression(record, packages)
|
@@ -205,9 +205,6 @@ module Milkode
|
|
205
205
|
# 除外ディレクトリならばパス
|
206
206
|
next if ignoreDir?(fpath, next_path)
|
207
207
|
|
208
|
-
# 読み込み不可ならばパス
|
209
|
-
next unless FileTest.readable?(fpath)
|
210
|
-
|
211
208
|
# ファイルならば中身を探索、ディレクトリならば再帰
|
212
209
|
case File.ftype(fpath)
|
213
210
|
when "directory"
|
@@ -229,9 +226,14 @@ module Milkode
|
|
229
226
|
end
|
230
227
|
|
231
228
|
def ignoreFile?(fpath, mini_path)
|
232
|
-
|
233
|
-
GrenFileTest::
|
234
|
-
|
229
|
+
begin
|
230
|
+
GrenFileTest::ignoreFile?(fpath) ||
|
231
|
+
GrenFileTest::binary?(fpath) ||
|
232
|
+
package_ignore?(fpath, mini_path)
|
233
|
+
rescue Errno::EACCES # Can't read file
|
234
|
+
alert_info("skip", "Permission denied - #{fpath}")
|
235
|
+
true
|
236
|
+
end
|
235
237
|
end
|
236
238
|
|
237
239
|
def package_ignore?(fpath, mini_path)
|
@@ -248,7 +250,7 @@ module Milkode
|
|
248
250
|
|
249
251
|
if File.exist? filename
|
250
252
|
alert_info("add_ignore", filename)
|
251
|
-
str = Util
|
253
|
+
str = Util.load_content($stdout, filename)
|
252
254
|
@current_ignore.add IgnoreSetting.create_from_gitignore(path, str)
|
253
255
|
end
|
254
256
|
end
|
@@ -256,7 +258,7 @@ module Milkode
|
|
256
258
|
def add_global_gitignore(filename)
|
257
259
|
if File.exist? filename
|
258
260
|
alert_info("add_ignore", filename)
|
259
|
-
str = Util
|
261
|
+
str = Util.load_content($stdout, filename)
|
260
262
|
@current_ignore.add IgnoreSetting.create_from_gitignore("/", str)
|
261
263
|
end
|
262
264
|
end
|
@@ -266,7 +268,7 @@ module Milkode
|
|
266
268
|
end
|
267
269
|
|
268
270
|
def alert(title, msg)
|
269
|
-
if (Util
|
271
|
+
if (Util.platform_win?)
|
270
272
|
@out.puts "#{title.ljust(10)} : #{Kconv.kconv(msg, Kconv::SJIS)}"
|
271
273
|
else
|
272
274
|
@out.puts "#{title.ljust(10)} : #{msg}"
|
@@ -14,8 +14,19 @@ module Milkode
|
|
14
14
|
AUTO_EXTERNAL_RECORD_NUM = 500
|
15
15
|
|
16
16
|
def self.execute(stdout, arguments=[])
|
17
|
+
begin
|
18
|
+
execute_in(stdout, arguments)
|
19
|
+
rescue Interrupt
|
20
|
+
puts
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.execute_in(stdout, arguments)
|
25
|
+
# Add ENV['GMILK_OPTIONS'] value
|
26
|
+
arguments += ENV['GMILK_OPTIONS'].split if ENV['GMILK_OPTIONS']
|
27
|
+
|
17
28
|
# 引数の文字コードをUTF-8に変換
|
18
|
-
if (Util
|
29
|
+
if (Util.platform_win?)
|
19
30
|
arguments = arguments.map{|arg| Kconv.kconv(arg, Kconv::UTF8)}
|
20
31
|
end
|
21
32
|
|
@@ -79,7 +90,7 @@ EOF
|
|
79
90
|
opt.on('-n NUM', 'Limits the number of match to show.') {|v| option.matchCountLimit = v.to_i }
|
80
91
|
opt.on('--no-external', 'Disable auto external.') {|v| my_option[:no_external] = true }
|
81
92
|
opt.on('--no-snip', 'There being a long line, it does not snip.') {|v| option.noSnip = true }
|
82
|
-
opt.on('-o ENCODE', '--output-encode ENCODE', 'Specify output encode(none, jis, sjis, euc, ascii, utf8, utf16). Default is "utf8"') {|v| option.output_kcode = Util
|
93
|
+
opt.on('-o ENCODE', '--output-encode ENCODE', 'Specify output encode(none, jis, sjis, euc, ascii, utf8, utf16). Default is "utf8"') {|v| option.output_kcode = Util.str2kcode(v) }
|
83
94
|
opt.on('-p PACKAGE', '--package PACKAGE', 'Specify search package.') {|v| setup_package(option, my_option, v) }
|
84
95
|
opt.on('-r', '--root', 'Search from package root.') {|v| current_dir = package_root_dir(File.expand_path(".")); my_option[:find_mode] = true }
|
85
96
|
opt.on('-s SUFFIX', '--suffix SUFFIX', 'Suffix.') {|v| option.suffixs << v; my_option[:find_mode] = true }
|
@@ -101,7 +112,7 @@ EOF
|
|
101
112
|
|
102
113
|
unless ap.gotowords.empty?
|
103
114
|
my_option[:find_mode] = true
|
104
|
-
my_option[:gotoline_data] = Util
|
115
|
+
my_option[:gotoline_data] = Util.parse_gotoline(ap.gotowords)
|
105
116
|
end
|
106
117
|
|
107
118
|
# p ap.arguments
|
@@ -189,7 +200,7 @@ EOF
|
|
189
200
|
my_option[:gotoline_data].each do |v|
|
190
201
|
if is_abs_path
|
191
202
|
# @memo ここにはこないはず
|
192
|
-
package, restpath = Util
|
203
|
+
package, restpath = Util.divide_shortpath(v[0][0])
|
193
204
|
# p [package, restpath]
|
194
205
|
option.packages = [package]
|
195
206
|
option.filePatterns = [restpath]
|
@@ -210,8 +221,8 @@ EOF
|
|
210
221
|
findGrep.searchAndPrint2(stdout, records)
|
211
222
|
else
|
212
223
|
# レコード数が多い時は"-e grep"で検索
|
213
|
-
if Util
|
214
|
-
$stderr.puts "
|
224
|
+
if Util.exist_command?('cat') && Util.exist_command?('grep') && Util.exist_command?('xargs')
|
225
|
+
$stderr.puts "Because number of records is large, Milkode use external tool. (Same as 'gmilk -e grep')"
|
215
226
|
search_external_tool(arguments, option, records, 'grep -n', 'grep')
|
216
227
|
else
|
217
228
|
findGrep.searchAndPrint2(stdout, records)
|
@@ -330,7 +341,7 @@ EOF
|
|
330
341
|
|
331
342
|
def after
|
332
343
|
if @arguments.first
|
333
|
-
if Util
|
344
|
+
if Util.gotoline_keyword? @arguments[0]
|
334
345
|
@state = :gotoline
|
335
346
|
end
|
336
347
|
end
|
@@ -16,12 +16,12 @@ module Milkode
|
|
16
16
|
|
17
17
|
def search_and_print(stdout)
|
18
18
|
@gotolines.each do |gotoline|
|
19
|
-
package_name, restpath = Util
|
19
|
+
package_name, restpath = Util.divide_shortpath(gotoline[0][0])
|
20
20
|
package = @yaml.find_name(package_name)
|
21
21
|
|
22
22
|
if package
|
23
23
|
path = File.join(package.directory, restpath)
|
24
|
-
relative_path = Util
|
24
|
+
relative_path = Util.relative_path(path, Dir.pwd).to_s
|
25
25
|
lineno = gotoline[1]
|
26
26
|
content = get_text_lineno(path, lineno)
|
27
27
|
|
@@ -45,8 +45,8 @@ module Milkode
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def print(stdout)
|
48
|
-
stdout.puts "dir : #{@start_dir} (#{Gren::Util
|
49
|
-
stdout.puts "files : #{@search_count} in #{@count} (#{Gren::Util
|
48
|
+
stdout.puts "dir : #{@start_dir} (#{Gren::Util.time_s(time)})"
|
49
|
+
stdout.puts "files : #{@search_count} in #{@count} (#{Gren::Util.size_s(@search_size)} in #{Gren::Util.size_s(@size)})"
|
50
50
|
stdout.puts "match : #{@match_file_count} files, #{match_count} hit"
|
51
51
|
end
|
52
52
|
end
|
@@ -91,7 +91,7 @@ module Milkode
|
|
91
91
|
|
92
92
|
strs.each do |v|
|
93
93
|
option = 0
|
94
|
-
option |= Regexp::IGNORECASE if (@option.ignoreCase || (!@option.caseSensitive && Milkode::Util
|
94
|
+
option |= Regexp::IGNORECASE if (@option.ignoreCase || (!@option.caseSensitive && Milkode::Util.downcase?(v)))
|
95
95
|
regs << Regexp.new(v, option)
|
96
96
|
end
|
97
97
|
|
@@ -155,7 +155,7 @@ module Milkode
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def time_s
|
158
|
-
Gren::Util
|
158
|
+
Gren::Util.time_s(@result.time)
|
159
159
|
end
|
160
160
|
|
161
161
|
def searchFromDB(stdout, records, dir)
|
@@ -167,7 +167,7 @@ module Milkode
|
|
167
167
|
if (@option.gotoline > 0)
|
168
168
|
records.each do |record|
|
169
169
|
if FileTest.exist?(record.path)
|
170
|
-
relative_path = Milkode::Util
|
170
|
+
relative_path = Milkode::Util.relative_path(record.path, Dir.pwd).to_s
|
171
171
|
line = getTextLineno(relative_path, @option.gotoline)
|
172
172
|
stdout.puts "#{relative_path}:#{@option.gotoline}:#{line}" if (line)
|
173
173
|
@result.match_file_count += 1
|
@@ -185,7 +185,7 @@ module Milkode
|
|
185
185
|
else
|
186
186
|
records.each do |record|
|
187
187
|
path = record.path
|
188
|
-
relative_path = Milkode::Util
|
188
|
+
relative_path = Milkode::Util.relative_path(path, Dir.pwd).to_s
|
189
189
|
stdout.puts relative_path
|
190
190
|
@result.match_file_count += 1
|
191
191
|
raise MatchCountOverError if (0 < @option.matchCountLimit && @option.matchCountLimit <= @result.match_file_count)
|
@@ -340,7 +340,7 @@ module Milkode
|
|
340
340
|
if ( result )
|
341
341
|
unless (@option.dispHtml)
|
342
342
|
# header = "#{path}:#{index + 1}:"
|
343
|
-
rpath = Milkode::Util
|
343
|
+
rpath = Milkode::Util.relative_path(path, Dir.pwd).to_s
|
344
344
|
header = "#{rpath}:#{index + 1}:"
|
345
345
|
|
346
346
|
line = GrenSnip::snip(line, match_datas) unless (@option.noSnip)
|
@@ -391,7 +391,7 @@ EOF
|
|
391
391
|
def self.file2lines(file, kcode)
|
392
392
|
data = file.read
|
393
393
|
|
394
|
-
unless Milkode::Util
|
394
|
+
unless Milkode::Util.ruby19?
|
395
395
|
if (kcode != Kconv::NOCONV)
|
396
396
|
file_kcode = Kconv::guess(data)
|
397
397
|
|
data/milkode.gemspec
CHANGED
@@ -5,17 +5,17 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "milkode"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.6.0"
|
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 = "2014-
|
13
|
-
s.description = "
|
12
|
+
s.date = "2014-04-13"
|
13
|
+
s.description = "Milkode is line based local source code search engine. It have command line interface and web application. It will accelerate the code reading of your life."
|
14
14
|
s.email = "ongaeshi0621@gmail.com"
|
15
15
|
s.executables = ["gmilk", "milk"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
|
-
"README.
|
18
|
+
"README.md"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"HISTORY.ja.rdoc",
|
25
25
|
"HISTORY.rdoc",
|
26
26
|
"LICENSE.txt",
|
27
|
-
"README.
|
27
|
+
"README.md",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"bin/gmilk",
|
@@ -202,7 +202,7 @@ Gem::Specification.new do |s|
|
|
202
202
|
s.licenses = ["MIT"]
|
203
203
|
s.require_paths = ["lib"]
|
204
204
|
s.rubygems_version = "1.8.23"
|
205
|
-
s.summary = "Line based local source code search engine
|
205
|
+
s.summary = "Line based local source code search engine."
|
206
206
|
|
207
207
|
if s.respond_to? :specification_version then
|
208
208
|
s.specification_version = 3
|
@@ -214,12 +214,13 @@ Gem::Specification.new do |s|
|
|
214
214
|
s.add_runtime_dependency(%q<sinatra>, [">= 1.2.6"])
|
215
215
|
s.add_runtime_dependency(%q<launchy>, [">= 0.3.7"])
|
216
216
|
s.add_runtime_dependency(%q<coderay>, [">= 1.0.5"])
|
217
|
-
s.add_runtime_dependency(%q<thin>, [">= 1.2.10"])
|
217
|
+
s.add_runtime_dependency(%q<thin>, ["< 2.0.0", ">= 1.2.10"])
|
218
218
|
s.add_runtime_dependency(%q<archive-zip>, [">= 0.4.0"])
|
219
219
|
s.add_runtime_dependency(%q<haml>, [">= 3.1.2"])
|
220
220
|
s.add_runtime_dependency(%q<sass>, [">= 3.1.3"])
|
221
221
|
s.add_runtime_dependency(%q<thor>, [">= 0.18.1"])
|
222
222
|
s.add_runtime_dependency(%q<i18n>, ["~> 0.6.5"])
|
223
|
+
s.add_runtime_dependency(%q<whichr>, ["~> 0.3"])
|
223
224
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
224
225
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
225
226
|
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
@@ -232,12 +233,13 @@ Gem::Specification.new do |s|
|
|
232
233
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
233
234
|
s.add_dependency(%q<launchy>, [">= 0.3.7"])
|
234
235
|
s.add_dependency(%q<coderay>, [">= 1.0.5"])
|
235
|
-
s.add_dependency(%q<thin>, [">= 1.2.10"])
|
236
|
+
s.add_dependency(%q<thin>, ["< 2.0.0", ">= 1.2.10"])
|
236
237
|
s.add_dependency(%q<archive-zip>, [">= 0.4.0"])
|
237
238
|
s.add_dependency(%q<haml>, [">= 3.1.2"])
|
238
239
|
s.add_dependency(%q<sass>, [">= 3.1.3"])
|
239
240
|
s.add_dependency(%q<thor>, [">= 0.18.1"])
|
240
241
|
s.add_dependency(%q<i18n>, ["~> 0.6.5"])
|
242
|
+
s.add_dependency(%q<whichr>, ["~> 0.3"])
|
241
243
|
s.add_dependency(%q<bundler>, [">= 0"])
|
242
244
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
243
245
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
@@ -251,12 +253,13 @@ Gem::Specification.new do |s|
|
|
251
253
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
252
254
|
s.add_dependency(%q<launchy>, [">= 0.3.7"])
|
253
255
|
s.add_dependency(%q<coderay>, [">= 1.0.5"])
|
254
|
-
s.add_dependency(%q<thin>, [">= 1.2.10"])
|
256
|
+
s.add_dependency(%q<thin>, ["< 2.0.0", ">= 1.2.10"])
|
255
257
|
s.add_dependency(%q<archive-zip>, [">= 0.4.0"])
|
256
258
|
s.add_dependency(%q<haml>, [">= 3.1.2"])
|
257
259
|
s.add_dependency(%q<sass>, [">= 3.1.3"])
|
258
260
|
s.add_dependency(%q<thor>, [">= 0.18.1"])
|
259
261
|
s.add_dependency(%q<i18n>, ["~> 0.6.5"])
|
262
|
+
s.add_dependency(%q<whichr>, ["~> 0.3"])
|
260
263
|
s.add_dependency(%q<bundler>, [">= 0"])
|
261
264
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
262
265
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
data/test/test_cli.rb
CHANGED
@@ -26,9 +26,9 @@ class TestCLI < Test::Unit::TestCase
|
|
26
26
|
def test_add
|
27
27
|
# system("type git")
|
28
28
|
command("add")
|
29
|
-
assert_not_match /error/, command("add git
|
30
|
-
assert_not_match /error/, command("add git
|
31
|
-
# assert_match /error/, command("add git
|
29
|
+
assert_not_match /error/, command("add git://github.com/ongaeshi/mini-repo-git.git")
|
30
|
+
assert_not_match /error/, command("add git://github.com/ongaeshi/mini-repo-git.git -n mrg-develop -b develop")
|
31
|
+
# assert_match /error/, command("add git://github.com/ongaeshi/mini-repo-git.git -n mrg-developa -b developa") # not found branch
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_grep
|
data/test/test_ignore_setting.rb
CHANGED
@@ -106,7 +106,7 @@ EOF
|
|
106
106
|
|
107
107
|
def test_create_from_gitignore_sjis
|
108
108
|
Dir.chdir(File.join(File.dirname(__FILE__))) do
|
109
|
-
str = Milkode::Util
|
109
|
+
str = Milkode::Util.load_content($stdout, "data/.gitignore.sjis") # sjis -> utf-8
|
110
110
|
is = IgnoreSetting.create_from_gitignore("/doc", str)
|
111
111
|
assert_equal "/doc", is.path
|
112
112
|
assert_equal ["coverage", "rdoc", "doc", ".yardoc", ".bundle", "pkg"], is.ignores
|
data/test/test_milkode_yaml.rb
CHANGED
@@ -36,9 +36,9 @@ EOF
|
|
36
36
|
|
37
37
|
def test_dump
|
38
38
|
obj = MilkodeYaml.new(SRC)
|
39
|
-
if Milkode::Util
|
39
|
+
if Milkode::Util.ruby20?
|
40
40
|
assert_equal SRC, obj.dump
|
41
|
-
elsif Milkode::Util
|
41
|
+
elsif Milkode::Util.ruby19?
|
42
42
|
assert_equal <<EOF, obj.dump
|
43
43
|
---
|
44
44
|
version: '0.2'
|
@@ -75,7 +75,7 @@ EOF
|
|
75
75
|
|
76
76
|
assert_equal 1, obj.contents.size
|
77
77
|
|
78
|
-
assert_equal <<EOF, obj.dump if Milkode::Util
|
78
|
+
assert_equal <<EOF, obj.dump if Milkode::Util.ruby19?
|
79
79
|
---
|
80
80
|
version: '0.2'
|
81
81
|
contents:
|
@@ -89,7 +89,7 @@ EOF
|
|
89
89
|
|
90
90
|
assert_equal 2, obj.contents.size
|
91
91
|
|
92
|
-
if Milkode::Util
|
92
|
+
if Milkode::Util.ruby20?
|
93
93
|
assert_equal <<EOF, obj.dump
|
94
94
|
---
|
95
95
|
version: '0.2'
|
@@ -100,7 +100,7 @@ contents:
|
|
100
100
|
- '*.bak'
|
101
101
|
- /rdoc
|
102
102
|
EOF
|
103
|
-
elsif Milkode::Util
|
103
|
+
elsif Milkode::Util.ruby19?
|
104
104
|
assert_equal <<EOF, obj.dump
|
105
105
|
---
|
106
106
|
version: '0.2'
|
@@ -122,7 +122,7 @@ EOF
|
|
122
122
|
obj = MilkodeYaml.new(V_0_1)
|
123
123
|
assert_equal true, obj.migrate
|
124
124
|
|
125
|
-
assert_equal <<EOF, obj.dump if Milkode::Util
|
125
|
+
assert_equal <<EOF, obj.dump if Milkode::Util.ruby19?
|
126
126
|
---
|
127
127
|
version: '0.2'
|
128
128
|
contents:
|
@@ -145,7 +145,7 @@ EOF
|
|
145
145
|
p = Package.create(p.directory, p.ignore + ['*.a'])
|
146
146
|
obj.update(p)
|
147
147
|
|
148
|
-
if Milkode::Util
|
148
|
+
if Milkode::Util.ruby20?
|
149
149
|
assert_equal <<EOF, obj.dump
|
150
150
|
---
|
151
151
|
version: '0.2'
|
@@ -158,7 +158,7 @@ contents:
|
|
158
158
|
- '*.a'
|
159
159
|
- directory: /a/b/c
|
160
160
|
EOF
|
161
|
-
elsif Milkode::Util
|
161
|
+
elsif Milkode::Util.ruby19?
|
162
162
|
assert_equal <<EOF, obj.dump
|
163
163
|
---
|
164
164
|
version: '0.2'
|
data/test/test_package_table.rb
CHANGED
data/test/test_util.rb
CHANGED
@@ -14,13 +14,13 @@ class TestUtil < Test::Unit::TestCase
|
|
14
14
|
include FileTestUtils
|
15
15
|
|
16
16
|
def test_zip_extract
|
17
|
-
Milkode::Util
|
17
|
+
Milkode::Util.zip_extract('../data/abc.zip', '.')
|
18
18
|
assert File.exist?('abc')
|
19
19
|
assert File.exist?('abc/a.txt')
|
20
20
|
assert File.exist?('abc/b.txt')
|
21
21
|
assert File.exist?('abc/c.txt')
|
22
22
|
|
23
|
-
Milkode::Util
|
23
|
+
Milkode::Util.zip_extract('../data/nodir_abc.zip', '.')
|
24
24
|
assert File.exist?('nodir_abc')
|
25
25
|
assert File.exist?('nodir_abc/a.txt')
|
26
26
|
assert File.exist?('nodir_abc/b.txt')
|
@@ -29,17 +29,17 @@ class TestUtil < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
# Remove because fail test on single test
|
31
31
|
# def test_root_entrylist
|
32
|
-
# assert_equal ['abc/'], Milkode::Util
|
33
|
-
# assert_equal ['a.txt', 'b.txt', 'c.txt'], Milkode::Util
|
32
|
+
# assert_equal ['abc/'], Milkode::Util.root_entrylist('../data/abc.zip')
|
33
|
+
# assert_equal ['a.txt', 'b.txt', 'c.txt'], Milkode::Util.root_entrylist('../data/nodir_abc.zip')
|
34
34
|
# end
|
35
35
|
|
36
36
|
def test_platform
|
37
|
-
if (Milkode::Util
|
38
|
-
assert_equal Milkode::Util
|
37
|
+
if (Milkode::Util.platform_osx?)
|
38
|
+
assert_equal Milkode::Util.shell_kcode, Kconv::UTF8
|
39
39
|
end
|
40
40
|
|
41
|
-
if (Milkode::Util
|
42
|
-
assert_equal Milkode::Util
|
41
|
+
if (Milkode::Util.platform_win?)
|
42
|
+
assert_equal Milkode::Util.shell_kcode, Kconv::SJIS
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -55,92 +55,92 @@ class TestUtil < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_filename_to_utf8
|
58
|
-
if (Milkode::Util
|
59
|
-
assert_equal Encoding::UTF_8, Milkode::Util
|
60
|
-
assert_equal Encoding::UTF_8, Milkode::Util
|
58
|
+
if (Milkode::Util.ruby19?)
|
59
|
+
assert_equal Encoding::UTF_8, Milkode::Util.filename_to_utf8('ダミー').encoding
|
60
|
+
assert_equal Encoding::UTF_8, Milkode::Util.filename_to_utf8(create_filename_str('ダミー')).encoding
|
61
61
|
else
|
62
62
|
# 実行だけはしておく
|
63
|
-
Milkode::Util
|
64
|
-
Milkode::Util
|
63
|
+
Milkode::Util.filename_to_utf8('ダミー')
|
64
|
+
Milkode::Util.filename_to_utf8(create_filename_str('ダミー'))
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_downcase?
|
69
|
-
assert !Milkode::Util
|
70
|
-
assert Milkode::Util
|
71
|
-
assert !Milkode::Util
|
72
|
-
assert !Milkode::Util
|
69
|
+
assert !Milkode::Util.downcase?("DUMMY")
|
70
|
+
assert Milkode::Util.downcase?("dummy")
|
71
|
+
assert !Milkode::Util.downcase?("Dummy")
|
72
|
+
assert !Milkode::Util.downcase?("dummyNode")
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_ignore_case?
|
76
|
-
assert_equal true, Milkode::Util
|
77
|
-
assert_equal false, Milkode::Util
|
78
|
-
assert_equal false, Milkode::Util
|
79
|
-
assert_equal false, Milkode::Util
|
76
|
+
assert_equal true, Milkode::Util.ignore_case?(['a', 'b'], false)
|
77
|
+
assert_equal false, Milkode::Util.ignore_case?(['a', 'b'], true)
|
78
|
+
assert_equal false, Milkode::Util.ignore_case?(['a', 'B'], false)
|
79
|
+
assert_equal false, Milkode::Util.ignore_case?(['A', 'b'], true)
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_parse_gotoline
|
83
|
-
assert_equal [[['a', 'b'], 123]], Milkode::Util
|
84
|
-
assert_equal [[['a', '123', 'b'], 55]], Milkode::Util
|
85
|
-
assert_equal [[['a', 'b'], 1]], Milkode::Util
|
86
|
-
assert_equal [[['a'], 55]], Milkode::Util
|
87
|
-
assert_equal [[['lib/aaa.c'], 8], [['test/bbb.rb'], 9]], Milkode::Util
|
88
|
-
assert_equal [[['c:/tmp/ccc.txt'], 99]], Milkode::Util
|
89
|
-
assert_equal [[['/milkode/hoge.rb'], 99]], Milkode::Util
|
83
|
+
assert_equal [[['a', 'b'], 123]], Milkode::Util.parse_gotoline(['a', '123', 'b'])
|
84
|
+
assert_equal [[['a', '123', 'b'], 55]], Milkode::Util.parse_gotoline(['a', '123', 'b', '55'])
|
85
|
+
assert_equal [[['a', 'b'], 1]], Milkode::Util.parse_gotoline(['a', 'b'])
|
86
|
+
assert_equal [[['a'], 55]], Milkode::Util.parse_gotoline(['a:55'])
|
87
|
+
assert_equal [[['lib/aaa.c'], 8], [['test/bbb.rb'], 9]], Milkode::Util.parse_gotoline(['lib/aaa.c:8', 'test/bbb.rb:9'])
|
88
|
+
assert_equal [[['c:/tmp/ccc.txt'], 99]], Milkode::Util.parse_gotoline(['c:/tmp/ccc.txt:99'])
|
89
|
+
assert_equal [[['/milkode/hoge.rb'], 99]], Milkode::Util.parse_gotoline(['/milkode/hoge.rb:99'])
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_gotoline_multi?
|
93
|
-
assert_equal true, Milkode::Util
|
94
|
-
assert_equal true, Milkode::Util
|
95
|
-
assert_equal false, Milkode::Util
|
96
|
-
assert_equal false, Milkode::Util
|
93
|
+
assert_equal true, Milkode::Util.gotoline_multi?("test:1".split)
|
94
|
+
assert_equal true, Milkode::Util.gotoline_multi?("test.rb:5 lib.c:10".split)
|
95
|
+
assert_equal false, Milkode::Util.gotoline_multi?("a 123 b".split)
|
96
|
+
assert_equal false, Milkode::Util.gotoline_multi?("c:/user 5".split)
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_git_url?
|
100
|
-
assert_equal false, Milkode::Util
|
101
|
-
assert_equal true, Milkode::Util
|
102
|
-
assert_equal true, Milkode::Util
|
103
|
-
assert_equal true, Milkode::Util
|
104
|
-
assert_equal true, Milkode::Util
|
100
|
+
assert_equal false, Milkode::Util.git_url?('http:://ongaeshi.me')
|
101
|
+
assert_equal true, Milkode::Util.git_url?('git://github.com/ongaeshi/milkode.git')
|
102
|
+
assert_equal true, Milkode::Util.git_url?('git@github.com:ongaeshi/milkode.git')
|
103
|
+
assert_equal true, Milkode::Util.git_url?('ssh:foo@bar/baz.git')
|
104
|
+
assert_equal true, Milkode::Util.git_url?('https://github.com/ongaeshi/milkode.git')
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_svn_url?
|
108
|
-
assert_equal true, Milkode::Util
|
109
|
-
assert_equal true, Milkode::Util
|
110
|
-
assert_equal false, Milkode::Util
|
111
|
-
assert_equal false, Milkode::Util
|
112
|
-
assert_equal false, Milkode::Util
|
113
|
-
assert_equal false, Milkode::Util
|
114
|
-
assert_equal false, Milkode::Util
|
108
|
+
assert_equal true, Milkode::Util.svn_url?('svn://ongaeshi.me/svn/trunk/')
|
109
|
+
assert_equal true, Milkode::Util.svn_url?('svn+ssh://ongaeshi.me/svn/trunk/')
|
110
|
+
assert_equal false, Milkode::Util.svn_url?('svna://ongaeshi.me/svn/trunk/')
|
111
|
+
assert_equal false, Milkode::Util.svn_url?('http:://ongaeshi.me')
|
112
|
+
assert_equal false, Milkode::Util.svn_url?('git://github.com/ongaeshi/milkode.git')
|
113
|
+
assert_equal false, Milkode::Util.svn_url?('git@github.com:ongaeshi/milkode.git')
|
114
|
+
assert_equal false, Milkode::Util.svn_url?('ssh:foo@bar/baz.git')
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_divide_shortpath
|
118
|
-
package, restpath = Milkode::Util
|
118
|
+
package, restpath = Milkode::Util.divide_shortpath('package/to/a.txt')
|
119
119
|
assert_equal 'package', package
|
120
120
|
assert_equal 'to/a.txt', restpath
|
121
121
|
|
122
|
-
package, restpath = Milkode::Util
|
122
|
+
package, restpath = Milkode::Util.divide_shortpath('/package/to/a.txt')
|
123
123
|
assert_equal 'package', package
|
124
124
|
assert_equal 'to/a.txt', restpath
|
125
125
|
end
|
126
126
|
|
127
127
|
def test_highlight_keywords
|
128
|
-
assert_equal "stringstr", Milkode::Util
|
129
|
-
assert_equal "<span class='attr'>str</span>ing", Milkode::Util
|
130
|
-
assert_equal "<span class='attr'>str</span>ing<span class='attr'>str</span>", Milkode::Util
|
131
|
-
assert_equal "<span class='attr'>stri</span>ng<span class='attr'>str</span>", Milkode::Util
|
132
|
-
assert_equal "abc<span class='attr'>d</span>", Milkode::Util
|
133
|
-
assert_equal "<span class='attr'>日本</span>語a<span class='attr'>bc</span>dで<span class='attr'>す</span>", Milkode::Util
|
134
|
-
assert_equal "<span><span class='attr'>span</span></span>", Milkode::Util
|
128
|
+
assert_equal "stringstr", Milkode::Util.highlight_keywords("stringstr", [], 'attr')
|
129
|
+
assert_equal "<span class='attr'>str</span>ing", Milkode::Util.highlight_keywords("string", ["str"], 'attr')
|
130
|
+
assert_equal "<span class='attr'>str</span>ing<span class='attr'>str</span>", Milkode::Util.highlight_keywords("stringstr", ["str"], 'attr')
|
131
|
+
assert_equal "<span class='attr'>stri</span>ng<span class='attr'>str</span>", Milkode::Util.highlight_keywords("stringstr", ["str", "i", "s"], 'attr')
|
132
|
+
assert_equal "abc<span class='attr'>d</span>", Milkode::Util.highlight_keywords("abcd", ["d"], 'attr')
|
133
|
+
assert_equal "<span class='attr'>日本</span>語a<span class='attr'>bc</span>dで<span class='attr'>す</span>", Milkode::Util.highlight_keywords("日本語abcdです", ["bc", "日本", "す"], 'attr')
|
134
|
+
assert_equal "<span><span class='attr'>span</span></span>", Milkode::Util.highlight_keywords("<span>span</span>", ["span"], 'attr')
|
135
135
|
end
|
136
136
|
|
137
137
|
def test_github_repo
|
138
|
-
assert_equal 'ongaeshi/firelink', Milkode::Util
|
139
|
-
assert_equal 'ongaeshi/milkode' , Milkode::Util
|
140
|
-
assert_equal 'ongaeshi/milkode' , Milkode::Util
|
141
|
-
assert_equal 'ongaeshi/milkode' , Milkode::Util
|
142
|
-
assert_equal 'ongaeshi/milkode' , Milkode::Util
|
143
|
-
assert_equal nil , Milkode::Util
|
138
|
+
assert_equal 'ongaeshi/firelink', Milkode::Util.github_repo('git@github.com:ongaeshi/firelink.git')
|
139
|
+
assert_equal 'ongaeshi/milkode' , Milkode::Util.github_repo('git@github.com:ongaeshi/milkode.git')
|
140
|
+
assert_equal 'ongaeshi/milkode' , Milkode::Util.github_repo('git://github.com/ongaeshi/milkode.git')
|
141
|
+
assert_equal 'ongaeshi/milkode' , Milkode::Util.github_repo('https://github.com/ongaeshi/milkode.git')
|
142
|
+
assert_equal 'ongaeshi/milkode' , Milkode::Util.github_repo('http://github.com/ongaeshi/milkode.git')
|
143
|
+
assert_equal nil , Milkode::Util.github_repo('https://ongaeshi.me/ongaeshi/milkode.git')
|
144
144
|
end
|
145
145
|
|
146
146
|
def teardown
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milkode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: termcolor
|
@@ -118,6 +118,9 @@ dependencies:
|
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
121
|
+
- - <
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 2.0.0
|
121
124
|
- - ! '>='
|
122
125
|
- !ruby/object:Gem::Version
|
123
126
|
version: 1.2.10
|
@@ -126,6 +129,9 @@ dependencies:
|
|
126
129
|
version_requirements: !ruby/object:Gem::Requirement
|
127
130
|
none: false
|
128
131
|
requirements:
|
132
|
+
- - <
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.0.0
|
129
135
|
- - ! '>='
|
130
136
|
- !ruby/object:Gem::Version
|
131
137
|
version: 1.2.10
|
@@ -209,6 +215,22 @@ dependencies:
|
|
209
215
|
- - ~>
|
210
216
|
- !ruby/object:Gem::Version
|
211
217
|
version: 0.6.5
|
218
|
+
- !ruby/object:Gem::Dependency
|
219
|
+
name: whichr
|
220
|
+
requirement: !ruby/object:Gem::Requirement
|
221
|
+
none: false
|
222
|
+
requirements:
|
223
|
+
- - ~>
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0.3'
|
226
|
+
type: :runtime
|
227
|
+
prerelease: false
|
228
|
+
version_requirements: !ruby/object:Gem::Requirement
|
229
|
+
none: false
|
230
|
+
requirements:
|
231
|
+
- - ~>
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0.3'
|
212
234
|
- !ruby/object:Gem::Dependency
|
213
235
|
name: bundler
|
214
236
|
requirement: !ruby/object:Gem::Requirement
|
@@ -289,7 +311,9 @@ dependencies:
|
|
289
311
|
- - ! '>='
|
290
312
|
- !ruby/object:Gem::Version
|
291
313
|
version: 2.5.4
|
292
|
-
description:
|
314
|
+
description: Milkode is line based local source code search engine. It have command
|
315
|
+
line interface and web application. It will accelerate the code reading of your
|
316
|
+
life.
|
293
317
|
email: ongaeshi0621@gmail.com
|
294
318
|
executables:
|
295
319
|
- gmilk
|
@@ -297,7 +321,7 @@ executables:
|
|
297
321
|
extensions: []
|
298
322
|
extra_rdoc_files:
|
299
323
|
- LICENSE.txt
|
300
|
-
- README.
|
324
|
+
- README.md
|
301
325
|
files:
|
302
326
|
- .document
|
303
327
|
- .travis.yml
|
@@ -305,7 +329,7 @@ files:
|
|
305
329
|
- HISTORY.ja.rdoc
|
306
330
|
- HISTORY.rdoc
|
307
331
|
- LICENSE.txt
|
308
|
-
- README.
|
332
|
+
- README.md
|
309
333
|
- Rakefile
|
310
334
|
- VERSION
|
311
335
|
- bin/gmilk
|
@@ -502,5 +526,5 @@ rubyforge_project:
|
|
502
526
|
rubygems_version: 1.8.23
|
503
527
|
signing_key:
|
504
528
|
specification_version: 3
|
505
|
-
summary: Line based local source code search engine
|
529
|
+
summary: Line based local source code search engine.
|
506
530
|
test_files: []
|