milkode 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Gemfile +17 -4
  2. data/HISTORY.ja.rdoc +27 -0
  3. data/HISTORY.rdoc +27 -0
  4. data/LICENSE.txt +23 -1
  5. data/Rakefile +1 -16
  6. data/VERSION +1 -1
  7. data/bin/gmilk +1 -1
  8. data/bin/milk +1 -1
  9. data/lib/milkode/cdstk/cdstk.rb +171 -168
  10. data/lib/milkode/cdstk/milkode_yaml.rb +1 -1
  11. data/lib/milkode/cdweb/app.rb +11 -3
  12. data/lib/milkode/cdweb/lib/command.rb +43 -0
  13. data/lib/milkode/cdweb/lib/database.rb +58 -210
  14. data/lib/milkode/cdweb/lib/mkurl.rb +10 -1
  15. data/lib/milkode/cdweb/lib/package_list.rb +61 -0
  16. data/lib/milkode/cdweb/lib/search_files.rb +2 -1
  17. data/lib/milkode/cdweb/public/css/bootstrap-responsive.min.css +9 -0
  18. data/lib/milkode/cdweb/public/css/bootstrap.min.css +9 -0
  19. data/lib/milkode/cdweb/public/css/milkode.css +44 -9
  20. data/lib/milkode/cdweb/public/img/glyphicons-halflings-white.png +0 -0
  21. data/lib/milkode/cdweb/public/img/glyphicons-halflings.png +0 -0
  22. data/lib/milkode/cdweb/public/js/bootstrap.min.js +6 -0
  23. data/lib/milkode/cdweb/views/index.haml +52 -16
  24. data/lib/milkode/cdweb/views/packages.haml +11 -0
  25. data/lib/milkode/cli.rb +8 -0
  26. data/lib/milkode/common/array_diff.rb +18 -0
  27. data/lib/milkode/common/util.rb +16 -0
  28. data/lib/milkode/database/document_record.rb +64 -0
  29. data/lib/milkode/database/document_table.rb +341 -0
  30. data/lib/milkode/database/groonga_database.rb +105 -0
  31. data/lib/milkode/database/package_table.rb +98 -0
  32. data/lib/milkode/findgrep/findgrep.rb +20 -124
  33. data/lib/milkode/grep/cli_grep.rb +3 -1
  34. data/milkode.gemspec +32 -2
  35. data/test/data/.gitignore +4 -0
  36. data/test/data/c_project/a.txt +1 -0
  37. data/test/data/c_project/abc.c +2 -0
  38. data/test/data/c_project/abc.h +3 -0
  39. data/test/data/c_project/b.txt +1 -0
  40. data/test/data/c_project/c.txt +1 -0
  41. data/test/data/c_project/cc.txt +1 -0
  42. data/test/data/c_project/to/file.rb +1 -0
  43. data/test/test_cdstk.rb +4 -4
  44. data/test/test_cli.rb +9 -2
  45. data/test/test_database.rb +5 -14
  46. data/test/test_document_record.rb +77 -0
  47. data/test/test_document_table.rb +317 -0
  48. data/test/test_groonga_database.rb +58 -0
  49. data/test/test_mkurl.rb +2 -0
  50. data/test/test_package_list.rb +21 -0
  51. data/test/test_package_table.rb +215 -0
  52. data/test/test_util.rb +8 -0
  53. metadata +57 -5
