milkode 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ === 0.2.1 2011/08/12
2
+
3
+ Milkode repository is version up.
4
+ Please rebuild repository.
5
+
6
+ milk rebuild
7
+
8
+ * Support AutoPagerize. (thanks awasira)
9
+ * 'documents' table type change, 'Groonga::Array -> Groonga:: Hash'.
10
+ * 'milk update' faster (thanks kou)
11
+ * Issues#6 CentOS 5.5 (32bit) in 'milk update' fails (thanks yoshikaw)
12
+
1
13
  === 0.2.0 2011/08/10
2
14
 
3
15
  * Issues#4 Bug fix, wrong display of search results. (thanks rakkoyaku, ryo)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bin/milk CHANGED
@@ -6,5 +6,5 @@
6
6
  require 'rubygems'
7
7
  require 'milkode/cdstk/cli_cdstk'
8
8
 
9
- Version = "0.2.0"
9
+ Version = "0.2.1"
10
10
  Milkode::CLI_Cdstk.execute(STDOUT, ARGV)
@@ -55,6 +55,10 @@ module Milkode
55
55
  end
56
56
  end
57
57
 
58
+ def compatible?
59
+ db_open(db_file)
60
+ end
61
+
58
62
  def update(args = nil)
59
63
  print_result do
60
64
  yaml = yaml_load
@@ -251,6 +255,10 @@ module Milkode
251
255
  end
252
256
 
253
257
  def cleanup(options)
258
+ # 互換性テスト
259
+ db_open(db_file)
260
+
261
+ # cleanup開始
254
262
  if (options[:force] or yes_or_no("cleanup contents? (yes/no)"))
255
263
  print_result do
256
264
  # yamlファイルのクリーンアップ
@@ -366,37 +374,44 @@ module Milkode
366
374
 
367
375
  unless dbfile.exist?
368
376
  Groonga::Database.create(:path => dbfile.to_s)
369
- Groonga::Schema.define do |schema|
370
- schema.create_table("documents") do |table|
371
- table.string("path")
372
- table.string("shortpath")
373
- table.text("content")
374
- table.time("timestamp")
375
- table.text("suffix")
376
- end
377
-
378
- schema.create_table("terms",
379
- :type => :patricia_trie,
380
- :key_normalize => true,
381
- :default_tokenizer => DEFAULT_TOKENIZER) do |table|
382
- table.index("documents.path", :with_position => true)
383
- table.index("documents.shortpath", :with_position => true)
384
- table.index("documents.content", :with_position => true)
385
- table.index("documents.suffix", :with_position => true)
386
- end
387
- end
377
+ db_define
388
378
  @out.puts "create : #{filename} created."
389
379
  else
390
380
  @out.puts "message : #{filename} already exist."
391
381
  end
392
382
  end
393
383
 
384
+ def db_define
385
+ Groonga::Schema.define do |schema|
386
+ schema.create_table("documents", :type => :hash) do |table|
387
+ table.string("path")
388
+ table.string("shortpath")
389
+ table.text("content")
390
+ table.time("timestamp")
391
+ table.text("suffix")
392
+ end
393
+
394
+ schema.create_table("terms",
395
+ :type => :patricia_trie,
396
+ :key_normalize => true,
397
+ :default_tokenizer => DEFAULT_TOKENIZER) do |table|
398
+ table.index("documents.path", :with_position => true)
399
+ table.index("documents.shortpath", :with_position => true)
400
+ table.index("documents.content", :with_position => true)
401
+ table.index("documents.suffix", :with_position => true)
402
+ end
403
+ end
404
+ end
405
+
394
406
  def db_open(filename)
395
407
  dbfile = Pathname(File.expand_path(filename))
396
408
 
397
409
  if dbfile.exist?
410
+ # データベースを開く
398
411
  Groonga::Database.open(dbfile.to_s)
399
- # @out.puts "open : #{dbfile} open."
412
+
413
+ # 互換性テスト
414
+ db_compatible?
400
415
  else
401
416
  raise "error : #{dbfile.to_s} not found!!"
402
417
  end
@@ -429,18 +444,14 @@ module Milkode
429
444
  # 検索するデータベース
430
445
  documents = Groonga::Context.default["documents"]
431
446
 
432
- # 既に登録されているファイルならばそれを上書き、そうでなければ新規レコードを作成
433
- _documents = documents.select do |record|
434
- record["path"] == values[:path]
435
- end
436
-
447
+ record = documents[ values[:path] ]
437
448
  isNewFile = false
438
449
 
439
- if _documents.size.zero?
440
- document = documents.add
450
+ unless record
451
+ document = documents.add(values[:path])
441
452
  isNewFile = true
442
453
  else
443
- document = _documents.to_a[0].key
454
+ document = record
444
455
  end
