speedo-formstrap 1.2.7 → 1.2.8

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 (63) hide show
  1. data/Gemfile +2 -2
  2. data/Gemfile.lock +67 -65
  3. data/README.md +12 -2
  4. data/Rakefile +1 -1
  5. data/VERSION +1 -1
  6. data/lib/formtastic-bootstrap.rb +1 -0
  7. data/lib/formtastic-bootstrap/actions.rb +4 -0
  8. data/lib/formtastic-bootstrap/actions/base.rb +18 -0
  9. data/lib/formtastic-bootstrap/actions/button_action.rb +7 -0
  10. data/lib/formtastic-bootstrap/actions/input_action.rb +7 -0
  11. data/lib/formtastic-bootstrap/actions/link_action.rb +7 -0
  12. data/lib/formtastic-bootstrap/form_builder.rb +7 -5
  13. data/lib/formtastic-bootstrap/helpers.rb +3 -1
  14. data/lib/formtastic-bootstrap/helpers/action_helper.rb +12 -0
  15. data/lib/formtastic-bootstrap/helpers/actions_helper.rb +23 -0
  16. data/lib/formtastic-bootstrap/helpers/buttons_helper.rb +13 -9
  17. data/lib/formtastic-bootstrap/helpers/fieldset_wrapper.rb +11 -6
  18. data/lib/formtastic-bootstrap/helpers/inputs_helper.rb +4 -4
  19. data/lib/formtastic-bootstrap/inputs/base.rb +2 -1
  20. data/lib/formtastic-bootstrap/inputs/base/choices.rb +12 -23
  21. data/lib/formtastic-bootstrap/inputs/base/labelling.rb +16 -6
  22. data/lib/formtastic-bootstrap/inputs/base/numeric.rb +18 -0
  23. data/lib/formtastic-bootstrap/inputs/base/timeish.rb +5 -12
  24. data/lib/formtastic-bootstrap/inputs/base/wrapping.rb +32 -14
  25. data/lib/formtastic-bootstrap/inputs/boolean_input.rb +7 -11
  26. data/lib/formtastic-bootstrap/inputs/check_boxes_input.rb +10 -9
  27. data/lib/formtastic-bootstrap/inputs/hidden_input.rb +5 -3
  28. data/lib/formtastic-bootstrap/inputs/number_input.rb +2 -2
  29. data/lib/formtastic-bootstrap/inputs/radio_input.rb +13 -12
  30. data/lib/formtastic-bootstrap/inputs/range_input.rb +2 -2
  31. data/spec/actions/button_action_spec.rb +68 -0
  32. data/spec/actions/generic_action_spec.rb +486 -0
  33. data/spec/actions/input_action_spec.rb +64 -0
  34. data/spec/actions/link_action_spec.rb +93 -0
  35. data/spec/builder/semantic_fields_for_spec.rb +14 -14
  36. data/spec/helpers/action_helper_spec.rb +365 -0
  37. data/spec/helpers/actions_helper_spec.rb +143 -0
  38. data/spec/helpers/buttons_helper_spec.rb +55 -45
  39. data/spec/helpers/input_helper_spec.rb +188 -188
  40. data/spec/helpers/inputs_helper_spec.rb +116 -102
  41. data/spec/inputs/boolean_input_spec.rb +72 -44
  42. data/spec/inputs/check_boxes_input_spec.rb +108 -80
  43. data/spec/inputs/date_input_spec.rb +80 -14
  44. data/spec/inputs/datetime_input_spec.rb +12 -12
  45. data/spec/inputs/email_input_spec.rb +33 -5
  46. data/spec/inputs/file_input_spec.rb +33 -5
  47. data/spec/inputs/hidden_input_spec.rb +40 -12
  48. data/spec/inputs/number_input_spec.rb +126 -96
  49. data/spec/inputs/password_input_spec.rb +33 -5
  50. data/spec/inputs/phone_input_spec.rb +33 -5
  51. data/spec/inputs/radio_input_spec.rb +72 -44
  52. data/spec/inputs/range_input_spec.rb +93 -65
  53. data/spec/inputs/search_input_spec.rb +32 -5
  54. data/spec/inputs/select_input_spec.rb +123 -77
  55. data/spec/inputs/string_input_spec.rb +66 -21
  56. data/spec/inputs/text_input_spec.rb +40 -13
  57. data/spec/inputs/time_input_spec.rb +22 -22
  58. data/spec/inputs/time_zone_input_spec.rb +17 -17
  59. data/spec/inputs/url_input_spec.rb +33 -5
  60. data/spec/support/custom_macros.rb +59 -188
  61. data/spec/support/formtastic_spec_helper.rb +19 -3
  62. data/speedo-formstrap.gemspec +146 -0
  63. metadata +31 -16
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'formtastic'
3
+ gem 'formtastic', '~> 2.1.0.beta1'
4
4
  gem 'rails', '>= 3.1.0'
