public
Fork of rails/rails
Description: Ruby on Rails - forked for implementing I18n patch
Homepage: http://rubyonrails.org
Clone URL: git://github.com/svenfuchs/rails.git
Merge docrails
lifo (author)
Sat Sep 13 12:28:01 -0700 2008
commit  a17027d13a48e1e64b14a28e7d58e341812f8cb4
tree    09699984d7a4f612689f19e3e0ccb663ae207d3f
parent  96055414d6197b9705e408c17236f79372a007e5
...
10
11
12
13
 
14
15
16
17
18
19
20
 
21
22
23
24
25
26
 
27
28
29
 
30
31
32
 
33
34
35
 
36
37
38
 
39
40
41
...
67
68
69
70
 
71
72
73
 
74
75
76
 
77
78
79
...
104
105
106
107
 
108
109
110
 
111
112
113
 
114
115
116
117
118
119
 
120
121
122
...
10
11
12
 
13
14
15
16
17
18
19
 
20
21
22
23
24
25
 
26
27
28
 
29
30
31
 
32
33
34
 
35
36
37
 
38
39
40
41
...
67
68
69
 
70
71
72
 
73
74
75
 
76
77
78
79
...
104
105
106
 
107
108
109
 
110
111
112
 
113
114
115
116
117
118
 
119
120
121
122
0
@@ -10,32 +10,32 @@ module ActionController
0
       # and a :method containing the required HTTP verb.
0
       #
0
       # # assert that POSTing to /items will call the create action on ItemsController
0
- # assert_recognizes({:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post})
0
+ # assert_recognizes {:controller => 'items', :action => 'create'}, {:path => 'items', :method => :post}
0
       #
0
       # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
0
       # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
0
       # extras argument, appending the query string on the path directly will not work. For example:
0
       #
0
       # # assert that a path of '/items/list/1?view=print' returns the correct options
0
- # assert_recognizes({:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" })
0
+ # assert_recognizes {:controller => 'items', :action => 'list', :id => '1', :view => 'print'}, 'items/list/1', { :view => "print" }
0
       #
0
       # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
0
       #
0
       # ==== Examples
0
       # # Check the default route (i.e., the index action)
0
- # assert_recognizes({:controller => 'items', :action => 'index'}, 'items')
0
+ # assert_recognizes {:controller => 'items', :action => 'index'}, 'items'
0
       #
0
       # # Test a specific action
0
- # assert_recognizes({:controller => 'items', :action => 'list'}, 'items/list')
0
+ # assert_recognizes {:controller => 'items', :action => 'list'}, 'items/list'
0
       #
0
       # # Test an action with a parameter
0
- # assert_recognizes({:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1')
0
+ # assert_recognizes {:controller => 'items', :action => 'destroy', :id => '1'}, 'items/destroy/1'
0
       #
0
       # # Test a custom route
0
- # assert_recognizes({:controller => 'items', :action => 'show', :id => '1'}, 'view/item1')
0
+ # assert_recognizes {:controller => 'items', :action => 'show', :id => '1'}, 'view/item1'
0
       #
0
       # # Check a Simply RESTful generated route
0
- # assert_recognizes(list_items_url, 'items/list')
0
+ # assert_recognizes list_items_url, 'items/list'
0
       def assert_recognizes(expected_options, path, extras={}, message=nil)
0
         if path.is_a? Hash
0
           request_method = path[:method]
0
@@ -67,13 +67,13 @@ module ActionController
0
       #
0
       # ==== Examples
0
       # # Asserts that the default action is generated for a route with no action
0
- # assert_generates("/items", :controller => "items", :action => "index")
0
+ # assert_generates "/items", :controller => "items", :action => "index"
0
       #
0
       # # Tests that the list action is properly routed
0
- # assert_generates("/items/list", :controller => "items", :action => "list")
0
+ # assert_generates "/items/list", :controller => "items", :action => "list"
0
       #
0
       # # Tests the generation of a route with a parameter
0
- # assert_generates("/items/list/1", { :controller => "items", :action => "list", :id => "1" })
0
+ # assert_generates "/items/list/1", { :controller => "items", :action => "list", :id => "1" }
0
       #
0
       # # Asserts that the generated route gives us our custom route