445
456
 
446
457
  # タイムスタンプが新しければデータベースに格納
@@ -514,5 +525,20 @@ module Milkode
514
525
  @out.puts "[fatal] #{msg}"
515
526
  end
516
527
 
528
+ def db_compatible?
529
+ begin
530
+ db_define
531
+ rescue Groonga::Schema::Error => e
532
+ puts <<EOF
533
+ Milkode repository is old -> #{db_dir_expand}.
534
+ Please rebuild repository,
535
+
536
+ milk rebuild
537
+
538
+ See 'milk --help' or http://milkode.ongaeshi.me .
539
+ EOF
540
+ exit -1
541
+ end
542
+ end
517
543
  end
518
544
  end
@@ -70,6 +70,7 @@ EOF
70
70
  when 'dump'
71
71
  obj.dump
72
72
  when 'web'
73
+ obj.compatible?
73
74
  Milkode::CLI_Cdweb.execute_with_options(stdout, suboptions[subcommand])
74
75
  end
75
76
  else
@@ -18,7 +18,7 @@ require 'milkode/cdweb/lib/mkurl'
18
18
  set :haml, :format => :html5
19
19
 
20
20
  get '/' do
21
- @version = "0.2.0"
21
+ @version = "0.2.1"
22
22
  @package_num = Database.instance.fileList('').size
23
23
  @file_num = Database.instance.fileNum
24
24
  haml :index
@@ -43,7 +43,7 @@ module Milkode
43
43
 
44
44
  @total_records = searcher.total_records
45
45
  @range = searcher.data_range
46
- @record_content = searcher.html_contents + searcher.html_pagination;
46
+ @record_content = "<dl class='autopagerize_page_element'>#{searcher.html_contents}</dl>#{searcher.html_pagination}";
47
47
  @match_num = searcher.match_num
48
48
  @elapsed = Time.now - before
49
49
  haml :search
@@ -106,7 +106,7 @@ EOS
106
106
  tmpp = @params
107
107
  tmpp[:offset] = offset.to_s
108
108
  href = Mkurl.new("", tmpp).inherit_query_shead_offset
109
- pagination_span("<a href='#{href}'>#{label}</a>")
109
+ pagination_span("<a href='#{href}' rel='next'>#{label}</a>")
110
110
  end
111
111
 
112
112
  def pagination_span(content)
@@ -68,7 +68,7 @@ EOF
68
68
  tmpp = @params
69
69
  tmpp[:offset] = offset.to_s
70
70
  href = Mkurl.new("", tmpp).inherit_query_shead_offset
71
- pagination_span("<a href='#{href}'>#{label}</a>")
71
+ pagination_span("<a href='#{href}' rel='next'>#{label}</a>")
72
72
  end
73
73
 
74
74
  def pagination_span(content)
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{milkode}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{ongaeshi}]
12
- s.date = %q{2011-08-09}
11
+ s.authors = ["ongaeshi"]
12
+ s.date = %q{2011-08-12}
13
13
  s.description = %q{Line based local source code search engine & web-app.}
14
14
  s.email = %q{ongaeshi0621@gmail.com}
15
- s.executables = [%q{cdv}, %q{cdview}, %q{milk}]
15
+ s.executables = ["cdv", "milk", "cdview"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
18
18
  "README.rdoc"
@@ -92,15 +92,36 @@ Gem::Specification.new do |s|
92
92
  "vendor/archive/support/io.rb"
93
93
  ]
