Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'develop'

  • Loading branch information...
commit b5e2070c1bacdc450f3f578c28a4329cacca58dc 2 parents 49ac457 + fcd2712
@ongaeshi authored
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','>= 1.1.0'
gem 'rack','>=1.3.4'
gem 'sinatra', '>=1.2.6'
gem 'launchy', '>=0.3.7'
View
17 HISTORY.ja.rdoc
@@ -1,3 +1,20 @@
+=== 0.9.7 2012/01/29
+
+* Support rroonga 2.1.x
+
+* Support TravisCI
+ * https://travis-ci.org/ongaeshi/milkode
+ * Util#truncate_nsec を追加
+
+* milk
+ * 'milk files -r' を追加
+ * 非データベースディレクトリでも'milk files'出来るように
+ * 'milk list -d' (ディレクトリのみ表示) を追加
+
+* gmilk
+ * 一部の単語が正しくマッチするように修正 ('a-list'等)
+ * Windows環境でも日本語検索を可能に
+
=== 0.9.6 2012/12/28
* milk web
View
17 HISTORY.rdoc
@@ -1,3 +1,20 @@
+=== 0.9.7 2012/01/29
+
+* Support rroonga 2.1.x
+
+* Support TravisCI
+ * https://travis-ci.org/ongaeshi/milkode
+ * Add Util#truncate_nsec
+
+* milk
+ * Add 'milk files -r'
+ * Can run 'milk files' in non-database directory
+ * Add 'milk list -d' (Display directory)
+
+* gmilk
+ * Fixed some words to match properly ('a-list' etc.)
+ * Can search non-ASCII characters in Windows environment
+
=== 0.9.6 2012/12/28
* milk web
View
2  VERSION
@@ -1 +1 @@
-0.9.6
+0.9.7
View
2  bin/gmilk
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/grep/cli_grep'
-Version = "0.9.6"
+Version = "0.9.7"
Milkode::CLI_Grep.execute(STDOUT, ARGV)
View
2  bin/milk
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cli'
-Version = "0.9.6"
+Version = "0.9.7"
Milkode::CLI.start(ARGV)
View
22 lib/milkode/cdstk/cdstk.rb
@@ -407,6 +407,8 @@ def list(args, options)
h = File.exist?(p.directory) ? '' : '? '
if (options[:verbose])
"#{(h + p.name).ljust(max+2)} #{p.directory}"
+ elsif (options[:directory])
+ "#{p.directory}"
else
"#{h}#{p.name}"
end
@@ -414,7 +416,7 @@ def list(args, options)
@out.puts str
- if Util.pipe? $stdout
+ if !options[:directory] && Util.pipe?($stdout)
if args.empty?
milkode_info
else
@@ -875,8 +877,12 @@ def find_packages(args)
else
dir = File.expand_path('.')
r = @yaml.package_root(dir)
- @out.puts "Not registered '#{dir}'." if r.nil?
- [r]
+ if r.nil?
+ @out.puts "Not registered '#{dir}'."
+ []
+ else
+ [r]
+ end
end
end
@@ -935,15 +941,21 @@ def ignore(args, options)
end
end
- def files(args)
+ def files(args, options)
packages = find_packages(args)
return if (packages.empty?)
db_open
+
+ basedir = File.expand_path('.') if options[:relative]
packages.each do |package|
package_records(package.name).each do |record|
- @out.puts record.restpath
+ if options[:relative]
+ @out.puts Util::relative_path(record.path, basedir)
+ else
+ @out.puts record.restpath
+ end
end
end
end
View
2  lib/milkode/cdweb/app.rb
@@ -22,7 +22,7 @@
get '/' do
@setting = WebSetting.new
- @version = "0.9.6"
+ @version = "0.9.7"
@package_num = Database.instance.yaml_package_num
@file_num = Database.instance.totalRecords
@package_list = PackageList.new(Database.instance.grndb)
View
4 lib/milkode/cli.rb
@@ -71,6 +71,7 @@ def remove(*args)
desc "list [package1 package2 ...]", "List package"
option :verbose, :type => :boolean, :aliases => '-v', :desc => 'Be verbose.'
+ option :directory, :type => :boolean, :aliases => '-d', :desc => 'Display direcory.'
option :check, :type => :boolean, :aliases => '-c', :desc => "Check integrity 'yaml and database'"
def list(*args)
cdstk.list(args, options)
@@ -193,8 +194,9 @@ def plugins(*args)
end
desc "files", "Display package files"
+ option :relative, :type => :boolean, :aliases => '-r', :desc => "Display relative path."
def files(*args)
- cdstk.files(args)
+ cdstk.files(args, options)
end
# --------------------------------------------------------------------------
View
22 lib/milkode/common/util.rb
@@ -5,6 +5,7 @@
require 'fileutils'
require 'pathname'
require 'kconv'
+require 'groonga'
module Milkode
module Util
@@ -205,7 +206,26 @@ def load_content(out, filename)
str
end
end
-
+
+ # Timeからnsecを切り捨てる
+ # rroongaのTimeカラムはマイクロ秒までしか格納出来ない
+ def truncate_nsec(t)
+ Time.at(t.to_i, t.usec)
+ end
+
+ # gem_version_more?('rroonga', '2.1.0') #=> rroonga >= '2.1.0'
+ def gem_version_more?(name, version)
+ Gem.loaded_specs[name].version >= Gem::Version.new(version)
+ end
+
+ # 互換性保持のため
+ def groonga_table_sort(table, keys, options = {})
+ if gem_version_more?('rroonga', '2.1.0')
+ table.sort(keys, options).map{|r| r.value}
+ else
+ table.sort(keys, options)
+ end
+ end
end
end
View
27 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]
@@ -287,10 +287,11 @@ def search_with_match(options)
# :limit => limit)
# ファイル名でソート
- records = result.sort([{:key => "package", :order => "ascending"},
- {:key => "restpath", :order => "ascending"}],
- :offset => offset,
- :limit => limit)
+ records = Util.groonga_table_sort(result,
+ [{:key => "package", :order => "ascending"},
+ {:key => "restpath", :order => "ascending"}],
+ :offset => offset,
+ :limit => limit)
# 検索結果のレコード(limitの影響を受ける), 総マッチ数(limitの影響を受けない)
return records, result.size
View
10 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 => Time.now,
+ :favtime => options[:fav] ? 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}])
+ Util.groonga_table_sort(@table, [{:key => kind, :order => order}])
end
def dump
View
3  lib/milkode/findgrep/findgrep.rb
@@ -55,7 +55,8 @@ class FindGrep
[],
[],
[],
- Platform.get_shell_kcode,
+ # Platform.get_shell_kcode,
+ Kconv::UTF8,
false,
nil,
false,
View
20 lib/milkode/grep/cli_grep.rb
@@ -6,10 +6,16 @@
require 'milkode/cdstk/cdstk'
require 'milkode/cdstk/yaml_file_wrapper'
require 'milkode/cdstk/package'
+require 'kconv'
module Milkode
class CLI_Grep
def self.execute(stdout, arguments=[])
+ # 引数の文字コードをUTF-8に変換
+ if (Util::platform_win?)
+ arguments = arguments.map{|arg| Kconv.kconv(arg, Kconv::UTF8)}
+ end
+
option = FindGrep::FindGrep::DEFAULT_OPTION.dup
# default option
@@ -221,11 +227,17 @@ def initialize(arguments)
def prev
@arguments.map! do |v|
- v.gsub("-l", ":l").
- gsub("-k", ":k").
- gsub("-g", ":g")
+ case v
+ when "-l"
+ ":l"
+ when "-k"
+ ":k"
+ when "-g"
+ ":g"
+ else
+ v
+ end
end
-
end
def after
View
11 milkode.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{milkode}
- s.version = "0.9.6"
+ s.version = "0.9.7"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["ongaeshi"]
- s.date = %q{2012-12-28}
+ s.date = %q{2013-01-30}
s.description = %q{Line based local source code search engine & grep-command & web-app.}
s.email = %q{ongaeshi0621@gmail.com}
s.executables = ["gmilk", "milk"]
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
]
s.files = [
".document",
+ ".travis.yml",
"Gemfile",
"HISTORY.ja.rdoc",
"HISTORY.rdoc",
@@ -194,7 +195,7 @@ Gem::Specification.new do |s|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
- s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0", "< 2.1.0"])
+ s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0"])
s.add_runtime_dependency(%q<rack>, [">= 1.3.4"])
s.add_runtime_dependency(%q<sinatra>, [">= 1.2.6"])
s.add_runtime_dependency(%q<launchy>, [">= 0.3.7"])
@@ -209,7 +210,7 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<rack-test>, [">= 0"])
else
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
- s.add_dependency(%q<rroonga>, [">= 1.1.0", "< 2.1.0"])
+ s.add_dependency(%q<rroonga>, [">= 1.1.0"])
s.add_dependency(%q<rack>, [">= 1.3.4"])
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
s.add_dependency(%q<launchy>, [">= 0.3.7"])
@@ -225,7 +226,7 @@ Gem::Specification.new do |s|
end
else
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
- s.add_dependency(%q<rroonga>, [">= 1.1.0", "< 2.1.0"])
+ s.add_dependency(%q<rroonga>, [">= 1.1.0"])
s.add_dependency(%q<rack>, [">= 1.3.4"])
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
s.add_dependency(%q<launchy>, [">= 0.3.7"])
View
5 test/test_cli.rb
@@ -76,6 +76,11 @@ def test_help_with_h_option
end
end
+ def test_files
+ command("files")
+ command("files -r")
+ end
+
private
def command(arg)
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
Please sign in to comment.
Something went wrong with that request. Please try again.