bijou 0.1.0
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/ChangeLog.txt +4 -0
- data/LICENSE.txt +58 -0
- data/README.txt +48 -0
- data/Rakefile +105 -0
- data/doc/INSTALL.rdoc +260 -0
- data/doc/README.rdoc +314 -0
- data/doc/releases/bijou-0.1.0.rdoc +60 -0
- data/examples/birthday/birthday.rb +34 -0
- data/examples/holiday/holiday.rb +61 -0
- data/examples/holiday/letterhead.txt +4 -0
- data/examples/holiday/signature.txt +9 -0
- data/examples/phishing/letter.txt +29 -0
- data/examples/phishing/letterhead.txt +4 -0
- data/examples/phishing/phishing.rb +21 -0
- data/examples/phishing/signature.txt +9 -0
- data/examples/profile/profile.rb +46 -0
- data/lib/bijou.rb +15 -0
- data/lib/bijou/backend.rb +542 -0
- data/lib/bijou/cgi/adapter.rb +201 -0
- data/lib/bijou/cgi/handler.rb +5 -0
- data/lib/bijou/cgi/request.rb +37 -0
- data/lib/bijou/common.rb +12 -0
- data/lib/bijou/component.rb +108 -0
- data/lib/bijou/config.rb +60 -0
- data/lib/bijou/console/adapter.rb +167 -0
- data/lib/bijou/console/handler.rb +4 -0
- data/lib/bijou/console/request.rb +26 -0
- data/lib/bijou/context.rb +431 -0
- data/lib/bijou/diagnostics.rb +87 -0
- data/lib/bijou/errorformatter.rb +322 -0
- data/lib/bijou/exception.rb +39 -0
- data/lib/bijou/filters.rb +107 -0
- data/lib/bijou/httprequest.rb +108 -0
- data/lib/bijou/httpresponse.rb +268 -0
- data/lib/bijou/lexer.rb +513 -0
- data/lib/bijou/minicgi.rb +159 -0
- data/lib/bijou/parser.rb +1026 -0
- data/lib/bijou/processor.rb +404 -0
- data/lib/bijou/prstringio.rb +400 -0
- data/lib/bijou/webrick/adapter.rb +174 -0
- data/lib/bijou/webrick/handler.rb +32 -0
- data/lib/bijou/webrick/request.rb +45 -0
- data/script/cgi.rb +25 -0
- data/script/console.rb +7 -0
- data/script/server.rb +7 -0
- data/test/t1.cfg +5 -0
- data/test/tc_config.rb +26 -0
- data/test/tc_filter.rb +25 -0
- data/test/tc_lexer.rb +120 -0
- data/test/tc_response.rb +103 -0
- data/test/tc_ruby.rb +62 -0
- data/test/tc_stack.rb +50 -0
- metadata +121 -0
data/test/tc_response.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
$:.push '../lib'
|
3
|
+
require 'bijou/httpresponse.rb'
|
4
|
+
|
5
|
+
require 'test/unit/testcase'
|
6
|
+
require 'test/unit/testsuite'
|
7
|
+
require 'test/unit/ui/console/testrunner'
|
8
|
+
|
9
|
+
class HttpResponseTestCase < Test::Unit::TestCase
|
10
|
+
HeaderContentType = 'text/html; charset=iso-8859-1'
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@r = Bijou::HttpResponse.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
@r = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_ct
|
21
|
+
assert @r.content_type == 'text/html'
|
22
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == HeaderContentType
|
23
|
+
@r.clear_headers
|
24
|
+
assert @r.content_type == nil
|
25
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_ct_set
|
29
|
+
assert @r.content_type == 'text/html'
|
30
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == HeaderContentType
|
31
|
+
|
32
|
+
list = [
|
33
|
+
# Plain content type
|
34
|
+
['text/plain', 'text/plain', nil],
|
35
|
+
['text/plain', 'text/plain', ''],
|
36
|
+
|
37
|
+
['text/plain; charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
38
|
+
# Don't trim; preserve space for interface orthogonality.
|
39
|
+
[' text/plain ; charset= iso-8859-1 ', ' text/plain ', ' iso-8859-1 '],
|
40
|
+
]
|
41
|
+
|
42
|
+
n = 0
|
43
|
+
list.each {|item|
|
44
|
+
@r.content_type = item[1]
|
45
|
+
@r.charset = item[2]
|
46
|
+
|
47
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == item[0],
|
48
|
+
"item #{n} '#{item[0]}' content type header"
|
49
|
+
|
50
|
+
assert @r.content_type == item[1], "item #{n} '#{item[0]}' content type"
|
51
|
+
assert @r.charset == item[2], "item #{n} '#{item[0]}' charset"
|
52
|
+
n += 1
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_ct_set_header
|
57
|
+
assert @r.content_type == 'text/html'
|
58
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == HeaderContentType
|
59
|
+
|
60
|
+
list = [
|
61
|
+
['text/plain', 'text/plain', nil],
|
62
|
+
['text/plain ', 'text/plain', nil],
|
63
|
+
[' text/plain', 'text/plain', nil],
|
64
|
+
['text/plain;', 'text/plain', nil],
|
65
|
+
['text/plain ;', 'text/plain', nil],
|
66
|
+
['text/plain; ', 'text/plain', nil],
|
67
|
+
['text/plain ; ', 'text/plain', nil],
|
68
|
+
[' text/plain ; ', 'text/plain', nil],
|
69
|
+
['text/plain ; ', 'text/plain', nil],
|
70
|
+
['text/plain ; ', 'text/plain', nil],
|
71
|
+
['text/plain ; ', 'text/plain', nil],
|
72
|
+
|
73
|
+
['text/plain;charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
74
|
+
['text/plain ;charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
75
|
+
['text/plain; charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
76
|
+
['text/plain ; charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
77
|
+
[' text/plain;charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
78
|
+
[' text/plain;charset=iso-8859-1 ', 'text/plain', 'iso-8859-1'],
|
79
|
+
[' text/plain ; charset=iso-8859-1 ', 'text/plain', 'iso-8859-1'],
|
80
|
+
|
81
|
+
['text/plain;charset=iso-8859-1;', 'text/plain', 'iso-8859-1'],
|
82
|
+
[' text/plain ; charset=iso-8859-1 ; ', 'text/plain', 'iso-8859-1'],
|
83
|
+
|
84
|
+
# Extra parameters
|
85
|
+
['text/plain; p1 = 1; charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
86
|
+
['text/plain; p1=1 ;charset=iso-8859-1', 'text/plain', 'iso-8859-1'],
|
87
|
+
['text/plain; p1=1 ;charset=iso-8859-1;p3=3', 'text/plain', 'iso-8859-1'],
|
88
|
+
['text/plain; p1=1 ; charset=iso-8859-1 ; p3=3 ; ', 'text/plain', 'iso-8859-1'],
|
89
|
+
]
|
90
|
+
|
91
|
+
n = 0
|
92
|
+
list.each {|item|
|
93
|
+
@r.set_header(Bijou::HttpResponse::ContentType, item[0])
|
94
|
+
|
95
|
+
assert @r.get_header(Bijou::HttpResponse::ContentType) == item[0]
|
96
|
+
|
97
|
+
# Make sure the CT attribute is updated
|
98
|
+
assert @r.content_type == item[1], "item #{n} '#{item[0]}' content type"
|
99
|
+
assert @r.charset == item[2], "item #{n} '#{item[0]}' charset"
|
100
|
+
n += 1
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
data/test/tc_ruby.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
$:.push '../lib'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class RubyTestCase < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_path
|
14
|
+
if RUBY_PLATFORM =~ /mswin32/
|
15
|
+
list = [
|
16
|
+
[ 'd:\src\project\web', '..\test.txt', 'd:/src/project/test.txt'],
|
17
|
+
[ 'd:\src\project\web\\', '..\test.txt', 'd:/src/project/test.txt'],
|
18
|
+
[ 'd:/src/project/web', '../test.txt', 'd:/src/project/test.txt'],
|
19
|
+
[ 'd:/src/project/web/', '../test.txt', 'd:/src/project/test.txt'],
|
20
|
+
|
21
|
+
[ 'd:/src/project/web', 'test.txt', 'd:/src/project/web/test.txt'],
|
22
|
+
[ 'd:/src/project/web', './test.txt', 'd:/src/project/web/test.txt'],
|
23
|
+
[ 'd:/src/project/web', '../web/test.txt', 'd:/src/project/web/test.txt'],
|
24
|
+
# We can rely on it stripping the trailing slash.
|
25
|
+
[ 'd:/src/project/web', '', 'd:/src/project/web'],
|
26
|
+
[ 'd:/src/project/web/', '', 'd:/src/project/web'],
|
27
|
+
[ 'd:/src/project/web', '.', 'd:/src/project/web'],
|
28
|
+
[ 'd:/src/project/web/', '.', 'd:/src/project/web'],
|
29
|
+
|
30
|
+
[ '.', '', Dir.getwd ],
|
31
|
+
[ '.', '.', Dir.getwd ],
|
32
|
+
[ '.', 'test.txt', Dir.getwd + '/test.txt' ],
|
33
|
+
[ '.', './test.txt', Dir.getwd + '/test.txt' ],
|
34
|
+
]
|
35
|
+
else
|
36
|
+
list = [
|
37
|
+
[ '/src/project/web', '../test.txt', '/src/project/test.txt'],
|
38
|
+
[ '/src/project/web/', '../test.txt', '/src/project/test.txt'],
|
39
|
+
|
40
|
+
[ '/src/project/web', 'test.txt', '/src/project/web/test.txt'],
|
41
|
+
[ '/src/project/web', './test.txt', '/src/project/web/test.txt'],
|
42
|
+
[ '/src/project/web', '../web/test.txt', '/src/project/web/test.txt'],
|
43
|
+
# We can rely on it stripping the trailing slash.
|
44
|
+
[ '/src/project/web', '', '/src/project/web'],
|
45
|
+
[ '/src/project/web/', '', '/src/project/web'],
|
46
|
+
[ '/src/project/web', '.', '/src/project/web'],
|
47
|
+
[ '/src/project/web/', '.', '/src/project/web'],
|
48
|
+
|
49
|
+
[ '.', '', Dir.getwd ],
|
50
|
+
[ '.', '.', Dir.getwd ],
|
51
|
+
[ '.', 'test.txt', Dir.getwd + '/test.txt' ],
|
52
|
+
[ '.', './test.txt', Dir.getwd + '/test.txt' ],
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
list.each {|paths|
|
57
|
+
path = File.expand_path(paths[1], paths[0])
|
58
|
+
puts "#{paths[0]} #{paths[1]} -> #{path}"
|
59
|
+
assert path == paths[2]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
data/test/tc_stack.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
$:.push '../lib'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'bijou/context'
|
6
|
+
|
7
|
+
class StackTestCase < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_basic
|
15
|
+
s1 = Bijou::Stack.new
|
16
|
+
|
17
|
+
s1.push_frame(nil)
|
18
|
+
s1.output << 'a'
|
19
|
+
s1.push_frame(nil)
|
20
|
+
s1.output << 'b'
|
21
|
+
s1.push_frame(nil)
|
22
|
+
s1.output << 'c'
|
23
|
+
s1.pop_frame
|
24
|
+
s1.pop_frame
|
25
|
+
s1.pop_frame
|
26
|
+
assert_equal('abc', s1.flush)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_filter
|
30
|
+
s1 = Bijou::Stack.new
|
31
|
+
|
32
|
+
s1.push_frame(nil)
|
33
|
+
s1.output << 'a'
|
34
|
+
s1.push_frame(nil)
|
35
|
+
s1.output << 'b'
|
36
|
+
|
37
|
+
# simulate a filter
|
38
|
+
t = s1.top_frame.flush
|
39
|
+
s1.push_frame(nil)
|
40
|
+
s1.output << "(#{t})"
|
41
|
+
s1.pop_frame()
|
42
|
+
|
43
|
+
s1.push_frame(nil)
|
44
|
+
s1.output << 'c'
|
45
|
+
s1.pop_frame
|
46
|
+
s1.pop_frame
|
47
|
+
s1.pop_frame
|
48
|
+
assert_equal('a(b)c', s1.flush)
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bijou
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Todd Lucas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-13 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Bijou is a web templating system in the style of Perl's HTML::Mason project. It is a flexible system that allows HTML to be mixed with Ruby code, and to allow page fragments to be shared and combined in a number of ways. It is written in pure Ruby with minimal dependencies and is designed to be run in a number of configurations, including as a CGI script, using the lightweight WEBrick server, or stand-alone via the stdio console.
|
17
|
+
email: tl@dogandponyshow.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- README.txt
|
27
|
+
- LICENSE.txt
|
28
|
+
- ChangeLog.txt
|
29
|
+
- doc/README.rdoc
|
30
|
+
- doc/releases
|
31
|
+
- doc/INSTALL.rdoc
|
32
|
+
- doc/releases/bijou-0.1.0.rdoc
|
33
|
+
- lib/bijou
|
34
|
+
- lib/bijou/parser.rb
|
35
|
+
- lib/bijou/config.rb
|
36
|
+
- lib/bijou/minicgi.rb
|
37
|
+
- lib/bijou/httprequest.rb
|
38
|
+
- lib/bijou/prstringio.rb
|
39
|
+
- lib/bijou/filters.rb
|
40
|
+
- lib/bijou/diagnostics.rb
|
41
|
+
- lib/bijou/processor.rb
|
42
|
+
- lib/bijou/cgi
|
43
|
+
- lib/bijou/cgi/handler.rb
|
44
|
+
- lib/bijou/cgi/adapter.rb
|
45
|
+
- lib/bijou/cgi/request.rb
|
46
|
+
- lib/bijou/console
|
47
|
+
- lib/bijou/console/handler.rb
|
48
|
+
- lib/bijou/console/adapter.rb
|
49
|
+
- lib/bijou/console/request.rb
|
50
|
+
- lib/bijou/webrick
|
51
|
+
- lib/bijou/webrick/handler.rb
|
52
|
+
- lib/bijou/webrick/adapter.rb
|
53
|
+
- lib/bijou/webrick/request.rb
|
54
|
+
- lib/bijou/errorformatter.rb
|
55
|
+
- lib/bijou/common.rb
|
56
|
+
- lib/bijou/lexer.rb
|
57
|
+
- lib/bijou/component.rb
|
58
|
+
- lib/bijou/exception.rb
|
59
|
+
- lib/bijou/httpresponse.rb
|
60
|
+
- lib/bijou/backend.rb
|
61
|
+
- lib/bijou/context.rb
|
62
|
+
- lib/bijou.rb
|
63
|
+
- examples/birthday
|
64
|
+
- examples/birthday/birthday.rb
|
65
|
+
- examples/holiday
|
66
|
+
- examples/holiday/letterhead.txt
|
67
|
+
- examples/holiday/holiday.rb
|
68
|
+
- examples/holiday/signature.txt
|
69
|
+
- examples/phishing
|
70
|
+
- examples/phishing/letterhead.txt
|
71
|
+
- examples/phishing/letter.txt
|
72
|
+
- examples/phishing/signature.txt
|
73
|
+
- examples/phishing/phishing.rb
|
74
|
+
- examples/profile
|
75
|
+
- examples/profile/profile.rb
|
76
|
+
- script/cgi.rb
|
77
|
+
- script/server.rb
|
78
|
+
- script/console.rb
|
79
|
+
- test/tc_config.rb
|
80
|
+
- test/tc_lexer.rb
|
81
|
+
- test/tc_response.rb
|
82
|
+
- test/tc_ruby.rb
|
83
|
+
- test/t1.cfg
|
84
|
+
- test/tc_stack.rb
|
85
|
+
- test/tc_filter.rb
|
86
|
+
has_rdoc: true
|
87
|
+
homepage: http://bijou.rubyforge.org/
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options:
|
90
|
+
- --main
|
91
|
+
- lib/bijou.rb
|
92
|
+
- --inline-source
|
93
|
+
- --line-numbers
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.8.4
|
101
|
+
version:
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: bijou
|
111
|
+
rubygems_version: 1.0.1
|
112
|
+
signing_key:
|
113
|
+
specification_version: 2
|
114
|
+
summary: Bijou is a web templating system for Ruby.
|
115
|
+
test_files:
|
116
|
+
- test/tc_config.rb
|
117
|
+
- test/tc_lexer.rb
|
118
|
+
- test/tc_response.rb
|
119
|
+
- test/tc_ruby.rb
|
120
|
+
- test/tc_stack.rb
|
121
|
+
- test/tc_filter.rb
|