ramaze 2011.01.30 → 2011.07.25
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/.gitignore +2 -1
- data/.mailmap +2 -0
- data/.rvmrc +1 -0
- data/README.md +119 -197
- data/Rakefile +14 -97
- data/bin/ramaze +6 -14
- data/doc/AUTHORS +8 -4
- data/doc/CHANGELOG +3784 -3339
- data/examples/app/chat/start.rb +2 -2
- data/lib/proto/app.rb +2 -3
- data/lib/proto/config.ru +4 -5
- data/lib/proto/controller/init.rb +11 -4
- data/lib/proto/controller/main.rb +12 -7
- data/lib/proto/layout/default.xhtml +56 -23
- data/lib/proto/model/init.rb +3 -1
- data/lib/proto/public/css/grid.css +107 -0
- data/lib/proto/public/css/layout.css +81 -0
- data/lib/proto/public/css/reset.css +123 -0
- data/lib/proto/public/css/text.css +109 -0
- data/lib/proto/public/images/bg.png +0 -0
- data/lib/proto/spec/main.rb +2 -2
- data/lib/proto/start.rb +11 -1
- data/lib/proto/view/index.xhtml +27 -23
- data/lib/ramaze.rb +0 -1
- data/lib/ramaze/app.rb +85 -12
- data/lib/ramaze/app_graph.rb +107 -0
- data/lib/ramaze/bin/console.rb +87 -0
- data/lib/ramaze/bin/create.rb +94 -0
- data/lib/ramaze/bin/helper.rb +107 -0
- data/lib/ramaze/bin/restart.rb +95 -0
- data/lib/ramaze/bin/runner.rb +141 -0
- data/lib/ramaze/bin/start.rb +206 -0
- data/lib/ramaze/bin/status.rb +152 -0
- data/lib/ramaze/bin/stop.rb +112 -0
- data/lib/ramaze/cache.rb +9 -4
- data/lib/ramaze/cache/localmemcache.rb +10 -13
- data/lib/ramaze/cache/lru.rb +49 -7
- data/lib/ramaze/cache/memcache.rb +170 -92
- data/lib/ramaze/cache/sequel.rb +301 -118
- data/lib/ramaze/controller.rb +108 -9
- data/lib/ramaze/controller/default.rb +15 -2
- data/lib/ramaze/current.rb +14 -2
- data/lib/ramaze/dependencies.rb +46 -0
- data/lib/ramaze/files.rb +38 -3
- data/lib/ramaze/gestalt.rb +12 -12
- data/lib/ramaze/helper.rb +0 -2
- data/lib/ramaze/helper/auth.rb +30 -23
- data/lib/ramaze/helper/blue_form.rb +175 -126
- data/lib/ramaze/helper/csrf.rb +76 -91
- data/lib/ramaze/helper/email.rb +105 -0
- data/lib/ramaze/helper/erector.rb +16 -15
- data/lib/ramaze/helper/gestalt.rb +2 -2
- data/lib/ramaze/helper/layout.rb +89 -73
- data/lib/ramaze/helper/link.rb +7 -6
- data/lib/ramaze/helper/localize.rb +6 -5
- data/lib/ramaze/helper/markaby.rb +25 -23
- data/lib/ramaze/helper/maruku.rb +3 -3
- data/lib/ramaze/helper/paginate.rb +19 -27
- data/lib/ramaze/helper/remarkably.rb +3 -3
- data/lib/ramaze/helper/request_accessor.rb +3 -3
- data/lib/ramaze/helper/send_file.rb +12 -8
- data/lib/ramaze/helper/simple_captcha.rb +5 -6
- data/lib/ramaze/helper/stack.rb +7 -4
- data/lib/ramaze/helper/tagz.rb +10 -11
- data/lib/ramaze/helper/thread.rb +19 -16
- data/lib/ramaze/helper/ultraviolet.rb +7 -4
- data/lib/ramaze/helper/user.rb +40 -21
- data/lib/ramaze/helper/xhtml.rb +29 -20
- data/lib/ramaze/log.rb +3 -11
- data/lib/ramaze/log/analogger.rb +5 -4
- data/lib/ramaze/log/growl.rb +9 -7
- data/lib/ramaze/log/hub.rb +3 -5
- data/lib/ramaze/log/informer.rb +15 -12
- data/lib/ramaze/log/knotify.rb +3 -5
- data/lib/ramaze/log/logger.rb +3 -5
- data/lib/ramaze/log/logging.rb +6 -8
- data/lib/ramaze/log/rotatinginformer.rb +27 -17
- data/lib/ramaze/log/syslog.rb +7 -7
- data/lib/ramaze/log/xosd.rb +3 -5
- data/lib/ramaze/middleware_compiler.rb +27 -4
- data/lib/ramaze/reloader.rb +50 -12
- data/lib/ramaze/reloader/watch_inotify.rb +4 -5
- data/lib/ramaze/reloader/watch_stat.rb +3 -3
- data/lib/ramaze/request.rb +18 -8
- data/lib/ramaze/response.rb +38 -7
- data/lib/ramaze/rest.rb +36 -0
- data/lib/ramaze/setup.rb +101 -31
- data/lib/ramaze/spec.rb +1 -1
- data/lib/ramaze/spec/bacon.rb +6 -3
- data/lib/ramaze/spec/helper/bacon.rb +0 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +2 -11
- data/lib/ramaze/view/erector.rb +46 -31
- data/lib/ramaze/view/erubis.rb +7 -3
- data/lib/ramaze/view/ezamar.rb +7 -3
- data/lib/ramaze/view/gestalt.rb +9 -3
- data/lib/ramaze/view/haml.rb +7 -3
- data/lib/ramaze/view/liquid.rb +3 -3
- data/lib/ramaze/view/lokar.rb +7 -3
- data/lib/ramaze/view/mustache.rb +11 -5
- data/lib/ramaze/view/nagoro.rb +3 -3
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/slippers.rb +40 -13
- data/lib/ramaze/view/tagz.rb +9 -5
- data/ramaze.gemspec +23 -128
- data/spec/helper.rb +5 -0
- data/spec/ramaze/bin/app/config.ru +11 -0
- data/spec/ramaze/bin/create.rb +28 -0
- data/spec/ramaze/bin/runner.rb +30 -0
- data/spec/ramaze/bin/start.rb +38 -0
- data/spec/ramaze/cache/memcache.rb +10 -3
- data/spec/ramaze/cache/sequel.rb +7 -0
- data/spec/ramaze/controller/provide_inheritance.rb +0 -10
- data/spec/ramaze/dispatcher/file.rb +19 -15
- data/spec/ramaze/helper/auth.rb +10 -9
- data/spec/ramaze/helper/blue_form.rb +121 -68
- data/spec/ramaze/helper/email.rb +69 -0
- data/spec/ramaze/helper/layout.rb +12 -15
- data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
- data/spec/ramaze/helper/user.rb +2 -0
- data/spec/ramaze/log/growl.rb +14 -1
- data/spec/{contrib → ramaze}/rest.rb +1 -1
- data/spec/ramaze/session/memcache.rb +2 -2
- data/spec/ramaze/view/sass.rb +1 -1
- data/tasks/bacon.rake +3 -3
- data/tasks/gem.rake +17 -18
- data/tasks/rcov.rake +2 -3
- data/tasks/release.rake +8 -65
- data/tasks/setup.rake +10 -8
- data/tasks/todo.rake +9 -5
- data/tasks/yard.rake +3 -2
- metadata +105 -397
- data/MANIFEST +0 -532
- data/TODO.md +0 -19
- data/benchmark/bench_templates/bench.rb +0 -67
- data/benchmark/bench_templates/view/large.erb +0 -79
- data/benchmark/bench_templates/view/large.haml +0 -41
- data/benchmark/bench_templates/view/large.lok +0 -79
- data/benchmark/bench_templates/view/large.xhtml +0 -79
- data/benchmark/bench_templates/view/small.erb +0 -21
- data/benchmark/bench_templates/view/small.haml +0 -12
- data/benchmark/bench_templates/view/small.lok +0 -21
- data/benchmark/bench_templates/view/small.xhtml +0 -21
- data/benchmark/results.txt +0 -131
- data/benchmark/run.rb +0 -355
- data/benchmark/suite/minimal.rb +0 -11
- data/benchmark/suite/no_informer.rb +0 -7
- data/benchmark/suite/no_sessions.rb +0 -9
- data/benchmark/suite/no_template.rb +0 -7
- data/benchmark/suite/simple.rb +0 -5
- data/benchmark/suite/template_erubis.rb +0 -8
- data/benchmark/suite/template_etanni.rb +0 -8
- data/benchmark/suite/template_ezamar.rb +0 -8
- data/benchmark/suite/template_haml.rb +0 -13
- data/benchmark/suite/template_liquid.rb +0 -11
- data/benchmark/suite/template_markaby.rb +0 -9
- data/benchmark/suite/template_nagoro.rb +0 -8
- data/benchmark/suite/template_redcloth.rb +0 -13
- data/benchmark/suite/template_tenjin.rb +0 -8
- data/benchmark/test.rb +0 -35
- data/doc/FAQ +0 -92
- data/doc/INSTALL +0 -92
- data/doc/TODO +0 -29
- data/doc/meta/announcement.txt +0 -119
- data/doc/meta/configuration.txt +0 -163
- data/doc/meta/internals.txt +0 -278
- data/doc/meta/users.kml +0 -64
- data/doc/tutorial/todolist.html +0 -1512
- data/doc/tutorial/todolist.txt +0 -920
- data/examples/app/sourceview/public/coderay.css +0 -104
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +0 -11
- data/examples/app/sourceview/public/jquery.treeview.css +0 -48
- data/examples/app/sourceview/public/jquery.treeview.js +0 -223
- data/examples/app/sourceview/public/sourceview.js +0 -52
- data/examples/app/sourceview/start.rb +0 -79
- data/examples/app/sourceview/view/index.haml +0 -59
- data/examples/helpers/httpdigest.rb +0 -107
- data/lib/proto/public/css/screen.css +0 -30
- data/lib/proto/public/js/jquery.js +0 -7179
- data/lib/ramaze/contrib/addressable_route.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/contrib/email.rb +0 -88
- data/lib/ramaze/contrib/facebook.rb +0 -23
- data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
- data/lib/ramaze/contrib/gettext.rb +0 -113
- data/lib/ramaze/contrib/gettext/mo.rb +0 -155
- data/lib/ramaze/contrib/gettext/parser.rb +0 -46
- data/lib/ramaze/contrib/gettext/po.rb +0 -109
- data/lib/ramaze/contrib/gzip_filter.rb +0 -1
- data/lib/ramaze/contrib/maruku_uv.rb +0 -59
- data/lib/ramaze/contrib/profiling.rb +0 -36
- data/lib/ramaze/contrib/rest.rb +0 -23
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
- data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
- data/lib/ramaze/contrib/sequel/image.rb +0 -196
- data/lib/ramaze/contrib/sequel/relation.rb +0 -98
- data/lib/ramaze/helper/httpdigest.rb +0 -96
- data/lib/ramaze/tool/bin.rb +0 -340
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -120
- data/lib/ramaze/view/less.rb +0 -12
- data/lib/ramaze/view/maruku.rb +0 -15
- data/lib/ramaze/view/redcloth.rb +0 -21
- data/spec/contrib/addressable_route.rb +0 -30
- data/spec/examples/helpers/httpdigest.rb +0 -64
- data/spec/examples/templates/template_redcloth.rb +0 -13
- data/spec/ramaze/bin/ramaze.rb +0 -96
- data/spec/ramaze/helper/httpdigest.rb +0 -176
- data/spec/ramaze/view/less.rb +0 -60
- data/spec/ramaze/view/less/file.css.less +0 -8
- data/spec/ramaze/view/redcloth.rb +0 -66
- data/spec/ramaze/view/redcloth/external.redcloth +0 -8
- data/tasks/copyright.rake +0 -21
- data/tasks/gem_setup.rake +0 -112
- data/tasks/git.rake +0 -46
- data/tasks/grancher.rake +0 -12
- data/tasks/jquery.rake +0 -15
- data/tasks/manifest.rake +0 -4
- data/tasks/metric_changes.rake +0 -24
- data/tasks/reversion.rake +0 -8
- data/tasks/traits.rake +0 -21
data/lib/ramaze/view/less.rb
DELETED
data/lib/ramaze/view/maruku.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
require 'maruku'
|
|
2
|
-
|
|
3
|
-
module Ramaze
|
|
4
|
-
module View
|
|
5
|
-
module Maruku
|
|
6
|
-
def self.call(action, string)
|
|
7
|
-
string = File.read(action.view) if action.view
|
|
8
|
-
maruku = View.compile(string){|s| ::Maruku.new(s) }
|
|
9
|
-
html = maruku.to_html
|
|
10
|
-
|
|
11
|
-
return html, 'text/html'
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/ramaze/view/redcloth.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
|
-
require 'redcloth'
|
|
5
|
-
|
|
6
|
-
module Ramaze
|
|
7
|
-
module View
|
|
8
|
-
module RedCloth
|
|
9
|
-
def self.call(action, string)
|
|
10
|
-
restrictions = action.variables[:redcloth_options] || []
|
|
11
|
-
rules = action.variables[:redcloth_options] || []
|
|
12
|
-
|
|
13
|
-
erubis, _ = Ramaze::View::Erubis.call(action, string)
|
|
14
|
-
redcloth = ::RedCloth.new(erubis, restrictions)
|
|
15
|
-
html = redcloth.to_html(*rules)
|
|
16
|
-
|
|
17
|
-
return html, 'text/html'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../spec/helper', __FILE__)
|
|
2
|
-
require 'ramaze/contrib/addressable_route'
|
|
3
|
-
|
|
4
|
-
class SpecAddressableRoute < Ramaze::Controller
|
|
5
|
-
map '/'
|
|
6
|
-
|
|
7
|
-
def order__show(*args)
|
|
8
|
-
[args, request.params].inspect
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe 'addressable routing' do
|
|
13
|
-
behaves_like :rack_test
|
|
14
|
-
|
|
15
|
-
Ramaze.middleware! :spec do |m|
|
|
16
|
-
m.use(Ramaze::AddressableRoute,
|
|
17
|
-
'/customer/{customer_id}/order/{order_id}' => '/order/show')
|
|
18
|
-
m.run Ramaze::AppMap
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should route based on URI template' do
|
|
22
|
-
body = eval(get('/customer/12/order/15').body)
|
|
23
|
-
body.should == [[], {'customer_id' => '12', 'order_id' => '15'}]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should not route URIs that don't match" do
|
|
27
|
-
get('/order/nothing/15')
|
|
28
|
-
last_response.status.should == 404
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
2
|
-
require File.expand_path('../../../../examples/helpers/httpdigest', __FILE__)
|
|
3
|
-
|
|
4
|
-
# Not sure if we should change the behaviour of digest_authorize, it keeps
|
|
5
|
-
# challenging the authorization even after a logout, which will log us in right
|
|
6
|
-
# away again.
|
|
7
|
-
#
|
|
8
|
-
# IMHO, digest_authorize should only be valid for the following request.
|
|
9
|
-
#
|
|
10
|
-
# So for now, we have to reset the values of @digest_username and
|
|
11
|
-
# @digest_password before we make a request.
|
|
12
|
-
|
|
13
|
-
describe Ramaze::Helper do
|
|
14
|
-
behaves_like :rack_test
|
|
15
|
-
|
|
16
|
-
it 'authorizes request for /eyes_only' do
|
|
17
|
-
digest_authorize nil, nil
|
|
18
|
-
get '/eyes_only'
|
|
19
|
-
last_response.status.should == 401
|
|
20
|
-
last_response.body.should == "Unauthorized"
|
|
21
|
-
|
|
22
|
-
digest_authorize 'foo', 'oof'
|
|
23
|
-
get '/eyes_only'
|
|
24
|
-
last_response.status.should == 200
|
|
25
|
-
last_response.body.should == "Shhhh don't tell anyone"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'authorizes request for /secret as admin' do
|
|
29
|
-
digest_authorize nil, nil
|
|
30
|
-
get '/secret'
|
|
31
|
-
last_response.status.should == 401
|
|
32
|
-
last_response.body.should == 'Unauthorized'
|
|
33
|
-
|
|
34
|
-
digest_authorize 'admin', 'secret'
|
|
35
|
-
get '/secret'
|
|
36
|
-
|
|
37
|
-
last_response.status.should == 200
|
|
38
|
-
last_response.body.should == "Hello <em>admin</em>, welcome to SECRET world."
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'authorizes request for /secret as root' do
|
|
42
|
-
digest_authorize nil, nil
|
|
43
|
-
get '/secret'
|
|
44
|
-
last_response.status.should == 401
|
|
45
|
-
last_response.body.should == 'Unauthorized'
|
|
46
|
-
|
|
47
|
-
digest_authorize 'root', 'password'
|
|
48
|
-
get '/secret'
|
|
49
|
-
last_response.status.should == 200
|
|
50
|
-
last_response.body.should == "Hello <em>root</em>, welcome to SECRET world."
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'authorizes request for /guest' do
|
|
54
|
-
digest_authorize nil, nil
|
|
55
|
-
get '/guest'
|
|
56
|
-
last_response.status.should == 401
|
|
57
|
-
last_response.body.should == 'Unauthorized'
|
|
58
|
-
|
|
59
|
-
digest_authorize 'guest', 'access'
|
|
60
|
-
get '/guest'
|
|
61
|
-
last_response.status.should == 200
|
|
62
|
-
last_response.body.should == "Hello <em>guest</em>, welcome to GUEST world."
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
-
require 'ramaze/spec/helper/template_examples'
|
|
6
|
-
|
|
7
|
-
spec_require 'redcloth'
|
|
8
|
-
require File.expand_path('../../../../examples/templates/template_redcloth', __FILE__)
|
|
9
|
-
|
|
10
|
-
describe 'Template RedCloth' do
|
|
11
|
-
behaves_like :template_spec
|
|
12
|
-
spec_template 'RedCloth'
|
|
13
|
-
end
|
data/spec/ramaze/bin/ramaze.rb
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
-
require "ramaze/tool/bin"
|
|
6
|
-
|
|
7
|
-
require "pathname"
|
|
8
|
-
|
|
9
|
-
module Ramaze
|
|
10
|
-
BINPATH = Pathname(Ramaze::ROOT).join("../bin/ramaze").expand_path
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
USAGE = <<TXT
|
|
14
|
-
|
|
15
|
-
Usage:
|
|
16
|
-
ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]
|
|
17
|
-
|
|
18
|
-
Commands:
|
|
19
|
-
|
|
20
|
-
* All commands which take an optional PIDFILE (defaults to PROJECT.pid otherwise).
|
|
21
|
-
* All commands which start a ramaze instance will default to webrick on port 7000
|
|
22
|
-
unless you supply the rack options -p/--port PORT and/or * -s/--server SERVER.
|
|
23
|
-
|
|
24
|
-
start - Starts an instance of this application.
|
|
25
|
-
|
|
26
|
-
stop - Stops a running instance of this application.
|
|
27
|
-
|
|
28
|
-
restart - Stops running instance of this application, then starts it back up. Pidfile
|
|
29
|
-
(if supplied) is used for both stop and start.
|
|
30
|
-
|
|
31
|
-
status - Gives status of a running ramaze instance
|
|
32
|
-
|
|
33
|
-
create - Creates a new prototype Ramaze application in a directory named PROJECT in
|
|
34
|
-
the current directory. ramaze create foo would make ./foo containing an
|
|
35
|
-
application prototype. Rack options are ignored here.
|
|
36
|
-
|
|
37
|
-
console - Starts an irb console with app.rb (and irb completion) loaded. This command
|
|
38
|
-
ignores rack options, ARGV is passed on to IRB.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Ruby options:
|
|
42
|
-
-e, --eval LINE evaluate a LINE of code
|
|
43
|
-
-d, --debug set debugging flags (set $DEBUG to true)
|
|
44
|
-
-w, --warn turn warnings on for your script
|
|
45
|
-
-I, --include PATH specify $LOAD_PATH (may be used more than once)
|
|
46
|
-
-r, --require LIBRARY require the library, before executing your script
|
|
47
|
-
|
|
48
|
-
Rack options:
|
|
49
|
-
-s, --server SERVER serve using SERVER (webrick/mongrel)
|
|
50
|
-
-o, --host HOST listen on HOST (default: 0.0.0.0)
|
|
51
|
-
-p, --port PORT use PORT (default: 9292)
|
|
52
|
-
-E, --env ENVIRONMENT use ENVIRONMENT for defaults (default: development)
|
|
53
|
-
-D, --daemonize run daemonized in the background
|
|
54
|
-
-P, --pid FILE file to store PID (default: rack.pid)
|
|
55
|
-
|
|
56
|
-
Common options:
|
|
57
|
-
-h, -?, --help Show this message
|
|
58
|
-
--version Show version
|
|
59
|
-
TXT
|
|
60
|
-
|
|
61
|
-
describe "bin/ramaze command" do
|
|
62
|
-
it "Can find the ramaze binary" do
|
|
63
|
-
Ramaze::BINPATH.file?.should == true
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "Shows command line help" do
|
|
67
|
-
output = `#{Ramaze::BINPATH} -h`
|
|
68
|
-
output.should == USAGE
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "Shows the correct version" do
|
|
72
|
-
output = %x{#{Ramaze::BINPATH} --version}
|
|
73
|
-
output.strip.should == Ramaze::VERSION
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "Can create a new tree from prototype" do
|
|
77
|
-
require "fileutils"
|
|
78
|
-
root = Pathname.new("/tmp/test_tree")
|
|
79
|
-
raise "#{root} already exists, please move it out of the way before running this test" if root.directory?
|
|
80
|
-
begin
|
|
81
|
-
output = %x{#{Ramaze::BINPATH} create #{root}}
|
|
82
|
-
root.directory?.should.be.true
|
|
83
|
-
root.join("config.ru").file?.should.be.true
|
|
84
|
-
root.join("start.rb").file?.should.be.true
|
|
85
|
-
root.join("controller").directory?.should.be.true
|
|
86
|
-
root.join("controller", "init.rb").file?.should.be.true
|
|
87
|
-
root.join("view").directory?.should.be.true
|
|
88
|
-
root.join("model").directory?.should.be.true
|
|
89
|
-
root.join("model", "init.rb").file?.should.be.true
|
|
90
|
-
ensure
|
|
91
|
-
FileUtils.rm_rf(root)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
-
|
|
6
|
-
REALM = 'HttpDigestTestRealm'
|
|
7
|
-
|
|
8
|
-
class MainController < Ramaze::Controller
|
|
9
|
-
map '/'
|
|
10
|
-
helper :httpdigest
|
|
11
|
-
|
|
12
|
-
def authenticate
|
|
13
|
-
user = httpdigest('protected', REALM) do |username|
|
|
14
|
-
Digest::MD5.hexdigest([username, REALM, username.reverse].join(':'))
|
|
15
|
-
end
|
|
16
|
-
"Hello #{user}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def logout
|
|
20
|
-
httpdigest_logout
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
class PlainTextController < Ramaze::Controller
|
|
26
|
-
map '/plaintext'
|
|
27
|
-
helper :httpdigest
|
|
28
|
-
|
|
29
|
-
def authenticate
|
|
30
|
-
user = httpdigest('protected', REALM)
|
|
31
|
-
"Hello #{user}"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
protected
|
|
35
|
-
|
|
36
|
-
def httpdigest_lookup_plaintext_password(username)
|
|
37
|
-
username.reverse
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
class PasswordLookupController < Ramaze::Controller
|
|
42
|
-
map '/lookup'
|
|
43
|
-
helper :httpdigest
|
|
44
|
-
|
|
45
|
-
def authenticate
|
|
46
|
-
user = httpdigest('protected', REALM)
|
|
47
|
-
"Hello #{user}"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
protected
|
|
51
|
-
|
|
52
|
-
def httpdigest_lookup_password username
|
|
53
|
-
Digest::MD5.hexdigest([username, REALM, username.reverse].join(':'))
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe Ramaze::Helper::HttpDigest do
|
|
58
|
-
describe 'headers' do
|
|
59
|
-
behaves_like :rack_test
|
|
60
|
-
|
|
61
|
-
it 'sends out all the required header information' do
|
|
62
|
-
get '/authenticate'
|
|
63
|
-
www_authenticate = last_response.headers['WWW-Authenticate']
|
|
64
|
-
authorization = Rack::Auth::Digest::Params.parse(www_authenticate)
|
|
65
|
-
|
|
66
|
-
authorization["opaque"].should.not.be.empty
|
|
67
|
-
authorization["nonce"].should.not.be.empty
|
|
68
|
-
authorization["realm"].should.equal REALM
|
|
69
|
-
authorization["qop"].should.equal "auth,auth-int"
|
|
70
|
-
|
|
71
|
-
digest_authorize 'foo', 'oof'
|
|
72
|
-
get '/authenticate'
|
|
73
|
-
|
|
74
|
-
last_response.headers.should.satisfy do |headers|
|
|
75
|
-
!headers.has_key? "WWW-Authenticate"
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe 'Digest authentication' do
|
|
81
|
-
behaves_like :rack_test
|
|
82
|
-
|
|
83
|
-
it 'authenticates a user with a block' do
|
|
84
|
-
get '/logout'
|
|
85
|
-
digest_authorize nil, nil
|
|
86
|
-
|
|
87
|
-
get '/authenticate'
|
|
88
|
-
last_response.status.should.equal 401
|
|
89
|
-
last_response.body.should.equal "Unauthorized"
|
|
90
|
-
|
|
91
|
-
digest_authorize 'foo', 'oof'
|
|
92
|
-
get '/authenticate'
|
|
93
|
-
last_response.status.should.equal 200
|
|
94
|
-
last_response.body.should.equal "Hello foo"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it 'fails to authenticate an incorrect password with a block' do
|
|
98
|
-
get '/logout'
|
|
99
|
-
digest_authorize nil, nil
|
|
100
|
-
|
|
101
|
-
get '/authenticate'
|
|
102
|
-
last_response.status.should.equal 401
|
|
103
|
-
last_response.body.should.equal "Unauthorized"
|
|
104
|
-
|
|
105
|
-
digest_authorize 'foo', 'bar'
|
|
106
|
-
get '/authenticate'
|
|
107
|
-
last_response.status.should.equal 401
|
|
108
|
-
last_response.body.should.equal "Unauthorized"
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
describe 'Plaintext authentication' do
|
|
113
|
-
behaves_like :rack_test
|
|
114
|
-
|
|
115
|
-
it 'authenticates a user with the plaintext method' do
|
|
116
|
-
get '/logout'
|
|
117
|
-
digest_authorize nil, nil
|
|
118
|
-
|
|
119
|
-
get '/plaintext/authenticate'
|
|
120
|
-
last_response.status.should.equal 401
|
|
121
|
-
last_response.body.should.equal 'Unauthorized'
|
|
122
|
-
|
|
123
|
-
digest_authorize 'foo', 'oof'
|
|
124
|
-
get '/plaintext/authenticate'
|
|
125
|
-
last_response.status.should.equal 200
|
|
126
|
-
last_response.body.should.equal "Hello foo"
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it 'fails to authenticate an incorrect password with the plaintext method' do
|
|
130
|
-
get '/logout'
|
|
131
|
-
digest_authorize nil, nil
|
|
132
|
-
|
|
133
|
-
get '/plaintext/authenticate'
|
|
134
|
-
last_response.status.should.equal 401
|
|
135
|
-
last_response.body.should.equal "Unauthorized"
|
|
136
|
-
|
|
137
|
-
digest_authorize 'foo', 'bar'
|
|
138
|
-
get '/plaintext/authenticate'
|
|
139
|
-
last_response.status.should.equal 401
|
|
140
|
-
last_response.body.should.equal "Unauthorized"
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
describe 'Password lookup authentication' do
|
|
145
|
-
behaves_like :rack_test
|
|
146
|
-
|
|
147
|
-
it 'authenticates a user with the password lookup method' do
|
|
148
|
-
get '/logout'
|
|
149
|
-
digest_authorize nil, nil
|
|
150
|
-
|
|
151
|
-
get '/lookup/authenticate'
|
|
152
|
-
last_response.status.should.equal 401
|
|
153
|
-
last_response.body.should.equal "Unauthorized"
|
|
154
|
-
|
|
155
|
-
digest_authorize 'foo', 'oof'
|
|
156
|
-
get '/lookup/authenticate'
|
|
157
|
-
last_response.status.should.equal 200
|
|
158
|
-
last_response.body.should.equal "Hello foo"
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
it 'fails to authenticate an incorrect password with the password lookup method' do
|
|
162
|
-
get '/logout'
|
|
163
|
-
digest_authorize nil, nil
|
|
164
|
-
|
|
165
|
-
get '/lookup/authenticate'
|
|
166
|
-
last_response.status.should.equal 401
|
|
167
|
-
last_response.body.should.equal "Unauthorized"
|
|
168
|
-
|
|
169
|
-
digest_authorize 'foo', 'bar'
|
|
170
|
-
get '/lookup/authenticate'
|
|
171
|
-
last_response.status.should.equal 401
|
|
172
|
-
last_response.body.should.equal "Unauthorized"
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
end
|
data/spec/ramaze/view/less.rb
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
-
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
|
-
require File.expand_path('../../../../spec/helper', __FILE__)
|
|
5
|
-
spec_require 'less'
|
|
6
|
-
|
|
7
|
-
Ramaze::App.options.views = 'less'
|
|
8
|
-
|
|
9
|
-
class SpecLess < Ramaze::Controller
|
|
10
|
-
map '/'
|
|
11
|
-
provide :css, :Less
|
|
12
|
-
|
|
13
|
-
def style
|
|
14
|
-
<<-LESS
|
|
15
|
-
@dark: #110011;
|
|
16
|
-
.outline { border: 1px solid black }
|
|
17
|
-
|
|
18
|
-
.article {
|
|
19
|
-
a { text-decoration: none }
|
|
20
|
-
p { color: @dark }
|
|
21
|
-
.outline;
|
|
22
|
-
}
|
|
23
|
-
LESS
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe Ramaze::View::Less do
|
|
28
|
-
behaves_like :rack_test
|
|
29
|
-
|
|
30
|
-
def cmp(actually, expected)
|
|
31
|
-
actually.strip.split("\n").sort.
|
|
32
|
-
should == expected.strip.split("\n").sort
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
should 'render inline' do
|
|
36
|
-
got = get('/style.css')
|
|
37
|
-
got.status.should == 200
|
|
38
|
-
got['Content-Type'].should == 'text/css'
|
|
39
|
-
|
|
40
|
-
cmp(got.body, <<-CSS)
|
|
41
|
-
.outline { border: 1px solid black; }
|
|
42
|
-
.article a { text-decoration: none; }
|
|
43
|
-
.article p { color: #110011; }
|
|
44
|
-
.article { border: 1px solid black; }
|
|
45
|
-
CSS
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
should 'render from file' do
|
|
49
|
-
got = get('/file.css')
|
|
50
|
-
got.status.should == 200
|
|
51
|
-
got['Content-Type'].should == 'text/css'
|
|
52
|
-
|
|
53
|
-
cmp(got.body, <<-CSS)
|
|
54
|
-
.outline { border: 1px solid black; }
|
|
55
|
-
.article a { text-decoration: none; }
|
|
56
|
-
.article p { color: #110011; }
|
|
57
|
-
.article { border: 1px solid black; }
|
|
58
|
-
CSS
|
|
59
|
-
end
|
|
60
|
-
end
|