ramaze 0.1.0 → 0.1.1

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 (195) hide show
  1. data/Rakefile +4 -12
  2. data/bin/ramaze +95 -171
  3. data/doc/CHANGELOG +387 -4
  4. data/doc/README +81 -13
  5. data/doc/meta/announcement.txt +51 -8
  6. data/doc/meta/configuration.txt +17 -34
  7. data/doc/meta/internals.txt +34 -4
  8. data/doc/migrate/1110_to_1111.txt +131 -0
  9. data/doc/readme_chunks/features.txt +81 -12
  10. data/doc/readme_chunks/installing.txt +0 -1
  11. data/doc/tutorial/todolist.html +293 -65
  12. data/doc/tutorial/{todolist.txt → todolist.mkd} +251 -51
  13. data/examples/blog/main.rb +1 -1
  14. data/examples/blog/src/model.rb +0 -1
  15. data/examples/hello.rb +2 -5
  16. data/examples/templates/template/external.haml +5 -5
  17. data/examples/templates/template/external.liquid +1 -1
  18. data/examples/templates/template/external.mab +8 -8
  19. data/examples/templates/template/external.rem +30 -0
  20. data/examples/templates/template/external.rhtml +6 -7
  21. data/examples/templates/template/external.zmr +13 -9
  22. data/examples/templates/template_amrita2.rb +8 -8
  23. data/examples/templates/template_erubis.rb +11 -11
  24. data/examples/templates/template_ezamar.rb +9 -11
  25. data/examples/templates/template_haml.rb +13 -13
  26. data/examples/templates/template_liquid.rb +10 -10
  27. data/examples/templates/template_markaby.rb +13 -10
  28. data/examples/templates/template_remarkably.rb +59 -0
  29. data/examples/todolist/main.rb +1 -7
  30. data/examples/todolist/src/controller/main.rb +26 -13
  31. data/examples/todolist/src/element/page.rb +5 -0
  32. data/examples/whywiki/main.rb +1 -1
  33. data/lib/proto/main.rb +0 -8
  34. data/lib/proto/public/css/ramaze_error.css +12 -4
  35. data/lib/proto/public/error.zmr +6 -25
  36. data/lib/ramaze.rb +35 -245
  37. data/lib/ramaze/action.rb +21 -0
  38. data/lib/ramaze/adapter.rb +94 -29
  39. data/lib/ramaze/adapter/base.rb +57 -0
  40. data/lib/ramaze/adapter/mongrel.rb +12 -19
  41. data/lib/ramaze/adapter/webrick.rb +21 -20
  42. data/lib/ramaze/cache.rb +47 -3
  43. data/lib/ramaze/cache/memcached.rb +22 -0
  44. data/lib/ramaze/cache/yaml_store.rb +19 -0
  45. data/lib/ramaze/controller.rb +47 -271
  46. data/lib/ramaze/controller/error.rb +43 -0
  47. data/lib/ramaze/controller/render.rb +90 -0
  48. data/lib/ramaze/controller/resolve.rb +147 -0
  49. data/lib/ramaze/dispatcher.rb +41 -9
  50. data/lib/ramaze/dispatcher/file.rb +1 -1
  51. data/lib/ramaze/global.rb +73 -158
  52. data/lib/ramaze/global/dsl.rb +29 -0
  53. data/lib/ramaze/global/globalstruct.rb +90 -0
  54. data/lib/ramaze/helper.rb +1 -1
  55. data/lib/ramaze/helper/aspect.rb +39 -179
  56. data/lib/ramaze/helper/cache.rb +8 -9
  57. data/lib/ramaze/helper/cgi.rb +23 -0
  58. data/lib/ramaze/helper/file.rb +3 -0
  59. data/lib/ramaze/helper/inform.rb +3 -0
  60. data/lib/ramaze/helper/link.rb +56 -63
  61. data/lib/ramaze/helper/nitroform.rb +4 -0
  62. data/lib/ramaze/helper/redirect.rb +1 -1
  63. data/lib/ramaze/inform.rb +6 -2
  64. data/lib/ramaze/inform/analogger.rb +5 -1
  65. data/lib/ramaze/inform/hub.rb +1 -1
  66. data/lib/ramaze/inform/informing.rb +7 -0
  67. data/lib/ramaze/snippets/kernel/aquire.rb +2 -0
  68. data/lib/ramaze/snippets/kernel/constant.rb +2 -0
  69. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +2 -0
  70. data/lib/ramaze/snippets/object/traits.rb +4 -0
  71. data/lib/ramaze/snippets/openstruct/temp.rb +3 -0
  72. data/lib/ramaze/snippets/string/DIVIDE.rb +2 -0
  73. data/lib/ramaze/snippets/string/camel_case.rb +2 -0
  74. data/lib/ramaze/snippets/string/color.rb +2 -0
  75. data/lib/ramaze/snippets/string/each.rb +2 -0
  76. data/lib/ramaze/snippets/string/snake_case.rb +3 -0
  77. data/lib/ramaze/snippets/struct/fill.rb +8 -2
  78. data/lib/ramaze/snippets/struct/values_at.rb +16 -0
  79. data/lib/ramaze/snippets/symbol/to_proc.rb +3 -0
  80. data/lib/ramaze/sourcereload.rb +89 -0
  81. data/lib/ramaze/template.rb +21 -12
  82. data/lib/ramaze/template/amrita2.rb +6 -6
  83. data/lib/ramaze/template/erubis.rb +4 -9
  84. data/lib/ramaze/template/ezamar.rb +13 -57
  85. data/lib/ramaze/template/ezamar/element.rb +10 -12
  86. data/lib/ramaze/template/ezamar/engine.rb +40 -101
  87. data/lib/ramaze/template/ezamar/morpher.rb +3 -3
  88. data/lib/ramaze/template/haml.rb +3 -6
  89. data/lib/ramaze/template/liquid.rb +4 -9
  90. data/lib/ramaze/template/markaby.rb +16 -22
  91. data/lib/ramaze/template/remarkably.rb +28 -0
  92. data/lib/ramaze/tool/mime.rb +2 -0
  93. data/lib/ramaze/tool/record.rb +6 -0
  94. data/lib/ramaze/trinity/request.rb +44 -54
  95. data/lib/ramaze/trinity/response.rb +1 -1
  96. data/lib/ramaze/trinity/session.rb +15 -37
  97. data/lib/ramaze/version.rb +1 -1
  98. data/rake_tasks/gem.rake +2 -2
  99. data/rake_tasks/maintaince.rake +42 -1
  100. data/rake_tasks/spec.rake +45 -0
  101. data/spec/examples/caching.rb +1 -1
  102. data/spec/examples/simple.rb +1 -1
  103. data/spec/examples/templates/template_amrita2.rb +1 -0
  104. data/spec/examples/templates/template_erubis.rb +2 -1
  105. data/spec/examples/templates/template_ezamar.rb +1 -1
  106. data/spec/examples/templates/template_haml.rb +2 -1
  107. data/spec/examples/templates/template_liquid.rb +2 -1
  108. data/spec/examples/templates/template_markaby.rb +2 -1
  109. data/spec/examples/templates/template_remarkably.rb +22 -0
  110. data/spec/examples/todolist.rb +125 -0
  111. data/spec/helper.rb +2 -23
  112. data/spec/helper/minimal.rb +20 -0
  113. data/spec/helper/mock_http.rb +24 -30
  114. data/spec/helper/simple_http.rb +2 -2
  115. data/spec/helper/wrap.rb +6 -9
  116. data/spec/ramaze/adapter.rb +1 -1
  117. data/spec/ramaze/adapter/record.rb +31 -0
  118. data/spec/ramaze/cache.rb +41 -54
  119. data/spec/ramaze/controller.rb +121 -137
  120. data/spec/ramaze/controller/template/list.xhtml +1 -0
  121. data/spec/ramaze/controller/template/other/greet/other.xhtml +1 -0
  122. data/spec/ramaze/controller/template_resolving.rb +27 -3
  123. data/spec/ramaze/element.rb +11 -7
  124. data/spec/ramaze/error.rb +1 -1
  125. data/spec/ramaze/gestalt.rb +2 -0
  126. data/spec/ramaze/helper/aspect.rb +30 -21
  127. data/spec/ramaze/helper/auth.rb +1 -1
  128. data/spec/ramaze/helper/cache.rb +2 -1
  129. data/spec/ramaze/helper/form.rb +14 -11
  130. data/spec/ramaze/helper/link.rb +18 -41
  131. data/spec/ramaze/localize.rb +29 -2
  132. data/spec/ramaze/morpher.rb +23 -12
  133. data/spec/ramaze/params.rb +46 -24
  134. data/spec/ramaze/request.rb +6 -2
  135. data/spec/ramaze/store/yaml.rb +5 -0
  136. data/spec/ramaze/template.rb +22 -27
  137. data/spec/ramaze/template/amrita2.rb +1 -2
  138. data/spec/ramaze/template/erubis.rb +1 -1
  139. data/spec/ramaze/template/ezamar.rb +1 -2
  140. data/spec/ramaze/template/haml.rb +2 -2
  141. data/spec/ramaze/template/haml/with_vars.haml +1 -1
  142. data/spec/ramaze/template/liquid.rb +1 -1
  143. data/spec/ramaze/template/markaby.rb +1 -1
  144. data/spec/ramaze/template/remarkably.rb +56 -0
  145. data/spec/ramaze/template/remarkably/external.rem +8 -0
  146. data/spec/ramaze/template/remarkably/sum.rem +1 -0
  147. metadata +38 -63
  148. data/doc/README.html +0 -637
  149. data/doc/allison/LICENSE +0 -184
  150. data/doc/allison/README +0 -37
  151. data/doc/allison/allison.css +0 -299
  152. data/doc/allison/allison.gif +0 -0
  153. data/doc/allison/allison.js +0 -307
  154. data/doc/allison/allison.rb +0 -287
  155. data/doc/allison/cache/BODY +0 -588
  156. data/doc/allison/cache/CLASS_INDEX +0 -4
  157. data/doc/allison/cache/CLASS_PAGE +0 -1
  158. data/doc/allison/cache/FILE_INDEX +0 -4
  159. data/doc/allison/cache/FILE_PAGE +0 -1
  160. data/doc/allison/cache/FONTS +0 -1
  161. data/doc/allison/cache/FR_INDEX_BODY +0 -1
  162. data/doc/allison/cache/IMGPATH +0 -1
  163. data/doc/allison/cache/INDEX +0 -1
  164. data/doc/allison/cache/JAVASCRIPT +0 -307
  165. data/doc/allison/cache/METHOD_INDEX +0 -4
  166. data/doc/allison/cache/METHOD_LIST +0 -1
  167. data/doc/allison/cache/SRC_PAGE +0 -1
  168. data/doc/allison/cache/STYLE +0 -321
  169. data/doc/allison/cache/URL +0 -1
  170. data/doc/changes.txt +0 -3375
  171. data/doc/changes.xml +0 -3378
  172. data/examples/todolist/conf/benchmark.yaml +0 -35
  173. data/examples/todolist/conf/debug.yaml +0 -34
  174. data/examples/todolist/conf/live.yaml +0 -33
  175. data/examples/todolist/conf/silent.yaml +0 -31
  176. data/examples/todolist/conf/stage.yaml +0 -33
  177. data/examples/todolist/public/css/coderay.css +0 -105
  178. data/examples/todolist/public/css/ramaze_error.css +0 -42
  179. data/lib/proto/conf/benchmark.yaml +0 -21
  180. data/lib/proto/conf/debug.yaml +0 -21
  181. data/lib/proto/conf/live.yaml +0 -21
  182. data/lib/proto/conf/silent.yaml +0 -21
  183. data/lib/proto/conf/stage.yaml +0 -21
  184. data/lib/proto/public/css/coderay.css +0 -105
  185. data/lib/ramaze/http_status.rb +0 -66
  186. data/lib/ramaze/snippets/hash/keys_to_sym.rb +0 -19
  187. data/lib/ramaze/snippets/kernel/method.rb +0 -26
  188. data/lib/ramaze/snippets/method/name.rb +0 -22
  189. data/lib/ramaze/snippets/ramaze/autoreload.rb +0 -135
  190. data/lib/ramaze/snippets/rdoc/usage_no_exit.rb +0 -65
  191. data/spec/all.rb +0 -32
  192. data/spec/ramaze/conf/locale_de.yaml +0 -6
  193. data/spec/ramaze/conf/locale_en.yaml +0 -6
  194. data/spec/ramaze/dependencies.rb +0 -16
  195. data/spec/ramaze/global.rb +0 -44
