ramaze 0.0.9 → 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.
Files changed (193) hide show
  1. data/Rakefile +14 -259
  2. data/bin/ramaze +52 -25
  3. data/doc/AUTHORS +6 -0
  4. data/doc/CHANGELOG +1363 -42
  5. data/doc/INSTALL +1 -1
  6. data/doc/README +48 -35
  7. data/doc/README.html +637 -0
  8. data/doc/TODO +7 -16
  9. data/doc/allison/allison.css +6 -7
  10. data/doc/allison/allison.gif +0 -0
  11. data/doc/allison/cache/STYLE +1 -2
  12. data/doc/changes.txt +3375 -0
  13. data/doc/changes.xml +3378 -0
  14. data/doc/meta/announcement.txt +47 -0
  15. data/doc/meta/configuration.txt +179 -0
  16. data/doc/meta/internals.txt +111 -0
  17. data/doc/readme_chunks/features.txt +8 -16
  18. data/doc/readme_chunks/installing.txt +7 -1
  19. data/doc/tutorial/todolist.txt +2 -3
  20. data/examples/blog/main.rb +9 -8
  21. data/examples/blog/public/styles/blog.css +132 -0
  22. data/examples/blog/src/controller.rb +14 -41
  23. data/examples/blog/src/model.rb +12 -13
  24. data/examples/blog/src/view.rb +16 -0
  25. data/examples/blog/template/edit.xhtml +19 -8
  26. data/examples/blog/template/index.xhtml +14 -22
  27. data/examples/blog/template/new.xhtml +18 -5
  28. data/examples/caching.rb +5 -8
  29. data/examples/element.rb +3 -3
  30. data/examples/hello.rb +3 -5
  31. data/examples/simple.rb +4 -7
  32. data/examples/templates/template/external.haml +8 -7
  33. data/examples/templates/template/external.mab +11 -8
  34. data/examples/templates/template_amrita2.rb +4 -4
  35. data/examples/templates/template_erubis.rb +3 -3
  36. data/examples/templates/template_ezamar.rb +1 -2
  37. data/examples/templates/template_haml.rb +24 -23
  38. data/examples/templates/template_liquid.rb +3 -1
  39. data/examples/templates/template_markaby.rb +15 -9
  40. data/examples/todolist/src/element/page.rb +1 -1
  41. data/lib/proto/conf/benchmark.yaml +6 -20
  42. data/lib/proto/conf/debug.yaml +6 -19
  43. data/lib/proto/conf/live.yaml +7 -19
  44. data/lib/proto/conf/silent.yaml +6 -16
  45. data/lib/proto/conf/stage.yaml +6 -18
  46. data/lib/proto/public/error.zmr +2 -2
  47. data/lib/ramaze.rb +34 -72
  48. data/lib/ramaze/adapter.rb +21 -18
  49. data/lib/ramaze/adapter/mongrel.rb +0 -3
  50. data/lib/ramaze/adapter/webrick.rb +6 -6
  51. data/lib/ramaze/cache/memcached.rb +3 -0
  52. data/lib/ramaze/controller.rb +227 -183
  53. data/lib/ramaze/dispatcher.rb +34 -129
  54. data/lib/ramaze/dispatcher/action.rb +28 -0
  55. data/lib/ramaze/dispatcher/error.rb +43 -0
  56. data/lib/ramaze/dispatcher/file.rb +34 -0
  57. data/lib/ramaze/global.rb +89 -48
  58. data/lib/ramaze/helper/aspect.rb +8 -6
  59. data/lib/ramaze/helper/auth.rb +3 -3
  60. data/lib/ramaze/helper/cache.rb +2 -2
  61. data/lib/ramaze/helper/file.rb +14 -0
  62. data/lib/ramaze/helper/inform.rb +36 -0
  63. data/lib/ramaze/helper/link.rb +7 -3
  64. data/lib/ramaze/helper/markaby.rb +30 -0
  65. data/lib/ramaze/helper/redirect.rb +2 -0
  66. data/lib/ramaze/inform.rb +8 -182
  67. data/lib/ramaze/inform/analogger.rb +19 -0
  68. data/lib/ramaze/inform/growl.rb +28 -0
  69. data/lib/ramaze/inform/hub.rb +26 -0
  70. data/lib/ramaze/inform/informer.rb +92 -0
  71. data/lib/ramaze/inform/informing.rb +44 -0
  72. data/lib/ramaze/inform/syslog.rb +27 -0
  73. data/lib/ramaze/inform/xosd.rb +42 -0
  74. data/lib/ramaze/snippets.rb +6 -2
  75. data/lib/ramaze/snippets/object/traits.rb +13 -1
  76. data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
  77. data/lib/ramaze/snippets/string/color.rb +27 -0
  78. data/lib/ramaze/snippets/string/each.rb +6 -0
  79. data/lib/ramaze/snippets/struct/fill.rb +15 -0
  80. data/lib/ramaze/template/ezamar.rb +13 -22
  81. data/lib/ramaze/template/ezamar/element.rb +12 -12
  82. data/lib/ramaze/template/liquid.rb +19 -18
  83. data/lib/ramaze/template/markaby.rb +37 -58
  84. data/lib/ramaze/tool/localize.rb +128 -0
  85. data/lib/ramaze/tool/tidy.rb +51 -21
  86. data/lib/ramaze/trinity.rb +3 -3
  87. data/lib/ramaze/trinity/request.rb +41 -23
  88. data/lib/ramaze/trinity/response.rb +10 -5
  89. data/lib/ramaze/trinity/session.rb +17 -3
  90. data/lib/ramaze/version.rb +2 -2
  91. data/rake_tasks/conf.rake +56 -0
  92. data/rake_tasks/gem.rake +44 -0
  93. data/rake_tasks/maintaince.rake +187 -0
  94. data/spec/all.rb +32 -0
  95. data/spec/examples/caching.rb +19 -0
  96. data/spec/examples/element.rb +15 -0
  97. data/spec/examples/hello.rb +11 -0
  98. data/spec/examples/simple.rb +51 -0
  99. data/spec/examples/templates/template_amrita2.rb +14 -0
  100. data/spec/examples/templates/template_erubis.rb +21 -0
  101. data/spec/examples/templates/template_ezamar.rb +22 -0
  102. data/spec/examples/templates/template_haml.rb +23 -0
  103. data/spec/examples/templates/template_liquid.rb +24 -0
  104. data/spec/examples/templates/template_markaby.rb +21 -0
  105. data/spec/helper.rb +81 -0
  106. data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
  107. data/spec/helper/layout.rb +55 -0
  108. data/spec/helper/mock_http.rb +66 -0
  109. data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
  110. data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
  111. data/spec/helper/wrap.rb +193 -0
  112. data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
  113. data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
  114. data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
  115. data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
  116. data/spec/ramaze/conf/locale_de.yaml +6 -0
  117. data/spec/ramaze/conf/locale_en.yaml +6 -0
  118. data/spec/ramaze/controller.rb +184 -0
  119. data/spec/ramaze/controller/template/greet.xhtml +1 -0
  120. data/spec/ramaze/controller/template_resolving.rb +54 -0
  121. data/spec/ramaze/dependencies.rb +16 -0
  122. data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
  123. data/spec/ramaze/error.rb +64 -0
  124. data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
  125. data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
  126. data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
  127. data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
  128. data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
  129. data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
  130. data/spec/ramaze/helper/file.rb +17 -0
  131. data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
  132. data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
  133. data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
  134. data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
  135. data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
  136. data/spec/ramaze/inform/informer.rb +40 -0
  137. data/spec/ramaze/inform/syslog.rb +10 -0
  138. data/spec/ramaze/localize.rb +40 -0
  139. data/spec/ramaze/morpher.rb +82 -0
  140. data/spec/ramaze/params.rb +124 -0
  141. data/spec/{public → ramaze/public}/error404.xhtml +0 -0
  142. data/spec/{public → ramaze/public}/favicon.ico +0 -0
  143. data/spec/{public → ramaze/public}/ramaze.png +0 -0
  144. data/spec/{public → ramaze/public}/test_download.css +0 -0
  145. data/spec/ramaze/request.rb +129 -0
  146. data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
  147. data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
  148. data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
  149. data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
  150. data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
  151. data/spec/ramaze/template.rb +86 -0
  152. data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
  153. data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
  154. data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
  155. data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
  156. data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
  157. data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
  158. data/spec/ramaze/template/ezamar.rb +62 -0
  159. data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
  160. data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
  161. data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
  162. data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
  163. data/spec/ramaze/template/ezamar/nested.zmr +1 -0
  164. data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
  165. data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
  166. data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
  167. data/spec/{template → ramaze/template}/haml/index.haml +0 -0
  168. data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
  169. data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
  170. data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
  171. data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
  172. data/spec/ramaze/template/markaby.rb +59 -0
  173. data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
  174. data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
  175. data/spec/ramaze/template/ramaze/external.test +1 -0
  176. data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
  177. metadata +145 -81
  178. data/examples/blog/public/screen.css +0 -106
  179. data/examples/blog/src/element.rb +0 -58
  180. data/examples/blog/template/view.xhtml +0 -15
  181. data/examples/blog/test/tc_entry.rb +0 -18
  182. data/lib/proto/public/404.jpg +0 -0
  183. data/spec/request_tc_helper.rb +0 -135
  184. data/spec/spec_all.rb +0 -118
  185. data/spec/spec_helper.rb +0 -66
  186. data/spec/tc_controller.rb +0 -49
  187. data/spec/tc_dependencies.rb +0 -13
  188. data/spec/tc_error.rb +0 -43
  189. data/spec/tc_morpher.rb +0 -88
  190. data/spec/tc_params.rb +0 -125
  191. data/spec/tc_template_ezamar.rb +0 -64
  192. data/spec/tc_template_markaby.rb +0 -72
  193. data/spec/template/ezamar/nested.zmr +0 -1
