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
@@ -7,8 +7,7 @@ module Ramaze
7
7
  # applications in Ramaze. It acts as a nice wrapper around Innate::Node and
8
8
  # allows for a more traditional MVC approach.
9
9
  #
10
- # == Example
11
- #
10
+ # @example An example controller
12
11
  # class Posts < Ramaze::Controller
13
12
  # map '/posts'
14
13
  #
@@ -1,4 +1,15 @@
1
1
  module Ramaze
2
+ # Array containing gems that aren't supported for certain reasons. The gems
3
+ # that are in this array by default will be removed if the current setup
4
+ # *does* support them.
5
+ UNSUPPORTED_GEMS = [
6
+ 'lokar',
7
+ 'localmemcache',
8
+ 'ruby-growl',
9
+ 'nagoro',
10
+ 'syslog'
11
+ ]
12
+
2
13
  # Array containing the names and versions of all the gems required by Ramaze
3
14
  # along with the name of how the gem should be required.
4
15
  DEPENDENCIES = [
@@ -17,10 +28,8 @@ module Ramaze
17
28
  {:name => 'hpricot' , :version => ['>= 0.8.4']},
18
29
  {:name => 'liquid' , :version => ['>= 2.2.2']},
19
30
  {:name => 'locale' , :version => ['>= 2.0.5']},
20
- {:name => 'lokar' , :version => ['>= 0.2.1']},
21
31
  {:name => 'maruku' , :version => ['>= 0.6.0']},
22
32
  {:name => 'mustache' , :version => ['>= 0.99.4']},
23
- {:name => 'nagoro' , :version => ['>= 2009.05']},
24
33
  {:name => 'rack-contrib', :version => ['>= 1.1.0'], :lib => 'rack/contrib'},
25
34
  {:name => 'rack-test' , :version => ['>= 0.6.0'], :lib => 'rack/test'},
26
35
  {:name => 'Remarkably' , :version => ['>= 0.6.1'], :lib => 'remarkably'},
@@ -30,17 +39,45 @@ module Ramaze
30
39
  {:name => 'tagz' , :version => ['>= 9.0.0']},
31
40
  {:name => 'tenjin' , :version => ['>= 0.6.1']},
32
41
  {:name => 'yard' , :version => ['>= 0.7.2']},
42
+ {:name => 'redis' , :version => ['>= 2.2.2']},
43
+ {:name => 'rdiscount' , :version => ['>= 1.6.8']}
33
44
  ]
34
45
 
35
- if !RUBY_PLATFORM.include?('darwin')
46
+ # Lokar requires Ruby >= 1.9
47
+ if RUBY_VERSION.to_f >= 1.9
48
+ DEVELOPMENT_DEPENDENCIES.push({:name => 'lokar', :version => ['>= 0.2.1']})
49
+ UNSUPPORTED_GEMS.delete('lokar')
50
+ end
51
+
52
+ # LocalMemcache doesn't work on Mac OS X or jruby.
53
+ if !RUBY_DESCRIPTION.include?('jruby') and !RUBY_PLATFORM.include?('darwin')
36
54
  DEVELOPMENT_DEPENDENCIES.push(
37
55
  {:name => 'localmemcache', :version => ['>= 0.4.4']}
38
56
  )
57
+
58
+ UNSUPPORTED_GEMS.delete('localmemcache')
39
59
  end
40
60
 
61
+ # Ruby-growl, requiring Growl, only works on Mac OS X.
41
62
  if RUBY_PLATFORM.include?('darwin')
42
63
  DEVELOPMENT_DEPENDENCIES.push(
43
64
  {:name => 'ruby-growl', :version => ['>= 3.0']}
44
65
  )
66
+
67
+ UNSUPPORTED_GEMS.delete('ruby-growl')
68
+ end
69
+
70
+ # Nagoro doesn't seem to work on Rbx
71
+ if !RUBY_DESCRIPTION.include?('rubinius')
72
+ DEVELOPMENT_DEPENDENCIES.push(
73
+ {:name => 'nagoro', :version => ['>= 2009.05']}
74
+ )
75
+
76
+ UNSUPPORTED_GEMS.delete('nagoro')
77
+ end
78
+
79
+ # Syslog uses forking which apparently isn't available on jruby.
80
+ if !RUBY_DESCRIPTION.include?('jruby')
81
+ UNSUPPORTED_GEMS.delete('syslog')
45
82
  end
46
83
  end # Ramaze
@@ -2,10 +2,14 @@ require 'benchmark'
2
2
 
3
3
  module Ramaze
4
4
  module Helper
5
-
6
- # Little helper to give you a hand when benching parts of actions
5
+ ##
6
+ # The Benchmark helper is a simple helper that can be used to benchmark
7
+ # certain blocks of code by wrapping them in a block. This can be useful if
8
+ # you want to see how long a certain query takes or how long it takes to
9
+ # create a new user.
10
+ #
7
11
  module Bench