@@ -15,33 +15,27 @@ module Ramaze
15
15
  # Also tries to render the template.
16
16
  # In Theory you can use this standalone, this has not been tested though.
17
17
 
18
- def transform controller, options = {}
19
- action, parameter, file, bound = *super
20
-
21
- unless controller.private_methods.include?(action)
22
- reaction = controller.__send__(action, *parameter)
23
- template =
24
- if file
25
- transform_file(controller, file)
26
- elsif reaction.respond_to?(:to_str)
27
- reaction
28
- end
29
- return template if template
30
- end
18
+ def transform action
19
+ result, file = result_and_file(action)
31
20
 
32
- raise Error::NoAction, "No Action found for `#{action}' on #{controller.class}"
21
+ result = transform_file(file, action) if file
22
+ result.to_s
33
23
  end
34
24
 
35
- def transform_file controller, file
36
- ivs = {}
37
- controller.instance_variables.each do |iv|
38
- ivs[iv.gsub('@', '').to_sym] = controller.instance_variable_get(iv)
39
- end
25
+ def transform_file file, action
26
+ controller = action.controller
27
+ ivs = extract_ivs(controller)
28
+
40
29
  controller.send(:mab, ivs) do
41
- instance_eval(File.read(file))
30
+ instance_eval(file)
31
+ end
32
+ end
33
+
34
+ def extract_ivs(controller)
35
+ controller.instance_variables.inject({}) do |hash, iv|
36
+ sym = iv.gsub('@', '').to_sym
37
+ hash.merge! sym => controller.instance_variable_get(iv)
42
38
  end