0
       # assert_generates "changesets/12", { :controller => 'scm', :action => 'show_diff', :revision => "12" }
0
@@ -104,19 +104,19 @@ module ActionController
0
       #
0
       # ==== Examples
0
       # # Assert a basic route: a controller with the default action (index)
0
- # assert_routing('/home', :controller => 'home', :action => 'index')
0
+ # assert_routing '/home', :controller => 'home', :action => 'index'
0
       #
0
       # # Test a route generated with a specific controller, action, and parameter (id)
0
- # assert_routing('/entries/show/23', :controller => 'entries', :action => 'show', id => 23)
0
+ # assert_routing '/entries/show/23', :controller => 'entries', :action => 'show', id => 23
0
       #
0
       # # Assert a basic route (controller + default action), with an error message if it fails
0
- # assert_routing('/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly')
0
+ # assert_routing '/store', { :controller => 'store', :action => 'index' }, {}, {}, 'Route for store index not generated properly'
0
       #
0
       # # Tests a route, providing a defaults hash
0
       # assert_routing 'controller/action/9', {:id => "9", :item => "square"}, {:controller => "controller", :action => "action"}, {}, {:item => "square"}
0
       #
0
       # # Tests a route with a HTTP method
0
- # assert_routing({ :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" })
0
+ # assert_routing { :method => 'put', :path => '/product/321' }, { :controller => "product", :action => "update", :id => "321" }
0
       def assert_routing(path, options, defaults={}, extras={}, message=nil)
0
         assert_recognizes(options, path, extras, message)
0
 
...
95
96
97
98
 
99
100
101
...
95
96
97
 
98
99
100
101
0
@@ -95,7 +95,7 @@ module ActionView
0
       # * <tt>:containment</tt> - Takes an element or array of elements to treat as
0
       # potential drop targets (defaults to the original target element).
0
       #
0
- # * <tt>:only</tt> - A CSS class name or arry of class names used to filter
0
+ # * <tt>:only</tt> - A CSS class name or array of class names used to filter
0
       # out child elements as candidates.
0
       #
0
       # * <tt>:scroll</tt> - Determines whether to scroll the list during drag
...
252
253
254
 
 
 
 
255
256
257
...
275
276
277
278
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
 
281
282
283
...
321
322
323
 
 
 
 
 
 
324
325
326
...
374
375
376
 
 
 
 
377
378
379
...
252
253
254
255
256
257
258
259
260
261
...
279
280
281
 
 
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
...
345
346
347
348
349
350
351
352
353
354
355
356
...
404
405
406
407
408
409
410
411
412
413
0
@@ -252,6 +252,10 @@ module ActiveRecord
0
     class IndexDefinition < Struct.new(:table, :name, :unique, :columns) #:nodoc:
0
     end
0
 
0
+ # Abstract representation of a column definition. Instances of this type
0
+ # are typically created by methods in TableDefinition, and added to the
0
+ # +columns+ attribute of said TableDefinition object, in order to be used
0
+ # for generating a number of table creation or table changing SQL statements.
0
     class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc:
0
 
0
       def sql_type
0
@@ -275,9 +279,29 @@ module ActiveRecord
0
         end
0
     end
0
 
0
- # Represents a SQL table in an abstract way.
0
- # Columns are stored as a ColumnDefinition in the +columns+ attribute.
0
+ # Represents the schema of an SQL table in an abstract way. This class
0
+ # provides methods for manipulating the schema representation.
0
+ #
0
+ # Inside migration files, the +t+ object in +create_table+ and
0
+ # +change_table+ is actually of this type:
0
+ #
0
+ # class SomeMigration < ActiveRecord::Migration
0
+ # def self.up
0
+ # create_table :foo do |t|
0
+ # puts t.class # => "ActiveRecord::ConnectionAdapters::TableDefinition"
0
+ # end
0
+ # end
0
+ #
0
+ # def self.down
0
+ # ...
0
+ # end
0
+ # end
0
+ #
0
+ # The table definitions
0
+ # The Columns are stored as a ColumnDefinition in the +columns+ attribute.
0
     class TableDefinition
0
+ # An array of ColumnDefinition objects, representing the column changes
0
+ # that have been defined.
0
       attr_accessor :columns
0
 
0
       def initialize(base)
0
@@ -321,6 +345,12 @@ module ActiveRecord
0
       # * <tt>:scale</tt> -
