bootstrap_builder 0.3.0 → 0.3.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "bootstrap_builder"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jack Neto", "The Working Group Inc."]
12
- s.date = "2012-06-09"
12
+ s.date = "2012-07-03"
13
13
  s.description = ""
14
14
  s.email = "jack@twg.ca"
15
15
  s.extra_rdoc_files = [
@@ -37,8 +37,7 @@ Gem::Specification.new do |s|
37
37
  "lib/bootstrap_builder/configuration.rb",
38
38
  "lib/bootstrap_builder/engine.rb",
39
39
  "lib/bootstrap_builder/helper.rb",
40
- "lib/bootstrap_builder/railtie.rb",
41
- "rails-bootstrap-builder.gemspec"
40
+ "lib/bootstrap_builder/railtie.rb"
42
41
  ]
43
42
  s.homepage = "http://github.com/twg/bootstrap_builder"
44
43
  s.licenses = ["MIT"]
@@ -10,20 +10,31 @@ module BootstrapBuilder
10
10
  number_field
11
11
  text_area
12
12
  file_field
13
- datetime_select
14
- date_select
15
- time_zone_select
16
13
  range_field
17
14
  search_field
18
15
  ).each do |field_name|
19
16
  define_method field_name do |method, *args|
20
17
  options = args.detect { |a| a.is_a?(Hash) } || {}
21
- render_field(field_name, method, options) { super(method, options) }
18
+ html_options = collect_html_options(options)
19
+ render_field(field_name, method, options, html_options) { super(method, options) }
20
+ end
21
+ end
22
+
23
+ %w{
24
+ datetime_select
25
+ date_select
26
+ time_select
27
+ time_zone_select
28
+ }.each do |field_name|
29
+ define_method field_name do |method, options = {}, html_options = {}|
30
+ render_field('select', method, options, html_options) do
31
+ super(method, options, html_options)
32
+ end
22
33
  end
23
34
  end
24
35
 
25
36
  def select(method, choices, options = {}, html_options = {})
26
- render_field('select', method, options) { super(method, choices, options, html_options) }
37
+ render_field('select', method, options, html_options) { super(method, choices, options, html_options) }
27
38
  end
28
39
 
29
40
  def hidden_field(method, options = {}, html_options = {})
@@ -122,11 +133,9 @@ module BootstrapBuilder
122
133
  def element(label = ' ', value = '', type = 'text_field', &block)
123
134
  value += @template.capture(&block) if block_given?
124
135
  %{
125
- <div class='form_element #{type}'>
126
- <div class='label'>
127
- #{label}
128
- </div>
129
- <div class='value'>
136
+ <div class='control-group'>
137
+ <label class='control-label'>#{label}</label>
138
+ <div class='controls'>
130
139
  #{value}
131
140
  </div>
132
141
  </div>
@@ -158,7 +167,7 @@ module BootstrapBuilder
158
167
  protected
159
168
 
160
169
  # Main rendering method
161
- def render_field(field_name, method, options={}, &block)
170
+ def render_field(field_name, method, options={}, html_options={}, &block)
162
171
  case field_name
163
172
  when 'check_box'
164
173
  template = field_name
@@ -166,14 +175,14 @@ module BootstrapBuilder
166
175
  template = 'default_field'
167
176
  end
168
177
  @template.render(:partial => "#{BootstrapBuilder.config.template_folder}/#{template}", :locals => {
169
- :builder => self,
170
- :method => method,
171
- :field => @template.capture(&block),
172
- :label_text => label_text(method, options.delete(:label)),
173
- :required => options.delete(:required),
174
- :prepend => @template.raw(options.delete(:prepend)),
175
- :append => @template.raw(options.delete(:append)),
176
- :help_block => @template.raw(options.delete(:help_block)),
178
+ :builder => self,
179
+ :method => method,
180
+ :field => @template.capture(&block),
181
+ :label_text => label_text(method, html_options[:label]),
182
+ :required => html_options[:required],
183
+ :prepend => html_options[:prepend],
184
+ :append => html_options[:append],
185
+ :help_block => html_options[:help_block],
177
186
  :error_messages => error_messages_for(method)
178
187
  })
179
188
  end
@@ -182,5 +191,18 @@ module BootstrapBuilder
182
191
  text.nil? ? method.to_s.titleize.capitalize : @template.raw(text)
183
192
  end
184
193
 
194
+ def collect_html_options(options = {})
195
+ [
196
+ :prepend,
197
+ :append,
198
+ :label,
199
+ :help_block,
200
+ :required
201
+ ].inject({}) do |h, attribute|
202
+ h[attribute] = @template.raw(options.delete(attribute))
203
+ h
204
+ end
205
+ end
206
+
185
207
  end
186
208
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-09 00:00:00.000000000 Z
13
+ date: 2012-07-03 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ''
16
16
  email: jack@twg.ca
@@ -41,7 +41,6 @@ files:
41
41
  - lib/bootstrap_builder/engine.rb
42
42
  - lib/bootstrap_builder/helper.rb
43
43
  - lib/bootstrap_builder/railtie.rb
44
- - rails-bootstrap-builder.gemspec
45
44
  homepage: http://github.com/twg/bootstrap_builder
46
45
  licenses:
47
46
  - MIT
@@ -1,52 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "rails-bootstrap-builder"
8
- s.version = "0.0.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jack Neto", "The Working Group Inc."]
12
- s.date = "2012-02-04"
13
- s.description = ""
14
- s.email = "jack@twg.ca"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- "LICENSE.txt",
21
- "README.md",
22
- "Rakefile",
23
- "VERSION",
24
- "app/.DS_Store",
25
- "app/views/bootstrap_builder/_check_box.html.haml",
26
- "app/views/bootstrap_builder/_default_field.html.haml",
27
- "app/views/bootstrap_builder/_radio_button.html.haml",
28
- "app/views/bootstrap_builder/_submit.html.haml",
29
- "lib/bootstrap_builder.rb",
30
- "lib/bootstrap_builder/.DS_Store",
31
- "lib/bootstrap_builder/builder.rb",
32
- "lib/bootstrap_builder/configuration.rb",
33
- "lib/bootstrap_builder/engine.rb",
34
- "lib/bootstrap_builder/helper.rb",
35
- "vendor/.DS_Store"
36
- ]
37
- s.homepage = "http://github.com/twg/rails-bootstrap-builder"
38
- s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.15"
41
- s.summary = "A Rails form builder to the generates Twitter Bootstrap markup"
42
-
43
- if s.respond_to? :specification_version then
44
- s.specification_version = 3
45
-
46
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
- else
48
- end
49
- else
50
- end
51
- end
52
-