ramaze 2011.07.25 → 2011.10.23
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.mailmap +3 -2
- data/.travis.yml +17 -0
- data/.yardopts +13 -0
- data/README.md +95 -352
- data/examples/app/blog/app.rb +25 -64
- data/examples/app/blog/config.ru +11 -9
- data/examples/app/blog/controller/init.rb +29 -86
- data/examples/app/blog/controller/posts.rb +232 -0
- data/examples/app/blog/controller/users.rb +160 -0
- data/examples/app/blog/layout/default.xhtml +61 -0
- data/examples/app/blog/migrations/01_create_schema.rb +50 -0
- data/examples/app/blog/model/comment.rb +41 -54
- data/examples/app/blog/model/init.rb +41 -13
- data/examples/app/blog/model/post.rb +35 -0
- data/examples/app/blog/model/user.rb +105 -0
- data/examples/app/blog/public/.htaccess +24 -0
- data/examples/app/blog/public/css/grid.css +107 -0
- data/examples/app/blog/public/css/layout.css +203 -0
- data/examples/app/blog/public/css/reset.css +123 -0
- data/examples/app/blog/public/css/text.css +109 -0
- data/examples/app/blog/public/dispatch.fcgi +11 -0
- data/examples/app/blog/public/favicon.ico +0 -0
- data/examples/app/blog/public/images/bg.png +0 -0
- data/examples/app/blog/start.rb +18 -3
- data/examples/app/blog/view/feed.xhtml +23 -0
- data/examples/app/blog/view/form.xhtml +11 -0
- data/examples/app/blog/view/index.xhtml +44 -0
- data/examples/app/blog/view/users/form.xhtml +12 -0
- data/examples/app/blog/view/users/index.xhtml +30 -0
- data/examples/app/blog/view/users/login.xhtml +8 -0
- data/examples/app/blog/view/view.xhtml +68 -0
- data/{doc → guide}/AUTHORS +5 -3
- data/{doc → guide}/CHANGELOG +428 -0
- data/{doc/GPL → guide/GPL_LICENSE} +0 -0
- data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
- data/guide/_static/logo.png +0 -0
- data/guide/_static/logo.svg +49 -0
- data/guide/_static/ramaze_console.png +0 -0
- data/guide/css/common.css +20 -0
- data/guide/general/cache.md +167 -0
- data/guide/general/configuration.md +168 -0
- data/guide/general/contributing.md +108 -0
- data/guide/general/controllers.md +115 -0
- data/guide/general/helpers.md +76 -0
- data/guide/general/installation.md +58 -0
- data/guide/general/logging.md +99 -0
- data/guide/general/middlewares.md +100 -0
- data/guide/general/models.md +78 -0
- data/guide/general/principles.md +53 -0
- data/guide/general/ramaze_command.md +155 -0
- data/guide/general/routes.md +81 -0
- data/guide/general/sessions.md +140 -0
- data/guide/general/special_thanks.md +67 -0
- data/guide/general/testing.md +61 -0
- data/guide/general/views.md +322 -0
- data/guide/tutorials/introduction.md +259 -0
- data/lib/proto/config.ru +1 -1
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/view/index.xhtml +7 -7
- data/lib/ramaze.rb +4 -4
- data/lib/ramaze/app.rb +11 -11
- data/lib/ramaze/app_graph.rb +2 -4
- data/lib/ramaze/bin/console.rb +3 -3
- data/lib/ramaze/bin/create.rb +2 -2
- data/lib/ramaze/bin/restart.rb +4 -4
- data/lib/ramaze/bin/runner.rb +5 -5
- data/lib/ramaze/bin/start.rb +19 -4
- data/lib/ramaze/bin/status.rb +3 -3
- data/lib/ramaze/bin/stop.rb +3 -3
- data/lib/ramaze/cache.rb +1 -0
- data/lib/ramaze/cache/lru.rb +8 -4
- data/lib/ramaze/cache/memcache.rb +32 -13
- data/lib/ramaze/cache/redis.rb +164 -0
- data/lib/ramaze/cache/sequel.rb +43 -28
- data/lib/ramaze/controller.rb +1 -2
- data/lib/ramaze/dependencies.rb +40 -3
- data/lib/ramaze/helper/bench.rb +26 -16
- data/lib/ramaze/helper/blue_form.rb +46 -73
- data/lib/ramaze/helper/cache.rb +10 -6
- data/lib/ramaze/helper/csrf.rb +35 -39
- data/lib/ramaze/helper/disqus.rb +5 -4
- data/lib/ramaze/helper/email.rb +35 -24
- data/lib/ramaze/helper/erector.rb +9 -13
- data/lib/ramaze/helper/flash.rb +7 -9
- data/lib/ramaze/helper/formatting.rb +194 -179
- data/lib/ramaze/helper/gravatar.rb +4 -8
- data/lib/ramaze/helper/identity.rb +3 -3
- data/lib/ramaze/helper/layout.rb +23 -8
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/paginate.rb +46 -39
- data/lib/ramaze/helper/request_accessor.rb +3 -1
- data/lib/ramaze/helper/simple_captcha.rb +18 -17
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/helper/tagz.rb +4 -2
- data/lib/ramaze/helper/upload.rb +523 -0
- data/lib/ramaze/helper/user.rb +4 -8
- data/lib/ramaze/helper/xhtml.rb +11 -15
- data/lib/ramaze/log.rb +9 -6
- data/lib/ramaze/log/rotatinginformer.rb +62 -27
- data/lib/ramaze/log/syslog.rb +20 -15
- data/lib/ramaze/log/xosd.rb +2 -1
- data/lib/ramaze/reloader.rb +2 -0
- data/lib/ramaze/request.rb +11 -10
- data/lib/ramaze/setup.rb +23 -6
- data/lib/ramaze/snippets/array/put_within.rb +3 -9
- data/lib/ramaze/snippets/binding/locals.rb +5 -10
- data/lib/ramaze/snippets/fiber.rb +1 -23
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
- data/lib/ramaze/snippets/numeric/time.rb +3 -7
- data/lib/ramaze/snippets/object/__dir__.rb +3 -7
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
- data/lib/ramaze/snippets/object/pretty.rb +3 -7
- data/lib/ramaze/snippets/object/scope.rb +7 -9
- data/lib/ramaze/snippets/proc/locals.rb +12 -12
- data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
- data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
- data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
- data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
- data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
- data/lib/ramaze/snippets/string/camel_case.rb +8 -10
- data/lib/ramaze/snippets/string/color.rb +3 -4
- data/lib/ramaze/snippets/string/end_with.rb +3 -6
- data/lib/ramaze/snippets/string/esc.rb +3 -8
- data/lib/ramaze/snippets/string/ord.rb +3 -8
- data/lib/ramaze/snippets/string/snake_case.rb +6 -9
- data/lib/ramaze/snippets/string/start_with.rb +3 -8
- data/lib/ramaze/snippets/string/unindent.rb +3 -6
- data/lib/ramaze/snippets/thread/into.rb +1 -3
- data/lib/ramaze/spec.rb +2 -31
- data/lib/ramaze/spec/bacon.rb +18 -2
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +1 -1
- data/ramaze.gemspec +1 -1
- data/spec/helper.rb +2 -1
- data/spec/ramaze/bin/start.rb +16 -20
- data/spec/ramaze/cache/localmemcache.rb +4 -7
- data/spec/ramaze/cache/memcache.rb +3 -1
- data/spec/ramaze/cache/redis.rb +62 -0
- data/spec/ramaze/helper/blue_form.rb +33 -4
- data/spec/ramaze/helper/layout.rb +40 -7
- data/spec/ramaze/helper/upload.rb +149 -0
- data/spec/ramaze/helper/uploads/text_1.txt +1 -0
- data/spec/ramaze/helper/uploads/text_2.txt +1 -0
- data/spec/ramaze/log/growl.rb +4 -6
- data/spec/ramaze/log/syslog.rb +6 -0
- data/spec/ramaze/view/lokar.rb +5 -0
- data/spec/ramaze/view/nagoro.rb +5 -0
- data/tasks/authors.rake +1 -1
- data/tasks/bacon.rake +14 -5
- data/tasks/changelog.rake +1 -1
- data/tasks/yard.rake +12 -4
- metadata +277 -239
- data/doc/LEGAL +0 -26
- data/examples/app/blog/README +0 -3
- data/examples/app/blog/controller/comment.rb +0 -45
- data/examples/app/blog/controller/entry.rb +0 -85
- data/examples/app/blog/controller/main.rb +0 -20
- data/examples/app/blog/controller/tag.rb +0 -9
- data/examples/app/blog/layout/default.nag +0 -31
- data/examples/app/blog/model/entry.rb +0 -89
- data/examples/app/blog/model/tag.rb +0 -36
- data/examples/app/blog/public/css/screen.css +0 -273
- data/examples/app/blog/spec/blog.rb +0 -87
- data/examples/app/blog/view/comment/form.nag +0 -10
- data/examples/app/blog/view/comment/show.nag +0 -16
- data/examples/app/blog/view/entry/edit.nag +0 -14
- data/examples/app/blog/view/entry/feed.atom.nag +0 -8
- data/examples/app/blog/view/entry/feed.rss.nag +0 -7
- data/examples/app/blog/view/entry/index.nag +0 -7
- data/examples/app/blog/view/entry/new.nag +0 -13
- data/examples/app/blog/view/entry/show.nag +0 -36
- data/examples/app/blog/view/feed.atom.nag +0 -18
- data/examples/app/blog/view/feed.rss.nag +0 -25
- data/examples/app/blog/view/index.nag +0 -6
- data/examples/app/blog/view/tag/index.nag +0 -5
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/ramaze/rest.rb +0 -36
- data/spec/ramaze/rest.rb +0 -28
- data/tasks/rcov.rake +0 -22
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'ramaze'
|
2
|
-
require 'ramaze/spec/helper'
|
3
|
-
|
4
|
-
spec_require 'hpricot', 'sequel'
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift base = __DIR__('..')
|
7
|
-
require 'start'
|
8
|
-
|
9
|
-
describe 'Blog' do
|
10
|
-
behaves_like 'http'
|
11
|
-
ramaze :public_root => base/:public,
|
12
|
-
:view_root => base/:view
|
13
|
-
|
14
|
-
after do
|
15
|
-
Entry.each{|e| e.delete unless e.id == 1 }
|
16
|
-
end
|
17
|
-
|
18
|
-
def check_page(name = '')
|
19
|
-
page = get("/#{name}")
|
20
|
-
page.status.should == 200
|
21
|
-
page.body.should.not == nil
|
22
|
-
|
23
|
-
doc = Hpricot(page.body)
|
24
|
-
doc.at('title').inner_html.should == 'Blog'
|
25
|
-
doc.at('h1').inner_html.should == 'Blog'
|
26
|
-
|
27
|
-
doc.search('div#entries').size.should == 1
|
28
|
-
|
29
|
-
doc
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_page(title,content)
|
33
|
-
page = post('/create','title'=>title,'content'=>content)
|
34
|
-
page.status.should == 302
|
35
|
-
page.location.should == '/'
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should have main page' do
|
39
|
-
doc = check_page
|
40
|
-
doc.at('div#actions>a').inner_html.should == 'new entry'
|
41
|
-
doc.search('div.entry').size.should == 1
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should have new entry page' do
|
45
|
-
doc = check_page('new')
|
46
|
-
form = doc.at('div.entry>form')
|
47
|
-
form.at('input[@name=title]')['value'].should == ''
|
48
|
-
form.at('textarea').inner_html.should == ''
|
49
|
-
form.at('input[@type=submit]')['value'].should == 'Add Entry'
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should add new pages' do
|
53
|
-
create_page('new page', 'cool! a new page')
|
54
|
-
doc = check_page
|
55
|
-
entry = doc.search('div.entry')
|
56
|
-
entry.size.should == 2
|
57
|
-
entry = entry.last
|
58
|
-
|
59
|
-
entry.at('div.title').inner_html == 'new page'
|
60
|
-
entry.at('div.content').inner_html == 'cool! a new page'
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should edit existing pages' do
|
64
|
-
create_page('new page', 'cool! a new page')
|
65
|
-
post('/save','id'=>'2','title'=>'new title','content'=>'bla bla')
|
66
|
-
doc = check_page
|
67
|
-
entries = doc/'div.entry'
|
68
|
-
entries.size.should == 2
|
69
|
-
entry = entries.first
|
70
|
-
|
71
|
-
entry.at('div.title').inner_html == 'new title'
|
72
|
-
entry.at('div.content').inner_html == 'bla bla'
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should delete existing pages' do
|
76
|
-
create_page("page to delete", 'content')
|
77
|
-
entries = check_page/'div.entry'
|
78
|
-
entries.size.should == 2
|
79
|
-
delete_link = entries.last.at("a:contains('delete')")
|
80
|
-
page = get(delete_link[:href])
|
81
|
-
page.status.should == 302
|
82
|
-
page.location.should == '/'
|
83
|
-
(check_page/'div.entry').size.should == 1
|
84
|
-
end
|
85
|
-
|
86
|
-
FileUtils.rm_f(__DIR__('../blog.db'))
|
87
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<form id="respond" method="post" action="#{r(:create)}">
|
2
|
-
#{form_hidden :entry_id, @entry.id}
|
3
|
-
<table>
|
4
|
-
#{form_text 'Name', :author, @comment.author}
|
5
|
-
#{form_text 'Homepage', :homepage, @comment.homepage}
|
6
|
-
#{form_text 'E-mail', :email, @comment.email}
|
7
|
-
#{form_textarea 'Comment', :content, @comment.content}
|
8
|
-
#{form_submit 'Send comment'}
|
9
|
-
</table>
|
10
|
-
</form>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<div class="comment" id="comment-#@id">
|
2
|
-
<div class="comment-info">
|
3
|
-
<div class="gravatar"><img src="#@gravatar" /></div>
|
4
|
-
<div class="about">
|
5
|
-
<a href="#@homepage" rel="nofollow" class="author">#@author</a> says:<br />
|
6
|
-
<a href="#@href"><span class="published">#@pub_formatted</span></a>
|
7
|
-
</div>
|
8
|
-
</div>
|
9
|
-
<div class="comment-content">#{h @comment.content}</div>
|
10
|
-
<?r if logged_in? ?>
|
11
|
-
<div class="actions">
|
12
|
-
#{a 'Edit', Blog::Comments.r(:edit, @comment.id)}
|
13
|
-
#{a 'Delete', Blog::Comments.r(:delete, @comment.id)}
|
14
|
-
</div>
|
15
|
-
<?r end ?>
|
16
|
-
</div>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<div class="entry-form">
|
2
|
-
<form method="post" action="#{Blog::Entries.r(:save)}">
|
3
|
-
#{form_hidden :id, @entry.id}
|
4
|
-
<fieldset>
|
5
|
-
<legend>Edit Entry</legend>
|
6
|
-
<table>
|
7
|
-
#{form_text 'Title', :title, @entry.title}
|
8
|
-
#{form_textarea 'Content', :content, @entry.content}
|
9
|
-
#{form_text 'Tags, space separated', :tags, @tags}
|
10
|
-
#{form_submit 'Update Entry'}
|
11
|
-
</table>
|
12
|
-
</fieldset>
|
13
|
-
</form>
|
14
|
-
</div>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<entry>
|
2
|
-
<title>#{ h @entry.title }</title>
|
3
|
-
<link href='#{ request.domain @entry.href }' />
|
4
|
-
<id>#{ "#{ Blog.options.uuid }#{ @entry.href }" }</id>
|
5
|
-
<updated>#{ @entry.updated.iso8601 }</updated>
|
6
|
-
<summary>#{ @entry.summary }</summary>
|
7
|
-
<content type="html">#{ h(Maruku.new(@entry.content).to_html) }</content>
|
8
|
-
</entry>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<item>
|
2
|
-
<title>#{ h @entry.title }</title>
|
3
|
-
<guid>#{ @entry.href }</guid>
|
4
|
-
<description>#{ h @entry.to_html }</description>
|
5
|
-
<pubDate>#{ @entry.published.iso8601 }</pubDate>
|
6
|
-
<author>#{Blog.options.author.name}, (#{ Blog.options.author.email })</author>
|
7
|
-
</item>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
#{ Blog::Entries.render_partial(:show, :entry => @entry) }
|
2
|
-
<div id="comments" class="comments">
|
3
|
-
<?r @entry.comments.each do |comment| ?>
|
4
|
-
#{ Blog::Comments.render_partial(:show, :comment => comment) }
|
5
|
-
<?r end ?>
|
6
|
-
#{ Blog::Comments.render_partial(:form, :entry => @entry) }
|
7
|
-
</div>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<div class="entry-form">
|
2
|
-
<form method="post" action="#{Blog::Entries.r(:create)}">
|
3
|
-
<fieldset>
|
4
|
-
<legend>New Entry</legend>
|
5
|
-
<table>
|
6
|
-
#{form_text 'Title', :title, @entry.title}
|
7
|
-
#{form_textarea 'Content', :content, @entry.content}
|
8
|
-
#{form_text 'Tags, space separated', :tags, @tags}
|
9
|
-
#{form_submit 'Create Entry'}
|
10
|
-
</table>
|
11
|
-
</fieldset>
|
12
|
-
</form>
|
13
|
-
</div>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<div id="entry-#@id" class="entry hentry">
|
2
|
-
<h2 class="title entry-title">
|
3
|
-
<a href="#@href" rel="bookmark" title="#@title">#@title</a>
|
4
|
-
</h2>
|
5
|
-
|
6
|
-
<div class="entry-content">
|
7
|
-
#{@entry.to_html}
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<div class="entry-info">
|
11
|
-
<ul class="tags">
|
12
|
-
<li>Tags:</li>
|
13
|
-
<?r @entry.tags.sort.each do |tag| ?>
|
14
|
-
<li><a href="#{Blog::Tags.r(tag)}" rel="tag">#{h tag}</a></li>
|
15
|
-
<?r end ?>
|
16
|
-
</ul>
|
17
|
-
|
18
|
-
<div class="count">
|
19
|
-
<a href="#{@comment_href}">#@comment_count</a>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<div class="about">
|
23
|
-
This entry was was posted on
|
24
|
-
<abbr class="published" title="#@pub_iso">#@pub_formatted</abbr>.
|
25
|
-
You can leave a #{a 'response', @respond_href},
|
26
|
-
or #{a 'trackback', @trackback_href} from your own site.
|
27
|
-
</div>
|
28
|
-
|
29
|
-
<?r if logged_in? ?>
|
30
|
-
<div class="actions">
|
31
|
-
#{a 'Edit', Blog::Entries.r(:edit, @entry.slug)}
|
32
|
-
#{a 'Delete', Blog::Entries.r(:delete, @entry.slug)}
|
33
|
-
</div>
|
34
|
-
<?r end ?>
|
35
|
-
</div>
|
36
|
-
</div>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<?xml version='1.0' encoding='utf-8' ?>
|
2
|
-
<feed xmlns='http://www.w3.org/2005/Atom'>
|
3
|
-
<title>#{ h Blog.options.title }</title>
|
4
|
-
<subtitle>#{ h Blog.options.subtitle }</subtitle>
|
5
|
-
<link rel='self' href='#{ request.domain Blog::Main.r("feed.atom") }' />
|
6
|
-
<link href='#{ request.domain Blog::Main.r("/") }' />
|
7
|
-
<author>
|
8
|
-
<name>#{ h Blog.options.author.name }</name>
|
9
|
-
<email>#{ h Blog.options.author.email }</email>
|
10
|
-
<uri>#{ author_url }</uri>
|
11
|
-
</author>
|
12
|
-
<updated>#{ @updated.iso8601 }</updated>
|
13
|
-
<id>#{ "#{ Blog.options.uuid }/atom" }</id>
|
14
|
-
<generator uri='#{ @generator_uri }'>#{ @generator }</generator>
|
15
|
-
<?r @entries.each do |entry| ?>
|
16
|
-
#{ Blog::Entries.render_partial('feed.atom', :entry => entry) }
|
17
|
-
<?end ?>
|
18
|
-
</feed>
|
@@ -1,25 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
-
<rss version="2.0" "xmlns:dc"="http://purl.org/dc/elements/1.1">
|
3
|
-
<channel>
|
4
|
-
<?r
|
5
|
-
year_range = [2009, Date.today.year].uniq.join('-')
|
6
|
-
author = "#{ Blog.options.author.name }, (#{ Blog.options.author.email })"
|
7
|
-
?>
|
8
|
-
<title>#{ Blog.options.title }</title>
|
9
|
-
<link>#{ request.domain Blog::Main.r("/") }</link>
|
10
|
-
<description>#{ Blog.options.subtitle }</description>
|
11
|
-
<copyright>
|
12
|
-
Copyright © #{year_range} by #{author}
|
13
|
-
Verbatim copying is permitted as long as this message is preserved.
|
14
|
-
</copyright>
|
15
|
-
<managingEditor>#{ author }</managingEditor>
|
16
|
-
<webMaster>#{ author }</webMaster>
|
17
|
-
<pubDate>#{ @updated.iso8601 }</pubDate>
|
18
|
-
<generator>#{ @generator }</generator>
|
19
|
-
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
|
20
|
-
<ttl>240</ttl>
|
21
|
-
<?r @entries.each do |entry| ?>
|
22
|
-
#{ Blog::Entries.render_partial('feed.rss', :entry => entry) }
|
23
|
-
<?r end ?>
|
24
|
-
</channel>
|
25
|
-
</rss>
|
data/lib/proto/public/ramaze.png
DELETED
Binary file
|
data/lib/ramaze/rest.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# The code in this file adds an extra option and a route to Ramaze that allows
|
3
|
-
# REST like HTTP requests. For example, when this file is loaded a GET request
|
4
|
-
# to a controller will be mapped to the "show" method while a POST request will
|
5
|
-
# be mapped to "create". In order to use this extension you have to load it
|
6
|
-
# manually:
|
7
|
-
#
|
8
|
-
# require 'ramaze/rest'
|
9
|
-
#
|
10
|
-
# From this point on you can customize the route as following:
|
11
|
-
#
|
12
|
-
# Ramaze.options.rest_rewrite['GET'] = 'another_method'
|
13
|
-
#
|
14
|
-
module Ramaze
|
15
|
-
# Don't use one option per method, we don't want to turn request_method into a
|
16
|
-
# symbol, together with MethodOverride this could lead to a memory leak.
|
17
|
-
options.o(
|
18
|
-
'REST rewrite mapping',
|
19
|
-
:rest_rewrite,
|
20
|
-
{
|
21
|
-
'GET' => 'show',
|
22
|
-
'POST' => 'create',
|
23
|
-
'PUT' => 'update',
|
24
|
-
'DELETE' => 'destroy'
|
25
|
-
}
|
26
|
-
)
|
27
|
-
|
28
|
-
# Re-write the URLs according to the settings set above
|
29
|
-
Rewrite['REST dispatch'] = lambda do |path, request|
|
30
|
-
if suffix = Ramaze.options[:rest_rewrite][request.request_method]
|
31
|
-
"#{path}/#{suffix}".squeeze('/')
|
32
|
-
else
|
33
|
-
path
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end # Ramaze
|
data/spec/ramaze/rest.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../spec/helper', __FILE__)
|
2
|
-
require 'ramaze/rest'
|
3
|
-
|
4
|
-
class Posts < Ramaze::Controller
|
5
|
-
map '/'
|
6
|
-
|
7
|
-
def show; 'Showing' end
|
8
|
-
def create; 'Creating' end
|
9
|
-
def update; 'Updating' end
|
10
|
-
def destroy; 'Destroying' end
|
11
|
-
|
12
|
-
def show_other; 'Showing other' end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'Contrib REST rewrite' do
|
16
|
-
behaves_like :rack_test
|
17
|
-
|
18
|
-
it('rewrites GET to show'){ get('/').body.should == 'Showing' }
|
19
|
-
it('rewrites POST to create'){ post('/').body.should == 'Creating' }
|
20
|
-
it('rewrites PUT to update'){ put('/').body.should == 'Updating' }
|
21
|
-
it('rewrites DELETE to destroy'){ delete('/').body.should == 'Destroying' }
|
22
|
-
|
23
|
-
it 'is configurable' do
|
24
|
-
Ramaze.options.rest_rewrite['GET'] = 'show_other'
|
25
|
-
|
26
|
-
get('/').body.should == 'Showing other'
|
27
|
-
end
|
28
|
-
end
|
data/tasks/rcov.rake
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
desc 'code coverage'
|
2
|
-
task :rcov do
|
3
|
-
specs = PROJECT_SPECS
|
4
|
-
ignore = %w[ gem rack bacon innate hpricot nagoro/lib/nagoro ]
|
5
|
-
|
6
|
-
if RUBY_VERSION >= '1.8.7'
|
7
|
-
ignore << 'begin_with' << 'end_with'
|
8
|
-
end
|
9
|
-
if RUBY_VERSION < '1.9'
|
10
|
-
ignore << 'fiber'
|
11
|
-
end
|
12
|
-
|
13
|
-
ignored = ignore.join(',')
|
14
|
-
|
15
|
-
cmd = "rcov --aggregate coverage.data --sort coverage -t --%s -x '#{ignored}' %s"
|
16
|
-
|
17
|
-
while spec = specs.shift
|
18
|
-
puts '', "Gather coverage for #{spec} ..."
|
19
|
-
html = specs.empty? ? 'html' : 'no-html'
|
20
|
-
sh(cmd % [html, spec])
|
21
|
-
end
|
22
|
-
end
|