5
5
 
6
6
  group :development, :test do
7
7
  gem "rspec"
8
8
  gem "bundler"
9
9
  gem "jeweler"
10
- gem "rcov", ">= 0"
10
+ gem "simplecov"
11
11
  gem "rspec_tag_matchers"
12
12
  end
data/Gemfile.lock CHANGED
@@ -1,119 +1,121 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.1.3)
5
- actionpack (= 3.1.3)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.3)
8
- activemodel (= 3.1.3)
9
- activesupport (= 3.1.3)
4
+ actionmailer (3.2.6)
5
+ actionpack (= 3.2.6)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.5)
14
- rack-cache (~> 1.1)
15
- rack-mount (~> 0.8.2)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
16
15
  rack-test (~> 0.6.1)
17
- sprockets (~> 2.0.3)
18
- activemodel (3.1.3)
19
- activesupport (= 3.1.3)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.6)
18
+ activesupport (= 3.2.6)
20
19
  builder (~> 3.0.0)
21
- i18n (~> 0.6)
22
- activerecord (3.1.3)
23
- activemodel (= 3.1.3)
24
- activesupport (= 3.1.3)
25
- arel (~> 2.2.1)
20
+ activerecord (3.2.6)
21
+ activemodel (= 3.2.6)
22
+ activesupport (= 3.2.6)
23
+ arel (~> 3.0.2)
26
24
  tzinfo (~> 0.3.29)
27
- activeresource (3.1.3)
28
- activemodel (= 3.1.3)
29
- activesupport (= 3.1.3)
30
- activesupport (3.1.3)
25
+ activeresource (3.2.6)
26
+ activemodel (= 3.2.6)
27
+ activesupport (= 3.2.6)
28
+ activesupport (3.2.6)
29
+ i18n (~> 0.6)
31
30
  multi_json (~> 1.0)
32
- arel (2.2.1)
31
+ arel (3.0.2)
33
32
  builder (3.0.0)
34
33
  diff-lcs (1.1.3)
35
34
  erubis (2.7.0)
36
- formtastic (2.0.2)
37
- rails (~> 3.0)
35
+ formtastic (2.1.1)
36
+ actionpack (~> 3.0)
38
37
  git (1.2.5)
39
38
  hike (1.2.1)
40
39
  i18n (0.6.0)
41
- jeweler (1.6.4)
40
+ jeweler (1.8.4)
42
41
  bundler (~> 1.0)
43
42
  git (>= 1.2.5)
44
43
  rake
45
- json (1.6.3)
46
- mail (2.3.0)
44
+ rdoc
45
+ journey (1.0.4)
46
+ json (1.7.3)
47
+ mail (2.4.4)
47
48
  i18n (>= 0.4.0)
48
49
  mime-types (~> 1.16)
49
50
  treetop (~> 1.4.8)
50
- mime-types (1.17.2)
51
- multi_json (1.0.4)
52
- nokogiri (1.5.0)
51
+ mime-types (1.19)
52
+ multi_json (1.3.6)
53
+ nokogiri (1.5.5)
53
54
  polyglot (0.3.3)
54
- rack (1.3.5)
55
- rack-cache (1.1)
55
+ rack (1.4.1)
56
+ rack-cache (1.2)
56
57
  rack (>= 0.4)
57
- rack-mount (0.8.3)
58
- rack (>= 1.0.0)
59
58
  rack-ssl (1.3.2)
60
59
  rack
61
60
  rack-test (0.6.1)
62
61
  rack (>= 1.0)
63
- rails (3.1.3)
64
- actionmailer (= 3.1.3)
65
- actionpack (= 3.1.3)
66
- activerecord (= 3.1.3)
67
- activeresource (= 3.1.3)
68
- activesupport (= 3.1.3)
62
+ rails (3.2.6)
63
+ actionmailer (= 3.2.6)
64
+ actionpack (= 3.2.6)
65
+ activerecord (= 3.2.6)
66
+ activeresource (= 3.2.6)
67
+ activesupport (= 3.2.6)
69
68
  bundler (~> 1.0)
