codestock 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ === 0.1.2 2011/07/03
2
+
3
+ * Syntax highlighting (using CodeRay)
4
+
5
+
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  require 'rubygems'
2
3
  require 'bundler'
3
4
  # begin
@@ -25,23 +26,35 @@ Jeweler::Tasks.new do |gem|
25
26
  gem.add_runtime_dependency 'rroonga','>= 1.0.0'
26
27
  gem.add_runtime_dependency 'rack','>=1.2.1'
27
28
  gem.add_runtime_dependency 'launchy', '>=0.3.7'
29
+ gem.add_runtime_dependency 'coderay', '>=0.9.8'
28
30
 
29
31
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
30
32
  # gem.add_development_dependency 'rspec', '> 1.2.3'
31
33
  end
32
34
  Jeweler::RubygemsDotOrgTasks.new
33
35
 
34
- # require 'rake/testtask'
35
- # Rake::TestTask.new(:test) do |test|
36
- # test.libs << 'lib' << 'test'
37
- # test.pattern = 'test/**/test_*.rb'
38
- # test.verbose = true
39
- # end
36
+ require 'rake/testtask'
40
37
 
41
- task :test do
42
- load "test/runner.rb"
38
+ # groonga関連のテストが通らないため、独自のrake_test_loaderを読み込む
39
+ module Rake
40
+ class TestTask < TaskLib
41
+ def rake_loader # :nodoc:
42
+ find_file('test/rake_test_loader') or
43
+ fail "unable to find rake test loader"
44
+ end
45
+ end
46
+ end
47
+
48
+ Rake::TestTask.new(:test) do |test|
49
+ test.libs << 'lib' << 'test'
50
+ test.pattern = 'test/**/test_*.rb'
51
+ test.verbose = true
43
52
  end
44
53
 
54
+ # task :test do
55
+ # load "test/runner.rb"
56
+ # end
57
+
45
58
  require 'rcov/rcovtask'
46
59
  Rcov::RcovTask.new do |test|
47
60
  test.libs << 'test'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/bin/cdstk CHANGED
@@ -4,7 +4,7 @@
4
4
  # Copyright (c) 2010. All rights reserved.
5
5
 
6
6
  require 'rubygems'
7
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cli_cdstk")
7
+ require 'cdstk/cli_cdstk'
8
8
 
9
9
  Version = "0.1.0"
10
10
  CodeStock::CLI_Cdstk.execute(STDOUT, ARGV)
data/bin/cdview CHANGED
@@ -4,7 +4,7 @@
4
4
  # Copyright (c) 2010. All rights reserved.
5
5
 
6
6
  require 'rubygems'
7
- require File.join(File.dirname(__FILE__), "../lib/cdview/cli_cdview")
7
+ require 'cdview/cli_cdview'
8
8
 
9
9
  Version = "0.1.0"
10
10
  CodeStock::CLI_Cdview.execute(STDOUT, ARGV)
data/bin/cdweb CHANGED
@@ -4,7 +4,7 @@
4
4
  # Copyright (c) 2010. All rights reserved.
5
5
 
6
6
  require 'rubygems'
7
- require File.join(File.dirname(__FILE__), "../lib/cdweb/cli_cdweb")
7
+ require 'cdweb/cli_cdweb'
8
8
 
9
9
  Version = "0.1.0"
10
10
  CodeStock::CLI_Cdweb.execute(STDOUT, ARGV)
data/codestock.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{codestock}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ongaeshi"]
12
- s.date = %q{2011-03-11}
12
+ s.date = %q{2011-06-08}
13
13
  s.description = %q{longer description of your gem}
14
14
  s.email = %q{ongaeshi0621@gmail.com}
15
15
  s.executables = ["cdweb", "cdv", "cdstk", "cdview"]
@@ -40,39 +40,15 @@ Gem::Specification.new do |s|
40
40
  "lib/common/util.rb",
41
41
  "lib/findgrep/findgrep.rb",
42
42
  "lib/findgrep/result.rb",