43
- rescue Object => ex
44
- raise Error::Template, ex.message, ex.backtrace
45
39
  end
46
40
  end
47
41
  end
@@ -0,0 +1,28 @@
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 'remarkably/engines/html'
5
+
6
+ module Ramaze
7
+ module Template
8
+ class Remarkably < Template
9
+ Controller.register_engine self, %w[ rem ]
10
+
11
+ class << self
12
+ def transform action
13
+ result, file = result_and_file(action)
14
+
15
+ result = transform_file(file, action) if file
16
+ result.to_s
17
+ end
18
+
19
+ def transform_file(file, action)
20
+ action.controller.instance_eval do
21
+ args = action.params
22
+ instance_eval(file)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
+ require 'yaml'
5
+
4
6
  module Ramaze
5
7
  module Tool
6
8
  module MIME
@@ -0,0 +1,6 @@
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
+ module Ramaze
5
+ Record = []
6
+ end
@@ -12,7 +12,7 @@ module Ramaze
12
12
  # The purpose of this class is to act as a simple wrapper for Rack::Request
13
13
  # and provide some convinient methods for our own use.
14
14
 
15
- module Request
15
+ class Request < ::Rack::Request
16
16
  class << self
17
17
 
18
18
  # get the current request out of Thread.current[:request]