70
- railties (= 3.1.3)
71
- railties (3.1.3)
72
- actionpack (= 3.1.3)
73
- activesupport (= 3.1.3)
69
+ railties (= 3.2.6)
70
+ railties (3.2.6)
71
+ actionpack (= 3.2.6)
72
+ activesupport (= 3.2.6)
74
73
  rack-ssl (~> 1.3.2)
75
74
  rake (>= 0.8.7)
76
75
  rdoc (~> 3.4)
77
- thor (~> 0.14.6)
76
+ thor (>= 0.14.6, < 2.0)
78
77
  rake (0.9.2.2)
79
- rcov (0.9.11)
80
78
  rdoc (3.12)
81
79
  json (~> 1.4)
82
- rspec (2.7.0)
83
- rspec-core (~> 2.7.0)
84
- rspec-expectations (~> 2.7.0)
85
- rspec-mocks (~> 2.7.0)
86
- rspec-core (2.7.1)
87
- rspec-expectations (2.7.0)
88
- diff-lcs (~> 1.1.2)
89
- rspec-mocks (2.7.0)
90
- rspec-rails (2.7.0)
91
- actionpack (~> 3.0)
92
- activesupport (~> 3.0)
93
- railties (~> 3.0)
94
- rspec (~> 2.7.0)
80
+ rspec (2.11.0)
81
+ rspec-core (~> 2.11.0)
82
+ rspec-expectations (~> 2.11.0)
83
+ rspec-mocks (~> 2.11.0)
84
+ rspec-core (2.11.0)
85
+ rspec-expectations (2.11.1)
86
+ diff-lcs (~> 1.1.3)
87
+ rspec-mocks (2.11.0)
88
+ rspec-rails (2.11.0)
89
+ actionpack (>= 3.0)
90
+ activesupport (>= 3.0)
91
+ railties (>= 3.0)
92
+ rspec (~> 2.11.0)
95
93
  rspec_tag_matchers (1.0.0)
96
94
  nokogiri (>= 1.4.0)
97
95
  rspec-rails (>= 1.2.6)
98
- sprockets (2.0.3)
96
+ simplecov (0.6.4)
97
+ multi_json (~> 1.0)
98
+ simplecov-html (~> 0.5.3)
99
+ simplecov-html (0.5.3)
100
+ sprockets (2.1.3)
99
101
  hike (~> 1.2)
100
102
  rack (~> 1.0)
101
103
  tilt (~> 1.1, != 1.3.0)
102
- thor (0.14.6)
104
+ thor (0.15.4)
103
105
  tilt (1.3.3)
104
106
  treetop (1.4.10)
105
107
  polyglot
106
108
  polyglot (>= 0.3.1)
107
- tzinfo (0.3.31)
109
+ tzinfo (0.3.33)
108
110
 
109
111
  PLATFORMS
110
112
  ruby
111
113
 
112
114
  DEPENDENCIES
113
115
  bundler
114
- formtastic
116
+ formtastic (~> 2.1.0.beta1)
115
117
  jeweler
116
118
  rails (>= 3.1.0)
117
- rcov
118
119
  rspec
119
120
  rspec_tag_matchers
121
+ simplecov
data/README.md CHANGED
@@ -127,7 +127,18 @@ In particular:
127
127
  Contributions are welcome!
128
128
 
129
129
  * Formtastic's <tt>:country</tt> has not yet been implemented.
130
- * Twitter Bootstrap's Date Range, Prepend Text, Prepend Checkbox and Appended Checkbox controls have not yet been implemented.
130
+ * Twitter Bootstrap's Date Range, Prepend Checkbox and Appended Checkbox controls have not yet been implemented.
131
+
132
+ ## Usage
133
+
134
+ #### Prepended Text
135
+ To create a Prepended Text field, use the ```:prepend``` option. This works on any text field input type, like ```:url```, ```:search```, and of course ```:string```
136
+
137
+ <%= semantic_form_for @user do |f| %>
138
+ <%= f.inputs do %>
139
+ <%= f.input :handle, :prepend => '@' %>
140
+ <% end %>
141
+ <% end %>
131
142
 
132
143
  ## Contributing
133
144
 
@@ -162,7 +173,6 @@ If you're filing a bug, thank you! Secondly, in the report please include:
162
173
  * :time_zone
