generic_form_for 0.0.1

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 (150) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +123 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.textile +217 -0
  8. data/Rakefile +52 -0
  9. data/VERSION +1 -0
  10. data/generic_form_for.gemspec +232 -0
  11. data/generic_form_for.tmproj +166 -0
  12. data/lib/generators/generic_form_for/form_builder/form_builder_generator.rb +16 -0
  13. data/lib/generators/generic_form_for/form_builder/templates/form_builder.erb +37 -0
  14. data/lib/generators/generic_form_for/form_builder/templates/helper.erb +15 -0
  15. data/lib/generators/generic_form_for/install/install_generator.rb +20 -0
  16. data/lib/generators/generic_form_for/install/templates/_form.html.erb +11 -0
  17. data/lib/generators/generic_form_for/install/templates/_form.html.haml +8 -0
  18. data/lib/generators/generic_form_for/install/templates/form_for.en.yml +11 -0
  19. data/lib/generators/generic_form_for/install/templates/initializer.rb +5 -0
  20. data/lib/generic_form_for.rb +22 -0
  21. data/lib/generic_form_for/actions.rb +10 -0
  22. data/lib/generic_form_for/actions/base.rb +63 -0
  23. data/lib/generic_form_for/actions/base/icon.rb +24 -0
  24. data/lib/generic_form_for/actions/button_action.rb +14 -0
  25. data/lib/generic_form_for/actions/input_action.rb +11 -0
  26. data/lib/generic_form_for/engine.rb +11 -0
  27. data/lib/generic_form_for/form_builder.rb +111 -0
  28. data/lib/generic_form_for/helpers.rb +10 -0
  29. data/lib/generic_form_for/helpers/action_helper.rb +52 -0
  30. data/lib/generic_form_for/helpers/actions_helper.rb +35 -0
  31. data/lib/generic_form_for/helpers/fieldset_helper.rb +48 -0
  32. data/lib/generic_form_for/helpers/form_helper.rb +64 -0
  33. data/lib/generic_form_for/helpers/input_helper.rb +77 -0
  34. data/lib/generic_form_for/i18n.rb +44 -0
  35. data/lib/generic_form_for/inputs.rb +22 -0
  36. data/lib/generic_form_for/inputs/base.rb +98 -0
  37. data/lib/generic_form_for/inputs/base/error_message.rb +30 -0
  38. data/lib/generic_form_for/inputs/base/hint.rb +28 -0
  39. data/lib/generic_form_for/inputs/base/label.rb +42 -0
  40. data/lib/generic_form_for/inputs/base/number.rb +18 -0
  41. data/lib/generic_form_for/inputs/base/placeholder.rb +20 -0
  42. data/lib/generic_form_for/inputs/base/string.rb +17 -0
  43. data/lib/generic_form_for/inputs/base/validations.rb +42 -0
  44. data/lib/generic_form_for/inputs/boolean_input.rb +35 -0
  45. data/lib/generic_form_for/inputs/email_input.rb +19 -0
  46. data/lib/generic_form_for/inputs/file_input.rb +13 -0
  47. data/lib/generic_form_for/inputs/hidden_input.rb +23 -0
  48. data/lib/generic_form_for/inputs/number_input.rb +20 -0
  49. data/lib/generic_form_for/inputs/password_input.rb +13 -0
  50. data/lib/generic_form_for/inputs/phone_input.rb +19 -0
  51. data/lib/generic_form_for/inputs/range_input.rb +19 -0
  52. data/lib/generic_form_for/inputs/search_input.rb +19 -0
  53. data/lib/generic_form_for/inputs/select_input.rb +32 -0
  54. data/lib/generic_form_for/inputs/string_input.rb +13 -0
  55. data/lib/generic_form_for/inputs/text_input.rb +20 -0
  56. data/lib/generic_form_for/inputs/url_input.rb +19 -0
  57. data/sample_app/.gitignore +15 -0
  58. data/sample_app/Gemfile +15 -0
  59. data/sample_app/Gemfile.lock +130 -0
  60. data/sample_app/README.rdoc +261 -0
  61. data/sample_app/Rakefile +7 -0
  62. data/sample_app/app/assets/images/rails.png +0 -0
  63. data/sample_app/app/assets/javascripts/application.js +14 -0
  64. data/sample_app/app/assets/javascripts/posts.js.coffee +3 -0
  65. data/sample_app/app/assets/javascripts/samples.js.coffee +3 -0
  66. data/sample_app/app/assets/stylesheets/application.css +14 -0
  67. data/sample_app/app/assets/stylesheets/posts.css.scss +3 -0
  68. data/sample_app/app/assets/stylesheets/samples.css.scss +3 -0
  69. data/sample_app/app/assets/stylesheets/scaffolds.css.scss +56 -0
  70. data/sample_app/app/controllers/application_controller.rb +3 -0
  71. data/sample_app/app/controllers/samples_controller.rb +83 -0
  72. data/sample_app/app/form_builders/sample_form_builder.rb +17 -0
  73. data/sample_app/app/helpers/application_helper.rb +2 -0
  74. data/sample_app/app/helpers/sample_form_builder_helper.rb +15 -0
  75. data/sample_app/app/helpers/samples_helper.rb +2 -0
  76. data/sample_app/app/mailers/.gitkeep +0 -0
  77. data/sample_app/app/models/.gitkeep +0 -0
  78. data/sample_app/app/models/sample.rb +29 -0
  79. data/sample_app/app/views/layouts/application.html.erb +16 -0
  80. data/sample_app/app/views/samples/_form.html.erb +49 -0
  81. data/sample_app/app/views/samples/edit.html.erb +6 -0
  82. data/sample_app/app/views/samples/index.html.erb +21 -0
  83. data/sample_app/app/views/samples/new.html.erb +5 -0
  84. data/sample_app/app/views/samples/show.html.erb +5 -0
  85. data/sample_app/config.ru +4 -0
  86. data/sample_app/config/application.rb +65 -0
  87. data/sample_app/config/boot.rb +6 -0
  88. data/sample_app/config/database.yml +25 -0
  89. data/sample_app/config/environment.rb +5 -0
  90. data/sample_app/config/environments/development.rb +37 -0
  91. data/sample_app/config/environments/production.rb +67 -0
  92. data/sample_app/config/environments/test.rb +37 -0
  93. data/sample_app/config/initializers/backtrace_silencers.rb +7 -0
  94. data/sample_app/config/initializers/generic_form_for.rb +5 -0
  95. data/sample_app/config/initializers/inflections.rb +15 -0
  96. data/sample_app/config/initializers/mime_types.rb +5 -0
  97. data/sample_app/config/initializers/secret_token.rb +7 -0
  98. data/sample_app/config/initializers/session_store.rb +8 -0
  99. data/sample_app/config/initializers/wrap_parameters.rb +14 -0
  100. data/sample_app/config/locales/en.yml +22 -0
  101. data/sample_app/config/locales/form_for.en.yml +13 -0
  102. data/sample_app/config/routes.rb +61 -0
  103. data/sample_app/db/migrate/20120203082117_create_samples.rb +22 -0
  104. data/sample_app/db/schema.rb +36 -0
  105. data/sample_app/db/seeds.rb +7 -0
  106. data/sample_app/lib/assets/.gitkeep +0 -0
  107. data/sample_app/lib/tasks/.gitkeep +0 -0
  108. data/sample_app/lib/templates/erb/scaffold/_form.html.erb +11 -0
  109. data/sample_app/log/.gitkeep +0 -0
  110. data/sample_app/public/404.html +26 -0
  111. data/sample_app/public/422.html +26 -0
  112. data/sample_app/public/500.html +25 -0
  113. data/sample_app/public/favicon.ico +0 -0
  114. data/sample_app/public/robots.txt +5 -0
  115. data/sample_app/script/rails +6 -0
  116. data/sample_app/vendor/assets/javascripts/.gitkeep +0 -0
  117. data/sample_app/vendor/assets/stylesheets/.gitkeep +0 -0
  118. data/sample_app/vendor/plugins/.gitkeep +0 -0
  119. data/spec/actions/base/icon_spec.rb +38 -0
  120. data/spec/actions/button_action_spec.rb +43 -0
  121. data/spec/actions/input_action_spec.rb +66 -0
  122. data/spec/helpers/action_helper_spec.rb +32 -0
  123. data/spec/helpers/actions_helper_spec.rb +60 -0
  124. data/spec/helpers/fieldset_helper_spec.rb +83 -0
  125. data/spec/helpers/form_helper_spec.rb +101 -0
  126. data/spec/helpers/input_helper_spec.rb +66 -0
  127. data/spec/i18n_spec.rb +46 -0
  128. data/spec/inputs/base/error_message_spec.rb +86 -0
  129. data/spec/inputs/base/hint_spec.rb +77 -0
  130. data/spec/inputs/base/label_spec.rb +99 -0
  131. data/spec/inputs/base/number_spec.rb +32 -0
  132. data/spec/inputs/base/placeholder_spec.rb +32 -0
  133. data/spec/inputs/base/string_spec.rb +25 -0
  134. data/spec/inputs/base/validations_spec.rb +53 -0
  135. data/spec/inputs/base_spec.rb +69 -0
  136. data/spec/inputs/boolean_input_spec.rb +95 -0
  137. data/spec/inputs/email_input_spec.rb +30 -0
  138. data/spec/inputs/file_input_spec.rb +30 -0
  139. data/spec/inputs/hidden_input_spec.rb +30 -0
  140. data/spec/inputs/number_input_spec.rb +37 -0
  141. data/spec/inputs/password_input_spec.rb +30 -0
  142. data/spec/inputs/phone_input_spec.rb +30 -0
  143. data/spec/inputs/range_input_spec.rb +37 -0
  144. data/spec/inputs/search_input_spec.rb +30 -0
  145. data/spec/inputs/select_input_spec.rb +51 -0
  146. data/spec/inputs/string_input_spec.rb +115 -0
  147. data/spec/inputs/text_input_spec.rb +30 -0
  148. data/spec/inputs/url_input_spec.rb +30 -0
  149. data/spec/spec_helper.rb +122 -0
  150. metadata +374 -0
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'GenericFormFor::Inputs::SearchInput' do
4
+ include GenericFormForSpecHelper
5
+
6
+ before do
7
+ @model = MyModel.new
8
+ @output_buffer = ''
9
+ end
10
+
11
+ it "should genearate wrapped input with label" do
12
+ with_form_config do
13
+ GenericFormFor::FormBuilder.input_wrapper do
14
+ wrap_in :class => "controls" do
15
+ label_html
16
+ input_html
17
+ error_html
18
+ end
19
+ end
20
+ @model.errors.add :search, "My mistake"
21
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
22
+ concat(builder.input(:search, :as => :search))
23
+ end)
24
+ output_buffer.should have_selector("input[@id='my_model_search'][@type='search']")
25
+ output_buffer.should have_selector("label[@for='my_model_search']", :content => "Search")
26
+ output_buffer.should have_selector("span[@class='error']", :content => "My mistake")
27
+ output_buffer.should have_selector("div", :class => "search-input controls")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'GenericFormFor::Inputs::SelectInput' do
4
+ include GenericFormForSpecHelper
5
+
6
+ before do
7
+ @model = MyModel.new
8
+ @output_buffer = ''
9
+ end
10
+
11
+ it "should genearate wrapped input with label" do
12
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
13
+ concat(builder.input(:home_page, :collection => 1..3))
14
+ end)
15
+ output_buffer.should have_selector("select[@id='my_model_home_page']")
16
+ output_buffer.should have_selector("option[@value='1']",:content => "1")
17
+ output_buffer.should have_selector("option[@value='2']",:content => "2")
18
+ output_buffer.should have_selector("option[@value='3']",:content => "3")
19
+ output_buffer.should have_selector("div", :class => "select-input")
20
+ end
21
+
22
+ it "should identify value from object" do
23
+ @model.home_page = "2"
24
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
25
+ concat(builder.input(:home_page, :collection => 1..3))
26
+ end)
27
+ output_buffer.should have_selector("select[@id='my_model_home_page']")
28
+ output_buffer.should have_selector("option[@value='1']",:content => "1")
29
+ output_buffer.should have_selector("option[@value='2'][@selected='selected']",:content => "2")
30
+ end
31
+
32
+ it "should identify value from parameters" do
33
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
34
+ concat(builder.input(:home_page, :collection => 1..3, :value => 2))
35
+ end)
36
+ output_buffer.should have_selector("select[@id='my_model_home_page']")
37
+ output_buffer.should have_selector("option[@value='1']",:content => "1")
38
+ output_buffer.should have_selector("option[@value='2'][@selected='selected']",:content => "2")
39
+ end
40
+
41
+ it "should identify options from parameters" do
42
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
43
+ concat(builder.input(:home_page, :collection => 1..3, :include_blank => true, :disabled => true, :class => "myclass", :value => 3))
44
+ end)
45
+ output_buffer.should have_selector("select[@id='my_model_home_page'][@disabled='disabled'][@class='select myclass']")
46
+ output_buffer.should have_selector("option[@value='']",:content => "")
47
+ output_buffer.should have_selector("option[@value='1']",:content => "1")
48
+ output_buffer.should have_selector("option[@value='2']",:content => "2")
49
+ output_buffer.should have_selector("option[@value='3'][@selected='selected']",:content => "3")
50
+ end
51
+ end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'GenericFormFor::Inputs::StringInput' do
4
+ include GenericFormForSpecHelper
5
+
6
+ before do
7
+ @model = MyModel.new
8
+ @output_buffer = ''
9
+ end
10
+
11
+ it "should genearate wrapped input with label" do
12
+ with_form_config do
13
+ GenericFormFor::FormBuilder.input_wrapper do
14
+ wrap_in :class => "controls" do
15
+ label_html
16
+ input_html
17
+ error_html
18
+ end
19
+ end
20
+ @model.errors.add :name, "My mistake"
21
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
22
+ concat(builder.input(:name, :as => :string))
23
+ end)
24
+ output_buffer.should have_selector("input[@id='my_model_name'][@type='text']")
25
+ output_buffer.should have_selector("label[@for='my_model_name']", :content => "Name")
26
+ output_buffer.should have_selector("span[@class='error']", :content => "My mistake")
27
+ output_buffer.should have_selector("div", :class => "string-input controls")
28
+ end
29
+ end
30
+
31
+ it "should apply default input options" do
32
+ with_config :default_text_field_size, 22 do
33
+ concat(generic_form_for(:user, :url => '/hello') do |builder|
34
+ concat(builder.input(:title, :as => :string))
35
+ end)
36
+ end
37
+ # output_buffer.should have_selector("input[@id='user_title'][@type='text'][@size='22']")
38
+ output_buffer.should have_selector("label[@for='user_title']", :content => "Title")
39
+ end
40
+
41
+ it "should owerwrite default input options" do
42
+ with_config :default_text_field_size, 22 do
43
+ concat(generic_form_for(:user, :url => '/hello') do |builder|
44
+ concat(builder.input(:title, :as => :string, :size => 44, :class => "myclass"))
45
+ end)
46
+ end
47
+ output_buffer.should have_selector("input[@id='user_title'][@type='text'][@size='44'][@class='string myclass']")
48
+ output_buffer.should have_selector("label[@for='user_title']", :content => "Title")
49
+ end
50
+
51
+ it "should add placeholder" do
52
+ with_config :default_text_field_size, 22 do
53
+ concat(generic_form_for(:user, :url => '/hello') do |builder|
54
+ concat(builder.input(:title, :as => :string, :placeholder => "Yo"))
55
+ end)
56
+ end
57
+ output_buffer.should have_selector("input[@id='user_title'][@type='text'][@placeholder='Yo']")
58
+ output_buffer.should have_selector("label[@for='user_title']", :content => "Title")
59
+ end
60
+
61
+ it "should add all input options" do
62
+ with_config :default_text_field_size, 22 do
63
+ concat(generic_form_for(:user, :url => '/hello') do |builder|
64
+ concat(builder.input(:title, :as => :string, :size => 44, :required => true, "data-field"=>"mydata"))
65
+ end)
66
+ end
67
+ output_buffer.should have_selector("input[@id='user_title'][@type='text'][@size='44'][@required='required'][@data-field='mydata']")
68
+ output_buffer.should have_selector("label[@for='user_title']", :content => "Title")
69
+ end
70
+
71
+ it "should add wrapper options from input" do
72
+ with_form_config do
73
+ GenericFormFor::FormBuilder.input_wrapper do
74
+ wrap_in :tag => :content, :class => "controls" do
75
+ label_html
76
+ input_html
77
+ error_html
78
+ end
79
+ end
80
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
81
+ concat(builder.input(:name, :as => :string, :wrapper_html => {:class => "myclass", :id => "myid"}))
82
+ end)
83
+ output_buffer.should have_selector("input[@id='my_model_name'][@type='text']")
84
+ output_buffer.should have_selector("content#myid", :class => "string-input controls myclass")
85
+ end
86
+ end
87
+
88
+ it "should add nested wrapper" do
89
+ with_form_config do
90
+ GenericFormFor::FormBuilder.input_wrapper do
91
+ wrap_in :tag => :content, :class => "controls" do
92
+ label_html
93
+ wrap_in :class => "my-inputs" do
94
+ input_html
95
+ wrap_in :class => "my-errors" do
96
+ error_html
97
+ error_html
98
+ wrap_in :class => "my-end"
99
+ end
100
+ end
101
+ end
102
+ end
103
+ @model.errors.add :name, "My mistake"
104
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
105
+ concat(builder.input(:name, :as => :string, :wrapper_html => {:class => "myclass", :id => "myid"}))
106
+ end)
107
+ output_buffer.should have_selector("label[@for='my_model_name']", :content => "Name")
108
+ output_buffer.should have_selector("input[@id='my_model_name'][@type='text']")
109
+ output_buffer.should have_selector("span[@class='error']", :content => "My mistake")
110
+ output_buffer.should have_selector("content#myid", :class => "string-input controls myclass")
111
+ output_buffer.should have_selector("div", :class => "my-inputs")
112
+ output_buffer.should have_selector("div", :class => "my-errors")
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'GenericFormFor::Inputs::UrlInput' do
4
+ include GenericFormForSpecHelper
5
+
6
+ before do
7
+ @model = MyModel.new
8
+ @output_buffer = ''
9
+ end
10
+
11
+ it "should genearate wrapped input with label" do
12
+ with_form_config do
13
+ GenericFormFor::FormBuilder.input_wrapper do
14
+ wrap_in :class => "controls" do
15
+ label_html
16
+ input_html
17
+ error_html
18
+ end
19
+ end
20
+ @model.errors.add :cv, "My mistake"
21
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
22
+ concat(builder.input(:cv, :as => :text))
23
+ end)
24
+ output_buffer.should have_selector("textarea[@id='my_model_cv'][@cols='35'][@rows='5']")
25
+ output_buffer.should have_selector("label[@for='my_model_cv']", :content => "Cv")
26
+ output_buffer.should have_selector("span[@class='error']", :content => "My mistake")
27
+ output_buffer.should have_selector("div", :class => "text-input controls")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'GenericFormFor::Inputs::UrlInput' do
4
+ include GenericFormForSpecHelper
5
+
6
+ before do
7
+ @model = MyModel.new
8
+ @output_buffer = ''
9
+ end
10
+
11
+ it "should genearate wrapped input with label" do
12
+ with_form_config do
13
+ GenericFormFor::FormBuilder.input_wrapper do
14
+ wrap_in :class => "controls" do
15
+ label_html
16
+ input_html
17
+ error_html
18
+ end
19
+ end
20
+ @model.errors.add :home_page, "My mistake"
21
+ concat(generic_form_for(@model, :url => "/hello") do |builder|
22
+ concat(builder.input(:home_page, :as => :url))
23
+ end)
24
+ output_buffer.should have_selector("input[@id='my_model_home_page'][@type='url']")
25
+ output_buffer.should have_selector("label[@for='my_model_home_page']", :content => "HomePage")
26
+ output_buffer.should have_selector("span[@class='error']", :content => "My mistake")
27
+ output_buffer.should have_selector("div", :class => "url-input controls")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,122 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ require 'active_support'
5
+ require 'active_support/core_ext'
6
+ require 'action_view'
7
+ require 'action_pack'
8
+ require 'active_record'
9
+ require 'action_controller'
10
+ require 'rspec'
11
+ require 'webrat'
12
+ require 'webrat/core/matchers'
13
+ require 'generic_form_for'
14
+
15
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
16
+
17
+ RSpec.configure do |config|
18
+
19
+ end
20
+ ActionView::Base.field_error_proc = proc { |input, instance| input }
21
+ module GenericFormForSpecHelper
22
+ include ActionPack
23
+ include ActionView::Context if defined?(ActionView::Context)
24
+ include ActionController::RecordIdentifier
25
+ include ActionView::Helpers::FormHelper
26
+ include ActionView::Helpers::FormTagHelper
27
+ include ActionView::Helpers::FormOptionsHelper
28
+ include ActionView::Helpers::UrlHelper
29
+ include ActionView::Helpers::TagHelper
30
+ include ActionView::Helpers::TextHelper
31
+ # include ActionView::Helpers::ActiveRecordHelper if defined?(ActionView::Helpers::ActiveRecordHelper)
32
+ # include ActionView::Helpers::ActiveModelHelper if defined?(ActionView::Helpers::ActiveModelHelper)
33
+ # include ActionView::Helpers::DateHelper
34
+ # include ActionView::Helpers::CaptureHelper
35
+ # include ActionView::Helpers::AssetTagHelper
36
+ include ActiveSupport
37
+
38
+ # include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)
39
+
40
+ include Webrat::Matchers
41
+
42
+ include GenericFormFor::Helpers::FormHelper
43
+ include GenericFormFor::Helpers::InputHelper
44
+ include GenericFormFor::Helpers::FieldsetHelper
45
+ include GenericFormFor::Helpers::ActionHelper
46
+ include GenericFormFor::Helpers::ActionsHelper
47
+
48
+ def protect_against_forgery?
49
+ false
50
+ end
51
+
52
+ class ::Tableless
53
+ extend ActiveModel::Naming
54
+ include ActiveModel::Conversion
55
+ include ActiveModel::Validations
56
+
57
+ def self.columns
58
+ @columns ||= [];
59
+ end
60
+
61
+ def self.column(name, sql_type = nil, default = nil, null = true)
62
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
63
+ code = <<-END
64
+ attr_accessor :#{name}
65
+ END
66
+ module_eval code, __FILE__, __LINE__
67
+ end
68
+
69
+ def column_for_attribute(method)
70
+ self.class.columns.select {|v| v.name == method.to_s}.first
71
+ end
72
+
73
+ def persisted?
74
+ end
75
+ end
76
+
77
+ class ::MyModel < Tableless
78
+ column :active, :boolean
79
+ column :email, :string
80
+ column :photo, :text
81
+ column :secret, :text
82
+ column :age, :integer
83
+ column :password, :string
84
+ column :mobile, :string
85
+ column :sex, :string
86
+ column :range, :integer
87
+ column :search, :string
88
+ column :category, :string
89
+ column :name, "string(255)"
90
+ column :cv, :text
91
+ column :home_page, :string
92
+ column :money, "decimal(12,2)"
93
+
94
+ validates_presence_of [:name, :email, :money]
95
+ validates :money, :numericality => {:greater_than_or_equal_to => 5, :less_than => 100}
96
+ end
97
+
98
+ def with_config(config_method_name, value, &block)
99
+ old_value = GenericFormFor::FormBuilder.send(config_method_name)
100
+ GenericFormFor::FormBuilder.send(:"#{config_method_name}=", value)
101
+ yield
102
+ ensure
103
+ GenericFormFor::FormBuilder.send(:"#{config_method_name}=", old_value)
104
+ end
105
+
106
+ def with_form_config
107
+ old_form_wrapper_proc = GenericFormFor::FormBuilder.send("form_wrapper_proc")
108
+ old_input_wrapper_proc = GenericFormFor::FormBuilder.send("input_wrapper_proc")
109
+ old_action_wrapper_proc = GenericFormFor::FormBuilder.send("action_wrapper_proc")
110
+ old_actions_wrapper_proc = GenericFormFor::FormBuilder.send("actions_wrapper_proc")
111
+ old_fieldset_wrapper_proc = GenericFormFor::FormBuilder.send("fieldset_wrapper_proc")
112
+ yield
113
+ ensure
114
+ GenericFormFor::FormBuilder.send("form_wrapper_proc=",old_form_wrapper_proc)
115
+ GenericFormFor::FormBuilder.send("input_wrapper_proc=",old_input_wrapper_proc)
116
+ GenericFormFor::FormBuilder.send("action_wrapper_proc=",old_action_wrapper_proc)
117
+ GenericFormFor::FormBuilder.send("actions_wrapper_proc=",old_actions_wrapper_proc)
118
+ GenericFormFor::FormBuilder.send("fieldset_wrapper_proc=",old_fieldset_wrapper_proc)
119
+ end
120
+ end
121
+
122
+ GenericFormFor::FormBuilder.use_translations = false
metadata ADDED
@@ -0,0 +1,374 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: generic_form_for
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aivars Akots
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: generic_form_for
16
+ requirement: &2176879440 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2176879440
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &2176878960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2176878960
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &2176878480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.12'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2176878480
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: &2176878000 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2176878000
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &2176877520 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.8.3
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2176877520
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rails
71
+ requirement: &2176877040 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>'
75
+ - !ruby/object:Gem::Version
76
+ version: 2.8.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2176877040
80
+ - !ruby/object:Gem::Dependency
81
+ name: webrat
82
+ requirement: &2176876560 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2176876560
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec-rails
93
+ requirement: &2176876080 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>'
97
+ - !ruby/object:Gem::Version
98
+ version: 2.8.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *2176876080
102
+ - !ruby/object:Gem::Dependency
103
+ name: webrat
104
+ requirement: &2176875600 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *2176875600
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec-rails
115
+ requirement: &2176875120 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>'
119
+ - !ruby/object:Gem::Version
120
+ version: 2.8.0
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *2176875120
124
+ - !ruby/object:Gem::Dependency
125
+ name: webrat
126
+ requirement: &2176874640 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *2176874640
135
+ - !ruby/object:Gem::Dependency
136
+ name: rspec-rails
137
+ requirement: &2176874160 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>'
141
+ - !ruby/object:Gem::Version
142
+ version: 2.8.0
143
+ type: :development
144
+ prerelease: false
145
+ version_requirements: *2176874160
146
+ - !ruby/object:Gem::Dependency
147
+ name: webrat
148
+ requirement: &2176873680 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: *2176873680
157
+ - !ruby/object:Gem::Dependency
158
+ name: rails
159
+ requirement: &2176873200 !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: 3.1.0
165
+ type: :runtime
166
+ prerelease: false
167
+ version_requirements: *2176873200
168
+ - !ruby/object:Gem::Dependency
169
+ name: rspec-rails
170
+ requirement: &2176872720 !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>'
174
+ - !ruby/object:Gem::Version
175
+ version: 2.8.0
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: *2176872720
179
+ - !ruby/object:Gem::Dependency
180
+ name: webrat
181
+ requirement: &2176888600 !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ type: :development
188
+ prerelease: false
189
+ version_requirements: *2176888600
190
+ description: Super easy adjustable form builder with formtastic style DSL
191
+ email: aivars.akots@gmail.com
192
+ executables: []
193
+ extensions: []
194
+ extra_rdoc_files:
195
+ - README.textile
196
+ files:
197
+ - .document
198
+ - .rspec
199
+ - .rvmrc
200
+ - Gemfile
201
+ - Gemfile.lock
202
+ - MIT-LICENSE
203
+ - README.textile
204
+ - Rakefile
205
+ - VERSION
206
+ - generic_form_for.gemspec
207
+ - generic_form_for.tmproj
208
+ - lib/generators/generic_form_for/form_builder/form_builder_generator.rb
209
+ - lib/generators/generic_form_for/form_builder/templates/form_builder.erb
210
+ - lib/generators/generic_form_for/form_builder/templates/helper.erb
211
+ - lib/generators/generic_form_for/install/install_generator.rb
212
+ - lib/generators/generic_form_for/install/templates/_form.html.erb
213
+ - lib/generators/generic_form_for/install/templates/_form.html.haml
214
+ - lib/generators/generic_form_for/install/templates/form_for.en.yml
215
+ - lib/generators/generic_form_for/install/templates/initializer.rb
216
+ - lib/generic_form_for.rb
217
+ - lib/generic_form_for/actions.rb
218
+ - lib/generic_form_for/actions/base.rb
219
+ - lib/generic_form_for/actions/base/icon.rb
220
+ - lib/generic_form_for/actions/button_action.rb
221
+ - lib/generic_form_for/actions/input_action.rb
222
+ - lib/generic_form_for/engine.rb
223
+ - lib/generic_form_for/form_builder.rb
224
+ - lib/generic_form_for/helpers.rb
225
+ - lib/generic_form_for/helpers/action_helper.rb
226
+ - lib/generic_form_for/helpers/actions_helper.rb
227
+ - lib/generic_form_for/helpers/fieldset_helper.rb
228
+ - lib/generic_form_for/helpers/form_helper.rb
229
+ - lib/generic_form_for/helpers/input_helper.rb
230
+ - lib/generic_form_for/i18n.rb
231
+ - lib/generic_form_for/inputs.rb
232
+ - lib/generic_form_for/inputs/base.rb
233
+ - lib/generic_form_for/inputs/base/error_message.rb
234
+ - lib/generic_form_for/inputs/base/hint.rb
235
+ - lib/generic_form_for/inputs/base/label.rb
236
+ - lib/generic_form_for/inputs/base/number.rb
237
+ - lib/generic_form_for/inputs/base/placeholder.rb
238
+ - lib/generic_form_for/inputs/base/string.rb
239
+ - lib/generic_form_for/inputs/base/validations.rb
240
+ - lib/generic_form_for/inputs/boolean_input.rb
241
+ - lib/generic_form_for/inputs/email_input.rb
242
+ - lib/generic_form_for/inputs/file_input.rb
243
+ - lib/generic_form_for/inputs/hidden_input.rb
244
+ - lib/generic_form_for/inputs/number_input.rb
245
+ - lib/generic_form_for/inputs/password_input.rb
246
+ - lib/generic_form_for/inputs/phone_input.rb
247
+ - lib/generic_form_for/inputs/range_input.rb
248
+ - lib/generic_form_for/inputs/search_input.rb
249
+ - lib/generic_form_for/inputs/select_input.rb
250
+ - lib/generic_form_for/inputs/string_input.rb
251
+ - lib/generic_form_for/inputs/text_input.rb
252
+ - lib/generic_form_for/inputs/url_input.rb
253
+ - sample_app/.gitignore
254
+ - sample_app/Gemfile
255
+ - sample_app/Gemfile.lock
256
+ - sample_app/README.rdoc
257
+ - sample_app/Rakefile
258
+ - sample_app/app/assets/images/rails.png
259
+ - sample_app/app/assets/javascripts/application.js
260
+ - sample_app/app/assets/javascripts/posts.js.coffee
261
+ - sample_app/app/assets/javascripts/samples.js.coffee
262
+ - sample_app/app/assets/stylesheets/application.css
263
+ - sample_app/app/assets/stylesheets/posts.css.scss
264
+ - sample_app/app/assets/stylesheets/samples.css.scss
265
+ - sample_app/app/assets/stylesheets/scaffolds.css.scss
266
+ - sample_app/app/controllers/application_controller.rb
267
+ - sample_app/app/controllers/samples_controller.rb
268
+ - sample_app/app/form_builders/sample_form_builder.rb
269
+ - sample_app/app/helpers/application_helper.rb
270
+ - sample_app/app/helpers/sample_form_builder_helper.rb
271
+ - sample_app/app/helpers/samples_helper.rb
272
+ - sample_app/app/mailers/.gitkeep
273
+ - sample_app/app/models/.gitkeep
274
+ - sample_app/app/models/sample.rb
275
+ - sample_app/app/views/layouts/application.html.erb
276
+ - sample_app/app/views/samples/_form.html.erb
277
+ - sample_app/app/views/samples/edit.html.erb
278
+ - sample_app/app/views/samples/index.html.erb
279
+ - sample_app/app/views/samples/new.html.erb
280
+ - sample_app/app/views/samples/show.html.erb
281
+ - sample_app/config.ru
282
+ - sample_app/config/application.rb
283
+ - sample_app/config/boot.rb
284
+ - sample_app/config/database.yml
285
+ - sample_app/config/environment.rb
286
+ - sample_app/config/environments/development.rb
287
+ - sample_app/config/environments/production.rb
288
+ - sample_app/config/environments/test.rb
289
+ - sample_app/config/initializers/backtrace_silencers.rb
290
+ - sample_app/config/initializers/generic_form_for.rb
291
+ - sample_app/config/initializers/inflections.rb
292
+ - sample_app/config/initializers/mime_types.rb
293
+ - sample_app/config/initializers/secret_token.rb
294
+ - sample_app/config/initializers/session_store.rb
295
+ - sample_app/config/initializers/wrap_parameters.rb
296
+ - sample_app/config/locales/en.yml
297
+ - sample_app/config/locales/form_for.en.yml
298
+ - sample_app/config/routes.rb
299
+ - sample_app/db/migrate/20120203082117_create_samples.rb
300
+ - sample_app/db/schema.rb
301
+ - sample_app/db/seeds.rb
302
+ - sample_app/lib/assets/.gitkeep
303
+ - sample_app/lib/tasks/.gitkeep
304
+ - sample_app/lib/templates/erb/scaffold/_form.html.erb
305
+ - sample_app/log/.gitkeep
306
+ - sample_app/public/404.html
307
+ - sample_app/public/422.html
308
+ - sample_app/public/500.html
309
+ - sample_app/public/favicon.ico
310
+ - sample_app/public/robots.txt
311
+ - sample_app/script/rails
312
+ - sample_app/vendor/assets/javascripts/.gitkeep
313
+ - sample_app/vendor/assets/stylesheets/.gitkeep
314
+ - sample_app/vendor/plugins/.gitkeep
315
+ - spec/actions/base/icon_spec.rb
316
+ - spec/actions/button_action_spec.rb
317
+ - spec/actions/input_action_spec.rb
318
+ - spec/helpers/action_helper_spec.rb
319
+ - spec/helpers/actions_helper_spec.rb
320
+ - spec/helpers/fieldset_helper_spec.rb
321
+ - spec/helpers/form_helper_spec.rb
322
+ - spec/helpers/input_helper_spec.rb
323
+ - spec/i18n_spec.rb
324
+ - spec/inputs/base/error_message_spec.rb
325
+ - spec/inputs/base/hint_spec.rb
326
+ - spec/inputs/base/label_spec.rb
327
+ - spec/inputs/base/number_spec.rb
328
+ - spec/inputs/base/placeholder_spec.rb
329
+ - spec/inputs/base/string_spec.rb
330
+ - spec/inputs/base/validations_spec.rb
331
+ - spec/inputs/base_spec.rb
332
+ - spec/inputs/boolean_input_spec.rb
333
+ - spec/inputs/email_input_spec.rb
334
+ - spec/inputs/file_input_spec.rb
335
+ - spec/inputs/hidden_input_spec.rb
336
+ - spec/inputs/number_input_spec.rb
337
+ - spec/inputs/password_input_spec.rb
338
+ - spec/inputs/phone_input_spec.rb
339
+ - spec/inputs/range_input_spec.rb
340
+ - spec/inputs/search_input_spec.rb
341
+ - spec/inputs/select_input_spec.rb
342
+ - spec/inputs/string_input_spec.rb
343
+ - spec/inputs/text_input_spec.rb
344
+ - spec/inputs/url_input_spec.rb
345
+ - spec/spec_helper.rb
346
+ homepage: http://github.com/aivarsak/generic_form_for
347
+ licenses:
348
+ - MIT
349
+ post_install_message:
350
+ rdoc_options: []
351
+ require_paths:
352
+ - lib
353
+ required_ruby_version: !ruby/object:Gem::Requirement
354
+ none: false
355
+ requirements:
356
+ - - ! '>='
357
+ - !ruby/object:Gem::Version
358
+ version: '0'
359
+ segments:
360
+ - 0
361
+ hash: 1205001474736662589
362
+ required_rubygems_version: !ruby/object:Gem::Requirement
363
+ none: false
364
+ requirements:
365
+ - - ! '>='
366
+ - !ruby/object:Gem::Version
367
+ version: '0'
368
+ requirements: []
369
+ rubyforge_project:
370
+ rubygems_version: 1.8.15
371
+ signing_key:
372
+ specification_version: 3
373
+ summary: Yet another form builder
374
+ test_files: []