@@ -24,33 +24,6 @@ module Ramaze
24
24
  end
25
25
  end
26
26
 
27
- # shortcut for request.params[key]
28
-
29
- def [](key)
30
- params[key.to_s]
31
- end
32
-
33
- # shortcut for request.params[key] = value
34
-
35
- def []=(key, value)
36
- params[key.to_s] = value
37
- end
38
-
39
- # like Hash#values_at
40
-
41
- def values_at(*keys)
42
- keys.map{|key| params[key] }
43
- end
44
-
45
-
46
- # the referer of the client or '/'
47
-
48
- def referer
49
- env['HTTP_REFERER'] || '/'
50
- end
51
-
52
- alias referrer referer
53
-
54
27
  # you can access the original @request via this method_missing,
55
28
  # first it tries to match your method with any of the HTTP parameters
56
29
  # then, in case that fails, it will relay to @request
@@ -61,35 +34,52 @@ module Ramaze
61
34
  super
62
35
  end
63
36
 
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] = {}}
37
+ unless defined?(rack_params)
38
+ alias rack_params params
80
39
 
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
40
+ # Wrapping Request#params to support a one-level hash notation.
41
+ # It doesn't support anything really fancy, so be conservative in its use.
42
+ #
43
+ # Example Usage:
44
+ #
45
+ # # Template:
46
+ #
47
+ # <form action="/paste">
48
+ # <input type="text" name="paste[name]" />
49
+ # <input type="text" name="paste[syntax]" />
50
+ # <input type="submit" />
51
+ # </form>
52
+ #
53
+ # # In your Controller:
54
+ #
55
+ # def paste
56
+ # name, syntax = request.params['paste'].values_at('name', 'syntax')
57
+ # paste = Paste.create_with(:name => name, :syntax => syntax)
58
+ # redirect '/'
59
+ # end
60
+ #
61
+ # # Or, easier:
62
+ #
63
+ # def paste
64
+ # paste = Paste.create_with(request.params)
65
+ # redirect '/'
66
+ # end
67
+
68
+ def params
69
+ ps = rack_params
70
+ temp = {}
71
+
72
+ ps.each do |key, value|
73
+ outer_key, inner_key = key.scan(/^(.+)\[(.*?)\]$/).first
74
+ if outer_key and inner_key
75
+ temp[outer_key] ||= {}
76
+ temp[outer_key][inner_key] = value
77
+ else
78
+ temp[key] = value
91
79
  end