0
       # Specifies the scale for a <tt>:decimal</tt> column.
0
       #
0
+ # For clarity's sake: the precision is the number of significant digits,
0
+ # while the scale is the number of digits that can be stored following
0
+ # the decimal point. For example, the number 123.45 has a precision of 5
0
+ # and a scale of 2. A decimal with a precision of 5 and a scale of 2 can
0
+ # range from -999.99 to 999.99.
0
+ #
0
       # Please be aware of different RDBMS implementations behavior with
0
       # <tt>:decimal</tt> columns:
0
       # * The SQL standard says the default scale should be 0, <tt>:scale</tt> <=
0
@@ -374,6 +404,10 @@ module ActiveRecord
0
       # td.column(:huge_integer, :decimal, :precision => 30)
0
       # # => huge_integer DECIMAL(30)
0
       #
0
+ # # Defines a column with a database-specific type.
0
+ # td.column(:foo, 'polygon')
0
+ # # => foo polygon
0
+ #
0
       # == Short-hand examples
0
       #
0
       # Instead of calling +column+ directly, you can also work with the short-hand definitions for the default types.
...
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
33
...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
 
 
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -25,9 +25,30 @@ en-US:
0
         even: "must be even"
0
         # Append your own errors here or at the model/attributes scope.
0
 
0
+ # You can define own errors for models or model attributes.
0
+ # The values :model, :attribute and :value are always available for interpolation.
0
+ #
0
+ # For example,
0
+ # models:
0
+ # user:
0
+ # blank: "This is a custom blank message for {{model}}: {{attribute}}"
0
+ # attributes:
0
+ # login:
0
+ # blank: "This is a custom blank message for User login"
0
+ # Will define custom blank validation message for User model and
0
+ # custom blank validation message for login attribute of User model.
0
       models:
0
- # Overrides default messages
0
-
0
- attributes:
0
- # Overrides model and default messages.
0
+
0
+ # Translate model names. Used in Model.human_name().
0
+ #models:
0
+ # For example,
0
+ # user: "Dude"
0
+ # will translate User model name to "Dude"
0
+
0
+ # Translate model attribute names. Used in Model.human_attribute_name(attribute).
0
+ #attributes:
0
+ # For example,
0
+ # user:
0
+ # login: "Handle"
0
+ # will translate User attribute "login" as "Handle"
0
 
...
259
260
261
 
 
262
263
264
...
297
298
299
300
301
302
303
304
...
313
314
315
316
317
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
320
321
...
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
509
510
511
512
 
513
514
515
516
517
518
 
 
 
519
520
521
...
526
527
528
529
530
531
 
 
 
532
533
534
...
731
732
733
734
 
735
736
737
...
765
766
767
768
 
769
770
771
...
259
260
261
262
263
264
265
266
...
299
300
301
 
 
302
303
304
...
313
314
315
 
 
 
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
...
370
371
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
374
375
...
522
523
524
 
525
526
527
528
 
 
 
529
530
531
532
533
534
...
539
540
541
 
 
 
542
543
544
545
546
547
...
744
745
746
 
747
748
749
750
...
778
779
780
 
781
782
783
784
0
@@ -259,6 +259,8 @@ module ActiveRecord
0
   end
0
 
0
 
0
+ # Please do have a look at ActiveRecord::Validations::ClassMethods for a higher level of validations.
0
+ #
0
   # Active Records implement validation by overwriting Base#validate (or the variations, +validate_on_create+ and
0
   # +validate_on_update+). Each of these methods can inspect the state of the object, which usually means ensuring
0
   # that a number of attributes have a certain value (such as not empty, within a given range, matching a certain regular expression).
0
@@ -297,8 +299,6 @@ module ActiveRecord
0
   # person.save # => true (and person is now saved in the database)
0
   #
0
   # An Errors object is automatically created for every Active Record.
0
- #
0
- # Please do have a look at ActiveRecord::Validations::ClassMethods for a higher level of validations.
0
   module Validations
0
     VALIDATIONS = %w( validate validate_on_create validate_on_update )
0
 
0
@@ -313,9 +313,50 @@ module ActiveRecord
0
       base.define_callbacks *VALIDATIONS
0
     end
0
 