8
-
12
+ ##
9
13
  # Will first run an empty loop to determine the overhead it imposes, then
10
14
  # goes on to yield your block +iterations+ times.
11
15
  #
@@ -15,27 +19,33 @@ module Ramaze
15
19
  #
16
20
  # Example:
17
21
  #
18
- # class MainController < Ramaze::Controller
19
- # def index
20
- # @users = bench{ User.all }
21
- # @tags = bench{ Article.tags }
22
+ # class MainController < Ramaze::Controller
23
+ # def index
24
+ # @users = bench{ User.all }
25
+ # @tags = bench{ Article.tags }
26
+ # end
22
27
  # end
23
- # end
24
28
  #
25
29
  # This will show something like following in your log:
26
- # [..] INFO Bench ./start.rb:3:in `index': 0.121163845062256
27
- # [..] INFO Bench ./start.rb:4:in `index': 2.234987235098341
30
+ #
31
+ # [..] INFO Bench ./start.rb:3:in `index': 0.121163845062256
32
+ # [..] INFO Bench ./start.rb:4:in `index': 2.234987235098341
28
33
  #
29
34
  # So now we know that the Article.tags call takes the most time and
30
35
  # should be improved.
36
+ #
37
+ # @param [Fixnum] iterations The amount of iterations to run.
38
+ # @return [Mixed]
39
+ #
31
40
  def bench(iterations = 1)
32
41
  result = nil
33
- from = caller[0]
34
- delta = Benchmark.realtime{ iterations.times{ nil }}
35
- taken = Benchmark.realtime{ iterations.times{ result = yield }}
42
+ from = caller[0]
43
+ delta = Benchmark.realtime{ iterations.times{ nil }}
44
+ taken = Benchmark.realtime{ iterations.times{ result = yield }}
45
+
36
46
  Log.info "Bench #{from}: #{taken - delta}"
37
47
  return result
38
48
  end
39
- end
40
- end
41
- end
49
+ end # Bench
50
+ end # Helper
51
+ end # Ramaze
@@ -4,34 +4,13 @@ require 'ramaze/gestalt'
4
4
  module Ramaze
5
5
  module Helper
6
6
  ##
7
- # == Introduction
8
- #
9
7
  # The BlueForm helper tries to be an even better way to build forms
10
- # programmatically. By using a simple block you can quickly create all the
8
+ # programmatically. By using a simple block you can quickly create all the
11
9
  # required elements for your form.
12
10
  #
13
- # Since November 2010 the BlueForm helper works different. You can now
14
- # specify an object as the first parameter of the form_for() method. This
15
- # object will be used to retrieve the values of each field. This means that
16
- # you can directly pass a database result object to the form and no longer
17
- # have to manually specify values. However, you can still specify your own
18
- # values if you want.
19
- #
20
- # Old behaviour:
21
- #
22
- # form_for(:method => :post) do |f|
23
- # f.input_text 'Username', :username, 'Chuck Norris'
24
- # end
25
- #
26
- # New behaviour:
11
+ # See {Ramaze::Helper::BlueForm::Form} for all the available methods.
27
12
  #
28
- # # @data is an object that contains an instance variable named "username".
29
- # # This variable contains the value "Chuck Norris".
30
- # form_for(@data, :method => :post) do |f|
31
- # f.input_text 'Username', :username
32
- # end
33
- #
34
- # == Form Data
13
+ # ## Form Data
35
14
  #
36
15
  # As stated earlier it's possible to pass an object to the form_for()
37
16
  # method. What kind of object this is, a database result object or an
@@ -40,16 +19,16 @@ module Ramaze
40
19
  # extremely easy to directly pass a result object from your favourite ORM.
41
20
  # Example:
42
21
  #
43
- # @data = User[1]
22
+ # @data = User[1]
44
23
  #
45
- # form_for(@data, :method => :post) do |f|
46
- # f.input_text 'Username', :username
47
- # end
24
+ # form_for(@data, :method => :post) do |f|
25
+ # f.input_text 'Username', :username
26
+ # end
48
27
  #
49
28
  # If you don't want to use an object you can simply set the first parameter
50
29
  # to nil.
51
30
  #
52
- # == HTML Output
31
+ # ## HTML Output
53
32
  #
54
33
  # The form helper uses Gestalt, Ramaze's custom HTML builder that works
55
34
  # somewhat like Erector. The output is very minimalistic, elements such as
@@ -61,14 +40,11 @@ module Ramaze
61
40
  # directly. When using Etanni this would result in something like the
62
41
  # following:
63
42
  #