92
80
  end
81
+
82
+ temp
93
83
  end
94
84
  end
95
85
  end
@@ -2,7 +2,7 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- module Response
5
+ class Response < ::Rack::Response
6
6
  class << self
7
7
 
8
8
  # get the current response out of Thread.current[:response]
@@ -22,7 +22,7 @@ module Ramaze
22
22
  old = @hash.dup
23
23
  result = @hash.send(*args, &block)
24
24
  unless old == @hash
25
- Session.current.sessions[Session.current.session_id] = self
25
+ Cache.sessions[Session.current.session_id] = self
26
26
  end
27
27
  result
28
28
  end
@@ -53,14 +53,19 @@ module Ramaze
53
53
 
54
54
  SESSION_KEY = '_ramaze_session_id'
55
55
 
56
- trait :finalize => [:finalize_flash]
56
+ IP_CACHE = Hash.new{|h,k| h[k] = []}
57
57
 
58
- trait :ip_cache => Hash.new{|h,k| h[k] = []}
59
-
60
- trait :ip_cache_limit => 1000
58
+ IP_CACHE_LIMIT = 1000
61
59
 
62
60
  class << self
63
61
 
62
+ # called from Ramaze::startup and adds Cache.sessions if cookies are
63
+ # enabled
64
+
65
+ def startup(options = {})
66
+ Cache.add(:sessions) if Global.cookies
67
+ end
68
+
64
69
  # answers with Thread.current[:session] which holds the current session