163
174
  * Fancy Bootstrap Fields
164
175
  * Date Range
165
- * Prepend Text
166
176
  * Prepend Checkbox
167
177
  * Appended Checkbox
168
178
  * :datetime, :date, :time
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ Jeweler::Tasks.new do |gem|
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Formtastic form builder to generate Twitter Bootstrap-friendly markup.}
21
21
  gem.description = gem.summary
22
- gem.email = "mjbellantoni@yahoo.com"
22
+ gem.email = "stu@t.apio.ca"
23
23
  gem.authors = ["Matthew Bellantoni", "Stu Basden"]
24
24
  # dependencies defined in Gemfile
25
25
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.6
1
+ 1.2.8
@@ -2,5 +2,6 @@ require "formtastic"
2
2
  require "formtastic-bootstrap/engine" if defined?(::Rails) # For tests
3
3
  require "formtastic-bootstrap/helpers"
4
4
  require "formtastic-bootstrap/inputs"
5
+ require "formtastic-bootstrap/actions"
5
6
  require "formtastic-bootstrap/form_builder"
6
7
  require "action_view/helpers/text_field_date_helper"
@@ -0,0 +1,4 @@
1
+ require "formtastic-bootstrap/actions/base"
2
+ require "formtastic-bootstrap/actions/input_action"
3
+ require "formtastic-bootstrap/actions/link_action"
4
+ require "formtastic-bootstrap/actions/button_action"
@@ -0,0 +1,18 @@
1
+ module FormtasticBootstrap
2
+ module Actions
3
+ module Base
4
+
5
+ def wrapper(&block)
6
+ template.capture(&block)
7
+ end
8
+
9
+ def button_html
10
+ new_class = [super[:class], wrapper_html_options[:class], "btn"]
11
+ new_class << "btn-primary" if method == :submit
12
+ new_class = new_class.compact.join(" ")
13
+ wrapper_html_options.merge(super).merge(:class => new_class)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module FormtasticBootstrap
2
+ module Actions
3
+ class ButtonAction < Formtastic::Actions::ButtonAction
4
+ include Base
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module FormtasticBootstrap
2
+ module Actions
3
+ class InputAction < Formtastic::Actions::InputAction
4
+ include Base
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module FormtasticBootstrap
2
+ module Actions
3
+ class LinkAction < Formtastic::Actions::LinkAction
4
+ include Base
5
+ end
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module FormtasticBootstrap
2
-
2
+
3
3
  class FormBuilder < Formtastic::FormBuilder
4
4
 
5
5
  configure :default_inline_error_class, 'help-inline'
@@ -11,18 +11,18 @@ module FormtasticBootstrap
11
11
  # self.default_inline_error_class
12
12
  raise
13
13
  end
14
-
14
+
15
15
  def self.default_error_class=(error_class)
16
16
  # self.default_inline_error_class = error_class
17
17
  # self.default_block_error_class = error_class
18
18
  raise
19
19
  end
20
-
20
+
21
21
  def self.default_hint_class
22
22
  # self.default_inline_hint_class
23
23
  raise
24
24
  end
25
-
25
+
26
26
  def self.default_hint_class=(hint_class)
27
27
  # self.default_inline_hint_class = hint_class
28
28
  # self.default_block_hint_class = hint_class
@@ -32,7 +32,9 @@ module FormtasticBootstrap
32
32
  include FormtasticBootstrap::Helpers::InputHelper
33
33
  include FormtasticBootstrap::Helpers::InputsHelper
34
34
  include FormtasticBootstrap::Helpers::ButtonsHelper
35
+ include FormtasticBootstrap::Helpers::ActionHelper
36
+ include FormtasticBootstrap::Helpers::ActionsHelper
35
37
 
36
38
  end
37
39
 
38
- end
40
+ end
@@ -1,5 +1,7 @@
1
1
  require "formtastic-bootstrap/helpers/buttons_helper"
2
2
  require "formtastic-bootstrap/helpers/fieldset_wrapper"
3
+ require "formtastic-bootstrap/helpers/action_helper"
4
+ require "formtastic-bootstrap/helpers/actions_helper"
3
5
  require "formtastic-bootstrap/helpers/input_helper"
4
6
  require "formtastic-bootstrap/helpers/inputs_helper"
5
7
 
@@ -11,7 +13,7 @@ module FormtasticBootstrap
11
13
  # autoload :FormHelper, 'formtastic/helpers/form_helper'