@@ -0,0 +1,58 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # @file
4
+ # @brief
5
+ # @author ongaeshi
6
+ # @date 2010/xx/xxxx
7
+
8
+ require 'test_helper'
9
+ require 'milkode/database/groonga_database'
10
+
11
+ module Milkode
12
+ class TestGroongaDatabase < Test::Unit::TestCase
13
+ def test_database
14
+ begin
15
+ t_setup
16
+ t_open
17
+ ensure
18
+ t_cleanup
19
+ end
20
+ end
21
+
22
+ def t_setup
23
+ @obj = GroongaDatabase.new
24
+ @tmp_dir = File.join(File.dirname(__FILE__), "groonga_database_work")
25
+ end
26
+
27
+ def t_cleanup
28
+ # 本当は明示的にcloseした方が行儀が良いのだけれど、
29
+ # 単体テストの時にSementationFaultが出るのでコメントアウト
30
+ # @obj.close
31
+
32
+ # データベース削除
33
+ @obj = nil
34
+ FileUtils.rm_rf(@tmp_dir)
35
+ end
36
+
37
+ def t_open
38
+ @obj.open(@tmp_dir)
39
+ # @obj.close
40
+ end
41
+
42
+ def test_compatible?
43
+ begin
44
+ t_setup
45
+
46
+ # 互換性の無いGroongaデータベースを作る
47
+ filename = Dbdir.groonga_path(@tmp_dir)
48
+ FileUtils.mkdir_p(File.dirname filename)
49
+ Groonga::Database.create(:path => filename)
50
+ # DocumentTable.define_schema
51
+
52
+ assert_equal nil, @obj.compatible?(filename, true)
53
+ ensure
54
+ t_cleanup
55
+ end
56
+ end
57
+ end
58
+ end
@@ -24,6 +24,8 @@ module Milkode
24
24
  assert_equal '.?shead=package', Mkurl.new('.', p1).inherit_shead
25
25
  assert_equal '/home/foo/bar.hpp', Mkurl.new('/home/foo/bar.hpp', p2).inherit_shead
26
26
  assert_equal '/home/foo/bar.hpp', Mkurl.new('/home/foo/bar.hpp', p3).inherit_shead
27
+
28
+ assert_equal '/home?sort=addtime', Mkurl.new('/home', p3).inherit_query_shead_set_sort('addtime')
27
29
 
28
30
  end