43
- "lib/gren.rb",
44
- "lib/gren/cli.rb",
45
- "lib/grendb/cli.rb",
46
- "lib/grenweb/cli.rb",
47
- "lib/grenweb/database.rb",
48
- "lib/grenweb/grenweb.ru",
49
- "lib/grenweb/grep.rb",
50
- "lib/grenweb/help.rb",
51
- "lib/grenweb/home.rb",
52
- "lib/grenweb/html_renderer.rb",
53
- "lib/grenweb/public/css/gren.css",
54
- "lib/grenweb/public/images/gren-icon-mini.png",
55
- "lib/grenweb/public/images/gren-icon.png",
56
- "lib/grenweb/query.rb",
57
- "lib/grenweb/searcher.rb",
58
- "lib/grenweb/viewer.rb",
59
- "lib/mkgrendb/cli.rb",
60
- "lib/mkgrendb/cli_old.rb",
61
- "lib/mkgrendb/grendbyaml.rb",
62
- "lib/mkgrendb/mkgrendb.rb",
63
43
  "test/file_test_utils.rb",
64
44
  "test/runner.rb",
65
45
  "test/test_dbdir.rb",
66
- "test/test_gren.rb",
67
46
  "test/test_gren_util.rb",
68
- "test/test_grendbyaml.rb",
69
- "test/test_grenweb_cli.rb",
70
47
  "test/test_grenweb_database.rb",
71
48
  "test/test_grenweb_html_renderer.rb",
72
49
  "test/test_grenweb_query.rb",
73
50
  "test/test_grenweb_searcher.rb",
74
51
  "test/test_helper.rb",
75
- "test/test_mkgrendb.rb",
76
52
  "test/test_string_snip.rb"
77
53
  ]
78
54
  s.homepage = %q{http://github.com/ongaeshi/codestock}
@@ -84,16 +60,12 @@ Gem::Specification.new do |s|
84
60
  "test/file_test_utils.rb",
85
61
  "test/runner.rb",
86
62
  "test/test_dbdir.rb",
87
- "test/test_gren.rb",
88
63
  "test/test_gren_util.rb",
89
- "test/test_grendbyaml.rb",
90
- "test/test_grenweb_cli.rb",
91
64
  "test/test_grenweb_database.rb",
92
65
  "test/test_grenweb_html_renderer.rb",
93
66
  "test/test_grenweb_query.rb",
94
67
  "test/test_grenweb_searcher.rb",
95
68
  "test/test_helper.rb",
96
- "test/test_mkgrendb.rb",
97
69
  "test/test_string_snip.rb"
98
70
  ]
99
71
 
data/lib/cdstk/cdstk.rb CHANGED
@@ -6,9 +6,9 @@ require 'rubygems'
6
6
  require 'groonga'
7
7
  require 'fileutils'
8
8
  require 'pathname'
9
- require File.join(File.dirname(__FILE__), 'cdstk_yaml')
10
- require File.join(File.dirname(__FILE__), '../common/grenfiletest')
11
- require File.join(File.dirname(__FILE__), '../common/util')
9
+ require 'cdstk/cdstk_yaml'
10
+ require 'common/grenfiletest'
11
+ require 'common/util'
12
12
  include CodeStock
13
13
 
14
14
  module CodeStock
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'optparse'
3
- require File.join(File.dirname(__FILE__), 'cdstk')
4
- require File.join(File.dirname(__FILE__), '../common/dbdir.rb')
3
+ require 'cdstk/cdstk'
4
+ require 'common/dbdir.rb'
5
5
  include CodeStock
6
6
 
7
7
  module CodeStock
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'optparse'
3
- require File.join(File.dirname(__FILE__), '../findgrep/findgrep')
4
- require File.join(File.dirname(__FILE__), '../common/dbdir')
3
+ require 'findgrep/findgrep'
4
+ require 'common/dbdir'
5
5
  include CodeStock
6
6
 
7
7
  module CodeStock
@@ -2,8 +2,8 @@
2
2
  require 'rubygems'
3
3
  require 'optparse'
4
4
  require 'fileutils'
5
- require File.join(File.dirname(__FILE__), 'database')
6
- require File.join(File.dirname(__FILE__), '../common/dbdir')
5
+ require 'cdweb/database'
6
+ require 'common/dbdir'
7
7
  include CodeStock
8
8
  require 'rack'
9
9
  require 'launchy'
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # @file
4
+ # @brief
5
+ # @author ongaeshi
6
+ # @date 2011/07/03
7
+
8
+ require 'rubygems'
9
+ require 'coderay'
10
+ require 'coderay/helpers/file_type'
11
+
12
+ module CodeStock
13
+ class CodeRayWrapper
14
+ def self.html_memfile(content, filename)
15
+ to_html_code(content, file_type(filename))
16
+ end
17
+
18
+ def self.to_html_code(code, kind)
19
+ CodeRay.scan(code, kind).
20
+ html(
21
+ :wrap => nil,
22
+ :line_numbers => :table,
23
+ :css => :class
24
+ )
25
+ end
26
+
27
+ def self.file_type(filename)
28
+ case File.extname(filename)
29
+ when ".el"
30
+ :scheme
31
+ else
32
+ CodeRay::FileType.fetch filename, :plaintext
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
3
  # @file
