gren 0.3.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +7 -0
  3. data/{History.ja.txt → HISTORY.ja.md} +41 -15
  4. data/HISTORY.md +92 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.ja.md +57 -0
  7. data/README.md +51 -0
  8. data/Rakefile +9 -39
  9. data/bin/gren +2 -7
  10. data/gren.gemspec +21 -0
  11. data/lib/gren.rb +3 -3
  12. data/lib/gren/cli.rb +13 -10
  13. data/lib/{common → gren/common}/grenfiletest.rb +0 -0
  14. data/lib/{common → gren/common}/grensnip.rb +1 -1
  15. data/lib/{common → gren/common}/platform.rb +0 -0
  16. data/lib/{common → gren/common}/string_snip.rb +0 -0
  17. data/lib/{common → gren/common}/util.rb +16 -10
  18. data/lib/{findgrep → gren/findgrep}/findgrep.rb +47 -143
  19. data/lib/{findgrep → gren/findgrep}/result.rb +1 -1
  20. data/lib/gren/version.rb +3 -0
  21. data/test/data/aaa.txt +1 -0
  22. data/test/data/abc.rb +8 -0
  23. data/test/data/bbb.txt +1 -0
  24. data/test/data/ccc.c +1 -0
  25. data/test/data/sub/ccc.txt +1 -0
  26. data/test/test_cli.rb +80 -0
  27. data/test/test_gren.rb +10 -10
  28. data/test/test_gren_util.rb +3 -2
  29. data/test/test_string_snip.rb +31 -31
  30. metadata +67 -177
  31. data/History.txt +0 -66
  32. data/Manifest.txt +0 -48
  33. data/PostInstall.txt +0 -7
  34. data/README.rdoc +0 -181
  35. data/bin/grendb +0 -11
  36. data/bin/grenweb +0 -11
  37. data/bin/mkgrendb +0 -11
  38. data/lib/common/display_util.rb +0 -62
  39. data/lib/grendb/cli.rb +0 -41
  40. data/lib/grenweb/cli.rb +0 -52
  41. data/lib/grenweb/database.rb +0 -179
  42. data/lib/grenweb/grenweb.ru +0 -35
  43. data/lib/grenweb/grep.rb +0 -52
  44. data/lib/grenweb/help.rb +0 -39
  45. data/lib/grenweb/home.rb +0 -39
  46. data/lib/grenweb/html_renderer.rb +0 -243
  47. data/lib/grenweb/public/css/gren.css +0 -63
  48. data/lib/grenweb/public/images/gren-icon-mini.png +0 -0
  49. data/lib/grenweb/public/images/gren-icon.png +0 -0
  50. data/lib/grenweb/query.rb +0 -82
  51. data/lib/grenweb/searcher.rb +0 -129
  52. data/lib/grenweb/viewer.rb +0 -51
  53. data/lib/mkgrendb/cli.rb +0 -49
  54. data/lib/mkgrendb/mkgrendb.rb +0 -230
  55. data/rake_rdoc_custom.rb +0 -13
  56. data/script/console +0 -10
  57. data/script/destroy +0 -14
  58. data/script/generate +0 -14
  59. data/test/test_grenweb_cli.rb +0 -10
  60. data/test/test_grenweb_html_renderer.rb +0 -41
  61. data/test/test_grenweb_query.rb +0 -54
  62. data/test/test_grenweb_searcher.rb +0 -35
@@ -1,13 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'rake'
4
- require 'rake/rdoctask'
5
-
6
- # RDocの文字コードをutf8に
7
- Rake::RDocTask.class_eval {
8
- alias :_option_list :option_list
9
- def option_list
10
- _option_list + ['-c', 'utf8']
11
- end
12
- }
13
-
@@ -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"
@@ -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)
@@ -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)
@@ -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
@@ -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, '&amp;p'
43
-
44
- q = create_query("int &p")
45
- assert_equal q.escape_html, 'int &amp;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