65
70
  # set by the Dispatcher#setup_environment.
66
71
 
@@ -73,34 +78,18 @@ module Ramaze
73
78
  # given to us from Dispatcher#setup_environment.
74
79
  #
75
80
  # sets @session_id and @session_flash
76
- #
77
- # will set Thread.main[:session_cache] to an instance of
78
- # Ramaze::Global.cache if no cache for the sessions is initialized yet
79
81
 
80
82
  def initialize request
81
83
  @session_id = (request.cookies[SESSION_KEY] || random_key)
82
- ip_cache = ancestral_trait[:ip_cache]
84
+ ip_cache = IP_CACHE
83
85
  ip = request.remote_addr
84
86
  ip_cache[ip] << @session_id
85
87
 
86
- if ip_cache[ip].size >= ancestral_trait[:ip_cache_limit]
88
+ if ip_cache[ip].size > IP_CACHE_LIMIT
87
89
  sessions.delete(ip_cache[ip].shift)
88
90
  end
89
91
 
90
92
  @flash = Ramaze::SessionFlash.new
91
-
92
- unless sessions
93
- global_cache = Ramaze::Global.cache
94
-
95
- if global_cache.respond_to?(:new)
96
- cache = global_cache.new
97
- else
98
- cache = constant("::Ramaze::#{global_cache}")
99
- cache = cache.new if cache.respond_to?(:new)
100
- end
101
-
102
- Thread.main[:session_cache] = cache
103
- end
104
93
  end
105
94
 
106
95
  # relay all messages we don't understand to the currently active session
@@ -116,10 +105,10 @@ module Ramaze
116
105
  sessions[session_id] ||= SessionHash.new
117
106
  end
118
107
 
119
- # shortcut to Thread.main[:session_cache]
108
+ # shortcut to Cache.sessions
120
109
 
121
110
  def sessions
122
- Thread.main[:session_cache]
111
+ Cache.sessions
123
112
  end
124
113
 
125
114
  # generate a random (and hopefully unique) id for the current session.
@@ -140,28 +129,17 @@ module Ramaze
140
129
  Digest::SHA256.hexdigest(h)
141
130
  end
142
131
 
143
- # send each element of the trait[:finalize]
144
- # this is at the moment used for flash_finalize.
145
-
146
- def finalize
147
- ancestral_trait[:finalize].each do |meth|
148
- send meth
149
- end
150
- end
151
-
152
132
  def inspect
153
133
  current.inspect
154
134
  end
155
135
 
156
- private
157
-
158
136
  # at the end of a request delete the current[:FLASH] and assign it to
159
137
  # current[:FLASH_PREVIOUS]
160
138
  #
161
139
  # this is needed so flash can iterate over requests
162
140
  # and always just keep the current and previous key/value pairs.
163
141
 
164
- def finalize_flash
142
+ def finalize
165
143
  old = delete(:FLASH)
166
144
  current[:FLASH_PREVIOUS] = old if old
167
145
  end
@@ -5,7 +5,7 @@ module Ramaze #:nodoc:
5
5
  module Version #:nodoc:
6
6
  MAJOR = 0
7
7
  MINOR = 1
8
- TINY = 0
8
+ TINY = 1
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY].join('.')
11
11
  end
@@ -17,8 +17,8 @@ spec =
17
17
  s.post_install_message = POST_INSTALL_MESSAGE
18
18
 
19
19
  s.add_dependency('rake', '>=0.7.3')
20
- s.add_dependency('rspec', '>=0.9.1')
21
- s.add_dependency('rack', '>=0.1.0')
20
+ s.add_dependency('rspec', '>=1.0.2')
21
+ s.add_dependency('rack', '>=0.2.0')
22
22
  # s.required_ruby_version = '>= 1.8.5'