4
- # @brief Grenwebで使用するデータベース
4
+ # @brief CodeStockで使用するデータベース
5
5
  # @author ongaeshi
6
6
  # @date 2010/10/17
7
7
 
@@ -9,7 +9,7 @@ require 'rubygems'
9
9
  require 'pathname'
10
10
  require 'singleton'
11
11
  require 'groonga'
12
- require File.join(File.dirname(__FILE__), "../common/dbdir")
12
+ require 'common/dbdir'
13
13
  include CodeStock
14
14
 
15
15
  module CodeStock
data/lib/cdweb/grenweb.ru CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rack'
10
- require File.join(File.dirname(__FILE__), 'home')
11
- require File.join(File.dirname(__FILE__), 'searcher')
12
- require File.join(File.dirname(__FILE__), 'viewer')
13
- require File.join(File.dirname(__FILE__), 'help')
10
+ require 'cdweb/home'
11
+ require 'cdweb/searcher'
12
+ require 'cdweb/viewer'
13
+ require 'cdweb/help'
14
14
 
15
15
  use Rack::CommonLogger
16
16
  use Rack::Runtime
@@ -18,18 +18,18 @@ use Rack::Static, :urls => ["/css", "/images"], :root => "public"
18
18
  use Rack::ContentLength
19
19
 
20
20
  map '/' do
21
- run Grenweb::Home.new
21
+ run CodeStock::Home.new
22
22
  end
23
23
 
24
24
  map '/::search' do
25
- run Grenweb::Searcher.new
25
+ run CodeStock::Searcher.new
26
26
  end
27
27
 
28
28
  map '/::view' do
29
- run Grenweb::Viewer.new
29
+ run CodeStock::Viewer.new
30
30
  end
31
31
 
32
32
  map '/::help' do
33
- run Grenweb::Help.new
33
+ run CodeStock::Help.new
34
34
  end
35
35
 
data/lib/cdweb/grep.rb CHANGED
@@ -5,12 +5,12 @@
5
5
  # @author ongaeshi
6
6
  # @date 2010/10/18
7
7
 
8
- module Grenweb
8
+ module CodeStock
9
9
  class Grep
10
10
  attr_reader :content
11
11
 
12
12
  def initialize(content)
13
- @content = content.split("\n")
13
+ @content = content ? content.split("\n") : []
14
14
  end
15
15
 
16
16
  MatchLineResult = Struct.new(:index, :match_datas)
data/lib/cdweb/help.rb CHANGED
@@ -7,11 +7,11 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rack'
10
- require File.join(File.dirname(__FILE__), 'database')
11
- require File.join(File.dirname(__FILE__), 'html_renderer')
12
- require File.join(File.dirname(__FILE__), 'query')
10
+ require 'cdweb/database'
11
+ require 'cdweb/html_renderer'
12
+ require 'cdweb/query'
13
13
 
14
- module Grenweb
14
+ module CodeStock
15
15
  class Help
16
16
  include Rack::Utils
17
17
 
data/lib/cdweb/home.rb CHANGED
@@ -7,11 +7,11 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rack'
10
- require File.join(File.dirname(__FILE__), 'database')
11
- require File.join(File.dirname(__FILE__), 'html_renderer')
12
- require File.join(File.dirname(__FILE__), 'query')
10
+ require 'cdweb/database'
11
+ require 'cdweb/html_renderer'
12
+ require 'cdweb/query'
13
13
 
14
- module Grenweb
14
+ module CodeStock
15
15
  class Home
16
16
  include Rack::Utils
17
17
 
@@ -8,14 +8,16 @@
8
8
  require 'rubygems'
9
9
  require 'pathname'
10
10
  require 'rack'
11
- require File.join(File.dirname(__FILE__), 'grep')
11
+ require 'cdweb/grep'
12
+ require 'cdweb/coderay_wrapper'
12
13
 
13
- module Grenweb
14
+ module CodeStock
14
15
  class HTMLRendeler
15
16
  include Rack::Utils
16
17
 