64
- # #{
65
- # form_for(@result, :method => :post) do |f| do
66
- # f.input_text 'Text label', :textname, 'Chunky bacon!'
67
- # end
68
- # }
69
- #
70
- # @example
43
+ # #{form_for(@result, :method => :post) do |f| do
44
+ # f.input_text 'Text label', :textname, 'Chunky bacon!'
45
+ # end}
71
46
  #
47
+ # @example Creating a basic form
72
48
  # form_for(@data, :method => :post) do |f|
73
49
  # f.input_text 'Username', :username
74
50
  # end
@@ -197,7 +173,6 @@ module Ramaze
197
173
  #
198
174
  # @param [String] text The text to display inside the legend tag.
199
175
  # @example
200
- #
201
176
  # form_for(@data, :method => :post) do |f|
202
177
  # f.legend 'Ramaze rocks!'
203
178
  # end
@@ -211,7 +186,6 @@ module Ramaze
211
186
  #
212
187
  # @param [Block] &block The form elements to display inside the fieldset.
213
188
  # @example
214
- #
215
189
  # form_for(@data, :method => :post) do |f|
216
190
  # f.fieldset do
217
191
  # f.legend 'Hello, world!'
@@ -232,7 +206,6 @@ module Ramaze
232
206
  # @param [Hash] args Any additional HTML attributes along with their
233
207
  # values.
234
208
  # @example
235
- #
236
209
  # form_for(@data, :method => :post) do |f|
237
210
  # f.input_text 'Username', :username
238
211
  # end
@@ -264,7 +237,6 @@ module Ramaze
264
237
  # @param [Hash] args Any additional HTML attributes along with their
265
238
  # values.
266
239
  # @example
267
- #
268
240
  # form_for(@data, :method => :post) do |f|
269
241
  # f.input_password 'My password', :password
270
242
  # end
@@ -293,7 +265,6 @@ module Ramaze
293
265
  # @param [Hash] args Any additional HTML attributes along with their
294
266
  # values.
295
267
  # @example
296
- #
297
268
  # form_for(@data, :method => :post) do |f|
298
269
  # f.input_submit 'Save'
299
270
  # end
@@ -316,20 +287,20 @@ module Ramaze
316
287
  # for each checkbox. When using a hash the key will be displayed and
317
288
  # the value will be the value of the checkbox. Example:
318
289
  #
319
- # @data = Class.new
320
- # attr_reader :gender_arr
321
- # attr_reader :gender_hash
290
+ # @data = Class.new
291
+ # attr_reader :gender_arr
292
+ # attr_reader :gender_hash
322
293
  #
323
- # def initialize
324
- # @gender_arr = ['male', 'female']
325
- # @gender_hash = {"Male" => "male", "Female" => "female"}
326
- # end
327
- # end.new
294
+ # def initialize
295
+ # @gender_arr = ['male', 'female']
296
+ # @gender_hash = {"Male" => "male", "Female" => "female"}
297
+ # end
298
+ # end.new
328
299
  #
329
- # form_for(@data, :method => :post) do |f|
330
- # f.input_checkbox "Gender", :gender_arr
331
- # f.input_checkbox "Gender", :gender_hash
332
- # end
300
+ # form_for(@data, :method => :post) do |f|
301
+ # f.input_checkbox "Gender", :gender_arr
302
+ # f.input_checkbox "Gender", :gender_hash
303
+ # end
333
304
  #
334
305
  # @example
335
306
  # form_for(@data, :method => :post) do |f|
@@ -338,8 +309,8 @@ module Ramaze
338
309
  #
339
310
  # @param [String] label The text to display inside the label tag.
340
311
  # @param [String Symbol] name The name of the checkbox.
341
- # @param [String] checked String that indicates if (and which) checkbox
342
- # should be checked.
312
+ # @param [String/Array] checked String or array that indicates which
313
+ # value(s) should be checked.
343
314
  # @param [Hash] args Any additional HTML attributes along with their
344
315
  # values.
345
316
  # @option args [String/Symbol] :id The value to use for the ID attribute.
@@ -430,8 +401,14 @@ module Ramaze
430
401
  end
431
402
 
432
403
  # Let's see if the current item is checked
433
- if checkbox_value == checked
434
- opts[:checked] = 'checked'
404
+ if checked.class == Array
405
+ if checked.include?(checkbox_value)
406
+ opts[:checked] = 'checked'
407
+ end
408
+ else
409
+ if checkbox_value == checked
410
+ opts[:checked] = 'checked'
411
+ end
435
412
  end
436
413
 
437
414
  # And we're done, easy wasn't it?
@@ -462,20 +439,20 @@ module Ramaze
462
439
  # If you want to generate multiple radio buttons you can use an array
463
440
  # just like you can with checkboxes. Example:
464
441
  #
