david-former 0.0.1 → 0.0.2

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 (4) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/former.rb +21 -21
  3. data/spec/former_spec.rb +2 -2
  4. metadata +1 -1
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 1
3
+ :patch: 2
4
4
  :major: 0
@@ -1,8 +1,9 @@
1
1
  gem 'actionpack'; require 'action_view'
2
2
 
3
- class StandardFormBuilder < ActionView::Helpers::FormBuilder
4
- %w(text_field text_area file_field).each do |field_type|
5
- self.class_eval <<-RUBY
3
+ module Former
4
+ class FormBuilder < ActionView::Helpers::FormBuilder
5
+ %w(text_field text_area file_field).each do |field_type|
6
+ self.class_eval <<-RUBY
6
7
  def #{field_type}(name, options = {})
7
8
  str = ""
8
9
 
@@ -16,26 +17,25 @@ class StandardFormBuilder < ActionView::Helpers::FormBuilder
16
17
 
17
18
  str << super(name, options)
18
19
  end
19
- RUBY
20
- end
21
-
22
- def radio_button_group(name, values, *args)
23
- options = Hash === args.last ? args.pop : {}
20
+ RUBY
21
+ end
22
+
23
+ def radio_button_group(name, values, *args)
24
+ options = Hash === args.last ? args.pop : {}
25
+
26
+ result = values.inject("") do |html, value|
27
+ label = label("#{name}_#{value}", value)
28
+ rb = radio_button(name, value)
29
+ unless options[:label_position] == :after
30
+ content = "#{label} #{rb}"
31
+ else
32
+ content = "#{rb} #{label}"
33
+ end
24
34
 
25
- result = values.inject("") do |html, value|
26
- label = label("#{name}_#{value}", value)
27
- rb = radio_button(name, value)
28
- unless options[:label_position] == :after
29
- content = "#{label} #{rb}"
30
- else
31
- content = "#{rb} #{label}"
35
+ html << "<li>#{content}</li>"
32
36
  end
33
-
34
- html << "<li>#{content}</li>"
37
+
38
+ "<ul>#{result}</ul>"
35
39
  end
36
-
37
- "<ul>#{result}</ul>"
38
40
  end
39
41
  end
40
-
41
- ActionView::Base.default_form_builder = StandardFormBuilder
@@ -1,10 +1,10 @@
1
1
  require File.join(File.dirname(__FILE__), %w(spec_helper))
2
2
 
3
- describe StandardFormBuilder do
3
+ describe Former::FormBuilder do
4
4
  before do
5
5
  @template = mock("template")
6
6
  @object = mock("model")
7
- @fb = StandardFormBuilder.new(:model, @object, @template, {}, nil)
7
+ @fb = Former::FormBuilder.new(:model, @object, @template, {}, nil)
8
8
  end
9
9
 
10
10
  %w(text_field text_area file_field).each do |field_type|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: david-former
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Leal