29
31
  end
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # @file
4
+ # @brief
5
+ # @author ongaeshi
6
+ # @date 2010/xx/xxxx
7
+
8
+ require 'test_helper'
9
+ require 'milkode/cdweb/lib/package_list'
10
+
11
+ module Milkode
12
+ class TestPackageList < Test::Unit::TestCase
13
+ def test_top_add
14
+ # obj = PackageList.new
15
+ # obj.top_add
16
+ # obj.top_update
17
+ # obj.top_view
18
+ # obj.top_fav
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,215 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # @file
4
+ # @brief
5
+ # @author ongaeshi
6
+ # @date 2010/xx/xxxx
7
+
8
+ require 'test_helper'
9
+ require 'milkode/database/groonga_database'
10
+ require 'milkode/cdstk/package.rb'
11
+
12
+ module Milkode
13
+ class TestPackageTable < Test::Unit::TestCase
14
+ def test_database
15
+ begin
16
+ t_setup
17
+ t_open
18
+ t_packages
19
+ t_packages_viewtime
20
+ t_sort
21
+ t_yaml_sync
22
+ t_touch
23
+ t_favs
24
+ t_touch_if
25
+ t_add_fav
26
+ ensure
27
+ t_cleanup
28
+ end
29
+ end
30
+
31
+ def t_setup
32
+ @obj = GroongaDatabase.new
33
+ @tmp_dir = File.join(File.dirname(__FILE__), "groonga_database_work")
34
+ end
35
+
36
+ def t_cleanup
37
+ # 本当は明示的にcloseした方が行儀が良いのだけれど、
38
+ # 単体テストの時にSementationFaultが出るのでコメントアウト
39
+ # @obj.close
40
+
41
+ # データベース削除
42
+ @obj = nil
43
+ FileUtils.rm_rf(@tmp_dir)
44
+ end
45
+
46
+ def t_open
47
+ @obj.open(@tmp_dir)
48
+ @packages = @obj.packages
49
+ # @obj.close
50
+ end
51
+
52
+ def t_packages
53
+ # @obj.open(@tmp_dir)
54
+
55
+ packages = @obj.packages
56
+ assert_equal 0, packages.size
57
+
58
+ packages.add("milkode", "", {})
59
+ assert_equal 1, packages.size
60
+
61
+ r = packages["milkode"]
62
+ assert_equal "milkode", r.name
63
+ assert r.addtime.to_i > 0
64
+ assert_equal 0, r.updatetime.to_i
65
+ assert_equal 0, r.viewtime.to_i
66
+ assert_equal 0, r.favtime.to_i
67
+
68
+ packages.remove("milkode")
69
+ assert_equal 0, packages.size
70
+ end
71
+
72
+ def t_packages_viewtime
73
+ packages = @obj.packages
74
+ packages.add("add", "", {})
75
+ packages.add("update", "", {})
76
+ packages.add("view", "", {})
77
+ packages.add("favorite", "", {})
78
+ assert_equal 4, packages.size
79
+
80
+ packages.each do |r|
81
+ # p r
82
+ end
83
+
84
+ r = packages["update"]
85
+ r.updatetime = Time.now
86
+
87
+ r = packages["view"]
88
+ r.viewtime = Time.now
89
+
90
+ r = packages["favorite"]
91
+ r.favtime = Time.now
92
+
93
+ # packages.dump
94
+
95
+ assert_not_equal 0, packages["update"].updatetime
96
+ assert_not_equal 0, packages["view"].viewtime
97
+ assert_not_equal 0, packages["favorite"].favtime
98
+
99
+ packages.remove_all
100
+ assert_equal 0, packages.size
101
+ end
102
+
103
+ def t_sort
104
+ packages = @obj.packages
105
+
106
+ t = Time.now
107
+
108
+ r = packages.add("r1", "", {})
109
+ r.updatetime = t + 1
110
+ r.viewtime = t + 2
111
+ r.favtime = t + 3
112
+
113
+ r = packages.add("r2", "", {})
114
+ r.updatetime = t + 3
115
+ r.viewtime = t + 1
116
+ # r.favtime
117
+
118
+ r = packages.add("r3", "", {})
119
+ r.updatetime = t + 2
120
+ r.viewtime = t + 3
121
+ r.favtime = t + 2
122
+
123
+ sorted = packages.sort("updatetime")
124
+ assert_equal "r2", sorted[0].name
125
+ assert_equal "r3", sorted[1].name
126
+ assert_equal "r1", sorted[2].name
127
+
128
+ sorted = packages.sort("viewtime")
129
+ assert_equal "r3", sorted[0].name
130
+ assert_equal "r1", sorted[1].name
131
+ assert_equal "r2", sorted[2].name
132
+
133
+ sorted = packages.sort("favtime")
134
+ assert_equal "r1", sorted[0].name
135
+ assert_equal "r3", sorted[1].name
136
+ assert_equal "r2", sorted[2].name
137
+
138
+ # sorted.each do |r|
139
+ # p [r.name, r.addtime, r.updatetime, r.viewtime, r.favtime]
140
+ # end
141
+
142
+ packages.remove_all
143
+ end
144
+
145
+ def t_yaml_sync
146
+ assert_equal 0, @obj.packages.size
147
+
148
+ yaml_contents =
149
+ [
150
+ Package.create('/path/to/dir'),
151
+ Package.create('/path/to/d2'),
152
+ Package.create('/path/to/d3', ["*.bak"])
153
+ ]
154
+ @obj.yaml_sync(yaml_contents)
155
+ assert_equal 3, @obj.packages.size
156
+
157
+ yaml_contents << Package.create('/path/to/d4')
158
+ @obj.yaml_sync(yaml_contents)
159
+ assert_equal 4, @obj.packages.size
160
+
161
+ # @obj.packages.dump
162
+
163
+ @obj.packages.remove_all
164
+ end
165
+
166
+ def t_touch
167
+ r = @packages.add("r1", "", {})
168
+ t = Time.now
169
+
170
+ assert_not_equal t, r.updatetime
171
+ assert_not_equal t, r.viewtime
172
+ assert_not_equal t, r.favtime
173
+
174
+ @packages.touch("r1", :updatetime, t)
175
+ assert_equal t, r.updatetime
176
+
177
+ @packages.touch("r1", :viewtime, t)
178
+ assert_equal t, r.viewtime
179
+
180
+ @packages.touch("r1", :favtime, t)
181
+ assert_equal t, r.favtime
182
+
183
+ @packages.remove_all
184
+ end
185
+
186
+ def t_favs
187
+ @packages.add("r1", "", {})
188
+ @packages.add("r2", "", {})
189
+ @packages.add("r3", "", {})
190
+
191
+ assert_equal [], @packages.favs.map{|r| r.name}
192
+
193
+ current = Time.now
194
+ @packages.touch('r1', :favtime, current)
195
+ @packages.touch('r3', :favtime, current + 1)
196
+ assert_equal ['r3', 'r1'], @packages.favs.map{|r| r.name}
197
+
198
+ @packages.touch('r2', :favtime, current + 2)
199
+ assert_equal ['r2', 'r3', 'r1'], @packages.favs.map{|r| r.name}
200
+
201
+ @packages.remove_all
202
+ end
203
+
204
+ def t_touch_if
205
+ assert_raise(NoMethodError) { @packages.touch("not_found", :favtime) }
206
+ assert_equal nil, @packages.touch_if("not_found", :favtime)
207
+ end
208
+
209
+ def t_add_fav
210
+ r = @packages.add("r1", "", {:fav => true})
211
+ assert r.favtime.to_i > 0
212
+ @packages.remove_all
213
+ end
214
+ end
215
+ end
@@ -86,6 +86,14 @@ class TestUtil < Test::Unit::TestCase
86
86
  assert_equal false, Milkode::Util::gotoline_multi?("a 123 b".split)