465
- # @data = Class.new
466
- # attr_reader :gender_arr
467
- # attr_reader :gender_hash
442
+ # @data = Class.new
443
+ # attr_reader :gender_arr
444
+ # attr_reader :gender_hash
468
445
  #
469
- # def initialize
470
- # @gender_arr = ['male', 'female']
471
- # @gender_hash = {"Male" => "male", "Female" => "female"}
472
- # end
473
- # end.new
446
+ # def initialize
447
+ # @gender_arr = ['male', 'female']
448
+ # @gender_hash = {"Male" => "male", "Female" => "female"}
449
+ # end
450
+ # end.new
474
451
  #
475
- # form_for(@data, :method => :post) do |f|
476
- # f.input_radio "Gender", :gender_arr
477
- # f.input_radio "Gender", :gender_hash
478
- # end
452
+ # form_for(@data, :method => :post) do |f|
453
+ # f.input_radio "Gender", :gender_arr
454
+ # f.input_radio "Gender", :gender_hash
455
+ # end
479
456
  #
480
457
  # For more information see the input_checkbox() method.
481
458
  #
@@ -511,7 +488,6 @@ module Ramaze
511
488
  # @param [Hash] args Any additional HTML attributes along with their
512
489
  # values.
513
490
  # @example
514
- #
515
491
  # form_for(@data, :method => :post) do |f|
516
492
  # f.input_file 'Image', :image
517
493
  # end
@@ -536,7 +512,6 @@ module Ramaze
536
512
  # @param [Hash] args Any additional HTML attributes along with their
537
513
  # values.
538
514
  # @example
539
- #
540
515
  # form_for(@data, :method => :post) do |f|
541
516
  # f.input_hidden :user_id
542
517
  # end
@@ -562,7 +537,6 @@ module Ramaze
562
537
  # @param [Hash] args Any additional HTML attributes along with their
563
538
  # values.
564
539
  # @example
565
- #
566
540
  # form_for(@data, :method => :post) do |f|
567
541
  # f.textarea 'Description', :description
568
542
  # end
@@ -593,7 +567,6 @@ module Ramaze
593
567
  # @param [String Symbol] name The name of the select tag.
594
568
  # @param [Hash] args Hash containing additional HTML attributes.
595
569
  # @example
596
- #
597
570
  # form_for(@data, :method => :post) do |f|
598
571
  # f.select 'Country', :country_list
599
572
  # end
@@ -3,15 +3,16 @@
3
3
 
4
4
  module Ramaze
5
5
  module Helper
6
-
6
+ ##
7
7
  # Caching of simple objects and whole action responses.
8
+ #
8
9
  module Cache
9
-
10
10
  # Setup needed traits, add the singleton methods and add the caches used
11
11
  # by this helper.
12
12
  #
13
13
  # @param [Class] into Class that this Module is included into
14
14
  # @author manveru
15
+ #
15
16
  def self.included(into)
16
17
  into.extend(SingletonMethods)
17
18
  into.add_action_wrapper(6.0, :cache_wrap)
@@ -19,11 +20,13 @@ module Ramaze
19
20
  Ramaze::Cache.add(:action, :cache_helper_value)
20
21
  end
21
22
 
23
+ ##
22
24
  # @param [Action] action The currently wrapped action
23
25
  # @yield The next block in wrap_action_call
24
26
  # @return [String] the response body
25
27
  # @see Innate::Node#wrap_action_call
26
28
  # @author manveru
29
+ #
27
30
  def cache_wrap(action)
28
31
  cache = Innate::Cache.action
29
32
 
@@ -58,6 +61,7 @@ module Ramaze
58
61
  yield
59
62
  end
60
63
 
64
+ ##
61
65
  # This method is used to access Ramaze::Cache.cache_helper_value.
62
66
  # It provides an easy way to cache long-running computations, gathering
63
67
  # external resources like RSS feeds or DB queries that are the same for
@@ -78,6 +82,7 @@ module Ramaze
78
82
  # @return [Object] The cache wrapper assigned for :cache_helper_value
79
83
  # @see Innate::Cache
80
84
  # @author manveru
85
+ #
81
86
  def cache_value(key = nil, options = {})
82
87
  cache = Ramaze::Cache.cache_helper_value
83
88
 
@@ -96,7 +101,6 @@ module Ramaze
96
101
  # This method allows you to cache whole actions.
97
102
  #
98
103
  # @example Basic usage
99
- #
100
104
  # class Foo < Ramaze::Controller
101
105
  # helper :cache
102
106
  # cache_action :method => :bar
@@ -112,6 +116,6 @@ module Ramaze
112
116
  trait[:cache_action] << hash
113
117
  end
114
118
  end
115
- end
116
- end
117
- end
119
+ end # Cache
120
+ end # Helper
121
+ end # Ramaze