ramaze 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -259
- data/bin/ramaze +52 -25
- data/doc/AUTHORS +6 -0
- data/doc/CHANGELOG +1363 -42
- data/doc/INSTALL +1 -1
- data/doc/README +48 -35
- data/doc/README.html +637 -0
- data/doc/TODO +7 -16
- data/doc/allison/allison.css +6 -7
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/cache/STYLE +1 -2
- data/doc/changes.txt +3375 -0
- data/doc/changes.xml +3378 -0
- data/doc/meta/announcement.txt +47 -0
- data/doc/meta/configuration.txt +179 -0
- data/doc/meta/internals.txt +111 -0
- data/doc/readme_chunks/features.txt +8 -16
- data/doc/readme_chunks/installing.txt +7 -1
- data/doc/tutorial/todolist.txt +2 -3
- data/examples/blog/main.rb +9 -8
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/src/controller.rb +14 -41
- data/examples/blog/src/model.rb +12 -13
- data/examples/blog/src/view.rb +16 -0
- data/examples/blog/template/edit.xhtml +19 -8
- data/examples/blog/template/index.xhtml +14 -22
- data/examples/blog/template/new.xhtml +18 -5
- data/examples/caching.rb +5 -8
- data/examples/element.rb +3 -3
- data/examples/hello.rb +3 -5
- data/examples/simple.rb +4 -7
- data/examples/templates/template/external.haml +8 -7
- data/examples/templates/template/external.mab +11 -8
- data/examples/templates/template_amrita2.rb +4 -4
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -2
- data/examples/templates/template_haml.rb +24 -23
- data/examples/templates/template_liquid.rb +3 -1
- data/examples/templates/template_markaby.rb +15 -9
- data/examples/todolist/src/element/page.rb +1 -1
- data/lib/proto/conf/benchmark.yaml +6 -20
- data/lib/proto/conf/debug.yaml +6 -19
- data/lib/proto/conf/live.yaml +7 -19
- data/lib/proto/conf/silent.yaml +6 -16
- data/lib/proto/conf/stage.yaml +6 -18
- data/lib/proto/public/error.zmr +2 -2
- data/lib/ramaze.rb +34 -72
- data/lib/ramaze/adapter.rb +21 -18
- data/lib/ramaze/adapter/mongrel.rb +0 -3
- data/lib/ramaze/adapter/webrick.rb +6 -6
- data/lib/ramaze/cache/memcached.rb +3 -0
- data/lib/ramaze/controller.rb +227 -183
- data/lib/ramaze/dispatcher.rb +34 -129
- data/lib/ramaze/dispatcher/action.rb +28 -0
- data/lib/ramaze/dispatcher/error.rb +43 -0
- data/lib/ramaze/dispatcher/file.rb +34 -0
- data/lib/ramaze/global.rb +89 -48
- data/lib/ramaze/helper/aspect.rb +8 -6
- data/lib/ramaze/helper/auth.rb +3 -3
- data/lib/ramaze/helper/cache.rb +2 -2
- data/lib/ramaze/helper/file.rb +14 -0
- data/lib/ramaze/helper/inform.rb +36 -0
- data/lib/ramaze/helper/link.rb +7 -3
- data/lib/ramaze/helper/markaby.rb +30 -0
- data/lib/ramaze/helper/redirect.rb +2 -0
- data/lib/ramaze/inform.rb +8 -182
- data/lib/ramaze/inform/analogger.rb +19 -0
- data/lib/ramaze/inform/growl.rb +28 -0
- data/lib/ramaze/inform/hub.rb +26 -0
- data/lib/ramaze/inform/informer.rb +92 -0
- data/lib/ramaze/inform/informing.rb +44 -0
- data/lib/ramaze/inform/syslog.rb +27 -0
- data/lib/ramaze/inform/xosd.rb +42 -0
- data/lib/ramaze/snippets.rb +6 -2
- data/lib/ramaze/snippets/object/traits.rb +13 -1
- data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
- data/lib/ramaze/snippets/string/color.rb +27 -0
- data/lib/ramaze/snippets/string/each.rb +6 -0
- data/lib/ramaze/snippets/struct/fill.rb +15 -0
- data/lib/ramaze/template/ezamar.rb +13 -22
- data/lib/ramaze/template/ezamar/element.rb +12 -12
- data/lib/ramaze/template/liquid.rb +19 -18
- data/lib/ramaze/template/markaby.rb +37 -58
- data/lib/ramaze/tool/localize.rb +128 -0
- data/lib/ramaze/tool/tidy.rb +51 -21
- data/lib/ramaze/trinity.rb +3 -3
- data/lib/ramaze/trinity/request.rb +41 -23
- data/lib/ramaze/trinity/response.rb +10 -5
- data/lib/ramaze/trinity/session.rb +17 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +56 -0
- data/rake_tasks/gem.rake +44 -0
- data/rake_tasks/maintaince.rake +187 -0
- data/spec/all.rb +32 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/simple.rb +51 -0
- data/spec/examples/templates/template_amrita2.rb +14 -0
- data/spec/examples/templates/template_erubis.rb +21 -0
- data/spec/examples/templates/template_ezamar.rb +22 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +24 -0
- data/spec/examples/templates/template_markaby.rb +21 -0
- data/spec/helper.rb +81 -0
- data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
- data/spec/helper/layout.rb +55 -0
- data/spec/helper/mock_http.rb +66 -0
- data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
- data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
- data/spec/helper/wrap.rb +193 -0
- data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
- data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
- data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
- data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
- data/spec/ramaze/conf/locale_de.yaml +6 -0
- data/spec/ramaze/conf/locale_en.yaml +6 -0
- data/spec/ramaze/controller.rb +184 -0
- data/spec/ramaze/controller/template/greet.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +54 -0
- data/spec/ramaze/dependencies.rb +16 -0
- data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
- data/spec/ramaze/error.rb +64 -0
- data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
- data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
- data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
- data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
- data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
- data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
- data/spec/ramaze/helper/file.rb +17 -0
- data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
- data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
- data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
- data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
- data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
- data/spec/ramaze/inform/informer.rb +40 -0
- data/spec/ramaze/inform/syslog.rb +10 -0
- data/spec/ramaze/localize.rb +40 -0
- data/spec/ramaze/morpher.rb +82 -0
- data/spec/ramaze/params.rb +124 -0
- data/spec/{public → ramaze/public}/error404.xhtml +0 -0
- data/spec/{public → ramaze/public}/favicon.ico +0 -0
- data/spec/{public → ramaze/public}/ramaze.png +0 -0
- data/spec/{public → ramaze/public}/test_download.css +0 -0
- data/spec/ramaze/request.rb +129 -0
- data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
- data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
- data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
- data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
- data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
- data/spec/ramaze/template.rb +86 -0
- data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
- data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
- data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
- data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
- data/spec/ramaze/template/ezamar.rb +62 -0
- data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
- data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
- data/spec/{template → ramaze/template}/haml/index.haml +0 -0
- data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
- data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
- data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
- data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
- data/spec/ramaze/template/markaby.rb +59 -0
- data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
- data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
- metadata +145 -81
- data/examples/blog/public/screen.css +0 -106
- data/examples/blog/src/element.rb +0 -58
- data/examples/blog/template/view.xhtml +0 -15
- data/examples/blog/test/tc_entry.rb +0 -18
- data/lib/proto/public/404.jpg +0 -0
- data/spec/request_tc_helper.rb +0 -135
- data/spec/spec_all.rb +0 -118
- data/spec/spec_helper.rb +0 -66
- data/spec/tc_controller.rb +0 -49
- data/spec/tc_dependencies.rb +0 -13
- data/spec/tc_error.rb +0 -43
- data/spec/tc_morpher.rb +0 -88
- data/spec/tc_params.rb +0 -125
- data/spec/tc_template_ezamar.rb +0 -64
- data/spec/tc_template_markaby.rb +0 -72
- data/spec/template/ezamar/nested.zmr +0 -1
data/spec/all.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'spec/helper/layout'
|
5
|
+
|
6
|
+
layout = {
|
7
|
+
'ramaze' => {
|
8
|
+
'.' => '*',
|
9
|
+
'adapter' => '*',
|
10
|
+
'helper' => '*',
|
11
|
+
'inform' => '*',
|
12
|
+
'request' => '*',
|
13
|
+
'store' => '*',
|
14
|
+
'template' => '*',
|
15
|
+
'controller' => '*'
|
16
|
+
},
|
17
|
+
'examples' => {
|
18
|
+
'.' => '*',
|
19
|
+
'templates' => '*'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
manually_add = %w[
|
24
|
+
ramaze/template ramaze/controller
|
25
|
+
]
|
26
|
+
manually_add.map!{|ma| File.expand_path("spec/#{ma}.rb") }
|
27
|
+
|
28
|
+
layout = SpecLayout.new(File.dirname(__FILE__), layout)
|
29
|
+
layout.gather
|
30
|
+
layout.clean
|
31
|
+
layout.files += manually_add
|
32
|
+
layout.run
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/caching.rb'
|
4
|
+
|
5
|
+
describe 'Caching' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
n1 = 10_0000
|
10
|
+
n2 = 10_000
|
11
|
+
result = n1 ** n2
|
12
|
+
url = "/#{n1}/#{n2}"
|
13
|
+
result_string = "Hello, i'm a little method with this calculation:\n#{n1} ** #{n2} = #{result}"
|
14
|
+
|
15
|
+
intense_time = Benchmark.realtime{ get(url).body.should == result_string }
|
16
|
+
cached_already = Benchmark.realtime{ 10.times{ get(url) } }
|
17
|
+
intense_time.should be > cached_already
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/element'
|
4
|
+
|
5
|
+
describe 'Element' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
r = get('/').body
|
10
|
+
r.should include('<title>examples/element</title>')
|
11
|
+
r.should include('<h1>Test</h1>')
|
12
|
+
r.should include('<a href="http://something.com">something</a>')
|
13
|
+
r.should include('Hello, World!')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/simple'
|
4
|
+
|
5
|
+
describe 'Simple' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
@response.status.should == 200
|
10
|
+
end
|
11
|
+
|
12
|
+
it '/' do
|
13
|
+
@response = get('/')
|
14
|
+
@response.body.should == 'simple'
|
15
|
+
end
|
16
|
+
|
17
|
+
it '/simple' do
|
18
|
+
@response = get('/simple')
|
19
|
+
@response.body.should =~ /^#<Rack::Request/
|
20
|
+
end
|
21
|
+
|
22
|
+
it '/join/foo/bar' do
|
23
|
+
@response = get('/join/foo/bar')
|
24
|
+
@response.body.should == 'foobar'
|
25
|
+
end
|
26
|
+
|
27
|
+
it '/join/bar/baz' do
|
28
|
+
@response = get('/join/bar/baz')
|
29
|
+
@response.body.should == 'barbaz'
|
30
|
+
end
|
31
|
+
|
32
|
+
it '/join_all' do
|
33
|
+
@response = get('/join_all/a/b/c/d/e/f')
|
34
|
+
@response.body.should == 'abcdef'
|
35
|
+
end
|
36
|
+
|
37
|
+
it '/sum' do
|
38
|
+
@response = get('/sum/1/2')
|
39
|
+
@response.body.should == '3'
|
40
|
+
end
|
41
|
+
|
42
|
+
it '/post_or_get' do
|
43
|
+
@response = get('/post_or_get')
|
44
|
+
@response.body.should == 'GET'
|
45
|
+
end
|
46
|
+
|
47
|
+
it '/other' do
|
48
|
+
@response = get('/other')
|
49
|
+
@response.body.should == "Hello, World from OtherController"
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_amrita2'
|
4
|
+
|
5
|
+
describe 'Template Amrita2' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/external' do
|
9
|
+
html = get('/external').body
|
10
|
+
html.should_not == nil
|
11
|
+
html.should =~ %r{<title>Template::Amrita2 external</title>}
|
12
|
+
html.should =~ %r{<h1>The external Template for Amrita2</h1>}
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_erubis'
|
4
|
+
|
5
|
+
describe 'Template Erubis' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
get('/').body.strip.should ==
|
10
|
+
"<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[/internal /external].each do |url|
|
14
|
+
it url do
|
15
|
+
html = get(url).body
|
16
|
+
html.should_not == nil
|
17
|
+
html.should =~ %r{<title>Template::Erubis (internal|external)</title>}
|
18
|
+
html.should =~ %r{<h1>The (internal|external) Template for Erubis</h1>}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_ezamar'
|
4
|
+
|
5
|
+
describe 'Template Ezamar' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
get('/').body.should ==
|
10
|
+
"<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[/internal /external].each do |url|
|
14
|
+
it url do
|
15
|
+
html = get(url).body
|
16
|
+
html.should_not == nil
|
17
|
+
html.should =~ %r{<title>Template::Ezamar (internal|external)</title>}
|
18
|
+
html.should =~ %r{<h1>The (internal|external) Template for Ezamar</h1>}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_haml'
|
4
|
+
|
5
|
+
describe 'Template Haml' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
get('/').body.strip.should ==
|
10
|
+
"<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[/internal /external].each do |url|
|
14
|
+
it url do
|
15
|
+
html = get(url).body
|
16
|
+
html.should_not == nil
|
17
|
+
html.should =~ %r{<title>Template::Haml (internal|external)</title>}
|
18
|
+
html.should =~ %r{<h1>The (internal|external) Template for Haml</h1>}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_liquid'
|
4
|
+
|
5
|
+
describe 'Template Liquid' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
get('/').body.strip.should ==
|
10
|
+
"<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[/internal /external].each do |url|
|
14
|
+
it url do
|
15
|
+
html = get(url).body
|
16
|
+
html.should_not == nil
|
17
|
+
html.should =~ %r{<title>Template::Liquid (internal|external)</title>}
|
18
|
+
html.should =~ %r{<h1>The (internal|external) Template for Liquid</h1>}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec/helper'
|
2
|
+
|
3
|
+
require 'examples/templates/template_markaby'
|
4
|
+
|
5
|
+
describe 'Template Markaby' do
|
6
|
+
ramaze
|
7
|
+
|
8
|
+
it '/' do
|
9
|
+
get('/').body.strip.should ==
|
10
|
+
"<a href=\"/\">index</a> | <a href=\"/internal\">internal</a> | <a href=\"/external\">external</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
%w[/internal /external].each do |url|
|
14
|
+
it url do
|
15
|
+
html = get(url).body
|
16
|
+
html.should_not == nil
|
17
|
+
html.should =~ %r{<title>Template::Markaby (internal|external)</title>}
|
18
|
+
html.should =~ %r{<h1>The (internal|external) Template for Markaby</h1>}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require 'timeout'
|
5
|
+
|
6
|
+
$:.unshift File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib')
|
7
|
+
$:.unshift '/home/manveru/prog/projects/rack/lib'
|
8
|
+
|
9
|
+
# $VERBOSE = 1
|
10
|
+
$context_runner = false
|
11
|
+
|
12
|
+
require 'ramaze'
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'rubygems'
|
16
|
+
rescue LoadError => ex
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec'
|
20
|
+
if Spec::VERSION::FULL_VERSION < "0.9.1 (r1880)"
|
21
|
+
puts "please update rspec >= 0.9.1"
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'spec/helper/mock_http'
|
26
|
+
require 'spec/helper/simple_http'
|
27
|
+
require 'spec/helper/requester'
|
28
|
+
require 'spec/helper/context'
|
29
|
+
|
30
|
+
Spec::Runner.configure do |config|
|
31
|
+
config.include MockHTTP
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
if defined?(::Spec)
|
36
|
+
exclude = Ramaze::Controller.class_trait[:exclude_action_modules]
|
37
|
+
exclude += [Base64::Deprecated, Base64, Spec::Expectations::ObjectExpectations]
|
38
|
+
exclude << Spec::Mocks::Methods if defined?(Spec::Mock::Methods)
|
39
|
+
end
|
40
|
+
|
41
|
+
# start up ramaze with a given hash of options
|
42
|
+
# that will be merged with the default-options.
|
43
|
+
|
44
|
+
def ramaze_start hash = {}
|
45
|
+
options = {
|
46
|
+
:mode => :debug,
|
47
|
+
:adapter => false,
|
48
|
+
:run_loose => true,
|
49
|
+
:error_page => false,
|
50
|
+
:port => 7007,
|
51
|
+
:host => '127.0.0.1',
|
52
|
+
:force => true,
|
53
|
+
:force_setup => true,
|
54
|
+
}.merge(hash)
|
55
|
+
|
56
|
+
Ramaze.start(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
alias ramaze ramaze_start
|
60
|
+
|
61
|
+
# shutdown ramaze, this is not implemeted yet
|
62
|
+
# (and might never be due to limited possibilites)
|
63
|
+
|
64
|
+
def browser(*args, &block)
|
65
|
+
Browser.new(*args, &block)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
# require each of the following and rescue LoadError, telling you why it failed.
|
70
|
+
|
71
|
+
def testcase_requires(*following)
|
72
|
+
following.each do |file|
|
73
|
+
require(file.to_s)
|
74
|
+
end
|
75
|
+
rescue LoadError => ex
|
76
|
+
puts ex
|
77
|
+
puts "Can't run #{$0}: #{ex}"
|
78
|
+
puts "Usually you should not worry about this failure, just install the"
|
79
|
+
puts "library and try again (if you want to use that feature later on)"
|
80
|
+
exit
|
81
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec/helper/wrap'
|
2
|
+
|
3
|
+
class SpecLayout
|
4
|
+
attr_accessor :base, :layout, :files
|
5
|
+
|
6
|
+
def initialize(base, layout)
|
7
|
+
@base, @layout = base, layout
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
SpecWrap.new(@files).run
|
12
|
+
end
|
13
|
+
|
14
|
+
def gather
|
15
|
+
@files = gather_files(@base, @layout)
|
16
|
+
end
|
17
|
+
|
18
|
+
def gather_files(base, layout)
|
19
|
+
files = Set.new
|
20
|
+
base = File.expand_path(base)
|
21
|
+
|
22
|
+
layout.each do |key, value|
|
23
|
+
if value.is_a?(Hash)
|
24
|
+
files += gather_files(base/key, value)
|
25
|
+
else
|
26
|
+
glob = base/key/"#{value}.rb"
|
27
|
+
files += Dir[glob].map{|f| File.expand_path(f)}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
files.reject{|f| File.directory?(f)}
|
32
|
+
end
|
33
|
+
|
34
|
+
def clean
|
35
|
+
@files = clean_files(@files, @layout)
|
36
|
+
end
|
37
|
+
|
38
|
+
def clean_files(files, layout)
|
39
|
+
layout.each do |key, value|
|
40
|
+
if value.is_a?(Hash)
|
41
|
+
clean_files(files, value)
|
42
|
+
elsif files
|
43
|
+
files.dup.each do |file|
|
44
|
+
name = File.basename(file, File.extname(file))
|
45
|
+
dir = file.gsub(File.extname(file), '')
|
46
|
+
if name == key and File.directory?(dir)
|
47
|
+
files.delete(file)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
files
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'ramaze'
|
2
|
+
require 'rack/mock'
|
3
|
+
|
4
|
+
module Ramaze::Adapter
|
5
|
+
class Fake < Ramaze::Adapter::Base
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module MockHTTP
|
10
|
+
DEFAULTS = {
|
11
|
+
'REMOTE_ADDR' => '127.0.0.1'
|
12
|
+
}
|
13
|
+
|
14
|
+
MOCK_URI = URI::HTTP.build(
|
15
|
+
:host => 'localhost',
|
16
|
+
:port => 80
|
17
|
+
)
|
18
|
+
|
19
|
+
def get(path, query = {})
|
20
|
+
uri = create_url(path, query)
|
21
|
+
mock_request.get(uri, DEFAULTS)
|
22
|
+
end
|
23
|
+
|
24
|
+
def post(path, query = {})
|
25
|
+
input = query.delete(:input)
|
26
|
+
uri = create_url(path, query)
|
27
|
+
if input
|
28
|
+
mock_request.post(uri, DEFAULTS.merge(:input => input))
|
29
|
+
else
|
30
|
+
mock_request.post(uri, DEFAULTS)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def put(path, query = {})
|
35
|
+
input = query.delete(:input)
|
36
|
+
uri = create_url(path, query)
|
37
|
+
if input
|
38
|
+
mock_request.put(uri, DEFAULTS.merge(:input => input))
|
39
|
+
else
|
40
|
+
mock_request.put(uri, DEFAULTS)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def delete(path, query = {})
|
45
|
+
uri = create_url(path, query)
|
46
|
+
mock_request.delete(uri, DEFAULTS)
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_url(path, query)
|
50
|
+
uri = MOCK_URI.dup
|
51
|
+
uri.path = path
|
52
|
+
uri.query = make_query(query)
|
53
|
+
uri.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
def make_query query
|
57
|
+
return query unless query && query.class == Hash
|
58
|
+
query.inject([]) do |s, (key, value)|
|
59
|
+
s + [CGI::escape(key) + "=" + CGI::escape(value)]
|
60
|
+
end.join('&')
|
61
|
+
end
|
62
|
+
|
63
|
+
def mock_request
|
64
|
+
::Rack::MockRequest.new(Ramaze::Adapter::Fake)
|
65
|
+
end
|
66
|
+
end
|