87
87
  assert_equal false, Milkode::Util::gotoline_multi?("c:/user 5".split)
88
88
  end
89
+
90
+ def test_git_url?
91
+ assert_equal false, Milkode::Util::git_url?('http:://ongaeshi.me')
92
+ assert_equal true, Milkode::Util::git_url?('git://github.com/ongaeshi/milkode.git')
93
+ assert_equal true, Milkode::Util::git_url?('git@github.com:ongaeshi/milkode.git')
94
+ assert_equal true, Milkode::Util::git_url?('ssh:foo@bar/baz.git')
95
+ end
96
+
89
97
 
90
98
  def teardown
91
99
  teardown_custom(true)
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: 1
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
9
- - 1
10
- version: 0.7.1
8
+ - 8
9
+ - 0
10
+ version: 0.8.0
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-05-15 00:00:00 +09:00
18
+ date: 2012-06-20 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -194,6 +194,34 @@ dependencies:
194
194
  - 0
195
195
  version: 0.15.0
196
196
  requirement: *id011
197
+ - !ruby/object:Gem::Dependency
198
+ type: :development
199
+ prerelease: false
200
+ name: bundler
201
+ version_requirements: &id012 !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ hash: 3
207
+ segments:
208
+ - 0
209
+ version: "0"
210
+ requirement: *id012
211
+ - !ruby/object:Gem::Dependency
212
+ type: :development
213
+ prerelease: false
214
+ name: jeweler
215
+ version_requirements: &id013 !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ hash: 3
221
+ segments:
222
+ - 0
223
+ version: "0"
224
+ requirement: *id013
197
225
  description: Line based local source code search engine & grep-command & web-app.
198
226
  email: ongaeshi0621@gmail.com
199
227
  executables:
@@ -229,10 +257,13 @@ files:
229
257
  - lib/milkode/cdweb/lib/database.rb
230
258
  - lib/milkode/cdweb/lib/grep.rb
231
259
  - lib/milkode/cdweb/lib/mkurl.rb
260
+ - lib/milkode/cdweb/lib/package_list.rb
232
261
  - lib/milkode/cdweb/lib/query.rb
233
262
  - lib/milkode/cdweb/lib/search_contents.rb
234
263
  - lib/milkode/cdweb/lib/search_files.rb
235
264
  - lib/milkode/cdweb/lib/web_setting.rb
