Permalink
Browse files

Merge branch 'feature/travis-ci' into develop

  • Loading branch information...
2 parents 49ac457 + 6ca0c06 commit 599f151ff4d2cc670d875ae5657ac7bac91b7af2 @ongaeshi committed Jan 6, 2013
View
14 .travis.yml
@@ -0,0 +1,14 @@
+language: ruby
+
+notifications:
+ email:
+ recipients:
+ # - kou@clear-code.com
+ - ongaeshi0621@gmail.com
+
+rvm:
+ - 1.8.7
+ - 1.9.3
+
+before_install:
+ - curl https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
View
2 Gemfile
@@ -5,7 +5,7 @@ source "http://rubygems.org"
# gem "activesupport", ">= 2.3.5"
# gemspec
gem 'termcolor','>= 1.2.0', '< 1.2.2'
-gem 'rroonga','>= 1.1.0', '< 2.1.0'
+gem 'rroonga','>= 2.1.2'
gem 'rack','>=1.3.4'
gem 'sinatra', '>=1.2.6'
gem 'launchy', '>=0.3.7'
View
7 lib/milkode/common/util.rb
@@ -205,7 +205,12 @@ def load_content(out, filename)
str
end
end
-
+
+ # Timeからnsecを切り捨てる
+ # rroongaのTimeカラムはマイクロ秒までしか格納出来ない
+ def truncate_nsec(t)
+ Time.at(t.to_i, t.usec)
+ end
end
end
View
23 lib/milkode/database/document_table.rb
@@ -6,7 +6,7 @@
# @date 2012/05/29
require 'kconv'
-require 'milkode/common/util.rb'
+require 'milkode/common/util'
module Milkode
class DocumentTable
@@ -84,14 +84,14 @@ def size
# @retval nil タイムスタンプ比較により更新無し
#
def add(package_dir, restpath, package_name = nil)
- filename = File.join(package_dir, restpath) # フルパスの作成
- filename = File.expand_path(filename) # 絶対パスに変換
- path = Util::filename_to_utf8(filename) # データベースに格納する時のファイル名はutf8
- package = package_name || File.basename(package_dir)
- package = Util::filename_to_utf8(package)
- restpath = Util::filename_to_utf8(restpath)
- suffix = File.extname(path).sub('.', "")
- timestamp = File.mtime(filename) # OSへの問い合わせは変換前のファイル名で
+ filename = File.join(package_dir, restpath) # フルパスの作成
+ filename = File.expand_path(filename) # 絶対パスに変換
+ path = Util::filename_to_utf8(filename) # データベースに格納する時のファイル名はutf8
+ package = package_name || File.basename(package_dir)
+ package = Util::filename_to_utf8(package)
+ restpath = Util::filename_to_utf8(restpath)
+ suffix = File.extname(path).sub('.', "")
+ timestamp = Util::truncate_nsec(File.mtime(filename)) # OSへの問い合わせは変換前のファイル名で
record = @table[path]
@@ -288,9 +288,10 @@ def search_with_match(options)
# ファイル名でソート
records = result.sort([{:key => "package", :order => "ascending"},
- {:key => "restpath", :order => "ascending"}],
- :offset => offset,
+ {:key => "restpath", :order => "ascending"}],
+ :offset => offset,
:limit => limit)
+ records = records.map {|r| r.value}
# 検索結果のレコード(limitの影響を受ける), 総マッチ数(limitの影響を受けない)
return records, result.size
View
14 lib/milkode/database/package_table.rb
@@ -5,6 +5,8 @@
# @author ongaeshi
# @date 2012/05/29
+require 'milkode/common/util'
+
module Milkode
class PackageTable
include Enumerable
@@ -32,10 +34,10 @@ def size
def add(name, directory, options)
@table.add(name,
- :name => name,
+ :name => name,
:directory => directory,
- :addtime => Time.now,
- :favtime => options[:fav] ? Time.now : Time.at(0))
+ :addtime => Util::truncate_nsec(Time.now),
+ :favtime => options[:fav] ? Util::truncate_nsec(Time.now) : Time.at(0))
end
def remove(name)
@@ -59,7 +61,7 @@ def each
end
def sort(kind, order = "descending")
- @table.sort([{:key => kind, :order => order}])
+ @table.sort([{:key => kind, :order => order}]).map {|r| r.value}
end
def dump
@@ -69,14 +71,14 @@ def dump
end
def touch(name, kind, time = Time.now)
- @table[name][kind] = time
+ @table[name][kind] = Util::truncate_nsec(time)
end
def touch_if(name, kind, time = Time.now)
record = @table[name]
if record
- record[kind] = time
+ record[kind] = Util::truncate_nsec(time)
else
nil
end
View
2 test/test_package_table.rb
@@ -165,7 +165,7 @@ def t_yaml_sync
def t_touch
r = @packages.add("r1", "", {})
- t = Time.now
+ t = Util::truncate_nsec(Time.now)
assert_not_equal t, r.updatetime
assert_not_equal t, r.viewtime

0 comments on commit 599f151

Please sign in to comment.