@@ -4,13 +4,15 @@
4
4
  require 'cgi'
5
5
  require 'tmpdir'
6
6
  require 'digest/md5'
7
+ require 'rack'
8
+ require 'rack/request'
7
9
 
8
10
  module Ramaze
9
11
 
10
12
  # The purpose of this class is to act as a simple wrapper for Rack::Request
11
13
  # and provide some convinient methods for our own use.
12
14
 
13
- class Request
15
+ module Request
14
16
  class << self
15
17
 
16
18
  # get the current request out of Thread.current[:request]
@@ -22,23 +24,16 @@ module Ramaze
22
24
  end
23
25
  end
24
26
 
25
- # create a new instance of Request, takes the original Rack::Request
26
- # instance
27
-
28
- def initialize request = {}
29
- @request = request
30
- end
31
-
32
27
  # shortcut for request.params[key]
33
28
 
34
29
  def [](key)
35
- params[key]
30
+ params[key.to_s]
36
31
  end
37
32
 
38
33
  # shortcut for request.params[key] = value
39
34
 
40
35
  def []=(key, value)
41
- params[key] = value
36
+ params[key.to_s] = value
42
37
  end
43
38
 
44
39
  # like Hash#values_at
@@ -47,6 +42,7 @@ module Ramaze
47
42
  keys.map{|key| params[key] }
