formula 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Formula is a Rails form generator that generates simple clean markup. The project aims to let users create semantically beautiful forms without introducing too much syntax. The goal is to make integrating advanced layout systems (such as grid systems) as simple as possible.
4
4
 
5
+ == Requirements
6
+
7
+ The gem has only been tested with Ruby 1.9.2 and Rails 3.0.3 but may well work with other versions of Ruby and Rails.
8
+
5
9
  == Installation
6
10
 
7
11
  gem install formula
@@ -1,3 +1,3 @@
1
1
  module Formula
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/formula.rb CHANGED
@@ -80,10 +80,13 @@ module Formula
80
80
 
81
81
  components << @template.capture(&block)
82
82
 
83
- components << @template.content_tag(::Formula.hint_tag, options[:hint], :class => ::Formula.hint_class) if options[:hint]
83
+ options[:container] ||= {}
84
+ options[:container][:class] = arrayorize(options[:container][:class]) << ::Formula.block_class
85
+
86
+ components << @template.content_tag(::Formula.hint_tag , options[:hint ], :class => ::Formula.hint_class ) if options[:hint ]
84
87
  components << @template.content_tag(::Formula.error_tag, options[:error], :class => ::Formula.error_class) if options[:error]
85
88
 
86
- @template.content_tag(::Formula.block_tag, options[:container], :class => ::Formula.block_class) do
89
+ @template.content_tag(::Formula.block_tag, options[:container]) do
87
90
  components
88
91
  end
89
92
  end
@@ -264,27 +267,34 @@ module Formula
264
267
 
265
268
  # Generate error messages by combining all errors on an object into a comma seperated string
266
269
  # representation.
267
- #
268
- # Returns:
269
- #
270
- # * "name "
271
- # * :email - for string columns named 'email'
272
- # * :phone - for string columns named 'phone'
273
- # * :password - for string columns named 'password'
274
- # * :number - for integer, float, or decimal columns
275
- # * :text - for all other cases
276
270
 
277
271
  def error(method)
278
272
  @object.errors[method].to_sentence
279
273
  end
280
274
 
275
+
276
+ # Create an array from a string, a symbol, or an undefined value. The default is to return
277
+ # the value and assume it has already is valid.
278
+
279
+ def arrayorize(value)
280
+ case value
281
+ when nil then return []
282
+ when String then value.to_s.split
283
+ when Symbol then value.to_s.split
284
+ else value
285
+ end
286
+ end
287
+
288
+
281
289
  public
282
290
 
291
+
283
292
  def formula_fields_for(record_or_name_or_array, *args, &block)
284
293
  options = args.extract_options!
285
294
  options[:builder] ||= self.class
286
295
  fields_for(record_or_name_or_array, *(args << options), &block)
287
296
  end
297
+
288
298
 
289
299
  end
290
300
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kevin Sylvestre
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-22 00:00:00 -05:00
17
+ date: 2010-12-27 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies: []
20
20