Skip to content
Browse files

Merge 0.6.0

  • Loading branch information...
2 parents 48625b3 + 05e7e0f commit fd2bc4dc9d6f705585f93ae5a5f560b6962920f8 @ongaeshi committed Mar 29, 2012
View
25 HISTORY.ja.rdoc
@@ -1,3 +1,28 @@
+=== 0.6.0 2012/03/28
+
+* milk web
+ * 高速化
+ * パッケージ数をmilkode.yamlから取得
+ * Database#fileList('/')をmilkode.yamlから取得
+ * CodeRay::Encoders::HTMLを直接カスタマイズすることで高速化
+ * ウェブアプリのタイトルやアイコンを簡単にカスタマイズ出来るように
+ * milk web --customize で、milkweb.yaml のテンプレートを作成
+ * milkweb.yaml を書き換えることでカスタマイズ出来ます
+ * 使い勝手の改善
+ * 近接行マッチはまとめて表示するように。
+ * 検索結果の行番号をクリックで指定行へジャンプ出来るように
+ * 検索結果はファイル名順にソートするように
+ * クリアボタンを追加
+ * ヘッダーメニューに'ヘルプ'の項目を追加
+ * ラジオボタンが未指定の時は'shead=package'に
+ * パッケージ検索を正確に
+ * CodeRay 1.0.5 に対応
+ * nokogiri, hpricot への依存を外す
+
+* common
+ * '\n' -> '$/'
+ * 'rroonga','>= 1.1.0','<2.0'
+
=== 0.5.0 2012/03/09
* milk
View
13 HISTORY.rdoc
@@ -1,3 +1,16 @@
+=== 0.6.0 2012/03/28
+
+* milk web
+ * Optimize
+ * Customize title and icon
+ * Usability improvements
+ * CodeRay 1.0.5
+ * Remove the dependency on hpricot, nokogiri
+
+* common
+ * '\n' -> '$/'
+ * 'rroonga','>= 1.1.0','<2.0'
+
=== 0.5.0 2012/03/09
* milk
View
10 Rakefile
@@ -23,17 +23,15 @@ Jeweler::Tasks.new do |gem|
# Include your dependencies below. Runtime dependencies are required when using your gem,
gem.add_runtime_dependency 'termcolor','>= 1.2.0'
- gem.add_runtime_dependency 'rroonga','>= 1.1.0'
+ gem.add_runtime_dependency 'rroonga','>= 1.1.0','<2.0'
gem.add_runtime_dependency 'rack','>=1.3.4'
gem.add_runtime_dependency 'sinatra', '>=1.2.6'
gem.add_runtime_dependency 'launchy', '>=0.3.7'
- gem.add_runtime_dependency 'coderay', '=0.9.8'
+ gem.add_runtime_dependency 'coderay', '>=1.0.5'
gem.add_runtime_dependency 'thin', '>=1.2.10'
gem.add_runtime_dependency 'archive-zip', '>=0.4.0'
gem.add_runtime_dependency 'haml', '>=3.1.2'
gem.add_runtime_dependency 'sass', '>=3.1.3'
- gem.add_runtime_dependency 'nokogiri', '>=1.5.0'
- gem.add_runtime_dependency 'hpricot', '>=0.8.2'
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
# gem.add_development_dependency 'rspec', '> 1.2.3'
@@ -55,7 +53,7 @@ end
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
- test.pattern = 'test/**/test_*.rb'
+ test.test_files = FileList['test/**/test_*.rb']
test.verbose = true
end
@@ -78,7 +76,7 @@ end
task :default => :test
-require 'rake/rdoctask'
+require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
View
2 VERSION
@@ -1 +1 @@
-0.5.0
+0.6.0
View
2 bin/gmilk
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/grep/cli_grep'
-Version = "0.5.0"
+Version = "0.6.0"
Milkode::CLI_Grep.execute(STDOUT, ARGV)
View
2 bin/milk
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cdstk/cli_cdstk'
-Version = "0.5.0"
+Version = "0.6.0"
Milkode::CLI_Cdstk.execute(STDOUT, ARGV)
View
4 lib/milkode/cdstk/cdstk.rb
@@ -636,12 +636,12 @@ def remove_dir(dir, no_yaml = false)
end
# データベースからも削除
- dir = File.expand_path(dir)
+ # dir = File.expand_path(dir)
alert("rm_package", dir)
@package_count += 1
- Database.instance.remove([File.basename(dir)]) do |record|
+ Database.instance.remove_fpath(dir) do |record|
alert_info("rm_record", record.path)
@file_count += 1
end
View
1 lib/milkode/cdstk/cli_cdstksub.rb
@@ -120,6 +120,7 @@ def self.setup_web
opts.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| options[:Port] = v }
opts.on("-s", "--server SERVER", "serve using SERVER (default : thin)") {|s| options[:server] = s }
opts.on('-n', '--no-browser', 'No launch browser.') {|v| options[:LaunchBrowser] = false }
+ opts.on('--customize', 'Create customize file.') {|v| options[:customize] = true }
# --hostが'-h'を上書きするので、'-h'を再定義してあげる
opts.on_tail("-h", "-?", "--help", "Show this message") do
View
5 lib/milkode/cdstk/milkode_yaml.rb
@@ -59,6 +59,11 @@ def find_name(name)
@contents.find {|v| v.same_name?(name)}
end
+ # 指定キーワードにマッチする全てのパッケージを返す
+ def match_all(keyword)
+ @contents.find_all {|p| p.name.include? keyword }
+ end
+
# ディレクトリ名が同じパッケージを検索
def find_dir(directory)
@contents.find {|v| v.directory == directory}
View
4 lib/milkode/cdstk/yaml_file_wrapper.rb
@@ -56,6 +56,10 @@ def find_name(name)
@data.find_name(name)
end
+ def match_all(keyword)
+ @data.match_all(keyword)
+ end
+
def find_dir(dir)
@data.find_dir(dir)
end
View
38 lib/milkode/cdweb/app.rb
@@ -14,27 +14,41 @@
require 'milkode/cdweb/lib/database'
require 'milkode/cdweb/lib/command'
require 'milkode/cdweb/lib/mkurl'
+require 'milkode/cdweb/lib/web_setting'
set :haml, :format => :html5
get '/' do
- @version = "0.5.0"
- @package_num = Database.instance.fileList('').size
- @file_num = Database.instance.fileNum
+ @setting = WebSetting.new
+ @version = "0.6.0"
+ @package_num = Database.instance.yaml_package_num
+ @file_num = Database.instance.totalRecords
haml :index
end
+def package_path(path)
+ path.split('/')[0,3].join('/')
+end
+
post '/search*' do
path = unescape(params[:pathname])
-
- case params[:shead]
- when 'all'
- path = "/home"
- when 'package'
- path = path.split('/')[0,3].join('/')
- end
- redirect Mkurl.new("#{path}", params).inherit_query_shead
+ if params[:clear]
+ redirect Mkurl.new("#{path}", params).inherit_shead
+ else
+ case params[:shead]
+ when 'all'
+ path = "/home"
+ when 'package'
+ path = package_path(path)
+ when 'directory'
+ # do nothing
+ else
+ path = package_path(path)
+ end
+
+ redirect Mkurl.new("#{path}", params).inherit_query_shead
+ end
end
get '/home*' do |path|
@@ -54,6 +68,7 @@
end
get %r{/help} do
+ @setting = WebSetting.new
haml :help
end
@@ -90,6 +105,7 @@ def create_headmenu(path, query, flistpath = '')
#{headicon('go-home-5.png')} <a href="/home" class="headmenu">全てのパッケージ</a>
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open('#{href}'); return false;">新しい検索</a>
#{headicon('directory.png')} <a href="#{flist}" class="headmenu">ファイル一覧</a>
+ #{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
EOF
end
View
46 lib/milkode/cdweb/cli_cdweb.rb
@@ -75,6 +75,7 @@ def self.execute(stdout, argv)
opts.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| options[:Port] = v }
opts.on("-s", "--server SERVER", "serve using SERVER (default : thin)") {|s| options[:server] = s }
opts.on('-n', '--no-browser', 'No launch browser.') {|v| options[:LaunchBrowser] = false }
+ opts.on('--customize', 'Create customize file.') {|v| options[:customize] = true }
# --hostが'-h'を上書きするので、'-h'を再定義してあげる
opts.on_tail("-h", "-?", "--help", "Show this message") do
@@ -89,16 +90,21 @@ def self.execute(stdout, argv)
end
def self.execute_with_options(stdout, options)
- # 使用するデータベースの位置設定
- Database.setup(File.expand_path(options[:DbDir]))
+ dbdir = File.expand_path(options[:DbDir])
+
+ unless options[:customize]
+ # 使用するデータベースの位置設定
+ Database.setup(dbdir)
- # サーバースクリプトのある場所へ移動
- FileUtils.cd(File.dirname(__FILE__))
+ # サーバースクリプトのある場所へ移動
+ FileUtils.cd(File.dirname(__FILE__))
- # Rackサーバー起動
- Rack::Server.start(options)
+ # Rackサーバー起動
+ Rack::Server.start(options)
+ else
+ create_customize_file(dbdir)
+ end
end
-
def self.select_dbdir
if (Dbdir.dbdir?('.') || !Dbdir.dbdir?(Dbdir.default_dir))
@@ -107,5 +113,31 @@ def self.select_dbdir
Dbdir.default_dir
end
end
+
+ def self.create_customize_file(dbdir)
+ fname = File.join(dbdir, "milkweb.yaml")
+
+ if File.exist? fname
+ puts "Already exist '#{fname}'"
+ else
+ puts <<EOF
+Create '#{fname}'.
+ Please customize yaml parameter.
+EOF
+
+ File.open(fname, "w") do |f|
+ f.write <<EOF
+---
+:home_title : "Milkode"
+:home_icon : "/images/MilkodeIcon135.png"
+
+:header_title: "Milkode"
+:header_icon : "/images/MilkodeIcon135.png"
+
+:display_about_milkode: true
+EOF
+ end
+ end
+ end
end
end
View
174 lib/milkode/cdweb/lib/coderay_html2.rb
@@ -0,0 +1,174 @@
+# -*- coding: utf-8 -*-
+#
+# @file
+# @brief
+# @author ongaeshi
+# @date 2012/03/18
+
+module CodeRay
+module Encoders
+ class HTML2 < HTML
+ register_for :html2
+
+ def text_token text, kind
+ # p "#{kind}: #{text}"
+ super
+ end
+
+ # [ref] CodeRay::Encoders::HTML#finish (coderay-1.0.5/lib/coderay/encoders/html.rb:219)
+ def finish options
+ @out = ornament_line_attr(options)
+
+ unless @opened.empty?
+ warn '%d tokens still open: %p' % [@opened.size, @opened] if $CODERAY_DEBUG
+ @out << '</span>' while @opened.pop
+ @last_opened = nil
+ end
+
+ @out.extend Output
+ @out.css = @css
+ if options[:line_numbers]
+ # Numbering.number! @out, options[:line_numbers], options
+ HTML2::number! @out, options[:line_numbers], options
+ end
+ @out.wrap! options[:wrap]
+ @out.apply_title! options[:title]
+
+ if defined?(@real_out) && @real_out
+ @real_out << @out
+ @out = @real_out
+ end
+
+ @out
+ end
+
+ def ornament_line_attr(options)
+ # p options
+ line_number = options[:line_number_start]
+
+ lines = @out.split("\n")
+
+ lines.map{|l|
+ line_number += 1
+ "<span #{line_attr(line_number - 1, options[:highlight_lines])}>#{l}</span>"
+ }.join("\n") + "\n"
+ end
+
+ def line_attr(no, highlight_lines)
+ r = []
+ r << "id=\"n#{no}\""
+ r << "class=\"highlight-line\"" if highlight_lines.include?(no)
+ r.join(" ")
+ end
+
+ # [ref] CodeRay::Encoders::Numberling#number! (coderay-1.0.5/lib/coderay/encoders/numbering.rb:8)
+ def self.number! output, mode = :table, options = {}
+ return self unless mode
+
+ options = DEFAULT_OPTIONS.merge options
+
+ start = options[:line_number_start]
+ unless start.is_a? Integer
+ raise ArgumentError, "Invalid value %p for :line_number_start; Integer expected." % start
+ end
+
+ anchor_prefix = options[:line_number_anchors]
+ anchor_prefix = 'line' if anchor_prefix == true
+ anchor_prefix = anchor_prefix.to_s[/\w+/] if anchor_prefix
+
+ anchor_url = options[:line_number_anchor_url] || ""
+
+ anchoring =
+ if anchor_prefix
+ proc do |line|
+ line = line.to_s
+ anchor = anchor_prefix + line
+ "<a href=\"#{anchor_url}##{anchor}\" name=\"#{anchor}\">#{line}</a>"
+ end
+ else
+ proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+
+ end
+
+ bold_every = options[:bold_every]
+ highlight_lines = options[:highlight_lines]
+ bolding =
+ if bold_every == false && highlight_lines == nil
+ anchoring
+ elsif highlight_lines.is_a? Enumerable
+ highlight_lines = highlight_lines.to_set
+ proc do |line|
+ if highlight_lines.include? line
+ "<strong class=\"highlighted\">#{anchoring[line]}</strong>" # highlighted line numbers in bold
+ else
+ anchoring[line]
+ end
+ end
+ elsif bold_every.is_a? Integer
+ raise ArgumentError, ":bolding can't be 0." if bold_every == 0
+ proc do |line|
+ if line % bold_every == 0
+ "<strong>#{anchoring[line]}</strong>" # every bold_every-th number in bold
+ else
+ anchoring[line]
+ end
+ end
+ else
+ raise ArgumentError, 'Invalid value %p for :bolding; false or Integer expected.' % bold_every
+ end
+
+ line_count = output.count("\n")
+ position_of_last_newline = output.rindex(RUBY_VERSION >= '1.9' ? /\n/ : ?\n)
+ if position_of_last_newline
+ after_last_newline = output[position_of_last_newline + 1 .. -1]
+ ends_with_newline = after_last_newline[/\A(?:<\/span>)*\z/]
+ line_count += 1 if not ends_with_newline
+ end
+
+ case mode
+ when :inline
+ max_width = (start + line_count).to_s.size
+ line_number = start
+ nesting = []
+ output.gsub!(/^.*$\n?/) do |line|
+ line.chomp!
+ open = nesting.join
+ line.scan(%r!<(/)?span[^>]*>?!) do |close,|
+ if close
+ nesting.pop
+ else
+ nesting << $&
+ end
+ end
+ close = '</span>' * nesting.size
+
+ line_number_text = bolding.call line_number
+ indent = ' ' * (max_width - line_number.to_s.size) # TODO: Optimize (10^x)
+ line_number += 1
+ "<span class=\"line-numbers\">#{indent}#{line_number_text}</span>#{open}#{line}#{close}\n"
+ end
+
+ when :table
+ line_numbers = (start ... start + line_count).map(&bolding).join("\n")
+ line_numbers << "\n"
+ line_numbers_table_template = Output::TABLE.apply('LINE_NUMBERS', line_numbers)
+
+ output.gsub!(/<\/div>\n/, '</div>')
+ output.wrap_in! line_numbers_table_template
+ output.wrapped_in = :div
+
+ when :list
+ raise NotImplementedError, 'The :list option is no longer available. Use :table.'
+
+ else
+ raise ArgumentError, 'Unknown value %p for mode: expected one of %p' %
+ [mode, [:table, :inline]]
+ end
+
+ output
+ end
+ end
+end
+end
+
+
+
View
112 lib/milkode/cdweb/lib/coderay_wrapper.rb
@@ -9,7 +9,7 @@
require 'coderay'
require 'coderay/helpers/file_type'
require 'milkode/common/util'
-require 'milkode/cdweb/lib/my_nokogiri'
+require 'milkode/cdweb/lib/coderay_html2'
module Milkode
class CodeRayWrapper
@@ -48,105 +48,39 @@ def limit_range(range, array)
end
def to_html
- html = CodeRay.scan(@content, file_type).
- html(
- :wrap => nil,
- :line_numbers => :table,
- :css => :class,
- :highlight_lines => @highlight_lines,
- :line_number_start => @line_number_start
- )
-
- if (is_ornament?)
- html_doc = MyNokogiri::HTML(html)
- add_spanid(html_doc)
- else
- html
- end
- end
-
- def to_html_anchor
- html = CodeRay.scan(@content, file_type).
- html(
- :wrap => nil,
- :line_numbers => :table,
- :css => :class,
- :highlight_lines => @highlight_lines,
- :line_number_start => @line_number_start
- )
-
- if (is_ornament?)
- html_doc = MyNokogiri::HTML(html)
- anchor = create_anchorlink(html_doc.at_css("table.CodeRay td.code pre").inner_html)
- body = add_spanid(html_doc)
- anchor + body
- else
- html
- end
- end
-
- def add_spanid(html_doc)
- # preに<span id="行番号"> を付ける
- table = html_doc.at_css("table.CodeRay")
- pre = table.at_css("td.code pre")
- pre.inner_html = add_spanid_in(pre.inner_html)
-
- # 結果を文字列で返す
- table.to_html
+ CodeRay.scan(@content, file_type).
+ html2(
+ :wrap => nil,
+ :line_numbers => :table,
+ :css => :class,
+ :highlight_lines => @highlight_lines,
+ :line_number_start => @line_number_start,
+ :line_number_anchors => false
+ )
end
- def add_spanid_in(html)
- lines = html.split("<tt>\n</tt>")
- line_number = @line_number_start
-
- lines.map {|l|
- line_number += 1
- "<span #{line_attr(line_number - 1)}>#{l}</span>"
- }.join("<tt>\n</tt>") + "<tt>\n</tt>"
+ def to_html_anchorlink(url)
+ CodeRay.scan(@content, file_type).
+ html2(
+ :wrap => nil,
+ :line_numbers => :table,
+ :css => :class,
+ :highlight_lines => @highlight_lines,
+ :line_number_start => @line_number_start,
+ :line_number_anchors => 'n',
+ :line_number_anchor_url => url
+ )
end
def file_type
case File.extname(@filename)
when ".el"
- :scheme
- else
+ # :scheme
CodeRay::FileType.fetch @filename, :plaintext
- end
- end
-
- def line_attr(no)
- r = []
- r << "id=\"#{no}\""
- r << "class=\"highlight-line\"" if @highlight_lines.include?(no)
- r.join(" ")
- end
-
- ANCHOR_OFFSET = 3
-
- def create_anchorlink(str)
- if @highlight_lines
- lines = str.split("\n")
-
- codes = @highlight_lines.map {|no|
- " <tr><td class=\"line_numbers\">#{no}</td> <td class=\"code\"><pre><a href=\"##{[no - ANCHOR_OFFSET, 1].max}\">#{lines[no - 1]}</a></pre></td> </tr>"
- }.join("\n")
-
- <<EOF
-<span class="match-num">#{@highlight_lines.size} results</span>
-<table class="CodeRay anchor-table">
-#{codes}
-</table>
-<p>
-EOF
else
- ""
+ CodeRay::FileType.fetch @filename, :plaintext
end
end
-
- def is_ornament?
- Util::larger_than_oneline(@content)
- end
-
end
end
View
5 lib/milkode/cdweb/lib/command.rb
@@ -14,6 +14,7 @@
module Milkode
def view(record, params, before)
+ @setting = WebSetting.new
@title = record.shortpath
@path = record.shortpath
@@ -22,7 +23,7 @@ def view(record, params, before)
if (Util::larger_than_oneline(record.content) and q and !q.keywords.empty?)
grep = Grep.new(record.content)
match_lines = grep.match_lines_and(q.keywords)
- @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html_anchor
+ @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html
else
@record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html
end
@@ -32,6 +33,7 @@ def view(record, params, before)
end
def search(path, params, before)
+ @setting = WebSetting.new
@path = path
query = Query.new(params[:query])
@title = "'#{query.query_string}' in #{path_title(path)}"
@@ -51,6 +53,7 @@ def search(path, params, before)
end
def filelist(path, params, before)
+ @setting = WebSetting.new
@title = filelist_title(path)
@path = path
fileList = Database.instance.fileList(path)
View
89 lib/milkode/cdweb/lib/database.rb
@@ -10,6 +10,7 @@
require 'singleton'
require 'groonga'
require 'milkode/common/dbdir'
+require 'milkode/cdstk/yaml_file_wrapper'
include Milkode
module Milkode
@@ -22,8 +23,18 @@ def self.setup(db_dir)
@@db_dir = db_dir
end
+ def self.dbdir
+ @@db_dir || Dbdir.default_dir
+ end
+
+ attr_reader :yaml
+
def initialize
- open(@@db_dir || Dbdir.default_dir)
+ open(Database.dbdir)
+ end
+
+ def yaml_reload
+ # @yaml = YamlFileWrapper.load_if(@@db_dir || Dbdir.default_dir)
end
def open(db_dir)
@@ -43,11 +54,18 @@ def record(shortpath)
return table.records[0]
end
- def fileNum
- @documents.select.size
- end
-
- def search(patterns, packages, fpaths, suffixs, offset = 0, limit = -1)
+ def search(patterns, packages, current_path, fpaths, suffixs, offset = 0, limit = -1)
+ # パッケージ名から絶対パスに変換
+ unless packages.empty?
+ packages = convert_packages(packages)
+
+ # キーワードがパッケージ名にマッチしなければ検索しない
+ return [], 0 if packages.empty?
+ else
+ # パッケージ名未指定の時は現在位置もfpathsに含める
+ fpaths << current_path + "/" unless current_path == ""
+ end
+
# @todo fpathを厳密に検索するには、検索結果からさらに先頭からのパスではないものを除外する
records, total_records = searchMain(patterns, packages, fpaths, suffixs, offset, limit)
end
@@ -88,10 +106,20 @@ def totalRecords
@documents.select.size
end
+ # yamlからパッケージの総数を得る
+ def yaml_package_num
+ yaml_load.contents.size
+ end
+
# @sample test/test_database.rb:43 TestDatabase#t_fileList
def fileList(base)
base_parts = base.split("/")
base_depth = base_parts.length
+
+ # 'depth==0'の時はMilkodeYaml#contentsからファイルリストを生成して高速化
+ if (base_depth == 0)
+ return yaml_load.contents.sort_by{|v| v.name}.map{|v| [v.name, false] }
+ end
# shortpathにマッチするものだけに絞り込む
if (base == "")
@@ -116,14 +144,13 @@ def fileList(base)
paths
end
- # コンテンツの削除
- # @todo パッケージ名完全一致になっていないので直す
- def remove(packages)
+ # 指定したfpathにマッチするレコードを削除する
+ def remove_fpath(fpath)
# データベースを開き直す
reopen_patch
- # 削除したコンテンツをインデックスから削除
- records, total_records = search([], packages, [], [])
+ # 削除したいコンテンツを検索
+ records, total_records = searchMain([], [], [fpath], [], 0, -1)
# 検索結果はHashのレコードなので、これを直接deleteしても駄目
# 1. Record#record_idを使って主キー(Groonga#Arrayのレコード)を取り出し
@@ -149,13 +176,13 @@ def cleanup
end
end
end
-
+
private
def reopen_patch
# 削除系のコマンドが上手く動作しないためのパッチ
# 本質的な解決にはなっていないと思う
- open(@@db_dir || Dbdir.default_dir)
+ open(Database.dbdir)
end
def searchMain(patterns, packages, fpaths, suffixs, offset, limit)
@@ -207,23 +234,15 @@ def searchMain(patterns, packages, fpaths, suffixs, offset, limit)
end
# スコアとタイムスタンプでソート
- records = table.sort([{:key => "_score", :order => "descending"},
- {:key => "timestamp", :order => "descending"}],
- :offset => offset,
- :limit => limit)
-
- # ファイル名でソート
- # @todo 本当はこっちが望ましい
- # records = table.sort([{:key => "shortpath", :order => "ascending"}],
+ # records = table.sort([{:key => "_score", :order => "descending"},
+ # {:key => "timestamp", :order => "descending"}],
# :offset => offset,
# :limit => limit)
-
- # パッケージの条件追加
- if (packages.size > 0)
- records.delete_if do |record|
- !packages.any?{|package| record.shortpath.split('/')[0] =~ /#{package}/ }
- end
- end
+
+ # ファイル名でソート
+ records = table.sort([{:key => "shortpath", :order => "ascending"}],
+ :offset => offset,
+ :limit => limit)
# マッチ数
total_records = table.size
@@ -266,5 +285,19 @@ def suffix_expression(record, suffixs)
end
private :suffix_expression
+ def convert_packages(packages)
+ packages.inject([]) {|r, p| r += expand_packages(p)}
+ end
+
+ def expand_packages(keyword)
+ yaml_load.match_all(keyword).map{|p| p.directory}
+ end
+
+ def yaml_load
+ YamlFileWrapper.load_if(Database.dbdir)
+ end
+
+ # --- error ---
+ class NotFoundPackage < RuntimeError ; end
end
end
View
34 lib/milkode/cdweb/lib/my_nokogiri.rb
@@ -1,34 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# @file
-# @brief
-# @author ongaeshi
-# @date 2011/12/02
-
-require 'hpricot'
-require 'nokogiri'
-require 'milkode/common/util'
-
-module Hpricot
- class Elements
- alias_method :at_css, :search
- end
-
- module Traverse
- alias_method :at_css, :search
- end
-end
-
-module Milkode
- class MyNokogiri
- def self.HTML(html)
- if Util::ruby19?
- Nokogiri::HTML(html)
- else
- Hpricot(html)
- end
- end
- end
-end
-
-
View
43 lib/milkode/cdweb/lib/search_contents.rb
@@ -34,9 +34,7 @@ def initialize(path, params, query)
@offset = params[:offset].to_i
@line = params[:line].to_i
@is_onematch = params[:onematch]
- fpaths = @q.fpaths
- fpaths << path + "/" unless path == ""
- @records, @total_records, @elapsed = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, LIMIT_NUM)
+ @records, @total_records, @elapsed = Database.instance.search(@q.keywords, @q.packages, path, @q.fpaths, @q.suffixs, @offset, LIMIT_NUM)
grep_contents
end
@@ -53,7 +51,26 @@ def data_range
end
def html_contents
- @match_records.map {|match_record| result_match_record(match_record)}.join
+ match_groups = @match_records.reduce([]) do |g, m|
+ if (g.empty?)
+ g << [m]
+ else
+ prev = g[-1][-1]
+
+ if (m.match_line.index - prev.match_line.index <= NTH * 2 &&
+ m.record.shortpath == prev.record.shortpath)
+ g[-1] << m # グループの末尾に追加
+ g
+ else
+ g << [m] # 新規グループ
+ end
+ end
+
+ # 近接マッチ無効
+ # g << [m]
+ end
+
+ match_groups.map{|g|result_match_record(g)}.join
end
def html_pagination
@@ -131,21 +148,23 @@ def grep_match_lines_stopover(record, index)
return false
end
- def result_match_record(match_record)
- record = match_record.record
- match_line = match_record.match_line
+ def result_match_record(match_group)
+ record = match_group[0].record
- first_index = match_line.index - NTH
- last_index = match_line.index + NTH
+ first_index = match_group[0].match_line.index - NTH
+ last_index = match_group[-1].match_line.index + NTH
+ match_lines = match_group.map{|m| m.match_line}
- coderay = CodeRayWrapper.new(record.content, record.shortpath, [match_line])
+ coderay = CodeRayWrapper.new(record.content, record.shortpath, match_lines)
coderay.col_limit(COL_LIMIT)
coderay.set_range(first_index..last_index)
+ url = "/home/" + record_link(record)
+
<<EOS
- <dt class='result-record'><a href='#{"/home/" + record_link(record) + "##{coderay.line_number_start}"}'>#{Util::relative_path record.shortpath, @path}</a></dt>
+ <dt class='result-record'><a href='#{url + "#n#{coderay.line_number_start}"}'>#{Util::relative_path record.shortpath, @path}</a></dt>
<dd>
-#{coderay.to_html}
+#{coderay.to_html_anchorlink(url)}
</dd>
EOS
end
View
7 lib/milkode/cdweb/lib/search_files.rb
@@ -23,13 +23,10 @@ def initialize(path, params, query)
@offset = params[:offset].to_i
- fpaths = @q.fpaths
- fpaths << path + "/" unless path == ""
-
- if (fpaths.include?("*"))
+ if (@q.fpaths.include?("*"))
@records, @total_records = Database.instance.selectAll(@offset, DISP_NUM)
else
- @records, @total_records = Database.instance.search(@q.keywords, @q.packages, fpaths, @q.suffixs, @offset, DISP_NUM)
+ @records, @total_records = Database.instance.search(@q.keywords, @q.packages, path, @q.fpaths, @q.suffixs, @offset, DISP_NUM)
end
end
View
55 lib/milkode/cdweb/lib/web_setting.rb
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+#
+# @file
+# @brief
+# @author ongaeshi
+# @date 2012/03/24
+
+require 'milkode/cdweb/lib/database'
+require 'yaml'
+
+module Milkode
+ class WebSetting
+ DEFAULT_SETTING = {
+ :home_title => "Milkode",
+ :home_icon => "/images/MilkodeIcon135.png",
+
+ :header_title => "Milkode",
+ :header_icon => "/images/MilkodeIcon135.png",
+
+ :display_about_milkode => true
+ }
+
+ def self.hash_method(name)
+ define_method(name) do
+ @data[name]
+ end
+ end
+
+ def initialize
+ fname = File.join(Database.dbdir, "milkweb.yaml")
+ if FileTest.exist? fname
+ open(fname) do |f|
+ @data = YAML.load(f.read)
+ end
+ else
+ @data = DEFAULT_SETTING
+ end
+ end
+
+ hash_method :home_title
+ hash_method :home_icon
+
+ hash_method :header_title
+ hash_method :header_icon
+
+ def about_milkode
+ if (@data[:display_about_milkode])
+ ', <a href="http://milkode.ongaeshi.me">milkodeについて</a>'
+ else
+ ''
+ end
+ end
+ end
+end
+
View
227 lib/milkode/cdweb/public/css/coderay.css
@@ -1,131 +1,120 @@
.CodeRay {
- background-color: #f8f8f8;
+ background-color: hsl(0,0%,95%);
border: 1px solid silver;
- font-family: 'Courier New', 'Terminal', monospace;
- color: #000;
+ color: black;
+}
+.CodeRay pre {
+ margin: 0px;
}
-.CodeRay pre { margin: 0px }
-
-div.CodeRay { }
-span.CodeRay { white-space: pre; border: 0px; padding: 2px }
+span.CodeRay { white-space: pre; border: 0px; padding: 2px; }
-table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
-table.CodeRay td { padding: 2px 4px; vertical-align: top }
+table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px; }
+table.CodeRay td { padding: 2px 4px; vertical-align: top; }
-.CodeRay .line_numbers, .CodeRay .no {
- background-color: #def;
+.CodeRay .line-numbers {
+ background-color: hsl(180,65%,90%);
color: gray;
text-align: right;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ user-select: none;
+}
+.CodeRay .line-numbers a {
+ background-color: hsl(180,65%,90%) !important;
+ color: gray !important;
+ text-decoration: none !important;
}
-.CodeRay .line_numbers tt { font-weight: bold }
-.CodeRay .line_numbers .highlighted { color: red }
+.CodeRay .line-numbers a:target { color: blue !important; }
+.CodeRay .line-numbers .highlighted { color: red !important; }
+.CodeRay .line-numbers .highlighted a { color: red !important; }
+.CodeRay span.line-numbers { padding: 0px 4px; }
.CodeRay .line { display: block; float: left; width: 100%; }
-.CodeRay .no { padding: 0px 4px }
-.CodeRay .code { width: 100% }
-
-ol.CodeRay { font-size: 10pt }
-ol.CodeRay li { white-space: pre }
-
-.CodeRay .code pre { overflow: auto }
-
-.CodeRay .debug { color:white ! important; background:blue ! important; }
-
-.CodeRay .af { color:#00C }
-.CodeRay .an { color:#007 }
-.CodeRay .at { color:#f08 }
-.CodeRay .av { color:#700 }
-.CodeRay .aw { color:#C00 }
-.CodeRay .bi { color:#509; font-weight:bold }
-.CodeRay .c { color:#888; }
-
-.CodeRay .ch { color:#04D }
-.CodeRay .ch .k { color:#04D }
-.CodeRay .ch .dl { color:#039 }
-
-.CodeRay .cl { color:#B06; font-weight:bold }
-.CodeRay .cm { color:#A08; font-weight:bold }
-.CodeRay .co { color:#036; font-weight:bold }
-.CodeRay .cr { color:#0A0 }
-.CodeRay .cv { color:#369 }
-.CodeRay .de { color:#B0B; }
-.CodeRay .df { color:#099; font-weight:bold }
-.CodeRay .di { color:#088; font-weight:bold }
-.CodeRay .dl { color:black }
-.CodeRay .do { color:#970 }
-.CodeRay .dt { color:#34b }
-.CodeRay .ds { color:#D42; font-weight:bold }
-.CodeRay .e { color:#666; font-weight:bold }
-.CodeRay .en { color:#800; font-weight:bold }
-.CodeRay .er { color:#F00; background-color:#FAA }
-.CodeRay .ex { color:#C00; font-weight:bold }
-.CodeRay .fl { color:#60E; font-weight:bold }
-.CodeRay .fu { color:#06B; font-weight:bold }
-.CodeRay .gv { color:#d70; font-weight:bold }
-.CodeRay .hx { color:#058; font-weight:bold }
-.CodeRay .i { color:#00D; font-weight:bold }
-.CodeRay .ic { color:#B44; font-weight:bold }
-
-.CodeRay .il { background: #ddd; color: black }
-.CodeRay .il .il { background: #ccc }
-.CodeRay .il .il .il { background: #bbb }
-.CodeRay .il .idl { background: #ddd; font-weight: bold; color: #666 }
-.CodeRay .idl { background-color: #bbb; font-weight: bold; color: #666; }
-
-.CodeRay .im { color:#f00; }
-.CodeRay .in { color:#B2B; font-weight:bold }
-.CodeRay .iv { color:#33B }
-.CodeRay .la { color:#970; font-weight:bold }
-.CodeRay .lv { color:#963 }
-.CodeRay .oc { color:#40E; font-weight:bold }
-.CodeRay .of { color:#000; font-weight:bold }
-.CodeRay .op { }
-.CodeRay .pc { color:#038; font-weight:bold }
-.CodeRay .pd { color:#369; font-weight:bold }
-.CodeRay .pp { color:#579; }
-.CodeRay .ps { color:#00C; font-weight:bold }
-.CodeRay .pt { color:#074; font-weight:bold }
-.CodeRay .r, .kw { color:#080; font-weight:bold }
-
-.CodeRay .ke { color: #808; }
-.CodeRay .ke .dl { color: #606; }
-.CodeRay .ke .ch { color: #80f; }
-.CodeRay .vl { color: #088; }
-
-.CodeRay .rx { background-color:#fff0ff }
-.CodeRay .rx .k { color:#808 }
-.CodeRay .rx .dl { color:#404 }
-.CodeRay .rx .mod { color:#C2C }
-.CodeRay .rx .fu { color:#404; font-weight: bold }
-
-.CodeRay .s { background-color:#fff0f0; color: #D20; }
-.CodeRay .s .s { background-color:#ffe0e0 }
-.CodeRay .s .s .s { background-color:#ffd0d0 }
-.CodeRay .s .k { }
-.CodeRay .s .ch { color: #b0b; }
-.CodeRay .s .dl { color: #710; }
-
-.CodeRay .sh { background-color:#f0fff0; color:#2B2 }
-.CodeRay .sh .k { }
-.CodeRay .sh .dl { color:#161 }
-
-.CodeRay .sy { color:#A60 }
-.CodeRay .sy .k { color:#A60 }
-.CodeRay .sy .dl { color:#630 }
-
-.CodeRay .ta { color:#070 }
-.CodeRay .tf { color:#070; font-weight:bold }
-.CodeRay .ts { color:#D70; font-weight:bold }
-.CodeRay .ty { color:#339; font-weight:bold }
-.CodeRay .v { color:#036 }
-.CodeRay .xt { color:#444 }
-
-.CodeRay .ins { background: #afa; }
-.CodeRay .del { background: #faa; }
-.CodeRay .chg { color: #aaf; background: #007; }
+.CodeRay .code { width: 100%; }
+
+.CodeRay .debug { color: white !important; background: blue !important; }
+
+.CodeRay .annotation { color:#007 }
+.CodeRay .attribute-name { color:#b48 }
+.CodeRay .attribute-value { color:#700 }
+.CodeRay .binary { color:#509 }
+.CodeRay .char .content { color:#D20 }
+.CodeRay .char .delimiter { color:#710 }
+.CodeRay .char { color:#D20 }
+.CodeRay .class { color:#B06; font-weight:bold }
+.CodeRay .class-variable { color:#369 }
+.CodeRay .color { color:#0A0 }
+.CodeRay .comment { color:#777 }
+.CodeRay .comment .char { color:#444 }
+.CodeRay .comment .delimiter { color:#444 }
+.CodeRay .complex { color:#A08 }
+.CodeRay .constant { color:#036; font-weight:bold }
+.CodeRay .decorator { color:#B0B }
+.CodeRay .definition { color:#099; font-weight:bold }
+.CodeRay .delimiter { color:black }
+.CodeRay .directive { color:#088; font-weight:bold }
+.CodeRay .doc { color:#970 }
+.CodeRay .doc-string { color:#D42; font-weight:bold }
+.CodeRay .doctype { color:#34b }
+.CodeRay .entity { color:#800; font-weight:bold }
+.CodeRay .error { color:#F00; background-color:#FAA }
+.CodeRay .escape { color:#666 }
+.CodeRay .exception { color:#C00; font-weight:bold }
+.CodeRay .float { color:#60E }
+.CodeRay .function { color:#06B; font-weight:bold }
+.CodeRay .global-variable { color:#d70 }
+.CodeRay .hex { color:#02b }
+.CodeRay .imaginary { color:#f00 }
+.CodeRay .include { color:#B44; font-weight:bold }
+.CodeRay .inline { background-color: hsla(0,0%,0%,0.07); color: black }
+.CodeRay .inline-delimiter { font-weight: bold; color: #666 }
+.CodeRay .instance-variable { color:#33B }
+.CodeRay .integer { color:#00D }
+.CodeRay .key .char { color: #60f }
+.CodeRay .key .delimiter { color: #404 }
+.CodeRay .key { color: #606 }
+.CodeRay .keyword { color:#080; font-weight:bold }
+.CodeRay .label { color:#970; font-weight:bold }
+.CodeRay .local-variable { color:#963 }
+.CodeRay .namespace { color:#707; font-weight:bold }
+.CodeRay .octal { color:#40E }
+.CodeRay .operator { }
+.CodeRay .predefined { color:#369; font-weight:bold }
+.CodeRay .predefined-constant { color:#069 }
+.CodeRay .predefined-type { color:#0a5; font-weight:bold }
+.CodeRay .preprocessor { color:#579 }
+.CodeRay .pseudo-class { color:#00C; font-weight:bold }
+.CodeRay .regexp .content { color:#808 }
+.CodeRay .regexp .delimiter { color:#404 }
+.CodeRay .regexp .modifier { color:#C2C }
+.CodeRay .regexp { background-color:hsla(300,100%,50%,0.06); }
+.CodeRay .reserved { color:#080; font-weight:bold }
+.CodeRay .shell .content { color:#2B2 }
+.CodeRay .shell .delimiter { color:#161 }
+.CodeRay .shell { background-color:hsla(120,100%,50%,0.06); }
+.CodeRay .string .char { color: #b0b }
+.CodeRay .string .content { color: #D20 }
+.CodeRay .string .delimiter { color: #710 }
+.CodeRay .string .modifier { color: #E40 }
+.CodeRay .string { background-color:hsla(0,100%,50%,0.05); }
+.CodeRay .symbol .content { color:#A60 }
+.CodeRay .symbol .delimiter { color:#630 }
+.CodeRay .symbol { color:#A60 }
+.CodeRay .tag { color:#070 }
+.CodeRay .type { color:#339; font-weight:bold }
+.CodeRay .value { color: #088; }
+.CodeRay .variable { color:#037 }
+
+.CodeRay .insert { background: hsla(120,100%,50%,0.12) }
+.CodeRay .delete { background: hsla(0,100%,50%,0.12) }
+.CodeRay .change { color: #bbf; background: #007; }
.CodeRay .head { color: #f8f; background: #505 }
+.CodeRay .head .filename { color: white; }
+
+.CodeRay .delete .eyecatcher { background-color: hsla(0,100%,50%,0.2); border: 1px solid hsla(0,100%,45%,0.5); margin: -1px; border-bottom: none; border-top-left-radius: 5px; border-top-right-radius: 5px; }
+.CodeRay .insert .eyecatcher { background-color: hsla(120,100%,50%,0.2); border: 1px solid hsla(120,100%,25%,0.5); margin: -1px; border-top: none; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }
-.CodeRay .ins .ins { color: #080; font-weight:bold }
-.CodeRay .del .del { color: #800; font-weight:bold }
-.CodeRay .chg .chg { color: #66f; }
-.CodeRay .head .head { color: #f4f; }
+.CodeRay .insert .insert { color: #0c0; background:transparent; font-weight:bold }
+.CodeRay .delete .delete { color: #c00; background:transparent; font-weight:bold }
+.CodeRay .change .change { color: #88f }
+.CodeRay .head .head { color: #f4f }
View
17 lib/milkode/cdweb/public/css/milkode.css
@@ -71,3 +71,20 @@ a.headmenu {
font-weight: normal;
}
+input#query {
+ height: 24px;
+ font-size: 12px;
+}
+
+input#search {
+ margin-left: 10px;
+ width: 80px;
+ font-size: 20px;
+}
+
+input#clear {
+ margin-left: 0px;
+ width: 80px;
+ font-size: 18px;
+}
+
View
BIN lib/milkode/cdweb/public/images/help.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 lib/milkode/cdweb/views/header_menu.haml
@@ -1,5 +1,5 @@
.header
%h1
- <a href="/"><img src="/images/MilkodeIcon135.png" alt="milkode-icon-mini" border="0" height="75px"/></a>
- Milkode
+ <a href="/"><img src=#{@setting.header_icon} alt="milkode-icon-mini" border="0" height="75px"/></a>
+ #{@setting.header_title}
= create_headmenu(@path, params, defined?(flistpath) ? flistpath : '')
View
4 lib/milkode/cdweb/views/help.haml
@@ -2,8 +2,8 @@
.header
%h1
- <a href="/"><img src="/images/MilkodeIcon135.png" alt="milkode-icon-mini" border="0" height="75px"/></a>
- #{@title} - Milkode
+ <a href="/"><img src=#{@setting.header_icon} alt="milkode-icon-mini" border="0" height="75px"/></a>
+ #{@title} - #{@setting.header_title}
.content
.sample-code
View
6 lib/milkode/cdweb/views/index.haml
@@ -1,6 +1,6 @@
%div(align="center")
.header_home
- %h1 <a href="/"><img src="/images/MilkodeIcon135.png" alt="milkode-icon" border="0" height="135px"/></a> Milkode <font class="version">#{@version}</font>
+ %h1 <a href="/"><img src=#{@setting.home_icon} alt="milkode-icon" border="0" height="135px"/></a> #{@setting.home_title} <font class="version">#{@version}</font>
.content
%form(method="post" action="/search")
@@ -12,7 +12,7 @@
.footer_home
<a href="/home">#{@package_num}</a>のパッケージ<br>
<a href="/home?query=f:*">#{@file_num}</a>のファイル<br>
- <a href="/help">ヘルプ</a> ,
- <a href="http://milkode.ongaeshi.me">milkodeについて</a>
+ <a href="/help">ヘルプ</a>
+ = @setting.about_milkode
View
11 lib/milkode/cdweb/views/search_form.haml
@@ -4,18 +4,19 @@
}
%form(name="searchform" action="/search" method="post")
%p
- %input(name="query" size="60" type="text"){:value => params[:query]}
- %input(type="submit" value="検索" onclick="set_pathname()")
+ %input#query(name="query" size="70" type="text"){:value => params[:query]}
+ %input#search(type="submit" name="search" value="検索" onclick="set_pathname()")
+ %input#clear(type="submit" name="clear" value="クリア" onclick="set_pathname()")
%br
%label
= create_radio('all', params[:shead])
- 全体を検索
+ 全て
%label
= create_radio('package', params[:shead])
- = package_name(@path) + '以下'
+ パッケージ(デフォルト)
%label
= create_radio('directory', params[:shead])
- = current_name(@path) + '以下'
+ ディレクトリ
%label
= create_checkbox('onematch', params[:onematch])
= '1ファイル1マッチ'
View
2 lib/milkode/common/util.rb
@@ -89,7 +89,7 @@ def filename_to_utf8(str_from_file)
end
def larger_than_oneline(content)
- content.count("\n") > 1
+ content.count($/) > 1
end
def normalize_filename(str)
View
26 milkode.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{milkode}
- s.version = "0.5.0"
+ s.version = "0.6.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["ongaeshi"]
- s.date = %q{2012-03-09}
+ s.date = %q{2012-03-29}
s.description = %q{Line based local source code search engine & grep-command & web-app.}
s.email = %q{ongaeshi0621@gmail.com}
s.executables = ["gmilk", "milk"]
@@ -39,15 +39,16 @@ Gem::Specification.new do |s|
"lib/milkode/cdweb/app.rb",
"lib/milkode/cdweb/cli_cdweb.rb",
"lib/milkode/cdweb/config.ru",
+ "lib/milkode/cdweb/lib/coderay_html2.rb",
"lib/milkode/cdweb/lib/coderay_wrapper.rb",
"lib/milkode/cdweb/lib/command.rb",
"lib/milkode/cdweb/lib/database.rb",
"lib/milkode/cdweb/lib/grep.rb",
"lib/milkode/cdweb/lib/mkurl.rb",
- "lib/milkode/cdweb/lib/my_nokogiri.rb",
"lib/milkode/cdweb/lib/query.rb",
"lib/milkode/cdweb/lib/search_contents.rb",
"lib/milkode/cdweb/lib/search_files.rb",
+ "lib/milkode/cdweb/lib/web_setting.rb",
"lib/milkode/cdweb/public/css/coderay-patch.css",
"lib/milkode/cdweb/public/css/coderay.css",
"lib/milkode/cdweb/public/css/milkode.css",
@@ -56,6 +57,7 @@ Gem::Specification.new do |s|
"lib/milkode/cdweb/public/images/document-new-4.png",
"lib/milkode/cdweb/public/images/file.png",
"lib/milkode/cdweb/public/images/go-home-5.png",
+ "lib/milkode/cdweb/public/images/help.png",
"lib/milkode/cdweb/public/js/milkode.js",
"lib/milkode/cdweb/views/filelist.haml",
"lib/milkode/cdweb/views/header_menu.haml",
@@ -132,50 +134,44 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_development_dependency(%q<rcov>, [">= 0"])
s.add_runtime_dependency(%q<termcolor>, [">= 1.2.0"])
- s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0"])
+ s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0", "< 2.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"])
- s.add_runtime_dependency(%q<coderay>, ["= 0.9.8"])
+ s.add_runtime_dependency(%q<coderay>, [">= 1.0.5"])
s.add_runtime_dependency(%q<thin>, [">= 1.2.10"])
s.add_runtime_dependency(%q<archive-zip>, [">= 0.4.0"])
s.add_runtime_dependency(%q<haml>, [">= 3.1.2"])
s.add_runtime_dependency(%q<sass>, [">= 3.1.3"])
- s.add_runtime_dependency(%q<nokogiri>, [">= 1.5.0"])
- s.add_runtime_dependency(%q<hpricot>, [">= 0.8.2"])
else
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<termcolor>, [">= 1.2.0"])
- s.add_dependency(%q<rroonga>, [">= 1.1.0"])
+ s.add_dependency(%q<rroonga>, [">= 1.1.0", "< 2.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"])
- s.add_dependency(%q<coderay>, ["= 0.9.8"])
+ s.add_dependency(%q<coderay>, [">= 1.0.5"])
s.add_dependency(%q<thin>, [">= 1.2.10"])
s.add_dependency(%q<archive-zip>, [">= 0.4.0"])
s.add_dependency(%q<haml>, [">= 3.1.2"])
s.add_dependency(%q<sass>, [">= 3.1.3"])
- s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
- s.add_dependency(%q<hpricot>, [">= 0.8.2"])
end
else
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
s.add_dependency(%q<rcov>, [">= 0"])
s.add_dependency(%q<termcolor>, [">= 1.2.0"])
- s.add_dependency(%q<rroonga>, [">= 1.1.0"])
+ s.add_dependency(%q<rroonga>, [">= 1.1.0", "< 2.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"])
- s.add_dependency(%q<coderay>, ["= 0.9.8"])
+ s.add_dependency(%q<coderay>, [">= 1.0.5"])
s.add_dependency(%q<thin>, [">= 1.2.10"])
s.add_dependency(%q<archive-zip>, [">= 0.4.0"])
s.add_dependency(%q<haml>, [">= 3.1.2"])
s.add_dependency(%q<sass>, [">= 3.1.3"])
- s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
- s.add_dependency(%q<hpricot>, [">= 0.8.2"])
end
end
View
2 test/test_cdstk.rb
@@ -66,6 +66,8 @@ def test_basic
# obj.update([], {})
end
+ Database.instance.yaml_reload
+
io.puts('--- remove ---')
obj.remove(['findgrep'], {:force => true})
obj.remove([], {:force => true})
View
3 test/test_coderay_wrapper.rb
@@ -15,9 +15,6 @@ class TestCodeRayWrapper < Test::Unit::TestCase
def test_basic
CodeRayWrapper.new(JS_SHORT_CODE, "console-dir.js").to_html
CodeRayWrapper.new(JS_CODE, "console-dir.js").to_html
-
- CodeRayWrapper.new(JS_SHORT_CODE, "console-dir.js").to_html_anchor
- CodeRayWrapper.new(JS_CODE, "console-dir.js").to_html_anchor
end
end
end
View
9 test/test_database.rb
@@ -33,6 +33,9 @@ def setup_db
# データベースのセットアップ
Database.setup('.')
+
+ # yamlファイルのリロード
+ Database.instance.yaml_reload
end
def test_database
@@ -49,7 +52,7 @@ def t_open
def t_fileList
db = Database.instance
- assert_equal [['lib', false], ['test', false], ["notfound.file", true]], db.fileList('')
+ assert_equal [['lib', false], ["notfound.file", false], ['test', false]], db.fileList('')
assert db.fileList('test').include? ['test/test_database.rb', true]
assert_equal ['lib/milkode', false], db.fileList('lib')[0]
assert_equal ['lib/milkode/cdstk/cdstk.rb', true], db.fileList('lib/milkode/cdstk')[0]
@@ -63,8 +66,8 @@ def t_cleanup
def t_remove
db = Database.instance
- db.remove(['test'])
- db.remove(['lib'])
+ db.remove_fpath(File.expand_path '../../test')
+ db.remove_fpath(File.expand_path '../../lib')
assert_equal 0, db.totalRecords
end

0 comments on commit fd2bc4d

Please sign in to comment.
Something went wrong with that request. Please try again.