48
43
  end
49
44
 
45
+
50
46
  # the referer of the client or '/'
51
47
 
52
48
  def referer
@@ -55,24 +51,46 @@ module Ramaze
55
51
 
56
52
  alias referrer referer
57
53
 
58
- def fullpath
59
- path = script_name + path_info
60
- path << "?" << query_string unless query_string.empty?
61
- path
62
- end
63
-
64
- def env
65
- @request.env
66
- end
67
-
68
54
  # you can access the original @request via this method_missing,
69
55
  # first it tries to match your method with any of the HTTP parameters
70
56
  # then, in case that fails, it will relay to @request
71
57
 
72
58
  def method_missing meth, *args, &block
73
- @request.send(meth, *args, &block)
74
- rescue
75
- env[meth.to_s.upcase]
59
+ key = meth.to_s.upcase
60
+ return env[key] if env.has_key?(key)
61
+ super
62
+ end
63
+
64
+ def self.included(klass)
65
+ klass.class_eval do
66
+ unless defined?(fullpath)
67
+ def fullpath
68
+ path = script_name + path_info
69
+ path << "?" << query_string unless query_string.empty?
70
+ path
71
+ end
72
+ end
73
+
74
+ unless defined?(rack_params)
75
+ alias rack_params params
76
+
77
+ def params
78
+ ps = rack_params
79
+ temp = Hash.new{|h,k| h[k] = {}}
80
+
81
+ ps.each do |key, value|
82
+ outer_key, inner_key = key.scan(/^(.+)\[(.*?)\]$/).first
83
+ if outer_key and inner_key
84
+ temp[outer_key][inner_key] = value
85
+ else
86
+ temp[key] = value
87
+ end
88
+ end
89
+
90
+ temp
91
+ end
92
+ end
93
+ end
76
94
  end
77
95
  end
78
96
  end
