Skip to content

Commit

Permalink
Merge branch 'feature/travis-ci' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ongaeshi committed Jan 6, 2013
2 parents 49ac457 + 6ca0c06 commit 599f151
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 20 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 6 additions & 1 deletion lib/milkode/common/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
23 changes: 12 additions & 11 deletions lib/milkode/database/document_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# @date 2012/05/29

require 'kconv'
require 'milkode/common/util.rb'
require 'milkode/common/util'

module Milkode
class DocumentTable
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions lib/milkode/database/package_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# @author ongaeshi
# @date 2012/05/29

require 'milkode/common/util'

module Milkode
class PackageTable
include Enumerable
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_package_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 599f151

Please sign in to comment.