0
- # All of the following validations are defined in the class scope of the model that you're interested in validating.
0
- # They offer a more declarative way of specifying when the model is valid and when it is not. It is recommended to use
0
- # these over the low-level calls to +validate+ and +validate_on_create+ when possible.
0
+ # Active Record classes can implement validations in several ways. The highest level, easiest to read,
0
+ # and recommended approach is to use the declarative <tt>validates_..._of</tt> class methods (and
0
+ # +validates_associated+) documented below. These are sufficient for most model validations.
0
+ #
0
+ # Slightly lower level is +validates_each+. It provides some of the same options as the purely declarative
0
+ # validation methods, but like all the lower-level approaches it requires manually adding to the errors collection
0
+ # when the record is invalid.
0
+ #
0
+ # At a yet lower level, a model can use the class methods +validate+, +validate_on_create+ and +validate_on_update+
0
+ # to add validation methods or blocks. These are ActiveSupport::Callbacks and follow the same rules of inheritance
0
+ # and chaining.
0
+ #
0
+ # The lowest level style is to define the instance methods +validate+, +validate_on_create+ and +validate_on_update+
0
+ # as documented in ActiveRecord::Validations.
0
+ #
0
+ # == +validate+, +validate_on_create+ and +validate_on_update+ Class Methods
0
+ #
0
+ # Calls to these methods add a validation method or block to the class. Again, this approach is recommended
0
+ # only when the higher-level methods documented below (<tt>validates_..._of</tt> and +validates_associated+) are
0
+ # insufficient to handle the required validation.
0
+ #
0
+ # This can be done with a symbol pointing to a method:
0
+ #
0
+ # class Comment < ActiveRecord::Base
0
+ # validate :must_be_friends
0
+ #
0
+ # def must_be_friends
0
+ # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee)
0
+ # end
0
+ # end
0
+ #
0
+ # Or with a block which is passed the current record to be validated:
0
+ #
0
+ # class Comment < ActiveRecord::Base
0
+ # validate do |comment|
0
+ # comment.must_be_friends
0
+ # end
0
+ #
0
+ # def must_be_friends
0
+ # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee)
0
+ # end
0
+ # end
0
+ #
0
+ # This usage applies to +validate_on_create+ and +validate_on_update+ as well.
0
     module ClassMethods
0
       DEFAULT_VALIDATION_OPTIONS = {
0
         :on => :save,
0
@@ -329,34 +370,6 @@ module ActiveRecord
0
                                   :equal_to => '==', :less_than => '<', :less_than_or_equal_to => '<=',
0
                                   :odd => 'odd?', :even => 'even?' }.freeze
0
 
0
- # Adds a validation method or block to the class. This is useful when
0
- # overriding the +validate+ instance method becomes too unwieldy and
0
- # you're looking for more descriptive declaration of your validations.
0
- #
0
- # This can be done with a symbol pointing to a method:
0
- #
0
- # class Comment < ActiveRecord::Base
0
- # validate :must_be_friends
0
- #
0
- # def must_be_friends
0
- # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee)
0
- # end
0
- # end
0
- #
0
- # Or with a block which is passed the current record to be validated:
0
- #
0
- # class Comment < ActiveRecord::Base
0
- # validate do |comment|
0
- # comment.must_be_friends
0
- # end
0
- #
0
- # def must_be_friends
0
- # errors.add_to_base("Must be friends to leave a comment") unless commenter.friend_of?(commentee)
0
- # end
0
- # end
0
- #
0
- # This usage applies to +validate_on_create+ and +validate_on_update+ as well.
0
-
0
       # Validates each attribute against a block.
0
       #
0
       # class Person < ActiveRecord::Base
0
@@ -509,13 +522,13 @@ module ActiveRecord
0
       #
0
       # class Person < ActiveRecord::Base
0
       # validates_length_of :first_name, :maximum=>30
0
- # validates_length_of :last_name, :maximum=>30, :message=>"less than %d if you don't mind"
0
+ # validates_length_of :last_name, :maximum=>30, :message=>"less than {{count}} if you don't mind"
0
       # validates_length_of :fax, :in => 7..32, :allow_nil => true
0
       # validates_length_of :phone, :in => 7..32, :allow_blank => true
0
       # validates_length_of :user_name, :within => 6..20, :too_long => "pick a shorter name", :too_short => "pick a longer name"