@@ -2,11 +2,16 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- # get the current response out of Thread.current[:response]
6
- #
7
- # You can call this from everywhere with Ramaze::Response.current
5
+ module Response
6
+ class << self
8
7
 
9
- def self.Response
10
- Thread.current[:response]
8
+ # get the current response out of Thread.current[:response]
9
+ #
10
+ # You can call this from everywhere with Ramaze::Response.current
11
+
12
+ def current
13
+ Thread.current[:response]
14
+ end
15
+ end
11
16
  end
12
17
  end
@@ -55,6 +55,10 @@ module Ramaze
55
55
 
56
56
  trait :finalize => [:finalize_flash]
57
57
 
58
+ trait :ip_cache => Hash.new{|h,k| h[k] = []}
59
+
60
+ trait :ip_cache_limit => 1000
61
+
58
62
  class << self
59
63
 
60
64
  # answers with Thread.current[:session] which holds the current session
@@ -75,6 +79,14 @@ module Ramaze
75
79
 
76
80
  def initialize request
77
81
  @session_id = (request.cookies[SESSION_KEY] || random_key)
82
+ ip_cache = ancestral_trait[:ip_cache]
83
+ ip = request.remote_addr
84
+ ip_cache[ip] << @session_id
85
+
86
+ if ip_cache[ip].size >= ancestral_trait[:ip_cache_limit]
87
+ sessions.delete(ip_cache[ip].shift)
88
+ end
89
+
78
90
  @flash = Ramaze::SessionFlash.new
79
91
 
80
92
  unless sessions
@@ -120,7 +132,7 @@ module Ramaze
120
132
 
121
133
  def random_key
122
134
  h = [
123
- Time.now.to_f.to_s.reverse, rand,
135
+ Time.now.to_f.to_s, rand,
124
136
  Thread.current[:request].hash, rand,
125
137
  Process.pid, rand,
126
138
  object_id, rand
@@ -191,7 +203,9 @@ module Ramaze
191
203
  end
192
204
 
193
205
  def []=(key, value)
194
- current[key] = value
206
+ prev = session[:FLASH] || {}
207
+ prev[key] = value
208
+ session[:FLASH] = prev
195
209
  end
196
210
 
197
211
  def inspect
@@ -201,7 +215,7 @@ module Ramaze
201
215
  private
202
216
 
203
217
  def session
204
- Ramaze::Session.current
218
+ Ramaze::Session.current || {}
205
219
  end
206
220
  end
207
221
  end
@@ -4,8 +4,8 @@
4
4
  module Ramaze #:nodoc:
5
5
  module Version #:nodoc:
6
6
  MAJOR = 0
7
- MINOR = 0
8
- TINY = 9
7
+ MINOR = 1
8
+ TINY = 0
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY].join('.')
11
11
  end
