gren 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/{History.ja.txt → HISTORY.ja.md} +41 -15
- data/HISTORY.md +92 -0
- data/LICENSE.txt +22 -0
- data/README.ja.md +57 -0
- data/README.md +51 -0
- data/Rakefile +9 -39
- data/bin/gren +2 -7
- data/gren.gemspec +21 -0
- data/lib/gren.rb +3 -3
- data/lib/gren/cli.rb +13 -10
- data/lib/{common → gren/common}/grenfiletest.rb +0 -0
- data/lib/{common → gren/common}/grensnip.rb +1 -1
- data/lib/{common → gren/common}/platform.rb +0 -0
- data/lib/{common → gren/common}/string_snip.rb +0 -0
- data/lib/{common → gren/common}/util.rb +16 -10
- data/lib/{findgrep → gren/findgrep}/findgrep.rb +47 -143
- data/lib/{findgrep → gren/findgrep}/result.rb +1 -1
- data/lib/gren/version.rb +3 -0
- data/test/data/aaa.txt +1 -0
- data/test/data/abc.rb +8 -0
- data/test/data/bbb.txt +1 -0
- data/test/data/ccc.c +1 -0
- data/test/data/sub/ccc.txt +1 -0
- data/test/test_cli.rb +80 -0
- data/test/test_gren.rb +10 -10
- data/test/test_gren_util.rb +3 -2
- data/test/test_string_snip.rb +31 -31
- metadata +67 -177
- data/History.txt +0 -66
- data/Manifest.txt +0 -48
- data/PostInstall.txt +0 -7
- data/README.rdoc +0 -181
- data/bin/grendb +0 -11
- data/bin/grenweb +0 -11
- data/bin/mkgrendb +0 -11
- data/lib/common/display_util.rb +0 -62
- data/lib/grendb/cli.rb +0 -41
- data/lib/grenweb/cli.rb +0 -52
- data/lib/grenweb/database.rb +0 -179
- data/lib/grenweb/grenweb.ru +0 -35
- data/lib/grenweb/grep.rb +0 -52
- data/lib/grenweb/help.rb +0 -39
- data/lib/grenweb/home.rb +0 -39
- data/lib/grenweb/html_renderer.rb +0 -243
- data/lib/grenweb/public/css/gren.css +0 -63
- data/lib/grenweb/public/images/gren-icon-mini.png +0 -0
- data/lib/grenweb/public/images/gren-icon.png +0 -0
- data/lib/grenweb/query.rb +0 -82
- data/lib/grenweb/searcher.rb +0 -129
- data/lib/grenweb/viewer.rb +0 -51
- data/lib/mkgrendb/cli.rb +0 -49
- data/lib/mkgrendb/mkgrendb.rb +0 -230
- data/rake_rdoc_custom.rb +0 -13
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/test/test_grenweb_cli.rb +0 -10
- data/test/test_grenweb_html_renderer.rb +0 -41
- data/test/test_grenweb_query.rb +0 -54
- data/test/test_grenweb_searcher.rb +0 -35
data/rake_rdoc_custom.rb
DELETED
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/gren.rb'}"
|
9
|
-
puts "Loading gren gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_grenweb_cli.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
2
|
-
require File.join(File.dirname(__FILE__), '../lib/grenweb/cli.rb')
|
3
|
-
require File.join(File.dirname(__FILE__), '../lib/grenweb/searcher.rb')
|
4
|
-
require File.join(File.dirname(__FILE__), '../lib/grenweb/viewer.rb')
|
5
|
-
|
6
|
-
class TestGrenwebCli < Test::Unit::TestCase
|
7
|
-
def test_print_default_output
|
8
|
-
# assert_match(/To update this executable/, @stdout)
|
9
|
-
end
|
10
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
3
|
-
require File.join(File.dirname(__FILE__), "../lib/grenweb/html_renderer.rb")
|
4
|
-
|
5
|
-
class TestGrenwebHTMLRendeler < Test::Unit::TestCase
|
6
|
-
include Grenweb
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@rendeler = HTMLRendeler.new('/')
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_pagination_line
|
13
|
-
assert_equal("<span class='pagination-link'><a href='?page=1'>test</a></span>\n", @rendeler.pagination_link(1, "test"))
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_search_summary
|
17
|
-
assert_equal(@rendeler.search_summary(10, 500, 10..20, 0.00893),
|
18
|
-
<<-EOS)
|
19
|
-
<div class='search-summary'>
|
20
|
-
<span class="keyword">10</span>の検索結果:
|
21
|
-
<span class="total-entries">500</span>件中
|
22
|
-
<span class="display-range">10 - 20</span>件(0.00893秒)
|
23
|
-
</div>
|
24
|
-
EOS
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_match_strong
|
28
|
-
assert_equal(@rendeler.match_strong("This is line.", [nil, nil]), "This is line.")
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_search_box
|
32
|
-
assert_equal(@rendeler.search_box('test must'), <<-EOF)
|
33
|
-
<form method="post" action="/::search">
|
34
|
-
<p>
|
35
|
-
<input name="query" type="text" size="60" value="test must" />
|
36
|
-
<input type="submit" value="検索" />
|
37
|
-
</p>
|
38
|
-
</form>
|
39
|
-
EOF
|
40
|
-
end
|
41
|
-
end
|
data/test/test_grenweb_query.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2010/10/21
|
7
|
-
|
8
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
9
|
-
require File.join(File.dirname(__FILE__), '../lib/grenweb/query')
|
10
|
-
|
11
|
-
class TestGrenWebQuery < Test::Unit::TestCase
|
12
|
-
include Grenweb
|
13
|
-
include Rack::Utils
|
14
|
-
|
15
|
-
def test_query
|
16
|
-
q = create_query("test fire beam")
|
17
|
-
assert_equal q.keywords, ['test', 'fire', 'beam']
|
18
|
-
assert_equal q.packages, []
|
19
|
-
assert_equal q.fpaths, []
|
20
|
-
assert_equal q.suffixs, []
|
21
|
-
assert_equal q.escape_html, 'test fire beam'
|
22
|
-
|
23
|
-
q = create_query("test fire beam f:testfile1")
|
24
|
-
assert_equal q.keywords, ['test', 'fire', 'beam']
|
25
|
-
assert_equal q.packages, []
|
26
|
-
assert_equal q.fpaths, ['testfile1']
|
27
|
-
assert_equal q.suffixs, []
|
28
|
-
|
29
|
-
q = create_query("test fire beam f:testfile1 filepath:dir32")
|
30
|
-
assert_equal q.keywords, ['test', 'fire', 'beam']
|
31
|
-
assert_equal q.packages, []
|
32
|
-
assert_equal q.fpaths, ['dir32', 'testfile1']
|
33
|
-
assert_equal q.suffixs, []
|
34
|
-
|
35
|
-
q = create_query("package:gren test fire beam f:testfile1 filepath:dir32 s:rb p:test suffix:pl")
|
36
|
-
assert_equal q.keywords, ['test', 'fire', 'beam']
|
37
|
-
assert_equal q.packages, ['gren', 'test']
|
38
|
-
assert_equal q.fpaths, ['dir32', 'testfile1']
|
39
|
-
assert_equal q.suffixs, ['pl', 'rb']
|
40
|
-
|
41
|
-
q = create_query("&p")
|
42
|
-
assert_equal q.escape_html, '&p'
|
43
|
-
|
44
|
-
q = create_query("int &p")
|
45
|
-
assert_equal q.escape_html, 'int &p'
|
46
|
-
|
47
|
-
q = create_query('"def update"')
|
48
|
-
assert_equal q.keywords, ['def update']
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_query(query)
|
52
|
-
Query.new(Rack::Request.new({"PATH_INFO"=>"/#{escape(query)}/"}))
|
53
|
-
end
|
54
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# @file
|
4
|
-
# @brief
|
5
|
-
# @author ongaeshi
|
6
|
-
# @date 2010/10/21
|
7
|
-
|
8
|
-
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
9
|
-
require File.join(File.dirname(__FILE__), "../lib/grenweb/searcher.rb")
|
10
|
-
require 'rack/mock'
|
11
|
-
|
12
|
-
class TestGrenwebSearcher < Test::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@app = Grenweb::Searcher.new
|
15
|
-
@mr = Rack::MockRequest.new(@app)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_get
|
19
|
-
res = nil
|
20
|
-
assert_nothing_raised('なんか失敗した') { res = @mr.get('/', :lint => true) }
|
21
|
-
assert_not_nil res, 'レスポンス来てない'
|
22
|
-
assert_equal 200, res.status, 'ステータスコードが変'
|
23
|
-
assert_equal 'text/html; charset=UTF-8', res['Content-Type'], 'Content-Typeが変'
|
24
|
-
#puts res.body
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_post
|
28
|
-
res = nil
|
29
|
-
assert_nothing_raised('なんか失敗した') { res = @mr.post('/', :lint => true) }
|
30
|
-
assert_not_nil res, 'レスポンス来てない'
|
31
|
-
assert_equal 302, res.status, 'ステータスコードが変'
|
32
|
-
assert_equal 'text/html; charset=UTF-8', res['Content-Type'], 'Content-Typeが変'
|
33
|
-
#puts res.body
|
34
|
-
end
|
35
|
-
end
|