94
94
  s.homepage = %q{http://github.com/ongaeshi/milkode}
95
- s.licenses = [%q{MIT}]
96
- s.require_paths = [%q{lib}]
97
- s.rubygems_version = %q{1.8.6}
95
+ s.licenses = ["MIT"]
96
+ s.require_paths = ["lib"]
97
+ s.rubygems_version = %q{1.3.6}
98
98
  s.summary = %q{Line based local source code search engine & web-app.}
99
+ s.test_files = [
100
+ "test/file_assert.rb",
101
+ "test/file_test_utils.rb",
102
+ "test/rake_test_loader.rb",
103
+ "test/runner.rb",
104
+ "test/test_bin_exec.rb",
105
+ "test/test_cdstk.rb",
106
+ "test/test_cdstk_yaml.rb",
107
+ "test/test_coderay_wrapper.rb",
108
+ "test/test_coderay_wrapper_data.rb",
109
+ "test/test_database.rb",
110
+ "test/test_dbdir.rb",
111
+ "test/test_dir.rb",
112
+ "test/test_gren_util.rb",
113
+ "test/test_helper.rb",
114
+ "test/test_mkurl.rb",
115
+ "test/test_query.rb",
116
+ "test/test_string_snip.rb",
117
+ "test/test_util.rb"
118
+ ]
99
119
 
100
120
  if s.respond_to? :specification_version then
121
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
101
122
  s.specification_version = 3
102
123
 
103
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
124
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
104
125
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
105
126
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
106
127
  s.add_development_dependency(%q<rcov>, [">= 0"])
metadata CHANGED
@@ -1,170 +1,214 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: milkode
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 1
9
+ version: 0.2.1
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - ongaeshi
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-08-09 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: bundler
16
- requirement: &2151836120 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
16
+
17
+ date: 2011-08-12 00:00:00 +09:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
19
23
  - - ~>
20
- - !ruby/object:Gem::Version
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 1
27
+ - 0
28
+ - 0
21
29
  version: 1.0.0
22
- type: :development
30
+ name: bundler
31
+ requirement: *id001
23
32
  prerelease: false
24
- version_requirements: *2151836120
25
- - !ruby/object:Gem::Dependency
26
- name: jeweler
27
- requirement: &2151835340 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
33
+ type: :development
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
30
37
  - - ~>
31
- - !ruby/object:Gem::Version
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 1
41
+ - 5
42
+ - 2
32
43
  version: 1.5.2
33
- type: :development
44
+ name: jeweler
45
+ requirement: *id002
34
46
  prerelease: false
35
- version_requirements: *2151835340
36
- - !ruby/object:Gem::Dependency
37
- name: rcov
38
- requirement: &2151834260 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
47
  type: :development
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ name: rcov
57
+ requirement: *id003
45
58
  prerelease: false
46
- version_requirements: *2151834260
47
- - !ruby/object:Gem::Dependency
48
- name: termcolor
49
- requirement: &2151833020 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
59
+ type: :development
60
+ - !ruby/object:Gem::Dependency
61
+ version_requirements: &id004 !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 1
67
+ - 2
68
+ - 0
54
69
  version: 1.2.0
55
- type: :runtime
70
+ name: termcolor
71
+ requirement: *id004
56
72
  prerelease: false
57
- version_requirements: *2151833020
58
- - !ruby/object:Gem::Dependency
59
- name: rroonga
60
- requirement: &2151831820 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: 1.0.0
66
73
  type: :runtime
74
+ - !ruby/object:Gem::Dependency
75
+ version_requirements: &id005 !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 1
81
+ - 0
82
+ - 0
83
+ version: 1.0.0
84
+ name: rroonga
85
+ requirement: *id005
67
86
  prerelease: false
68
- version_requirements: *2151831820
69
- - !ruby/object:Gem::Dependency
70
- name: rack
71
- requirement: &2151830480 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: 1.2.1
77
87
  type: :runtime
88
+ - !ruby/object:Gem::Dependency
89
+ version_requirements: &id006 !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 1
95
+ - 2
96
+ - 1
97
+ version: 1.2.1
98
+ name: rack
99
+ requirement: *id006
78
100
  prerelease: false
79
- version_requirements: *2151830480
80
- - !ruby/object:Gem::Dependency
81
- name: sinatra
82
- requirement: &2151829080 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: 1.2.6
88
101
  type: :runtime
102
+ - !ruby/object:Gem::Dependency
103
+ version_requirements: &id007 !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ segments:
108
+ - 1
109
+ - 2
110
+ - 6
111
+ version: 1.2.6
112
+ name: sinatra
113
+ requirement: *id007
89
114
  prerelease: false
90
- version_requirements: *2151829080
91
- - !ruby/object:Gem::Dependency
92
- name: launchy
93
- requirement: &2151828080 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: 0.3.7
99
115
  type: :runtime
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id008 !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ - 3
124
+ - 7
125
+ version: 0.3.7
126
+ name: launchy
127
+ requirement: *id008
100
128
  prerelease: false
101
- version_requirements: *2151828080
102
- - !ruby/object:Gem::Dependency
103
- name: coderay
104
- requirement: &2151826860 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: 0.9.8
110
129
  type: :runtime
130
+ - !ruby/object:Gem::Dependency
131
+ version_requirements: &id009 !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ segments:
136
+ - 0
137
+ - 9
138
+ - 8
139
+ version: 0.9.8
140
+ name: coderay
141
+ requirement: *id009
111
142
  prerelease: false
112
- version_requirements: *2151826860
113
- - !ruby/object:Gem::Dependency
114
- name: thin
115
- requirement: &2151825960 !ruby/object:Gem::Requirement
116
- none: false
117
- requirements:
118
- - - ! '>='
119
- - !ruby/object:Gem::Version
120
- version: 1.2.10
121
143
  type: :runtime
144
+ - !ruby/object:Gem::Dependency
145
+ version_requirements: &id010 !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ segments:
150
+ - 1
151
+ - 2
152
+ - 10
153
+ version: 1.2.10
154
+ name: thin
155
+ requirement: *id010
122
156
  prerelease: false
123
- version_requirements: *2151825960
124
- - !ruby/object:Gem::Dependency
125
- name: archive-zip
126
- requirement: &2151824500 !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: 0.3.0
132
157
  type: :runtime
158
+ - !ruby/object:Gem::Dependency
159
+ version_requirements: &id011 !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ segments:
164
+ - 0
165
+ - 3
166
+ - 0
167
+ version: 0.3.0
168
+ name: archive-zip
169
+ requirement: *id011
133
170
  prerelease: false
134
- version_requirements: *2151824500
135
- - !ruby/object:Gem::Dependency
136
- name: haml
137
- requirement: &2151823320 !ruby/object:Gem::Requirement
138
- none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: 3.1.2
143
171
  type: :runtime
172
+ - !ruby/object:Gem::Dependency
173
+ version_requirements: &id012 !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ segments:
178
+ - 3
179
+ - 1
180
+ - 2
181
+ version: 3.1.2
182
+ name: haml
183
+ requirement: *id012
144
184
  prerelease: false
145
- version_requirements: *2151823320
146
- - !ruby/object:Gem::Dependency
147
- name: sass
148
- requirement: &2151821740 !ruby/object:Gem::Requirement
149
- none: false
150
- requirements:
151
- - - ! '>='
152
- - !ruby/object:Gem::Version
153
- version: 3.1.3
154
185
  type: :runtime
186
+ - !ruby/object:Gem::Dependency
187
+ version_requirements: &id013 !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ segments:
192
+ - 3
193
+ - 1
194
+ - 3
195
+ version: 3.1.3
196
+ name: sass
197
+ requirement: *id013
155
198
  prerelease: false
156
- version_requirements: *2151821740
199
+ type: :runtime
157
200
  description: Line based local source code search engine & web-app.
158
201
  email: ongaeshi0621@gmail.com
159
- executables:
202
+ executables:
160
203
  - cdv
161
- - cdview
162
204
  - milk
205
+ - cdview
163
206
  extensions: []
164
- extra_rdoc_files:
207
+
208
+ extra_rdoc_files:
165
209
  - LICENSE.txt
166
210
  - README.rdoc
167
- files:
211
+ files:
168
212
  - .document
169
213
  - Gemfile
170
214
  - Gemfile.lock
@@ -237,29 +281,52 @@ files:
237
281
  - test/test_string_snip.rb
238
282
  - test/test_util.rb
239
283
  - vendor/archive/support/io.rb
284
+ has_rdoc: true
240
285
  homepage: http://github.com/ongaeshi/milkode
241
- licenses:
286
+ licenses:
242
287
  - MIT
243
288
  post_install_message:
244
289
  rdoc_options: []
245
- require_paths:
290
+
291
+ require_paths:
246
292
  - lib
247
- required_ruby_version: !ruby/object:Gem::Requirement
248
- none: false
249
- requirements:
250
- - - ! '>='
251
- - !ruby/object:Gem::Version
252
- version: '0'
253
- required_rubygems_version: !ruby/object:Gem::Requirement
254
- none: false
255
- requirements:
256
- - - ! '>='
257
- - !ruby/object:Gem::Version
258
- version: '0'
293
+ required_ruby_version: !ruby/object:Gem::Requirement
294
+ requirements:
295
+ - - ">="
296
+ - !ruby/object:Gem::Version
297
+ segments:
298
+ - 0
299
+ version: "0"
300
+ required_rubygems_version: !ruby/object:Gem::Requirement
301
+ requirements:
302
+ - - ">="
303
+ - !ruby/object:Gem::Version
304
+ segments:
305
+ - 0
306
+ version: "0"
259
307
  requirements: []
308
+
260
309
  rubyforge_project:
261
- rubygems_version: 1.8.6
310
+ rubygems_version: 1.3.6
262
311
  signing_key:
263
312
  specification_version: 3
264
313
  summary: Line based local source code search engine & web-app.
265
- test_files: []
314
+ test_files:
315
+ - test/file_assert.rb
316
+ - test/file_test_utils.rb
317
+ - test/rake_test_loader.rb
318
+ - test/runner.rb
319
+ - test/test_bin_exec.rb
320
+ - test/test_cdstk.rb
321
+ - test/test_cdstk_yaml.rb
322
+ - test/test_coderay_wrapper.rb
323
+ - test/test_coderay_wrapper_data.rb
324
+ - test/test_database.rb
325
+ - test/test_dbdir.rb
326
+ - test/test_dir.rb
327
+ - test/test_gren_util.rb
328
+ - test/test_helper.rb
329
+ - test/test_mkurl.rb
330
+ - test/test_query.rb
331
+ - test/test_string_snip.rb
332
+ - test/test_util.rb