ramaze 2011.07.25 → 2011.10.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.gitignore +3 -0
  2. data/.mailmap +3 -2
  3. data/.travis.yml +17 -0
  4. data/.yardopts +13 -0
  5. data/README.md +95 -352
  6. data/examples/app/blog/app.rb +25 -64
  7. data/examples/app/blog/config.ru +11 -9
  8. data/examples/app/blog/controller/init.rb +29 -86
  9. data/examples/app/blog/controller/posts.rb +232 -0
  10. data/examples/app/blog/controller/users.rb +160 -0
  11. data/examples/app/blog/layout/default.xhtml +61 -0
  12. data/examples/app/blog/migrations/01_create_schema.rb +50 -0
  13. data/examples/app/blog/model/comment.rb +41 -54
  14. data/examples/app/blog/model/init.rb +41 -13
  15. data/examples/app/blog/model/post.rb +35 -0
  16. data/examples/app/blog/model/user.rb +105 -0
  17. data/examples/app/blog/public/.htaccess +24 -0
  18. data/examples/app/blog/public/css/grid.css +107 -0
  19. data/examples/app/blog/public/css/layout.css +203 -0
  20. data/examples/app/blog/public/css/reset.css +123 -0
  21. data/examples/app/blog/public/css/text.css +109 -0
  22. data/examples/app/blog/public/dispatch.fcgi +11 -0
  23. data/examples/app/blog/public/favicon.ico +0 -0
  24. data/examples/app/blog/public/images/bg.png +0 -0
  25. data/examples/app/blog/start.rb +18 -3
  26. data/examples/app/blog/view/feed.xhtml +23 -0
  27. data/examples/app/blog/view/form.xhtml +11 -0
  28. data/examples/app/blog/view/index.xhtml +44 -0
  29. data/examples/app/blog/view/users/form.xhtml +12 -0
  30. data/examples/app/blog/view/users/index.xhtml +30 -0
  31. data/examples/app/blog/view/users/login.xhtml +8 -0
  32. data/examples/app/blog/view/view.xhtml +68 -0
  33. data/{doc → guide}/AUTHORS +5 -3
  34. data/{doc → guide}/CHANGELOG +428 -0
  35. data/{doc/GPL → guide/GPL_LICENSE} +0 -0
  36. data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
  37. data/guide/_static/logo.png +0 -0
  38. data/guide/_static/logo.svg +49 -0
  39. data/guide/_static/ramaze_console.png +0 -0
  40. data/guide/css/common.css +20 -0
  41. data/guide/general/cache.md +167 -0
  42. data/guide/general/configuration.md +168 -0
  43. data/guide/general/contributing.md +108 -0
  44. data/guide/general/controllers.md +115 -0
  45. data/guide/general/helpers.md +76 -0
  46. data/guide/general/installation.md +58 -0
  47. data/guide/general/logging.md +99 -0
  48. data/guide/general/middlewares.md +100 -0
  49. data/guide/general/models.md +78 -0
  50. data/guide/general/principles.md +53 -0
  51. data/guide/general/ramaze_command.md +155 -0
  52. data/guide/general/routes.md +81 -0
  53. data/guide/general/sessions.md +140 -0
  54. data/guide/general/special_thanks.md +67 -0
  55. data/guide/general/testing.md +61 -0
  56. data/guide/general/views.md +322 -0
  57. data/guide/tutorials/introduction.md +259 -0
  58. data/lib/proto/config.ru +1 -1
  59. data/lib/proto/public/favicon.ico +0 -0
  60. data/lib/proto/view/index.xhtml +7 -7
  61. data/lib/ramaze.rb +4 -4
  62. data/lib/ramaze/app.rb +11 -11
  63. data/lib/ramaze/app_graph.rb +2 -4
  64. data/lib/ramaze/bin/console.rb +3 -3
  65. data/lib/ramaze/bin/create.rb +2 -2
  66. data/lib/ramaze/bin/restart.rb +4 -4
  67. data/lib/ramaze/bin/runner.rb +5 -5
  68. data/lib/ramaze/bin/start.rb +19 -4
  69. data/lib/ramaze/bin/status.rb +3 -3
  70. data/lib/ramaze/bin/stop.rb +3 -3
  71. data/lib/ramaze/cache.rb +1 -0
  72. data/lib/ramaze/cache/lru.rb +8 -4
  73. data/lib/ramaze/cache/memcache.rb +32 -13
  74. data/lib/ramaze/cache/redis.rb +164 -0
  75. data/lib/ramaze/cache/sequel.rb +43 -28
  76. data/lib/ramaze/controller.rb +1 -2
  77. data/lib/ramaze/dependencies.rb +40 -3
  78. data/lib/ramaze/helper/bench.rb +26 -16
  79. data/lib/ramaze/helper/blue_form.rb +46 -73
  80. data/lib/ramaze/helper/cache.rb +10 -6
  81. data/lib/ramaze/helper/csrf.rb +35 -39
  82. data/lib/ramaze/helper/disqus.rb +5 -4
  83. data/lib/ramaze/helper/email.rb +35 -24
  84. data/lib/ramaze/helper/erector.rb +9 -13
  85. data/lib/ramaze/helper/flash.rb +7 -9
  86. data/lib/ramaze/helper/formatting.rb +194 -179
  87. data/lib/ramaze/helper/gravatar.rb +4 -8
  88. data/lib/ramaze/helper/identity.rb +3 -3
  89. data/lib/ramaze/helper/layout.rb +23 -8
  90. data/lib/ramaze/helper/markaby.rb +1 -1
  91. data/lib/ramaze/helper/paginate.rb +46 -39
  92. data/lib/ramaze/helper/request_accessor.rb +3 -1
  93. data/lib/ramaze/helper/simple_captcha.rb +18 -17
  94. data/lib/ramaze/helper/stack.rb +1 -1
  95. data/lib/ramaze/helper/tagz.rb +4 -2
  96. data/lib/ramaze/helper/upload.rb +523 -0
  97. data/lib/ramaze/helper/user.rb +4 -8
  98. data/lib/ramaze/helper/xhtml.rb +11 -15
  99. data/lib/ramaze/log.rb +9 -6
  100. data/lib/ramaze/log/rotatinginformer.rb +62 -27
  101. data/lib/ramaze/log/syslog.rb +20 -15
  102. data/lib/ramaze/log/xosd.rb +2 -1
  103. data/lib/ramaze/reloader.rb +2 -0
  104. data/lib/ramaze/request.rb +11 -10
  105. data/lib/ramaze/setup.rb +23 -6
  106. data/lib/ramaze/snippets/array/put_within.rb +3 -9
  107. data/lib/ramaze/snippets/binding/locals.rb +5 -10
  108. data/lib/ramaze/snippets/fiber.rb +1 -23
  109. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
  110. data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
  111. data/lib/ramaze/snippets/numeric/time.rb +3 -7
  112. data/lib/ramaze/snippets/object/__dir__.rb +3 -7
  113. data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
  114. data/lib/ramaze/snippets/object/pretty.rb +3 -7
  115. data/lib/ramaze/snippets/object/scope.rb +7 -9
  116. data/lib/ramaze/snippets/proc/locals.rb +12 -12
  117. data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
  118. data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
  119. data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
  120. data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
  121. data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
  122. data/lib/ramaze/snippets/string/camel_case.rb +8 -10
  123. data/lib/ramaze/snippets/string/color.rb +3 -4
  124. data/lib/ramaze/snippets/string/end_with.rb +3 -6
  125. data/lib/ramaze/snippets/string/esc.rb +3 -8
  126. data/lib/ramaze/snippets/string/ord.rb +3 -8
  127. data/lib/ramaze/snippets/string/snake_case.rb +6 -9
  128. data/lib/ramaze/snippets/string/start_with.rb +3 -8
  129. data/lib/ramaze/snippets/string/unindent.rb +3 -6
  130. data/lib/ramaze/snippets/thread/into.rb +1 -3
  131. data/lib/ramaze/spec.rb +2 -31
  132. data/lib/ramaze/spec/bacon.rb +18 -2
  133. data/lib/ramaze/version.rb +1 -1
  134. data/lib/ramaze/view.rb +1 -1
  135. data/ramaze.gemspec +1 -1
  136. data/spec/helper.rb +2 -1
  137. data/spec/ramaze/bin/start.rb +16 -20
  138. data/spec/ramaze/cache/localmemcache.rb +4 -7
  139. data/spec/ramaze/cache/memcache.rb +3 -1
  140. data/spec/ramaze/cache/redis.rb +62 -0
  141. data/spec/ramaze/helper/blue_form.rb +33 -4
  142. data/spec/ramaze/helper/layout.rb +40 -7
  143. data/spec/ramaze/helper/upload.rb +149 -0
  144. data/spec/ramaze/helper/uploads/text_1.txt +1 -0
  145. data/spec/ramaze/helper/uploads/text_2.txt +1 -0
  146. data/spec/ramaze/log/growl.rb +4 -6
  147. data/spec/ramaze/log/syslog.rb +6 -0
  148. data/spec/ramaze/view/lokar.rb +5 -0
  149. data/spec/ramaze/view/nagoro.rb +5 -0
  150. data/tasks/authors.rake +1 -1
  151. data/tasks/bacon.rake +14 -5
  152. data/tasks/changelog.rake +1 -1
  153. data/tasks/yard.rake +12 -4
  154. metadata +277 -239
  155. data/doc/LEGAL +0 -26
  156. data/examples/app/blog/README +0 -3
  157. data/examples/app/blog/controller/comment.rb +0 -45
  158. data/examples/app/blog/controller/entry.rb +0 -85
  159. data/examples/app/blog/controller/main.rb +0 -20
  160. data/examples/app/blog/controller/tag.rb +0 -9
  161. data/examples/app/blog/layout/default.nag +0 -31
  162. data/examples/app/blog/model/entry.rb +0 -89
  163. data/examples/app/blog/model/tag.rb +0 -36
  164. data/examples/app/blog/public/css/screen.css +0 -273
  165. data/examples/app/blog/spec/blog.rb +0 -87
  166. data/examples/app/blog/view/comment/form.nag +0 -10
  167. data/examples/app/blog/view/comment/show.nag +0 -16
  168. data/examples/app/blog/view/entry/edit.nag +0 -14
  169. data/examples/app/blog/view/entry/feed.atom.nag +0 -8
  170. data/examples/app/blog/view/entry/feed.rss.nag +0 -7
  171. data/examples/app/blog/view/entry/index.nag +0 -7
  172. data/examples/app/blog/view/entry/new.nag +0 -13
  173. data/examples/app/blog/view/entry/show.nag +0 -36
  174. data/examples/app/blog/view/feed.atom.nag +0 -18
  175. data/examples/app/blog/view/feed.rss.nag +0 -25
  176. data/examples/app/blog/view/index.nag +0 -6
  177. data/examples/app/blog/view/tag/index.nag +0 -5
  178. data/lib/proto/public/ramaze.png +0 -0
  179. data/lib/ramaze/rest.rb +0 -36
  180. data/spec/ramaze/rest.rb +0 -28
  181. 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 &copy; #{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>
@@ -1,6 +0,0 @@
1
- <div id="entries">
2
- <?r @pager.each do |entry| ?>
3
- #{Blog::Entries.render_partial(:show, :entry => entry)}
4
- <?r end ?>
5
- #{ @pager.navigation if @pager.needed? }
6
- </div>
@@ -1,5 +0,0 @@
1
- <?r @tags.each do |tag| ?>
2
- <?r tag.entries.each do |entry| ?>
3
- #{Blog::Entries.render_partial(:show, :entry => entry)}
4
- <?r end ?>
5
- <?r end ?>
Binary file
@@ -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
@@ -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
@@ -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