265
+ - lib/milkode/cdweb/public/css/bootstrap-responsive.min.css
266
+ - lib/milkode/cdweb/public/css/bootstrap.min.css
236
267
  - lib/milkode/cdweb/public/css/coderay-patch.css
237
268
  - lib/milkode/cdweb/public/css/coderay.css
238
269
  - lib/milkode/cdweb/public/css/milkode.css
@@ -242,17 +273,22 @@ files:
242
273
  - lib/milkode/cdweb/public/images/file.png
243
274
  - lib/milkode/cdweb/public/images/go-home-5.png
244
275
  - lib/milkode/cdweb/public/images/help.png
276
+ - lib/milkode/cdweb/public/img/glyphicons-halflings-white.png
277
+ - lib/milkode/cdweb/public/img/glyphicons-halflings.png
278
+ - lib/milkode/cdweb/public/js/bootstrap.min.js
245
279
  - lib/milkode/cdweb/public/js/milkode.js
246
280
  - lib/milkode/cdweb/views/filelist.haml
247
281
  - lib/milkode/cdweb/views/header_menu.haml
248
282
  - lib/milkode/cdweb/views/help.haml
249
283
  - lib/milkode/cdweb/views/index.haml
250
284
  - lib/milkode/cdweb/views/layout.haml
285
+ - lib/milkode/cdweb/views/packages.haml
251
286
  - lib/milkode/cdweb/views/search.haml
252
287
  - lib/milkode/cdweb/views/search_form.haml
253
288
  - lib/milkode/cdweb/views/view.haml
254
289
  - lib/milkode/cli.rb
255
290
  - lib/milkode/common/archive-zip.rb
291
+ - lib/milkode/common/array_diff.rb
256
292
  - lib/milkode/common/dbdir.rb
257
293
  - lib/milkode/common/dir.rb
258
294
  - lib/milkode/common/display_util.rb
@@ -263,6 +299,10 @@ files:
263
299
  - lib/milkode/common/platform.rb
264
300
  - lib/milkode/common/string_snip.rb
265
301
  - lib/milkode/common/util.rb
302
+ - lib/milkode/database/document_record.rb
303
+ - lib/milkode/database/document_table.rb
304
+ - lib/milkode/database/groonga_database.rb
305
+ - lib/milkode/database/package_table.rb
266
306
  - lib/milkode/findgrep/findgrep.rb
267
307
  - lib/milkode/findgrep/result.rb
268
308
  - lib/milkode/grep/cli_grep.rb
@@ -273,6 +313,13 @@ files:
273
313
  - test/data/abc.zip
274
314
  - test/data/b_project/runner.rb
275
315
  - test/data/b_project/test_dir.rb
316
+ - test/data/c_project/a.txt
317
+ - test/data/c_project/abc.c
318
+ - test/data/c_project/abc.h
319
+ - test/data/c_project/b.txt
320
+ - test/data/c_project/c.txt
321
+ - test/data/c_project/cc.txt
322
+ - test/data/c_project/to/file.rb
276
323
  - test/data/no_auto_ignore/.gitignore
277
324
  - test/data/no_auto_ignore/a.txt
278
325
  - test/data/nodir_abc.zip
@@ -291,14 +338,19 @@ files:
291
338
  - test/test_database.rb
292
339
  - test/test_dbdir.rb
293
340
  - test/test_dir.rb
341
+ - test/test_document_record.rb
342
+ - test/test_document_table.rb
294
343
  - test/test_findgrep.rb
295
344
  - test/test_gren_util.rb
345
+ - test/test_groonga_database.rb
296
346
  - test/test_helper.rb
297
347
  - test/test_ignore_checker.rb
298
348
  - test/test_ignore_setting.rb
299
349
  - test/test_milkode_yaml.rb
300
350
  - test/test_mkurl.rb
301
351
  - test/test_package.rb
352
+ - test/test_package_list.rb
353
+ - test/test_package_table.rb
302
354
  - test/test_query.rb
303
355
  - test/test_string_snip.rb
304
356
  - test/test_util.rb