0
- # validates_length_of :fav_bra_size, :minimum => 1, :too_short => "please enter at least %d character"
0
- # validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with %d characters... don't play me."
0
- # validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least %d words."), :tokenizer => lambda {|str| str.scan(/\w+/) }
0
+ # validates_length_of :fav_bra_size, :minimum => 1, :too_short => "please enter at least {{count}} character"
0
+ # validates_length_of :smurf_leader, :is => 4, :message => "papa is spelled with {{count}} characters... don't play me."
0
+ # validates_length_of :essay, :minimum => 100, :too_short => "Your essay must be at least {{count}} words."), :tokenizer => lambda {|str| str.scan(/\w+/) }
0
       # end
0
       #
0
       # Configuration options:
0
@@ -526,9 +539,9 @@ module ActiveRecord
0
       # * <tt>:in</tt> - A synonym(or alias) for <tt>:within</tt>.
0
       # * <tt>:allow_nil</tt> - Attribute may be +nil+; skip validation.
0
       # * <tt>:allow_blank</tt> - Attribute may be blank; skip validation.
0
- # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is %d characters)").
0
- # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is %d characters)").
0
- # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be %d characters)").
0
+ # * <tt>:too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is {{count}} characters)").
0
+ # * <tt>:too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is {{count}} characters)").
0
+ # * <tt>:wrong_length</tt> - The error message if using the <tt>:is</tt> method and the attribute is the wrong size (default is: "is the wrong length (should be {{count}} characters)").
0
       # * <tt>:message</tt> - The error message to use for a <tt>:minimum</tt>, <tt>:maximum</tt>, or <tt>:is</tt> violation. An alias of the appropriate <tt>too_long</tt>/<tt>too_short</tt>/<tt>wrong_length</tt> message.
0
       # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
0
       # * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
0
@@ -731,7 +744,7 @@ module ActiveRecord
0
       # class Person < ActiveRecord::Base
0
       # validates_inclusion_of :gender, :in => %w( m f ), :message => "woah! what are you then!??!!"
0
       # validates_inclusion_of :age, :in => 0..99
0
- # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension %s is not included in the list"
0
+ # validates_inclusion_of :format, :in => %w( jpg gif png ), :message => "extension {{value}} is not included in the list"
0
       # end
0
       #
0
       # Configuration options:
0
@@ -765,7 +778,7 @@ module ActiveRecord
0
       # class Person < ActiveRecord::Base
0
       # validates_exclusion_of :username, :in => %w( admin superuser ), :message => "You don't belong here"
0
       # validates_exclusion_of :age, :in => 30..60, :message => "This site is only for under 30 and over 60"
0
- # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension %s is not allowed"
0
+ # validates_exclusion_of :format, :in => %w( mov avi ), :message => "extension {{value}} is not allowed"
0
       # end
0
       #
0
       # Configuration options:
...
7
8
9
10
 
11
12
13
14
15
 
16
17
18
19
 
20
21
22
...
42
43
44
45
 
46
47
48
49
50
 
51
52
53
54
55
 
56
57
58
...
7
8
9
 
10
11
12
13
14
 
15
16
17
18
 
19
20
21
22
...
42
43
44
 
45
46
47
48
49
 
50
51
52
53
54
 
55
56
57
58
0
@@ -7,16 +7,16 @@ module ActiveSupport #:nodoc:
0
         # Splits or iterates over the array in groups of size +number+,
0
         # padding any remaining slots with +fill_with+ unless it is +false+.
0
         #
0
- # %w(1 2 3 4 5 6 7).in_groups_of(3) {|g| p g}
0
+ # %w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group}
0
         # ["1", "2", "3"]
0
         # ["4", "5", "6"]
0
         # ["7", nil, nil]
0
         #
0
- # %w(1 2 3).in_groups_of(2, '&nbsp;') {|g| p g}
0
+ # %w(1 2 3).in_groups_of(2, '&nbsp;') {|group| p group}
0
         # ["1", "2"]
0
         # ["3", "&nbsp;"]
0
         #
0
- # %w(1 2 3).in_groups_of(2, false) {|g| p g}
0
+ # %w(1 2 3).in_groups_of(2, false) {|group| p group}
0
         # ["1", "2"]
