magic_form 0.1.1 → 0.1.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.
data/Rakefile CHANGED
@@ -15,8 +15,8 @@ Jeweler::Tasks.new do |gem|
15
15
  gem.name = "magic_form"
16
16
  gem.homepage = "http://github.com/MGalv/magic_form"
17
17
  gem.license = "MIT"
18
- gem.summary = %Q{Generate a form using a specific resource}
19
- gem.description = %Q{Generate a form using a specific resource}
18
+ gem.summary = %Q{Form builder. The laziest way to implement a Form}
19
+ gem.description = %Q{Form builder. The laziest way to implement a Form}
20
20
  gem.email = "luis.galaviz@crowdint.com"
21
21
  gem.authors = ["Luis Galaviz"]
22
22
  # Include your dependencies below. Runtime dependencies are required when using your gem,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -8,29 +8,19 @@ module ActionView
8
8
  include FormHelper
9
9
 
10
10
  def magic_form(*resources)
11
- form_content = ""
12
- form_eval = []
13
- out = ""
14
11
  options = resources.extract_options!
15
12
  resource = resources.last
16
- resource.attribute_names.each do |attribute|
17
- unless attribute == "created_at" || attribute == "updated_at"
18
- form_eval << "f.label '#{options[attribute.to_sym] || attribute.to_sym}'"
19
- form_eval << "f.text_field :#{attribute}"
13
+ attributes = resource.attribute_names - ["created_at", "updated_at"]
14
+
15
+ form_for(resources) do |f|
16
+ attributes.each do |attribute|
17
+ concat(f.label attribute, options[attribute.to_sym])
18
+ concat(f.text_field attribute)
20
19
  end
20
+ concat(f.submit)
21
21
  end
22
-
23
- form_eval << "f.submit '#{options[:submit] || 'submit' }'"
24
- out = form_for resources do |f|
25
- form_eval.each do |c|
26
- form_content << "#{eval(c)}"
27
- end
28
- form_content
29
- end
30
- out
31
22
  end
32
23
  end
33
-
34
24
  end
35
25
 
36
26
  ActionView::Helpers.autoload :MagicFormHelper
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{magic_form}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Luis Galaviz"]
12
- s.date = %q{2010-12-01}
13
- s.description = %q{Generate a form using a specific resource}
12
+ s.date = %q{2010-12-02}
13
+ s.description = %q{Form builder. The laziest way to implement a Form}
14
14
  s.email = %q{luis.galaviz@crowdint.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.licenses = ["MIT"]
34
34
  s.require_paths = ["lib"]
35
35
  s.rubygems_version = %q{1.3.7}
36
- s.summary = %q{Generate a form using a specific resource}
36
+ s.summary = %q{Form builder. The laziest way to implement a Form}
37
37
  s.test_files = [
38
38
  "test/helper.rb",
39
39
  "test/test_magic_form.rb"
@@ -17,36 +17,26 @@ class MagicFormTest < ActionView::TestCase
17
17
  context "having a product create a form with the Product attributes" do
18
18
 
19
19
  should "work with no options" do
20
- assert_equal magic_form(@product),
21
- (form_for @product do |f|
22
- form_content = ""
23
- form_content << (f.label :name)
24
- form_content << (f.text_field :name)
25
- form_content << (f.submit 'submit')
26
- form_content
27
- end)
20
+ assert_equal "",
21
+ magic_form(@product)
28
22
  end
29
23
 
30
24
  should "work with options" do
31
- assert_equal magic_form(@product, :name => "Product name: "),
32
- (form_for @product do |f|
33
- form_content = ""
34
- form_content << (f.label "Product name: ")
35
- form_content << (f.text_field :name)
36
- form_content << (f.submit 'submit')
37
- form_content
38
- end)
25
+ assert_equal (form_for @product do |f|
26
+ concat(f.label :name, "Product name: ")
27
+ concat(f.text_field :name)
28
+ concat(f.submit)
29
+ end),
30
+ magic_form(@product, :name => "Product name: ")
39
31
  end
40
32
 
41
33
  should "play nice with nested resources" do
42
- assert_equal magic_form(:admin, @product),
43
- (form_for [:admin, @product] do |f|
44
- form_content = ""
45
- form_content << (f.label :name)
46
- form_content << (f.text_field :name)
47
- form_content << (f.submit 'submit')
48
- form_content
49
- end)
34
+ assert_equal (form_for [:admin, @product] do |f|
35
+ concat(f.label :name)
36
+ concat(f.text_field :name)
37
+ concat(f.submit)
38
+ end),
39
+ magic_form(:admin, @product)
50
40
  end
51
41
  end
52
42
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luis Galaviz
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-01 00:00:00 -06:00
17
+ date: 2010-12-02 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -112,7 +112,7 @@ dependencies:
112
112
  type: :development
113
113
  prerelease: false
114
114
  version_requirements: *id007
115
- description: Generate a form using a specific resource
115
+ description: Form builder. The laziest way to implement a Form
116
116
  email: luis.galaviz@crowdint.com
117
117
  executables: []
118
118
 
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- hash: 1201021153162256010
150
+ hash: 2050444690164462371
151
151
  segments:
152
152
  - 0
153
153
  version: "0"
@@ -165,7 +165,7 @@ rubyforge_project:
165
165
  rubygems_version: 1.3.7
166
166
  signing_key:
167
167
  specification_version: 3
168
- summary: Generate a form using a specific resource
168
+ summary: Form builder. The laziest way to implement a Form
169
169
  test_files:
170
170
  - test/helper.rb
171
171
  - test/test_magic_form.rb