codestock 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +8 -9
- data/VERSION +1 -1
- data/bin/cdstk +3 -5
- data/bin/cdv +1 -6
- data/bin/cdview +3 -4
- data/bin/cdweb +4 -5
- data/lib/{mkgrendb/mkgrendb.rb → cdstk/cdstk.rb} +15 -9
- data/lib/{mkgrendb/grendbyaml.rb → cdstk/cdstk_yaml.rb} +4 -4
- data/lib/{mkgrendb/cli.rb → cdstk/cli_cdstk.rb} +7 -7
- data/lib/{grendb/cli.rb → cdview/cli_cdview.rb} +2 -2
- data/lib/{grenweb/cli.rb → cdweb/cli_cdweb.rb} +2 -2
- data/lib/{grenweb → cdweb}/database.rb +2 -1
- data/lib/{grenweb → cdweb}/grenweb.ru +0 -0
- data/lib/{grenweb → cdweb}/grep.rb +0 -0
- data/lib/{grenweb → cdweb}/help.rb +0 -0
- data/lib/{grenweb → cdweb}/home.rb +0 -0
- data/lib/{grenweb → cdweb}/html_renderer.rb +0 -0
- data/lib/{grenweb → cdweb}/public/css/gren.css +0 -0
- data/lib/{grenweb → cdweb}/public/images/gren-icon-mini.png +0 -0
- data/lib/{grenweb → cdweb}/public/images/gren-icon.png +0 -0
- data/lib/{grenweb → cdweb}/query.rb +0 -0
- data/lib/{grenweb → cdweb}/searcher.rb +0 -0
- data/lib/{grenweb → cdweb}/viewer.rb +0 -0
- data/test/test_bin_exec.rb +31 -0
- data/test/{test_mkgrendb.rb → test_cdstk.rb} +37 -37
- data/test/{test_grendbyaml.rb → test_cdstk_yaml.rb} +11 -11
- data/test/test_grenweb_database.rb +3 -4
- data/test/test_grenweb_html_renderer.rb +1 -1
- data/test/test_grenweb_query.rb +1 -1
- data/test/test_grenweb_searcher.rb +1 -1
- metadata +26 -31
- data/lib/gren.rb +0 -6
- data/lib/gren/cli.rb +0 -65
- data/lib/mkgrendb/cli_old.rb +0 -49
- data/test/test_gren.rb +0 -10
- data/test/test_grenweb_cli.rb +0 -10
data/Rakefile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
-
begin
|
4
|
-
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
3
|
+
# begin
|
4
|
+
# Bundler.setup(:default, :development)
|
5
|
+
# rescue Bundler::BundlerError => e
|
6
|
+
# $stderr.puts e.message
|
7
|
+
# $stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
# exit e.status_code
|
9
|
+
# end
|
10
10
|
require 'rake'
|
11
11
|
|
12
12
|
require 'jeweler'
|
@@ -39,8 +39,7 @@ Jeweler::RubygemsDotOrgTasks.new
|
|
39
39
|
# end
|
40
40
|
|
41
41
|
task :test do
|
42
|
-
|
43
|
-
# load "test/runner.rb"
|
42
|
+
load "test/runner.rb"
|
44
43
|
end
|
45
44
|
|
46
45
|
require 'rcov/rcovtask'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/cdstk
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
# Copyright (c) 2010. All rights reserved.
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
|
-
require File.
|
8
|
-
require "mkgrendb/cli"
|
9
|
-
#require "mkgrendb/cli_old"
|
7
|
+
require File.join(File.dirname(__FILE__), "../lib/cdstk/cli_cdstk")
|
10
8
|
|
11
|
-
Version = "0.
|
12
|
-
|
9
|
+
Version = "0.1.0"
|
10
|
+
CodeStock::CLI_Cdstk.execute(STDOUT, ARGV)
|
data/bin/cdv
CHANGED
@@ -3,9 +3,4 @@
|
|
3
3
|
# Created on 2010-8-25.
|
4
4
|
# Copyright (c) 2010. All rights reserved.
|
5
5
|
|
6
|
-
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/gren")
|
8
|
-
require "grendb/cli"
|
9
|
-
|
10
|
-
Version = "0.2.4"
|
11
|
-
Grendb::CLI.execute(STDOUT, ARGV)
|
6
|
+
load File.join(File.dirname(__FILE__), "cdview")
|
data/bin/cdview
CHANGED
@@ -4,8 +4,7 @@
|
|
4
4
|
# Copyright (c) 2010. All rights reserved.
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
|
-
require File.
|
8
|
-
require "grendb/cli"
|
7
|
+
require File.join(File.dirname(__FILE__), "../lib/cdview/cli_cdview")
|
9
8
|
|
10
|
-
Version = "0.
|
11
|
-
|
9
|
+
Version = "0.1.0"
|
10
|
+
CodeStock::CLI_Cdview.execute(STDOUT, ARGV)
|
data/bin/cdweb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Created on 2010-
|
3
|
+
# Created on 2010-8-25.
|
4
4
|
# Copyright (c) 2010. All rights reserved.
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
|
-
require File.
|
8
|
-
require "grenweb/cli"
|
7
|
+
require File.join(File.dirname(__FILE__), "../lib/cdweb/cli_cdweb")
|
9
8
|
|
10
|
-
Version = "0.
|
11
|
-
|
9
|
+
Version = "0.1.0"
|
10
|
+
CodeStock::CLI_Cdweb.execute(STDOUT, ARGV)
|
@@ -6,15 +6,21 @@ require 'rubygems'
|
|
6
6
|
require 'groonga'
|
7
7
|
require 'fileutils'
|
8
8
|
require 'pathname'
|
9
|
-
require File.join(File.dirname(__FILE__), '
|
9
|
+
require File.join(File.dirname(__FILE__), 'cdstk_yaml')
|
10
10
|
require File.join(File.dirname(__FILE__), '../common/grenfiletest')
|
11
11
|
require File.join(File.dirname(__FILE__), '../common/util')
|
12
|
-
include
|
12
|
+
include CodeStock
|
13
13
|
|
14
|
-
module
|
15
|
-
class
|
14
|
+
module CodeStock
|
15
|
+
class Cdstk
|
16
16
|
DB_FILE_PATH = 'db/grendb.db'
|
17
17
|
|
18
|
+
# バイグラムでトークナイズする。連続する記号・アルファベット・数字は一語として扱う。
|
19
|
+
# DEFAULT_TOKENIZER = "TokenBigram"
|
20
|
+
|
21
|
+
# 記号・アルファベット・数字もバイグラムでトークナイズする。
|
22
|
+
DEFAULT_TOKENIZER = "TokenBigramSplitSymbolAlphaDigit"
|
23
|
+
|
18
24
|
def initialize(io = $stdout, db_dir = ".")
|
19
25
|
@db_dir = db_dir
|
20
26
|
@out = io
|
@@ -26,7 +32,7 @@ module Mkgrendb
|
|
26
32
|
|
27
33
|
def init
|
28
34
|
if Dir.entries(@db_dir) == [".", ".."]
|
29
|
-
|
35
|
+
CdstkYaml.create(@db_dir)
|
30
36
|
@out.puts "create : #{yaml_file}"
|
31
37
|
db_create(db_file)
|
32
38
|
else
|
@@ -112,11 +118,11 @@ module Mkgrendb
|
|
112
118
|
end
|
113
119
|
|
114
120
|
def yaml_file
|
115
|
-
|
121
|
+
CdstkYaml.yaml_file @db_dir
|
116
122
|
end
|
117
123
|
|
118
124
|
def yaml_load
|
119
|
-
|
125
|
+
CdstkYaml.load(@db_dir)
|
120
126
|
end
|
121
127
|
|
122
128
|
def update_dir_in(dir)
|
@@ -141,7 +147,7 @@ module Mkgrendb
|
|
141
147
|
@end_time = Time.now
|
142
148
|
|
143
149
|
@out.puts
|
144
|
-
@out.puts "time : #{Util::time_s(time)}"
|
150
|
+
@out.puts "time : #{Gren::Util::time_s(time)}"
|
145
151
|
@out.puts "files : #{@file_count}"
|
146
152
|
@out.puts "add : #{@add_count}"
|
147
153
|
@out.puts "update : #{@update_count}"
|
@@ -166,7 +172,7 @@ module Mkgrendb
|
|
166
172
|
schema.create_table("terms",
|
167
173
|
:type => :patricia_trie,
|
168
174
|
:key_normalize => true,
|
169
|
-
:default_tokenizer =>
|
175
|
+
:default_tokenizer => DEFAULT_TOKENIZER) do |table|
|
170
176
|
table.index("documents.path", :with_position => true)
|
171
177
|
table.index("documents.shortpath", :with_position => true)
|
172
178
|
table.index("documents.content", :with_position => true)
|
@@ -8,8 +8,8 @@
|
|
8
8
|
require 'yaml'
|
9
9
|
require 'pathname'
|
10
10
|
|
11
|
-
module
|
12
|
-
class
|
11
|
+
module CodeStock
|
12
|
+
class CdstkYaml
|
13
13
|
class YAMLAlreadyExist < RuntimeError
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ module Mkgrendb
|
|
19
19
|
def self.create(path = ".")
|
20
20
|
yf = yaml_file(path)
|
21
21
|
raise YAMLAlreadyExist.new if FileTest.exist? yf
|
22
|
-
obj =
|
22
|
+
obj = CdstkYaml.new(yf, {'contents' => [], 'version' => 0.1})
|
23
23
|
obj.save
|
24
24
|
return obj
|
25
25
|
end
|
@@ -28,7 +28,7 @@ module Mkgrendb
|
|
28
28
|
yf = yaml_file(path)
|
29
29
|
raise YAMLNotExist.new unless FileTest.exist? yf
|
30
30
|
open(yf) do |f|
|
31
|
-
return
|
31
|
+
return CdstkYaml.new(yf, YAML.load(f.read()))
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'optparse'
|
3
|
-
require File.join(File.dirname(__FILE__), '
|
3
|
+
require File.join(File.dirname(__FILE__), 'cdstk')
|
4
4
|
require File.join(File.dirname(__FILE__), '../common/dbdir.rb')
|
5
5
|
include CodeStock
|
6
6
|
|
7
|
-
module
|
8
|
-
class
|
7
|
+
module CodeStock
|
8
|
+
class CLI_Cdstk
|
9
9
|
def self.execute(stdout, arguments=[])
|
10
10
|
opt = OptionParser.new <<EOF
|
11
11
|
#{File.basename($0)} COMMAND [ARGS]
|
12
12
|
|
13
|
-
The most commonly used
|
13
|
+
The most commonly used #{File.basename($0)} are:
|
14
14
|
init Init db.
|
15
15
|
update Update db.
|
16
|
-
add Add contents. (ex. ~/Documents/
|
16
|
+
add Add contents. (ex. ~/Documents/cdstock, git://github.com/ongaeshi/cdstock.git)
|
17
17
|
remove Remove contents.
|
18
18
|
list List all contents.
|
19
19
|
rebuild Rebuild db.
|
@@ -40,7 +40,7 @@ EOF
|
|
40
40
|
subopt[subcommand].parse!(arguments) unless arguments.empty?
|
41
41
|
|
42
42
|
db_dir = select_dbdir(subcommand, init_default)
|
43
|
-
obj =
|
43
|
+
obj = Cdstk.new(stdout, db_dir)
|
44
44
|
|
45
45
|
case subcommand
|
46
46
|
when 'init'
|
@@ -61,7 +61,7 @@ EOF
|
|
61
61
|
end
|
62
62
|
else
|
63
63
|
if subcommand
|
64
|
-
$stderr.puts "
|
64
|
+
$stderr.puts "#{File.basename($0)}: '#{subcommand}' is not a #{File.basename($0)} command. See '#{File.basename($0)} --help'"
|
65
65
|
else
|
66
66
|
stdout.puts opt.help
|
67
67
|
end
|
@@ -4,8 +4,8 @@ require File.join(File.dirname(__FILE__), '../findgrep/findgrep')
|
|
4
4
|
require File.join(File.dirname(__FILE__), '../common/dbdir')
|
5
5
|
include CodeStock
|
6
6
|
|
7
|
-
module
|
8
|
-
class
|
7
|
+
module CodeStock
|
8
|
+
class CLI_Cdview
|
9
9
|
def self.execute(stdout, arguments=[])
|
10
10
|
# オプション
|
11
11
|
option = FindGrep::FindGrep::DEFAULT_OPTION
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# @file
|
4
|
+
# @brief
|
5
|
+
# @author ongaeshi
|
6
|
+
# @date 2011/03/08
|
7
|
+
|
8
|
+
require 'rubygems'
|
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")
|
13
|
+
|
14
|
+
class TestBinExec < Test::Unit::TestCase
|
15
|
+
def test_bin_exec
|
16
|
+
io = StringIO.new
|
17
|
+
|
18
|
+
CodeStock::CLI_Cdstk.execute(io)
|
19
|
+
|
20
|
+
CodeStock::CLI_Cdview.execute(io)
|
21
|
+
|
22
|
+
# 一定時間だけ起動するような仕組みは無いものか
|
23
|
+
# CodeStock::CLI_Cdweb.execute(io, "--no-browser -p 5555".split)
|
24
|
+
|
25
|
+
# puts io.string
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
@@ -9,12 +9,12 @@ require 'rubygems'
|
|
9
9
|
require 'groonga'
|
10
10
|
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
11
11
|
require File.join(File.dirname(__FILE__), "file_test_utils")
|
12
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
13
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
12
|
+
require File.join(File.dirname(__FILE__), "../lib/cdstk/cli_cdstk.rb")
|
13
|
+
require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk")
|
14
14
|
require 'stringio'
|
15
15
|
|
16
|
-
class
|
17
|
-
include
|
16
|
+
class TestCdstk < Test::Unit::TestCase
|
17
|
+
include CodeStock
|
18
18
|
include FileTestUtils
|
19
19
|
|
20
20
|
def test_create
|
@@ -25,9 +25,9 @@ class TestMkgrendb < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
def test_mkgrendb
|
27
27
|
io = StringIO.new
|
28
|
-
obj =
|
28
|
+
obj = Cdstk.new(io)
|
29
29
|
|
30
|
-
#
|
30
|
+
# Cdstk#init
|
31
31
|
obj.init
|
32
32
|
assert_equal <<EOF, io.string
|
33
33
|
create : grendb.yaml
|
@@ -38,26 +38,26 @@ EOF
|
|
38
38
|
obj.init
|
39
39
|
assert_match "Can't create Grendb Database (Not empty)", io.string
|
40
40
|
|
41
|
-
#
|
41
|
+
# Cdstk#add, remove
|
42
42
|
obj.add('test1.html', 'test2.html')
|
43
43
|
|
44
44
|
f1 = File.expand_path 'test1.html'
|
45
45
|
f2 = File.expand_path 'test2.html'
|
46
46
|
|
47
|
-
assert_equal [f1, f2],
|
47
|
+
assert_equal [f1, f2], CdstkYaml.load.directorys
|
48
48
|
assert_match /WARNING.*test1.html/, io.string
|
49
49
|
assert_match /WARNING.*test2.html/, io.string
|
50
50
|
|
51
51
|
obj.remove(f1, f2)
|
52
|
-
assert_equal [],
|
52
|
+
assert_equal [], CdstkYaml.load.directorys
|
53
53
|
|
54
|
-
#
|
54
|
+
# Cdstk#add
|
55
55
|
io.string = ""
|
56
56
|
obj.add('../../lib/findgrep', '../../lib/common')
|
57
57
|
assert_match /add_file\s+:\s+.*findgrep.rb/, io.string
|
58
58
|
assert_match /add_file\s+:\s+.*grenfiletest.rb/, io.string
|
59
59
|
|
60
|
-
#
|
60
|
+
# Cdstk#update
|
61
61
|
io.string = ""
|
62
62
|
obj.update
|
63
63
|
end
|
@@ -65,9 +65,9 @@ EOF
|
|
65
65
|
def test_mkgrendb_other_path
|
66
66
|
io = StringIO.new
|
67
67
|
FileUtils.mkdir 'other_path'
|
68
|
-
obj =
|
68
|
+
obj = Cdstk.new(io, 'other_path')
|
69
69
|
|
70
|
-
#
|
70
|
+
# Cdstk#init
|
71
71
|
obj.init
|
72
72
|
assert_equal <<EOF, io.string
|
73
73
|
create : other_path/grendb.yaml
|
@@ -78,59 +78,59 @@ EOF
|
|
78
78
|
obj.init
|
79
79
|
assert_match "Can't create Grendb Database (Not empty)", io.string
|
80
80
|
|
81
|
-
#
|
81
|
+
# Cdstk#add, remove
|
82
82
|
obj.add('test1.html', 'test2.html')
|
83
83
|
|
84
84
|
f1 = File.expand_path 'test1.html'
|
85
85
|
f2 = File.expand_path 'test2.html'
|
86
|
-
assert_equal [f1, f2],
|
86
|
+
assert_equal [f1, f2], CdstkYaml.load('other_path').directorys
|
87
87
|
assert_match /WARNING.*test1.html/, io.string
|
88
88
|
assert_match /WARNING.*test2.html/, io.string
|
89
89
|
|
90
90
|
obj.remove(f1, f2)
|
91
|
-
assert_equal [],
|
91
|
+
assert_equal [], CdstkYaml.load('other_path').directorys
|
92
92
|
|
93
|
-
#
|
93
|
+
# Cdstk#add
|
94
94
|
io.string = ""
|
95
95
|
obj.add('../../lib/findgrep', '../../lib/common')
|
96
96
|
assert_match /add_file\s+:\s+.*findgrep.rb/, io.string
|
97
97
|
assert_match /add_file\s+:\s+.*grenfiletest.rb/, io.string
|
98
98
|
|
99
|
-
#
|
99
|
+
# Cdstk#update
|
100
100
|
io.string = ""
|
101
101
|
obj.update
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_cli
|
105
105
|
io = StringIO.new
|
106
|
-
|
106
|
+
CLI_Cdstk.execute(io, ["init"])
|
107
107
|
|
108
108
|
io.string = ""
|
109
|
-
|
109
|
+
CLI_Cdstk.execute(io, ["add", "dummy/bar", "foo"])
|
110
110
|
assert_match /dummy\/bar/, io.string
|
111
111
|
assert_match /foo/, io.string
|
112
112
|
|
113
113
|
io.string = ""
|
114
|
-
|
114
|
+
CLI_Cdstk.execute(io, ["list"])
|
115
115
|
assert_match /dummy\/bar/, io.string
|
116
116
|
assert_match /foo/, io.string
|
117
117
|
|
118
|
-
|
118
|
+
CLI_Cdstk.execute(io, ["remove", "foo"])
|
119
119
|
io.string = ""
|
120
|
-
|
120
|
+
CLI_Cdstk.execute(io, ["list"])
|
121
121
|
assert_match /dummy\/bar/, io.string
|
122
122
|
assert_no_match /foo/, io.string
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
CLI_Cdstk.execute(io, ["update"])
|
125
|
+
CLI_Cdstk.execute(io, ["rebuild"])
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_dump
|
129
129
|
io = StringIO.new
|
130
|
-
|
131
|
-
|
130
|
+
CLI_Cdstk.execute(io, ["init"])
|
131
|
+
CLI_Cdstk.execute(io, ["add", "../runner.rb"])
|
132
132
|
io.string = ""
|
133
|
-
|
133
|
+
CLI_Cdstk.execute(io, ["dump"])
|
134
134
|
lines = io.string.split("\n")
|
135
135
|
assert_match /path : .*test\/runner.rb/, lines[2]
|
136
136
|
assert_match /shortpath : runner.rb/, lines[3]
|
@@ -140,18 +140,18 @@ EOF
|
|
140
140
|
def test_add_remove_compact
|
141
141
|
io = StringIO.new
|
142
142
|
|
143
|
-
|
144
|
-
|
145
|
-
|
143
|
+
CLI_Cdstk.execute(io, ["init"])
|
144
|
+
CLI_Cdstk.execute(io, ["add", "dummy/bar"])
|
145
|
+
CLI_Cdstk.execute(io, ["add", "dummy/bar"])
|
146
146
|
|
147
|
-
assert_equal 1,
|
147
|
+
assert_equal 1, CdstkYaml.load.directorys.select{|i|i == File.expand_path("dummy/bar")}.count
|
148
148
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
149
|
+
CLI_Cdstk.execute(io, ["add", "dummy/da"])
|
150
|
+
CLI_Cdstk.execute(io, ["add", "dummy/ad"])
|
151
|
+
CLI_Cdstk.execute(io, ["add", "dummy/foo"])
|
152
|
+
CLI_Cdstk.execute(io, ["add", "dummy/bar"])
|
153
153
|
|
154
|
-
assert_equal 1,
|
154
|
+
assert_equal 1, CdstkYaml.load.directorys.select{|i|i == File.expand_path("dummy/bar")}.count
|
155
155
|
end
|
156
156
|
|
157
157
|
def teardown
|
@@ -6,11 +6,11 @@
|
|
6
6
|
# @date 2011/02/20
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
9
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
9
|
+
require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk_yaml.rb")
|
10
10
|
require 'fileutils'
|
11
11
|
|
12
|
-
class
|
13
|
-
include
|
12
|
+
class TestCdstkYaml < Test::Unit::TestCase
|
13
|
+
include CodeStock
|
14
14
|
|
15
15
|
def setup
|
16
16
|
@prev_dir = Dir.pwd
|
@@ -22,20 +22,20 @@ class TestGrendbYAML < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
def test_000
|
24
24
|
# create
|
25
|
-
yaml =
|
25
|
+
yaml = CdstkYaml.create
|
26
26
|
assert_equal yaml.contents, []
|
27
27
|
assert_equal yaml.version, 0.1
|
28
|
-
assert_raise(
|
28
|
+
assert_raise(CdstkYaml::YAMLAlreadyExist) { CdstkYaml.create }
|
29
29
|
|
30
30
|
# load
|
31
|
-
yaml =
|
31
|
+
yaml = CdstkYaml.load
|
32
32
|
assert_equal yaml.contents, []
|
33
33
|
assert_equal yaml.version, 0.1
|
34
34
|
|
35
35
|
# load fail
|
36
36
|
FileUtils.mkdir 'loadtest'
|
37
37
|
FileUtils.cd 'loadtest' do
|
38
|
-
assert_raise(
|
38
|
+
assert_raise(CdstkYaml::YAMLNotExist) { CdstkYaml.load }
|
39
39
|
end
|
40
40
|
|
41
41
|
# add
|
@@ -64,20 +64,20 @@ EOF
|
|
64
64
|
FileUtils.mkdir 'otherpath'
|
65
65
|
|
66
66
|
# create
|
67
|
-
yaml =
|
67
|
+
yaml = CdstkYaml.create('otherpath')
|
68
68
|
assert_equal yaml.contents, []
|
69
69
|
assert_equal yaml.version, 0.1
|
70
|
-
assert_raise(
|
70
|
+
assert_raise(CdstkYaml::YAMLAlreadyExist) { CdstkYaml.create('otherpath') }
|
71
71
|
|
72
72
|
# load
|
73
|
-
yaml =
|
73
|
+
yaml = CdstkYaml.load 'otherpath'
|
74
74
|
assert_equal yaml.contents, []
|
75
75
|
assert_equal yaml.version, 0.1
|
76
76
|
|
77
77
|
# load fail
|
78
78
|
FileUtils.mkdir 'loadtest'
|
79
79
|
FileUtils.cd 'loadtest' do
|
80
|
-
assert_raise(
|
80
|
+
assert_raise(CdstkYaml::YAMLNotExist) { CdstkYaml.load }
|
81
81
|
end
|
82
82
|
|
83
83
|
# add
|
@@ -9,19 +9,18 @@ require 'rubygems'
|
|
9
9
|
require 'groonga'
|
10
10
|
require File.join(File.dirname(__FILE__), "test_helper")
|
11
11
|
require File.join(File.dirname(__FILE__), "file_test_utils")
|
12
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
12
|
+
require File.join(File.dirname(__FILE__), "../lib/cdweb/database")
|
13
13
|
require File.join(File.dirname(__FILE__), "../lib/common/dbdir")
|
14
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
14
|
+
require File.join(File.dirname(__FILE__), "../lib/cdstk/cdstk")
|
15
15
|
require 'stringio'
|
16
16
|
|
17
17
|
class TestMkgrendb < Test::Unit::TestCase
|
18
|
-
include Grenweb
|
19
18
|
include FileTestUtils
|
20
19
|
include CodeStock
|
21
20
|
|
22
21
|
def test_setup_and_open
|
23
22
|
io = StringIO.new
|
24
|
-
obj =
|
23
|
+
obj = Cdstk.new(io)
|
25
24
|
obj.init
|
26
25
|
|
27
26
|
Database.setup('.')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
3
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
3
|
+
require File.join(File.dirname(__FILE__), "../lib/cdweb/html_renderer.rb")
|
4
4
|
|
5
5
|
class TestGrenwebHTMLRendeler < Test::Unit::TestCase
|
6
6
|
include Grenweb
|
data/test/test_grenweb_query.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# @date 2010/10/21
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
9
|
-
require File.join(File.dirname(__FILE__), '../lib/
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/cdweb/query')
|
10
10
|
|
11
11
|
class TestGrenWebQuery < Test::Unit::TestCase
|
12
12
|
include Grenweb
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# @date 2010/10/21
|
7
7
|
|
8
8
|
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
9
|
-
require File.join(File.dirname(__FILE__), "../lib/
|
9
|
+
require File.join(File.dirname(__FILE__), "../lib/cdweb/searcher.rb")
|
10
10
|
require 'rack/mock'
|
11
11
|
|
12
12
|
class TestGrenwebSearcher < Test::Unit::TestCase
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
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-
|
17
|
+
date: 2011-06-08 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -138,6 +138,23 @@ files:
|
|
138
138
|
- bin/cdview
|
139
139
|
- bin/cdweb
|
140
140
|
- codestock.gemspec
|
141
|
+
- lib/cdstk/cdstk.rb
|
142
|
+
- lib/cdstk/cdstk_yaml.rb
|
143
|
+
- lib/cdstk/cli_cdstk.rb
|
144
|
+
- lib/cdview/cli_cdview.rb
|
145
|
+
- lib/cdweb/cli_cdweb.rb
|
146
|
+
- lib/cdweb/database.rb
|
147
|
+
- lib/cdweb/grenweb.ru
|
148
|
+
- lib/cdweb/grep.rb
|
149
|
+
- lib/cdweb/help.rb
|
150
|
+
- lib/cdweb/home.rb
|
151
|
+
- lib/cdweb/html_renderer.rb
|
152
|
+
- lib/cdweb/public/css/gren.css
|
153
|
+
- lib/cdweb/public/images/gren-icon-mini.png
|
154
|
+
- lib/cdweb/public/images/gren-icon.png
|
155
|
+
- lib/cdweb/query.rb
|
156
|
+
- lib/cdweb/searcher.rb
|
157
|
+
- lib/cdweb/viewer.rb
|
141
158
|
- lib/codestock.rb
|
142
159
|
- lib/common/dbdir.rb
|
143
160
|
- lib/common/display_util.rb
|
@@ -148,39 +165,18 @@ files:
|
|
148
165
|
- lib/common/util.rb
|
149
166
|
- lib/findgrep/findgrep.rb
|
150
167
|
- lib/findgrep/result.rb
|
151
|
-
- lib/gren.rb
|
152
|
-
- lib/gren/cli.rb
|
153
|
-
- lib/grendb/cli.rb
|
154
|
-
- lib/grenweb/cli.rb
|
155
|
-
- lib/grenweb/database.rb
|
156
|
-
- lib/grenweb/grenweb.ru
|
157
|
-
- lib/grenweb/grep.rb
|
158
|
-
- lib/grenweb/help.rb
|
159
|
-
- lib/grenweb/home.rb
|
160
|
-
- lib/grenweb/html_renderer.rb
|
161
|
-
- lib/grenweb/public/css/gren.css
|
162
|
-
- lib/grenweb/public/images/gren-icon-mini.png
|
163
|
-
- lib/grenweb/public/images/gren-icon.png
|
164
|
-
- lib/grenweb/query.rb
|
165
|
-
- lib/grenweb/searcher.rb
|
166
|
-
- lib/grenweb/viewer.rb
|
167
|
-
- lib/mkgrendb/cli.rb
|
168
|
-
- lib/mkgrendb/cli_old.rb
|
169
|
-
- lib/mkgrendb/grendbyaml.rb
|
170
|
-
- lib/mkgrendb/mkgrendb.rb
|
171
168
|
- test/file_test_utils.rb
|
172
169
|
- test/runner.rb
|
170
|
+
- test/test_bin_exec.rb
|
171
|
+
- test/test_cdstk.rb
|
172
|
+
- test/test_cdstk_yaml.rb
|
173
173
|
- test/test_dbdir.rb
|
174
|
-
- test/test_gren.rb
|
175
174
|
- test/test_gren_util.rb
|
176
|
-
- test/test_grendbyaml.rb
|
177
|
-
- test/test_grenweb_cli.rb
|
178
175
|
- test/test_grenweb_database.rb
|
179
176
|
- test/test_grenweb_html_renderer.rb
|
180
177
|
- test/test_grenweb_query.rb
|
181
178
|
- test/test_grenweb_searcher.rb
|
182
179
|
- test/test_helper.rb
|
183
|
-
- test/test_mkgrendb.rb
|
184
180
|
- test/test_string_snip.rb
|
185
181
|
has_rdoc: true
|
186
182
|
homepage: http://github.com/ongaeshi/codestock
|
@@ -215,15 +211,14 @@ summary: one-line summary of your gem
|
|
215
211
|
test_files:
|
216
212
|
- test/file_test_utils.rb
|
217
213
|
- test/runner.rb
|
214
|
+
- test/test_bin_exec.rb
|
215
|
+
- test/test_cdstk.rb
|
216
|
+
- test/test_cdstk_yaml.rb
|
218
217
|
- test/test_dbdir.rb
|
219
|
-
- test/test_gren.rb
|
220
218
|
- test/test_gren_util.rb
|
221
|
-
- test/test_grendbyaml.rb
|
222
|
-
- test/test_grenweb_cli.rb
|
223
219
|
- test/test_grenweb_database.rb
|
224
220
|
- test/test_grenweb_html_renderer.rb
|
225
221
|
- test/test_grenweb_query.rb
|
226
222
|
- test/test_grenweb_searcher.rb
|
227
223
|
- test/test_helper.rb
|
228
|
-
- test/test_mkgrendb.rb
|
229
224
|
- test/test_string_snip.rb
|
data/lib/gren.rb
DELETED
data/lib/gren/cli.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'optparse'
|
3
|
-
require File.join(File.dirname(__FILE__), '../findgrep/findgrep')
|
4
|
-
|
5
|
-
module Gren
|
6
|
-
class CLI
|
7
|
-
def self.execute(stdout, arguments=[])
|
8
|
-
# オプション
|
9
|
-
option = FindGrep::FindGrep::DEFAULT_OPTION
|
10
|
-
|
11
|
-
# オプション解析
|
12
|
-
opt = OptionParser.new("#{File.basename($0)} [option] pattern")
|
13
|
-
opt.on('--not PATTERN', 'Keyword is not included.') {|v| option.keywordsNot << v}
|
14
|
-
opt.on('--or PATTERN', 'Either of keyword is contained.') {|v| option.keywordsOr << v}
|
15
|
-
opt.on('-d DIR', '--directory DIR', 'Start directory. (deafult:".")') {|v| option.directory = v}
|
16
|
-
opt.on('--depth DEPTH', 'Limit search depth. ') {|v| option.depth = v.to_i}
|
17
|
-
opt.on('--this', '"--depth 0"') {|v| option.depth = 0}
|
18
|
-
opt.on('-i', '--ignore', 'Ignore case.') {|v| option.ignoreCase = true}
|
19
|
-
opt.on('-s', '--silent', 'Silent. Display match line only.') {|v| option.isSilent = true}
|
20
|
-
opt.on('--debug', 'Debug display.') {|v| option.debugMode = true}
|
21
|
-
opt.on('-c', '--color', 'Color highlight.') {|v| option.colorHighlight = true}
|
22
|
-
opt.on('-f REGEXP', '--file-regexp REGEXP', 'Search file regexp. (Enable multiple call)') {|v| option.filePatterns << v}
|
23
|
-
opt.on('--if REGEXP', '--ignore-file REGEXP', 'Ignore file pattern. (Enable multiple call)') {|v| option.ignoreFiles << v}
|
24
|
-
opt.on('--id REGEXP', '--ignore-dir REGEXP', 'Ignore dir pattern. (Enable multiple call)') {|v| option.ignoreDirs << v}
|
25
|
-
opt.on('-e ENCODE', '--encode ENCODE', 'Specify encode(none, auto, jis, sjis, euc, ascii, utf8, utf16). Default is "auto"') {|v| setupEncodeOption(option, v) }
|
26
|
-
opt.on('--no-snip', 'There being a long line, it does not snip.') {|v| option.noSnip = true }
|
27
|
-
opt.parse!(arguments)
|
28
|
-
|
29
|
-
# 検索オブジェクトの生成
|
30
|
-
if (arguments.size > 0 || option.keywordsOr.size > 0)
|
31
|
-
findGrep = FindGrep::FindGrep.new(arguments, option)
|
32
|
-
findGrep.searchAndPrint(stdout)
|
33
|
-
else
|
34
|
-
stdout.print opt.help
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.setupEncodeOption(option, encode)
|
40
|
-
case encode.downcase
|
41
|
-
when 'none'
|
42
|
-
option.kcode = Kconv::NOCONV
|
43
|
-
when 'auto'
|
44
|
-
option.kcode = Platform.get_shell_kcode
|
45
|
-
when 'jis'
|
46
|
-
option.kcode = Kconv::JIS
|
47
|
-
when 'sjis'
|
48
|
-
option.kcode = Kconv::SJIS
|
49
|
-
when 'euc'
|
50
|
-
option.kcode = Kconv::EUC
|
51
|
-
when 'ascii'
|
52
|
-
option.kcode = Kconv::ASCII
|
53
|
-
when 'utf8'
|
54
|
-
option.kcode = Kconv::UTF8
|
55
|
-
when 'utf16'
|
56
|
-
option.kcode = Kconv::UTF16
|
57
|
-
else
|
58
|
-
puts "Invalid encode."
|
59
|
-
puts " none, auto, jis, sjis, euc, ascii, utf8, utf16"
|
60
|
-
exit(-1)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
data/lib/mkgrendb/cli_old.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'optparse'
|
3
|
-
require File.join(File.dirname(__FILE__), 'mkgrendb')
|
4
|
-
|
5
|
-
module Mkgrendb
|
6
|
-
class CLI
|
7
|
-
def self.execute(stdout, arguments=[])
|
8
|
-
input_yamls = []
|
9
|
-
isDump = false
|
10
|
-
isFull = false
|
11
|
-
isDelete = false
|
12
|
-
isReport = false
|
13
|
-
|
14
|
-
opt = OptionParser.new "#{File.basename($0)} INPUT_YAML1 [INPUT_YAML2 ...]"
|
15
|
-
opt.on('--ddb', "--default-db", "Create or Update default DB. (Plase set ENV['GRENDB_DEFAULT_DB'])") {|v| input_yamls << ENV['GRENDB_DEFAULT_DB']}
|
16
|
-
opt.on('--full', "Full update DB. (Delete and create)") {|v| isFull = true }
|
17
|
-
opt.on('--delete', "Delete DB. (Not delete yaml)") {|v| isDelete = true }
|
18
|
-
opt.on('--dump', "Dump DB.") {|v| isDump = true }
|
19
|
-
opt.on('--report', "Database Report.") {|v| isReport = true }
|
20
|
-
opt.parse!(arguments)
|
21
|
-
|
22
|
-
input_yamls.concat arguments
|
23
|
-
|
24
|
-
if (input_yamls.size >= 1)
|
25
|
-
input_yamls.each do |input_yaml|
|
26
|
-
obj = Mkgrendb.new(input_yaml)
|
27
|
-
|
28
|
-
if (isFull)
|
29
|
-
obj.full
|
30
|
-
stdout.puts
|
31
|
-
elsif (isDelete)
|
32
|
-
obj.delete
|
33
|
-
stdout.puts
|
34
|
-
elsif (isDump)
|
35
|
-
obj.dump
|
36
|
-
elsif (isReport)
|
37
|
-
obj.report
|
38
|
-
else
|
39
|
-
obj.update
|
40
|
-
stdout.puts
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
else
|
45
|
-
stdout.puts opt.help
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/test/test_gren.rb
DELETED
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
|