23
23
 
24
24
  s.files = (RDOC_FILES + %w[Rakefile] + Dir["{examples,bin,doc,spec,lib,rake_tasks}/**/*"]).uniq
@@ -119,7 +119,7 @@ task 'tutorial2html' do
119
119
 
120
120
  basefile = File.join('doc', 'tutorial', 'todolist')
121
121
 
122
- content = File.read(basefile + '.txt')
122
+ content = File.read(basefile + '.mkd')
123
123
 
124
124
  html = BlueCloth.new(content).to_html
125
125
 
@@ -156,6 +156,47 @@ task 'tutorial2html' do
156
156
  File.open(basefile + '.html', 'w+'){|f| f.puts(wrap) }
157
157
  end
158
158
 
159
+ task 'tutorial' => ['tutorial2html'] do
160
+ require 'hpricot'
161
+
162
+ system 'rake tutorial2html'
163
+
164
+ filename = 'doc/tutorial/todolist.html'
165
+ file = File.read(filename)
166
+ doc = Hpricot(file)
167
+
168
+ to_links = []
169
+
170
+ (doc/:h2).each do |h2|
171
+ text = h2.inner_html
172
+ link_id = text.gsub(' ', '_')
173
+ to_links << %{<a href="##{link_id}">#{text}</a>}
174
+ to_link = %{<a name="#{link_id}"><h2>#{text}</h2></a>}
175
+
176
+ file.gsub!(h2.to_html, to_link)
177
+ end
178
+
179
+ links = to_links.join("</ol>\n <ol>")
180
+ h1 = "<h1>To-do List Tutorial</h1>"
181
+ menu =
182
+ %{
183
+ #{h1}
184
+
185
+ <div class="menu">
186
+ <h3>Table of Contents</h3>
187
+ <li>
188
+ <ol>#{links}</ol>
189
+ </li>
190
+ </div>
191
+ }
192
+
193
+ file.gsub!(h1, menu)
194
+
195
+ File.open(filename, 'w+') do |f|
196
+ f.puts file
197
+ end
198
+ end
199
+
159
200
  task 'authors' do
160
201
  changes = `darcs changes`
161
202
  authors = []
@@ -0,0 +1,45 @@
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 'rake'
5
+ require 'spec/helper/layout'
6
+ require 'lib/ramaze/snippets/string/DIVIDE'
7
+
8
+ SPEC_BASE = File.expand_path('spec')
9
+
10
+ # ignore files with these paths
11
+ ignores = [ './*', './helper/*', './ramaze/adapter.rb', './ramaze/request.rb', ]
12
+
13
+ files = Dir[SPEC_BASE/'**'/'*.rb']
14
+ ignores.each do |ignore|
15
+ ignore_files = Dir[SPEC_BASE/ignore]
16
+ ignore_files.each do |ignore_file|
17
+ files.delete File.expand_path(ignore_file)
18
+ end
19
+ end
20
+
21
+ files.sort!
22
+
23
+ spec_layout = Hash.new{|h,k| h[k] = []}
24
+
25
+ files.each do |file|
26
+ name = file.gsub(/^#{SPEC_BASE}/, '.')
27
+ dir_name = File.dirname(name)[2..-1]
28
+ task_name = ([:test] + dir_name.split('/')).join(':')
29
+ spec_layout[task_name] << file
30
+ end
31
+
32
+ spec_layout.each do |task_name, specs|
33
+
34
+ desc task_name
35
+ task task_name => [:clean] do
36
+ wrap = SpecWrap.new(*specs)
37
+ wrap.run
38
+ end
39
+ end
40
+
41
+ desc "Test all"
42
+ task "test:all" => [:clean] do
43
+ wrap = SpecWrap.new(*spec_layout.values.flatten)
44
+ wrap.run
45
+ end