17
18
  def initialize(script_name)
18
- @script_name = Pathname(script_name)
19
+ # @script_name = Pathname(script_name)
20
+ @script_name = '/'
19
21
  end
20
22
 
21
23
  def header(title, header1)
@@ -29,6 +31,7 @@ module Grenweb
29
31
  <!-- <meta name="robot" content="noindex,nofollow" /> -->
30
32
  <title>#{title}</title>
31
33
  <link rel="stylesheet" href="#{fullpath('css/gren.css')}" type="text/css" media="all" />
34
+ <link rel="stylesheet" href="#{fullpath('css/coderay.css')}" type="text/css" media="all" />
32
35
  </head>
33
36
  <body>
34
37
  <div class="header">
@@ -132,11 +135,7 @@ EOS
132
135
  end
133
136
 
134
137
  def record_content(record)
135
- <<EOS
136
- <pre>
137
- #{record_content_line(record)}
138
- </pre>
139
- EOS
138
+ CodeRayWrapper.html_memfile(record.content, record.shortpath)
140
139
  end
141
140
 
142
141
  def record_content_line(record)
@@ -0,0 +1,131 @@
1
+ .CodeRay {
2
+ background-color: #f8f8f8;
3
+ border: 1px solid silver;
4
+ font-family: 'Courier New', 'Terminal', monospace;
5
+ color: #000;
6
+ }
7
+ .CodeRay pre { margin: 0px }
8
+
9
+ div.CodeRay { }
10
+
11
+ span.CodeRay { white-space: pre; border: 0px; padding: 2px }
12
+
13
+ table.CodeRay { border-collapse: collapse; width: 100%; padding: 2px }
14
+ table.CodeRay td { padding: 2px 4px; vertical-align: top }
15
+
16
+ .CodeRay .line_numbers, .CodeRay .no {
17
+ background-color: #def;
18
+ color: gray;
19
+ text-align: right;
20
+ }
21
+ .CodeRay .line_numbers tt { font-weight: bold }
22
+ .CodeRay .line_numbers .highlighted { color: red }
23
+ .CodeRay .line { display: block; float: left; width: 100%; }
24
+ .CodeRay .no { padding: 0px 4px }
25
+ .CodeRay .code { width: 100% }
26
+
27
+ ol.CodeRay { font-size: 10pt }
28
+ ol.CodeRay li { white-space: pre }
29
+
30
+ .CodeRay .code pre { overflow: auto }
31
+
32
+ .CodeRay .debug { color:white ! important; background:blue ! important; }
33
+
34
+ .CodeRay .af { color:#00C }
35
+ .CodeRay .an { color:#007 }
36
+ .CodeRay .at { color:#f08 }
37
+ .CodeRay .av { color:#700 }
38
+ .CodeRay .aw { color:#C00 }
39
+ .CodeRay .bi { color:#509; font-weight:bold }
40
+ .CodeRay .c { color:#888; }
41
+
42
+ .CodeRay .ch { color:#04D }
43
+ .CodeRay .ch .k { color:#04D }
44
+ .CodeRay .ch .dl { color:#039 }
45
+
46
+ .CodeRay .cl { color:#B06; font-weight:bold }
47
+ .CodeRay .cm { color:#A08; font-weight:bold }
48
+ .CodeRay .co { color:#036; font-weight:bold }
49
+ .CodeRay .cr { color:#0A0 }
50
+ .CodeRay .cv { color:#369 }
51
+ .CodeRay .de { color:#B0B; }
52
+ .CodeRay .df { color:#099; font-weight:bold }
53
+ .CodeRay .di { color:#088; font-weight:bold }
54
+ .CodeRay .dl { color:black }
55
+ .CodeRay .do { color:#970 }
56
+ .CodeRay .dt { color:#34b }
57
+ .CodeRay .ds { color:#D42; font-weight:bold }
58
+ .CodeRay .e { color:#666; font-weight:bold }
59
+ .CodeRay .en { color:#800; font-weight:bold }
60
+ .CodeRay .er { color:#F00; background-color:#FAA }
61
+ .CodeRay .ex { color:#C00; font-weight:bold }
62
+ .CodeRay .fl { color:#60E; font-weight:bold }
63
+ .CodeRay .fu { color:#06B; font-weight:bold }
64
+ .CodeRay .gv { color:#d70; font-weight:bold }
65
+ .CodeRay .hx { color:#058; font-weight:bold }
66
+ .CodeRay .i { color:#00D; font-weight:bold }
67
+ .CodeRay .ic { color:#B44; font-weight:bold }
68
+
69
+ .CodeRay .il { background: #ddd; color: black }
70
+ .CodeRay .il .il { background: #ccc }
71
+ .CodeRay .il .il .il { background: #bbb }
72
+ .CodeRay .il .idl { background: #ddd; font-weight: bold; color: #666 }
73
+ .CodeRay .idl { background-color: #bbb; font-weight: bold; color: #666; }
74
+
75
+ .CodeRay .im { color:#f00; }
76
+ .CodeRay .in { color:#B2B; font-weight:bold }
77
+ .CodeRay .iv { color:#33B }
78
+ .CodeRay .la { color:#970; font-weight:bold }
79
+ .CodeRay .lv { color:#963 }
80
+ .CodeRay .oc { color:#40E; font-weight:bold }
81
+ .CodeRay .of { color:#000; font-weight:bold }
82
+ .CodeRay .op { }
83
+ .CodeRay .pc { color:#038; font-weight:bold }
84
+ .CodeRay .pd { color:#369; font-weight:bold }
85
+ .CodeRay .pp { color:#579; }
86
+ .CodeRay .ps { color:#00C; font-weight:bold }
87
+ .CodeRay .pt { color:#074; font-weight:bold }
88
+ .CodeRay .r, .kw { color:#080; font-weight:bold }
89
+
90
+ .CodeRay .ke { color: #808; }
91
+ .CodeRay .ke .dl { color: #606; }
92
+ .CodeRay .ke .ch { color: #80f; }
93
+ .CodeRay .vl { color: #088; }
94
+
95
+ .CodeRay .rx { background-color:#fff0ff }
96
+ .CodeRay .rx .k { color:#808 }
97
+ .CodeRay .rx .dl { color:#404 }
98
+ .CodeRay .rx .mod { color:#C2C }
99
+ .CodeRay .rx .fu { color:#404; font-weight: bold }
100
+
101
+ .CodeRay .s { background-color:#fff0f0; color: #D20; }
102
+ .CodeRay .s .s { background-color:#ffe0e0 }
103
+ .CodeRay .s .s .s { background-color:#ffd0d0 }
104
+ .CodeRay .s .k { }
105
+ .CodeRay .s .ch { color: #b0b; }
106
+ .CodeRay .s .dl { color: #710; }
107
+
108
+ .CodeRay .sh { background-color:#f0fff0; color:#2B2 }
109
+ .CodeRay .sh .k { }
110
+ .CodeRay .sh .dl { color:#161 }
111
+
112
+ .CodeRay .sy { color:#A60 }
113
+ .CodeRay .sy .k { color:#A60 }
114
+ .CodeRay .sy .dl { color:#630 }
115
+
116
+ .CodeRay .ta { color:#070 }
117
+ .CodeRay .tf { color:#070; font-weight:bold }
118
+ .CodeRay .ts { color:#D70; font-weight:bold }
119
+ .CodeRay .ty { color:#339; font-weight:bold }
120
+ .CodeRay .v { color:#036 }
121
+ .CodeRay .xt { color:#444 }
122
+
123
+ .CodeRay .ins { background: #afa; }
124
+ .CodeRay .del { background: #faa; }
125
+ .CodeRay .chg { color: #aaf; background: #007; }
126
+ .CodeRay .head { color: #f8f; background: #505 }
127
+
128
+ .CodeRay .ins .ins { color: #080; font-weight:bold }
129
+ .CodeRay .del .del { color: #800; font-weight:bold }
130
+ .CodeRay .chg .chg { color: #66f; }
131
+ .CodeRay .head .head { color: #f4f; }
@@ -34,16 +34,13 @@ dt.result-record {
34
34
  font-size: 105%;
35
35
  }
36
36
 
37
- pre.lines {
38
- }
39
-
40
37
  div.pagination {
41
38
  background-color:#FEFFF0;
42
39
  text-align: center;
43
40
  margin-bottom: 20px;
44
41
  }
45
42
 
46
- pre {
43
+ pre.lines {
47
44
  border: 1px solid #dedede;
48
45
  margin-bottom: 5px;
49
46
  padding-left: 5px;
data/lib/cdweb/query.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'rubygems'
9
9
  require 'rack'
10
10
 
11
- module Grenweb
11
+ module CodeStock
12
12
  class Query
13
13
  include Rack::Utils
14
14
  attr_reader :query_string
@@ -7,11 +7,11 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rack'
10
- require File.join(File.dirname(__FILE__), 'database')
11
- require File.join(File.dirname(__FILE__), 'html_renderer')
12
- require File.join(File.dirname(__FILE__), 'query')
10
+ require 'cdweb/database'
11
+ require 'cdweb/html_renderer'
12
+ require 'cdweb/query'
13
13
 
14
- module Grenweb
14
+ module CodeStock
15
15
  class Searcher
16
16
  include Rack::Utils
17
17
 
data/lib/cdweb/viewer.rb CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rack'
10
- require File.join(File.dirname(__FILE__), 'database')
11
- require File.join(File.dirname(__FILE__), 'html_renderer')
10
+ require 'cdweb/database'
11
+ require 'cdweb/html_renderer'
12
12
 
13
- module Grenweb
13
+ module CodeStock
14
14
  class Viewer
15
15
  include Rack::Utils
16
16
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require File.join(File.dirname(__FILE__), 'string_snip')
3
+ require 'common/string_snip'
4
4
 
5
5
  class GrenSnip
6
6
  MAX_LINE_SIZE = 256
data/lib/common/util.rb CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  module Gren
4
4
  module Util
5
+ # アルファベットと演算子で表示する数を変える
6
+ ALPHABET_DISP_NUM = 5
7
+ OPERATOR_DISP_NUM = 10
8
+
5
9
  def time_s(time)
6
10
  t = time.truncate
7
11
  h = t / 3600
@@ -45,10 +49,6 @@ module Gren
45
49
  end
46
50
  module_function :size_s
47
51
 
48
- # アルファベットと演算子で表示する数を変える
49
- ALPHABET_DISP_NUM = 5
50
- OPERATOR_DISP_NUM = 10
51
-
52
52
  def p_classtree(c)
53
53
  unless c.is_a?(Class)
54
54
  c = c.class
@@ -1,14 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'find'
3
- require File.join(File.dirname(__FILE__), 'result')
3
+ require 'findgrep/result'
4
4
  require 'rubygems'
5
5
  require 'termcolor'
6
6
  require 'kconv'
7
- require File.join(File.dirname(__FILE__), '../common/platform')
8
- require File.join(File.dirname(__FILE__), '../common/grenfiletest')
9
- require File.join(File.dirname(__FILE__), '../common/grensnip')
7
+ require 'common/platform'
8
+ require 'common/grenfiletest'
9
+ require 'common/grensnip'
10
10
  require 'groonga'
11
- require File.join(File.dirname(__FILE__), '../common/util')
11
+ require 'common/util'
12
12
  include Gren
13
13
  require 'cgi'
14
14
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'find'
3
- require File.join(File.dirname(__FILE__), '../common/util')
3
+ require 'common/util'
4
4
  include Gren
5
5
 
6
6
  module FindGrep
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the test files from the command line.
4
+ require 'rubygems'
5
+ require 'groonga'
6
+
7
+ ARGV.each { |f| load f unless f =~ /^-/ }
@@ -7,9 +7,9 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'test/unit'
10
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cli_cdstk")
11
- require File.join(File.dirname(__FILE__), "../lib/cdview/cli_cdview")
12
- require File.join(File.dirname(__FILE__), "../lib/cdweb/cli_cdweb")
10
+ require 'cdstk/cli_cdstk'
11
+ require 'cdview/cli_cdview'
12
+ require 'cdweb/cli_cdweb'
13
13
 
14
14
  class TestBinExec < Test::Unit::TestCase
15
15
  def test_bin_exec
data/test/test_cdstk.rb CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'groonga'
10
- require File.join(File.dirname(__FILE__), "test_helper.rb")
11
- require File.join(File.dirname(__FILE__), "file_test_utils")
12
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cli_cdstk.rb")
13
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk")
10
+ require 'test_helper'
11
+ require 'file_test_utils'
12
+ require 'cdstk/cli_cdstk.rb'
13
+ require 'cdstk/cdstk'
14
14
  require 'stringio'
15
15
 
16
16
  class TestCdstk < Test::Unit::TestCase
@@ -5,8 +5,8 @@
5
5
  # @author ongaeshi
6
6
  # @date 2011/02/20
7
7
 
8
- require File.join(File.dirname(__FILE__), "test_helper.rb")
9
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk_yaml.rb")
8
+ require 'test_helper'
9
+ require 'cdstk/cdstk_yaml.rb'
10
10
  require 'fileutils'
11
11
 
12
12
  class TestCdstkYaml < Test::Unit::TestCase
data/test/test_dbdir.rb CHANGED
@@ -6,9 +6,9 @@
6
6
  # @date 2011/03/08
7
7
 
8
8
  require 'rubygems'
9
- require File.join(File.dirname(__FILE__), "test_helper")
10
- require File.join(File.dirname(__FILE__), "../lib/common/dbdir")
11
- require File.join(File.dirname(__FILE__), "file_test_utils")
9
+ require 'test_helper'
10
+ require 'common/dbdir'
11
+ require 'file_test_utils'
12
12
 
13
13
  class TestDbDir< Test::Unit::TestCase
14
14
  include CodeStock
@@ -1,6 +1,6 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
- require File.join(File.dirname(__FILE__), '../lib/common/util')
3
- require File.join(File.dirname(__FILE__), '../lib/common/grensnip')
1
+ require 'test_helper'
2
+ require 'common/util'
3
+ require 'common/grensnip'
4
4
 
5
5
  class TestGrenSnip < Test::Unit::TestCase
6
6
  def setup
@@ -7,11 +7,11 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'groonga'
10
- require File.join(File.dirname(__FILE__), "test_helper")
11
- require File.join(File.dirname(__FILE__), "file_test_utils")
12
- require File.join(File.dirname(__FILE__), "../lib/cdweb/database")
13
- require File.join(File.dirname(__FILE__), "../lib/common/dbdir")
14
- require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk")
10
+ require 'test_helper'
11
+ require 'file_test_utils'
12
+ require 'cdweb/database'
13
+ require 'common/dbdir'
14
+ require 'cdstk/cdstk'
15
15
  require 'stringio'
16
16
 
17
17
  class TestMkgrendb < Test::Unit::TestCase
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), "test_helper.rb")
3
- require File.join(File.dirname(__FILE__), "../lib/cdweb/html_renderer.rb")
2
+ require 'test_helper'
3
+ require 'cdweb/html_renderer.rb'
4
4
 
5
5
  class TestGrenwebHTMLRendeler < Test::Unit::TestCase
6
- include Grenweb
6
+ include CodeStock
7
7
 
8
8
  def setup
9
9
  @rendeler = HTMLRendeler.new('/')
@@ -5,11 +5,11 @@
5
5
  # @author ongaeshi
6
6
  # @date 2010/10/21
7
7
 
8
- require File.join(File.dirname(__FILE__), 'test_helper')
9
- require File.join(File.dirname(__FILE__), '../lib/cdweb/query')
8
+ require 'test_helper'
9
+ require 'cdweb/query'
10
10
 
11
11
  class TestGrenWebQuery < Test::Unit::TestCase
12
- include Grenweb
12
+ include CodeStock
13
13
  include Rack::Utils
14
14
 
15
15
  def test_query
@@ -5,13 +5,13 @@
5
5
  # @author ongaeshi
6
6
  # @date 2010/10/21
7
7
 
8
- require File.join(File.dirname(__FILE__), "test_helper.rb")
9
- require File.join(File.dirname(__FILE__), "../lib/cdweb/searcher.rb")
8
+ require 'test_helper'
9
+ require 'cdweb/searcher.rb'
10
10
  require 'rack/mock'
11
11
 
12
12
  class TestGrenwebSearcher < Test::Unit::TestCase
13
13
  def setup
14
- @app = Grenweb::Searcher.new
14
+ @app = CodeStock::Searcher.new
15
15
  @mr = Rack::MockRequest.new(@app)
16
16
  end
17
17
 
@@ -1,31 +1,31 @@
1
- require File.join(File.dirname(__FILE__), "test_helper.rb")
2
- require File.join(File.dirname(__FILE__), "../lib/common/util.rb")
3
- require File.join(File.dirname(__FILE__), "../lib/common/grensnip.rb")
4
-
5
- class TestStringSnip < Test::Unit::TestCase
6
- def setup
7
- end
8
-
9
- def test_ranges_compound
10
- ranges = [0..7, 8..232, 121..150, 248..255]
11
- assert_equal(StringSnip.ranges_compound(ranges), [0..232, 248..255])
12
-
13
- ranges = [10..20, 22..30, 33..40]
14
- assert_equal(StringSnip.ranges_compound(ranges), [10..20, 22..30, 33..40])
15
-
16
- ranges = [10..30, 20..30, 30..40]
17
- assert_equal(StringSnip.ranges_compound(ranges), [10..40])
18
- end
19
-
20
- def test_string_snip
21
- str = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|12345678901234567890123456789012345678901234567890123456"
22
-
23
- snipper = StringSnip.new
24
- snip_str = snipper.snip(str, [0..7, -8..-1])
25
- assert_equal(snip_str, str)
26
-
27
- snipper = StringSnip.new(64)
28
- snip_str = snipper.snip(str, [-8..-1, 10..20, 0..7])
29
- assert_equal(snip_str, "12345678<<snip>>12345678901<<snip>>90123456")
30
- end
31
- end
1
+ require 'test_helper'
2
+ require 'common/util.rb'
3
+ require 'common/grensnip.rb'
4
+
5
+ class TestStringSnip < Test::Unit::TestCase
6
+ def setup
7
+ end
8
+
9
+ def test_ranges_compound
10
+ ranges = [0..7, 8..232, 121..150, 248..255]
11
+ assert_equal(StringSnip.ranges_compound(ranges), [0..232, 248..255])
12
+
13
+ ranges = [10..20, 22..30, 33..40]
14
+ assert_equal(StringSnip.ranges_compound(ranges), [10..20, 22..30, 33..40])
15
+
16
+ ranges = [10..30, 20..30, 30..40]
17
+ assert_equal(StringSnip.ranges_compound(ranges), [10..40])
18
+ end
19
+
20
+ def test_string_snip
21
+ str = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789|12345678901234567890123456789012345678901234567890123456"
22
+
23
+ snipper = StringSnip.new
24
+ snip_str = snipper.snip(str, [0..7, -8..-1])
25
+ assert_equal(snip_str, str)
26
+
27
+ snipper = StringSnip.new(64)
28
+ snip_str = snipper.snip(str, [-8..-1, 10..20, 0..7])
29
+ assert_equal(snip_str, "12345678<<snip>>12345678901<<snip>>90123456")
30
+ end
31
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - ongaeshi
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-08 00:00:00 +09:00
17
+ date: 2011-07-03 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,20 @@ dependencies:
113
113
  requirement: *id007
114
114
  prerelease: false
115
115
  type: :runtime
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id008 !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ - 9
124
+ - 8
125
+ version: 0.9.8
126
+ name: coderay
127
+ requirement: *id008
128
+ prerelease: false
129
+ type: :runtime
116
130
  description: longer description of your gem
117
131
  email: ongaeshi0621@gmail.com
118
132
  executables:
@@ -129,6 +143,7 @@ files:
129
143
  - .document
130
144
  - Gemfile
131
145
  - Gemfile.lock
146
+ - HISTORY.rdoc
132
147
  - LICENSE.txt
133
148
  - README.rdoc
134
149
  - Rakefile
@@ -143,12 +158,14 @@ files:
143
158
  - lib/cdstk/cli_cdstk.rb
144
159
  - lib/cdview/cli_cdview.rb
145
160
  - lib/cdweb/cli_cdweb.rb
161
+ - lib/cdweb/coderay_wrapper.rb
146
162
  - lib/cdweb/database.rb
147
163
  - lib/cdweb/grenweb.ru
148
164
  - lib/cdweb/grep.rb
149
165
  - lib/cdweb/help.rb
150
166
  - lib/cdweb/home.rb
151
167
  - lib/cdweb/html_renderer.rb
168
+ - lib/cdweb/public/css/coderay.css
152
169
  - lib/cdweb/public/css/gren.css
153
170
  - lib/cdweb/public/images/gren-icon-mini.png
154
171
  - lib/cdweb/public/images/gren-icon.png
@@ -166,6 +183,7 @@ files:
166
183
  - lib/findgrep/findgrep.rb
167
184
  - lib/findgrep/result.rb
168
185
  - test/file_test_utils.rb
186
+ - test/rake_test_loader.rb
169
187
  - test/runner.rb
170
188
  - test/test_bin_exec.rb
171
189
  - test/test_cdstk.rb
@@ -210,6 +228,7 @@ specification_version: 3
210
228
  summary: one-line summary of your gem
211
229
  test_files:
212
230
  - test/file_test_utils.rb
231
+ - test/rake_test_loader.rb
213
232
  - test/runner.rb
214
233
  - test/test_bin_exec.rb
215
234
  - test/test_cdstk.rb