0
         # ["3"]
0
         def in_groups_of(number, fill_with = nil)
0
@@ -42,17 +42,17 @@ module ActiveSupport #:nodoc:
0
         # Splits or iterates over the array in +number+ of groups, padding any
0
         # remaining slots with +fill_with+ unless it is +false+.
0
         #
0
- # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|g| p g}
0
+ # %w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group}
0
         # ["1", "2", "3", "4"]
0
         # ["5", "6", "7", nil]
0
         # ["8", "9", "10", nil]
0
         #
0
- # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|g| p g}
0
+ # %w(1 2 3 4 5 6 7).in_groups(3, '&nbsp;') {|group| p group}
0
         # ["1", "2", "3"]
0
         # ["4", "5", "&nbsp;"]
0
         # ["6", "7", "&nbsp;"]
0
         #
0
- # %w(1 2 3 4 5 6 7).in_groups(3, false) {|g| p g}
0
+ # %w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group}
0
         # ["1", "2", "3"]
0
         # ["4", "5"]
0
         # ["6", "7"]
...
272
273
274
275
276
277
278
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
281
282
283
 
 
 
 
284
285
286
 
 
 
 
 
 
287
288
 
289
290
291
...
272
273
274
 
 
 
 
 
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
 
 
 
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
0
@@ -272,20 +272,49 @@ Rake::RDocTask.new { |rdoc|
0
   rdoc.rdoc_files.include('lib/commands/**/*.rb')
0
 }
0
 
0
-guides = ['securing_rails_applications', 'testing_rails_applications', 'creating_plugins']
0
-guides_html_files = []
0
-guides.each do |guide_name|
0
- input = "doc/guides/#{guide_name}/#{guide_name}.txt"
0
- output = "doc/guides/#{guide_name}/#{guide_name}.html"
0
+# In this array, one defines the guides for which HTML output should be
0
+# generated. Specify the folder names of the guides. If the .txt filename
0
+# doesn't equal its folder name, then specify a hash: { 'folder_name' => 'basename' }
0
+guides = [
0
+ 'getting_started_with_rails',
0
+ 'securing_rails_applications',
0
+ 'testing_rails_applications',
0
+ 'creating_plugins',
0
+ 'migrations',
0
+ { 'routing' => 'routing_outside_in' },
0
+ { 'forms' =>'form_helpers' },
0
+ { 'activerecord' => 'association_basics' },
0
+ { 'debugging' => 'debugging_rails_applications' }
0
+]
0
+
0
+guides_html_files = [] # autogenerated from the 'guides' variable.
0
+guides.each do |entry|
0
+ if entry.is_a?(Hash)
0
+ guide_folder = entry.keys.first
0
+ guide_name = entry.values.first
0
+ else
0
+ guide_folder = entry
0
+ guide_name = entry
0
+ end
0
+ input = "doc/guides/#{guide_folder}/#{guide_name}.txt"
0
+ output = "doc/guides/#{guide_folder}/#{guide_name}.html"
0
   guides_html_files << output
0
- file output => Dir["doc/guides/#{guide_name}/*.txt"] do
0
- sh "mizuho", input, "--template", "manualsonrails", "--multi-page",
0
- "--icons-dir", "../icons"
0
+ task output => Dir["doc/guides/#{guide_folder}/*.txt"] do
0
+ ENV['MANUALSONRAILS_INDEX_URL'] = '../index.html'
0
+ ENV.delete('MANUALSONRAILS_TOC')
0
+ sh "mizuho", input, "--template", "manualsonrails", "--icons-dir", "../icons"
0
   end
0
 end
0
 
0
+task 'doc/guides/index.html' => 'doc/guides/index.txt' do
0
+ ENV.delete('MANUALSONRAILS_INDEX_URL')
0
+ ENV['MANUALSONRAILS_TOC'] = 'no'
0
+ sh "mizuho", 'doc/guides/index.txt', "--template", "manualsonrails", "--icons-dir", "icons"
0
+end
0
+
0
 desc "Generate HTML output for the guides"
0
 task :generate_guides => guides_html_files
0
+task :generate_guides => 'doc/guides/index.html'
0
 
0
 # Generate GEM ----------------------------------------------------------------------------
0
 

Comments

    No one has commented yet.