@@ -0,0 +1,56 @@
1
+ AUTHOR = "manveru"
2
+ EMAIL = "m.fellinger@gmail.com"
3
+ DESCRIPTION = "Ramaze tries to be a very simple Webframework without the voodoo"
4
+ HOMEPATH = 'http://ramaze.rubyforge.org'
5
+ BIN_FILES = %w( ramaze )
6
+
7
+ BASEDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
+
9
+ NAME = "ramaze"
10
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
11
+ VERS = ENV['VERSION'] || (Ramaze::VERSION + (REV ? ".#{REV}" : ""))
12
+ COPYRIGHT = [
13
+ "# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com",
14
+ "# All files in this distribution are subject to the terms of the Ruby license."
15
+ ]
16
+ CLEAN.include %w[
17
+ **/.*.sw?
18
+ *.gem
19
+ .config
20
+ **/*~
21
+ **/{data.db,cache.yaml}
22
+ *.yaml
23
+ pkg
24
+ rdoc
25
+ ]
26
+ RDOC_OPTS = %w[
27
+ --all
28
+ --quiet
29
+ --op rdoc
30
+ --line-numbers
31
+ --inline-source
32
+ --main doc/README
33
+ --opname index.html
34
+ --title "Ramaze\ documentation"
35
+ --exclude "^(_darcs|spec|examples|bin|pkg)/"
36
+ --exclude "lib/proto"
37
+ --include "doc"
38
+ --accessor "trait"
39
+ ]
40
+ RDOC_FILES = %w[
41
+ lib doc doc/README doc/FAQ doc/CHANGELOG
42
+ ]
43
+ POST_INSTALL_MESSAGE = %{
44
+ #{'=' * 60}
45
+
46
+ Thank you for installing Ramaze!
47
+ You can now do following:
48
+
49
+ * Create a new project using the `ramaze' command:
50
+ ramaze --create yourproject
51
+
52
+ * Browse and try the Examples in
53
+ #{File.join(Gem.path, 'gems', 'ramaze-' + VERS, 'examples')}
54
+
55
+ #{'=' * 60}
56
+ }.strip
@@ -0,0 +1,44 @@
1
+ spec =
2
+ Gem::Specification.new do |s|
3
+ s.name = NAME
4
+ s.version = VERS
5
+ s.platform = Gem::Platform::RUBY
6
+ s.has_rdoc = true
7
+ s.extra_rdoc_files = RDOC_FILES
8
+ s.rdoc_options += RDOC_OPTS
9
+ s.summary = DESCRIPTION
10
+ s.description = DESCRIPTION
11
+ s.author = AUTHOR
12
+ s.email = EMAIL
13
+ s.homepage = HOMEPATH
14
+ s.executables = BIN_FILES
15
+ s.bindir = "bin"
16
+ s.require_path = "lib"
17
+ s.post_install_message = POST_INSTALL_MESSAGE
18
+
19
+ s.add_dependency('rake', '>=0.7.3')
20
+ s.add_dependency('rspec', '>=0.9.1')
21
+ s.add_dependency('rack', '>=0.1.0')
22
+ # s.required_ruby_version = '>= 1.8.5'
23
+
24
+ s.files = (RDOC_FILES + %w[Rakefile] + Dir["{examples,bin,doc,spec,lib,rake_tasks}/**/*"]).uniq
25
+
26
+ # s.extensions = FileList["ext/**/extconf.rb"].to_a
27
+ end
28
+
29
+ Rake::GemPackageTask.new(spec) do |p|
30
+ p.need_tar = true
31
+ p.gem_spec = spec
32
+ end
33
+
34
+ desc "package and install ramaze"
35
+ task :install do
36
+ name = "#{NAME}-#{VERS}.gem"
37
+ sh %{rake package}
38
+ sh %{sudo gem install pkg/#{name}}
39
+ end
40
+
41
+ desc "uninstall the ramaze gem"
42
+ task :uninstall => [:clean] do
43
+ sh %{sudo gem uninstall #{NAME}}
44
+ end
@@ -0,0 +1,187 @@
1
+ desc "add copyright to all .rb files in the distribution"
2
+ task 'add-copyright' do
3
+ puts "adding copyright to files that don't have it currently"
4
+ Dir['{lib,test}/**/*{.rb}'].each do |file|
5
+ next if file =~ /_darcs/
6
+ lines = File.readlines(file).map{|l| l.chomp}
7
+ unless lines.first(COPYRIGHT.size) == COPYRIGHT
8
+ puts "fixing #{file}"
9
+ File.open(file, 'w+') do |f|
10
+ (COPYRIGHT + ["\n"] + lines).each do |line|
11
+ f.puts(line)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ desc "doc/README to html"
19
+ Rake::RDocTask.new('readme2html-build') do |rd|
20
+ rd.options = %w[
21
+ --quiet
22
+ --opname readme.html
23
+ ]
24
+
25
+ rd.rdoc_dir = 'readme'
26
+ rd.rdoc_files = ['doc/README']
27
+ rd.main = 'doc/README'
28
+ rd.title = "Ramaze documentation"
29
+ end
30
+
31
+ desc "doc/README to doc/README.html"
32
+ task 'readme2html' => ['readme-build', 'readme2html-build'] do
33
+ cp('readme/files/doc/README.html', 'doc/README.html')
34
+ rm_rf('readme')
35
+ end
36
+
37
+ desc "generate doc/TODO from the TODO tags in the source"
38
+ task 'todolist' do
39
+ list = `rake todo`
40
+ tasks = {}
41
+ current = nil
42
+
43
+ list.split("\n")[2..-1].each do |line|
44
+ if line =~ /TODO/ or line.empty?
45
+ elsif line =~ /^vim/
46
+ current = line.split[1]
47
+ tasks[current] = []
48
+ else
49
+ tasks[current] << line
50
+ end
51
+ end
52
+
53
+ lines = tasks.map{ |name, items| [name, items, ''] }.flatten
54
+ lines.pop
55
+
56
+ File.open(File.join('doc', 'TODO'), 'w+') do |f|
57
+ f.puts "This list is programmaticly generated by `rake todolist`"
58
+ f.puts "If you want to add/remove items from the list, change them at the"
59
+ f.puts "position specified in the list."
60
+ f.puts
61
+ f.puts(lines)
62
+ end
63
+ end
64
+
65
+ desc "remove those annoying spaces at the end of lines"
66
+ task 'fix-end-spaces' do
67
+ Dir['{lib,spec}/**/*.rb'].each do |file|
68
+ next if file =~ /_darcs/
69
+ lines = File.readlines(file)
70
+ new = lines.dup
71
+ lines.each_with_index do |line, i|
72
+ if line =~ /\s+\n/
73
+ puts "fixing #{file}:#{i + 1}"
74
+ p line
75
+ new[i] = line.rstrip
76
+ end
77
+ end
78
+
79
+ unless new == lines
80
+ File.open(file, 'w+') do |f|
81
+ new.each do |line|
82
+ f.puts(line)
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ desc "Compile the doc/README from the parts of doc/readme"
90
+ task 'readme-build' do
91
+ require 'enumerator'
92
+
93
+ chapters = [
94
+ 'About Ramaze', 'introduction',
95
+ 'Features Overview', 'features',
96
+ 'Basic Principles', 'principles',
97
+ 'Installation', 'installing',
98
+ 'Getting Started', 'getting_started',
99
+ 'A couple of Examples', 'examples',
100
+ 'How to find Help', 'getting_help',
101
+ 'Appendix', 'appendix',
102
+ 'And thanks to...', 'thanks',
103
+ ]
104
+
105
+ File.open('doc/README', 'w+') do |readme|
106
+ readme.puts COPYRIGHT.map{|l| l[1..-1]}, ''
107
+
108
+ chapters.each_slice(2) do |title, file|
109
+ file = File.join('doc', 'readme_chunks', "#{file}.txt")
110
+ chapter = File.read(file)
111
+ readme.puts "= #{title}", '', chapter
112
+ readme.puts '', '' unless title == chapters[-2]
113
+ end
114
+ end
115
+ end
116
+
117
+ task 'tutorial2html' do
118
+ require 'bluecloth'
119
+
120
+ basefile = File.join('doc', 'tutorial', 'todolist')
121
+
122
+ content = File.read(basefile + '.txt')
123
+
124
+ html = BlueCloth.new(content).to_html
125
+
126
+ wrap = %{
127
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
128
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
129
+ <html>
130
+ <head>
131
+ <title>Ramaze Tutorial: Todolist</title>
132
+ <style>
133
+ body {
134
+ background: #eee;
135
+ }
136
+ code {
137
+ background: #ddd;
138
+ }
139
+ pre code {
140
+ background: #ddd;
141
+ width: 70%;
142
+ display: block;
143
+ margin: 1em;
144
+ padding: 0.7em;
145
+ overflow: auto;
146
+ }
147
+ </style>
148
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
149
+ </head>
150
+ <body>
151
+ #{html}
152
+ </body>
153
+ </html>
154
+ }.strip
155
+
156
+ File.open(basefile + '.html', 'w+'){|f| f.puts(wrap) }
157
+ end
158
+
159
+ task 'authors' do
160
+ changes = `darcs changes`
161
+ authors = []
162
+ mapping = {}
163
+ author_map = {
164
+ 'm.fellinger@gmail.com' => 'Michael Fellinger',
165
+ 'manveru@weez-int.com' => 'Michael Fellinger',
166
+ 'clive@crous.co.za' => 'Clive Crous'
167
+ }
168
+ changes.split("\n").grep(/^\w/).each do |line|
169
+ splat = line.split
170
+ author = splat[6..-1]
171
+ email = author.pop
172
+ email.gsub!(/<(.*?)>/, '\1')
173
+ name = author.join(' ')
174
+ name = author_map[email] if name.empty?
175
+ mapping[name] = email
176
+ end
177
+
178
+ max = mapping.map{|k,v| k.size}.max
179
+
180
+ File.open('doc/AUTHORS', 'w+') do |fp|
181
+ fp.puts("Following persons have contributed to Ramaze:")
182
+ fp.puts
183
+ mapping.sort_by{|k,v| v}.each do |name, email|
184
+ fp.puts("#{name.ljust(max)} - #{email}")
185
+ end
186
+ end
187
+ end