12
14
  # autoload :InputHelper, 'formtastic/helpers/input_helper'
13
15
  # autoload :InputsHelper, 'formtastic/helpers/inputs_helper'
14
- # autoload :LabelHelper, 'formtastic/helpers/label_helper'
16
+ # autoload :LabelHelper, 'formtastic/helpers/label_helper'
15
17
  # autoload :SemanticFormHelper, 'formtastic/helpers/semantic_form_helper'
16
18
  # autoload :Reflection, 'formtastic/helpers/reflection'
17
19
  end
@@ -0,0 +1,12 @@
1
+ module FormtasticBootstrap
2
+ module Helpers
3
+ module ActionHelper
4
+ include Formtastic::Helpers::ActionHelper
5
+
6
+ def standard_action_class_name(as)
7
+ "FormtasticBootstrap::Actions::#{as.to_s.camelize}Action"
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ module FormtasticBootstrap
2
+ module Helpers
3
+ module ActionsHelper
4
+
5
+ include Formtastic::Helpers::ActionsHelper
6
+ include FormtasticBootstrap::Helpers::FieldsetWrapper
7
+
8
+ def actions(*args, &block)
9
+ html_options = args.extract_options!
10
+ html_options[:class] ||= "form-actions"
11
+
12
+ if block_given?
13
+ field_set_and_list_wrapping(html_options, &block)
14
+ else
15
+ args = default_actions if args.empty?
16
+ contents = args.map { |action_name| action(action_name) }
17
+ field_set_and_list_wrapping(html_options, contents)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -5,10 +5,11 @@ module FormtasticBootstrap
5
5
  include Formtastic::Helpers::ButtonsHelper
6
6
 
7
7
  def buttons(*args, &block)
8
+ ::ActiveSupport::Deprecation.warn("f.buttons is deprecated in favour of f.actions and will be removed from Formtastic after 2.1. Please see ActionsHelper and InputAction or ButtonAction for more information")
8
9
 
9
10
  html_options = args.extract_options!
10
- html_options[:class] ||= "actions"
11
-
11
+ html_options[:class] ||= "form-actions"
12
+
12
13
  if html_options.has_key?(:name)
13
14
  ActiveSupport::Deprecation.warn('The :name option is not supported')
14
15
  end
@@ -16,7 +17,7 @@ module FormtasticBootstrap
16
17
  if block_given?
17
18
  template.content_tag(:div, html_options) do
18
19
  yield
19
- end
20
+ end
20
21
  else
21
22
  args = [:commit] if args.empty?
22
23
  contents = args.map { |button_name| send(:"#{button_name}_button") }
@@ -28,25 +29,28 @@ module FormtasticBootstrap
28
29
  end
29
30
 
30
31
  def commit_button(*args)
32
+ ::ActiveSupport::Deprecation.warn("f.commit_button is deprecated in favour of f.action(:submit) and will be removed from Formtastic after 2.1. Please see ActionsHelper and InputAction or ButtonAction for more information")
33
+
31
34
  options = args.extract_options!
32
35
  text = options.delete(:label) || args.shift
33
-
36
+
34
37
  text = (localized_string(commit_button_i18n_key, text, :action, :model => commit_button_object_name) ||
35
38
  Formtastic::I18n.t(commit_button_i18n_key, :model => commit_button_object_name)) unless text.is_a?(::String)
36
-
39
+
37
40
  button_html = options.delete(:button_html) || {}
41
+ button_html[:id] ||= "#{@object_name}_submit"
38
42
  button_html.merge!(:class => [button_html[:class], "btn commit", commit_button_i18n_key].compact.join(' '))
39
-
43
+
40
44
  # TODO We don't have a wrapper. Add deprecation message.
41
45
  # wrapper_html = options.delete(:wrapper_html) || {}
42
46
  # wrapper_html[:class] = (commit_button_wrapper_html_class << wrapper_html[:class]).flatten.compact.join(' ')
43
-
47
+
44
48
  accesskey = (options.delete(:accesskey) || default_commit_button_accesskey) unless button_html.has_key?(:accesskey)
45
49
  button_html = button_html.merge(:accesskey => accesskey) if accesskey
46
-
50
+
47
51
  Formtastic::Util.html_safe(submit(text, button_html))
48
52
  end
49
53
 
50
54
  end
51
55
  end
52
- end
56
+ end