padrino-helpers 0.12.9 → 0.13.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +5 -13
  2. data/lib/padrino-helpers.rb +2 -2
  3. data/lib/padrino-helpers/asset_tag_helpers.rb +18 -26
  4. data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +3 -56
  5. data/lib/padrino-helpers/form_builder/standard_form_builder.rb +1 -1
  6. data/lib/padrino-helpers/form_helpers.rb +11 -227
  7. data/lib/padrino-helpers/form_helpers/options.rb +5 -7
  8. data/lib/padrino-helpers/output_helpers.rb +1 -1
  9. data/lib/padrino-helpers/output_helpers/abstract_handler.rb +1 -1
  10. data/lib/padrino-helpers/output_helpers/erb_handler.rb +1 -2
  11. data/lib/padrino-helpers/render_helpers.rb +2 -23
  12. data/lib/padrino-helpers/tag_helpers.rb +1 -14
  13. data/lib/padrino/rendering.rb +4 -56
  14. data/lib/padrino/rendering/erb_template.rb +0 -12
  15. data/lib/padrino/rendering/erubis_template.rb +1 -1
  16. data/padrino-helpers.gemspec +1 -1
  17. data/test/fixtures/markup_app/views/form_for.erb +0 -28
  18. data/test/fixtures/markup_app/views/form_for.haml +0 -22
  19. data/test/fixtures/markup_app/views/form_for.slim +0 -21
  20. data/test/fixtures/markup_app/views/form_tag.erb +0 -21
  21. data/test/fixtures/markup_app/views/form_tag.haml +0 -14
  22. data/test/fixtures/markup_app/views/form_tag.slim +0 -14
  23. data/test/helper.rb +17 -6
  24. data/test/test_asset_tag_helpers.rb +92 -110
  25. data/test/test_form_builder.rb +450 -691
  26. data/test/test_form_helpers.rb +457 -770
  27. data/test/test_format_helpers.rb +37 -17
  28. data/test/test_helpers.rb +0 -8
  29. data/test/test_output_helpers.rb +72 -72
  30. data/test/test_render_helpers.rb +100 -142
  31. data/test/test_rendering.rb +1 -58
  32. data/test/test_tag_helpers.rb +39 -41
  33. metadata +118 -34
  34. data/lib/padrino-helpers/form_builder/deprecated_builder_methods.rb +0 -79
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NWZmYWM3OThmOGFlNjFhMTZhMzUxNWFjYjBkNGQyZjYxOTI2NTM3Yg==
5
- data.tar.gz: !binary |-
6
- OWUzZmRkZGE3NTlkZTY4OWY5OGEyN2I3YzQ2YWE5NDAwZTUwOTQxNw==
2
+ SHA1:
3
+ metadata.gz: 90f809ec2266b9152c925d2f58349e4c21aad7ba
4
+ data.tar.gz: bd46c487a141f9dd7ec10e47c750a12563de6b42
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzBkY2FiOGQzNmEwNTA2N2NjMWQzZDIwY2Y4ZjU1OWJhOWI3NGFjZTVhZDhi
10
- OTQxYjIyMGQ2MDZhYzdlZmY3MDQxZDBiYmE5NWI0MjUzZjgzNDUwZjg4NzIw
11
- OTI4M2ZmYWYzMDhhMjlhY2Y4OWMyMDQ0Y2VmMTczYjQ1NDQ0ZDM=
12
- data.tar.gz: !binary |-
13
- YmYyOWE2NzFlZmNjYjJmMmJiZjM5NzFiMDg5ZTQ2NDljYzUzZDY2MjlhMGE0
14
- NDNlMmZkZjVlZWQwN2ZmNzg5NzQ4YjgwZjdkZTlhMDVkZDE0ZTU2NjQ0YzAz
15
- ZTVkZjA0MWI3NjMyZTE4NGE0NTBkYjM3ZGE4YTFkODUyZDVhYmQ=
6
+ metadata.gz: b6d5d486ffa13c48f4f228911a21eb05ee37137f8e089ab0ea11db55f3ce5fadf0780596a670380e6dbc0d9d52eb1b7e77cf163bd0c40627495c937c5e955e5a
7
+ data.tar.gz: d8545dcaf232f2c57905fd64370fba723bd60c8015cb4c5341df244d8aa21df9b070d65d64ffca40a7dcccc9b825495bb3be33c8869778738680dd9eb7c42131
@@ -6,6 +6,7 @@ require 'active_support/core_ext/string/conversions' # to_date
6
6
  require 'active_support/option_merger' # with_options
7
7
  require 'active_support/core_ext/object/with_options' # with_options
8
8
  require 'active_support/inflector' # humanize
9
+ require 'active_support/core_ext/hash/except' # Hash#except
9
10
  require 'padrino/rendering'
10
11
 
11
12
  FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__)
@@ -41,9 +42,8 @@ module Padrino
41
42
  # end
42
43
  #
43
44
  def registered(app)
44
- require 'padrino/rendering'
45
45
  app.register Padrino::Rendering
46
- app.set :default_builder, 'StandardFormBuilder' unless app.respond_to?(:default_builder)
46
+ app.set :default_builder, 'StandardFormBuilder'
47
47
  included(app)
48
48
  end
49
49
 
@@ -24,7 +24,7 @@ module Padrino
24
24
  #
25
25
  # @example
26
26
  # flash_tag(:notice, :id => 'flash-notice')
27
- # # Generates: <div class="notice">flash-notice</div>
27
+ # # Generates: <div class="notice" id="flash-notice">flash-notice</div>
28
28
  # flash_tag(:error, :success)
29
29
  # # Generates: <div class="error">flash-error</div>
30
30
  # # <div class="success">flash-success</div>
@@ -67,22 +67,25 @@ module Padrino
67
67
  #
68
68
  # @example
69
69
  # link_to('click me', '/dashboard', :class => 'linky')
70
+ # # Generates <a class="linky" href="/dashboard">click me</a>
71
+ #
70
72
  # link_to('click me', '/dashboard', :remote => true)
73
+ # # Generates <a href="/dashboard" data-remote="true">click me</a>
74
+ #
71
75
  # link_to('click me', '/dashboard', :method => :delete)
72
- # link_to('/dashboard', :class => 'blocky') do; end
76
+ # # Generates <a href="/dashboard" data-method="delete" rel="nofollow">click me</a>
77
+ #
78
+ # link_to('click me', :class => 'blocky') do; end
79
+ # # Generates <a class="blocky" href="#">click me</a>
73
80
  #
74
81
  # Note that you can pass :+if+ or :+unless+ conditions, but if you provide :current as
75
82
  # condition padrino return true/false if the request.path_info match the given url.
76
83
  #
77
84
  def link_to(*args, &block)
78
- options = args.extract_options!
85
+ options = args.extract_options!
79
86
  name = block_given? ? '' : args.shift
80
87
  href = args.first
81
- if fragment = options[:fragment] || options[:anchor]
82
- warn 'Options :anchor and :fragment are deprecated for #link_to. Please use :fragment for #url'
83
- href << '#' << fragment.to_s
84
- end
85
- options = { :href => href ? escape_link(href) : '#' }.update(options)
88
+ options.reverse_merge!(:href => href || '#')
86
89
  return name unless parse_conditions(href, options)
87
90
  block_given? ? content_tag(:a, options, &block) : content_tag(:a, name, options)
88
91
  end
@@ -133,10 +136,11 @@ module Padrino
133
136
  # @return [String] Mail link html tag with specified +options+.
134
137
  #
135
138
  # @example
136
- # # Generates: <a href="mailto:me@demo.com">me@demo.com</a>
137
139
  # mail_to "me@demo.com"
138
- # # Generates: <a href="mailto:me@demo.com">My Email</a>
140
+ # # Generates: <a href="mailto:me@demo.com">me@demo.com</a>
141
+ #
139
142
  # mail_to "me@demo.com", "My Email"
143
+ # # Generates: <a href="mailto:me@demo.com">My Email</a>
140
144
  #
141
145
  def mail_to(email, caption=nil, mail_options={})
142
146
  html_options = mail_options.slice!(:cc, :bcc, :subject, :body)
@@ -156,11 +160,11 @@ module Padrino
156
160
  # @return [String] Meta html tag with specified +options+.
157
161
  #
158
162
  # @example
159
- # # Generates: <meta name="keywords" content="weblog,news" />
160
163
  # meta_tag "weblog,news", :name => "keywords"
164
+ # # Generates: <meta name="keywords" content="weblog,news" />
161
165
  #
162
- # # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
163
166
  # meta_tag "text/html; charset=UTF-8", 'http-equiv' => "Content-Type"
167
+ # # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
164
168
  #
165
169
  def meta_tag(content, options={})
166
170
  options.reverse_merge!("content" => content)
@@ -204,21 +208,9 @@ module Padrino
204
208
  #
205
209
  def image_tag(url, options={})
206
210
  options.reverse_merge!(:src => image_path(url))
207
- options[:alt] ||= image_alt(url) unless url =~ /\A(?:cid|data):/ || url.blank?
208
211
  tag(:img, options)
209
212
  end
210
213
 
211
- ##
212
- # Returns a string suitable for an alt attribute of img element.
213
- #
214
- # @param [String] src
215
- # The source path for the image tag.
216
- # @return [String] The alt attribute value.
217
- #
218
- def image_alt(src)
219
- File.basename(src, '.*').sub(/-[[:xdigit:]]{32,64}\z/, '').tr('-_', ' ').capitalize
220
- end
221
-
222
214
  ##
223
215
  # Returns a html link tag for each of the sources provided.
224
216
  # You can pass in the filename without extension or a symbol and we search it in your +appname.public_folder+
@@ -245,7 +237,7 @@ module Padrino
245
237
  end
246
238
 
247
239
  ##
248
- # Returns an html script tag for each of the sources provided.
240
+ # Returns a html script tag for each of the sources provided.
249
241
  # You can pass in the filename without extension or a symbol and we search it in your +appname.public_folder+
250
242
  # like app/public/javascript for inclusion. You can provide also a full path.
251
243
  #
@@ -310,7 +302,7 @@ module Padrino
310
302
  #
311
303
  def asset_path(kind, source = nil)
312
304
  kind, source = source, kind if source.nil?
313
- source = asset_normalize_extension(kind, escape_link(source.to_s))
305
+ source = asset_normalize_extension(kind, URI.escape(source.to_s))
314
306
  return source if source =~ ABSOLUTE_URL_PATTERN || source =~ /^\//
315
307
  source = File.join(asset_folder_name(kind), source)
316
308
  timestamp = asset_timestamp(source)
@@ -1,5 +1,3 @@
1
- require 'padrino-helpers/form_builder/deprecated_builder_methods'
2
-
3
1
  module Padrino
4
2
  module Helpers
5
3
  module FormBuilder
@@ -8,8 +6,6 @@ module Padrino
8
6
  attr_accessor :template, :object, :multipart
9
7
  attr_reader :namespace, :is_nested, :parent_form, :nested_index, :attributes_name, :model_name
10
8
 
11
- include DeprecatedBuilderMethods
12
-
13
9
  def initialize(template, object, options={})
14
10
  @template = template
15
11
  fail "FormBuilder template must be initialized" unless template
@@ -37,9 +33,7 @@ module Padrino
37
33
  def label(field, options={}, &block)
38
34
  options[:id] ||= nil
39
35
  options[:caption] ||= I18n.t("#{model_name}.attributes.#{field}", :count => 1, :default => field.to_s.humanize, :scope => :models) + ': '
40
- defaults = default_options(field, options)
41
- defaults.delete(:value)
42
- @template.label_tag(field_id(field), defaults, &block)
36
+ @template.label_tag(field_id(field), default_options(field, options), &block)
43
37
  end
44
38
 
45
39
  def hidden_field(field, options={})
@@ -112,9 +106,7 @@ module Padrino
112
106
 
113
107
  def file_field(field, options={})
114
108
  self.multipart = true
115
- defaults = default_options(field, options)
116
- defaults.delete(:value)
117
- @template.file_field_tag field_name(field), defaults
109
+ @template.file_field_tag field_name(field), default_options(field, options).except(:value)
118
110
  end
119
111
 
120
112
  def submit(*args)
@@ -125,34 +117,6 @@ module Padrino
125
117
  @template.image_submit_tag source, options
126
118
  end
127
119
 
128
- def datetime_field(field, options={})
129
- @template.datetime_field_tag field_name(field), default_options(field, options)
130
- end
131
-
132
- def datetime_local_field(field, options={})
133
- @template.datetime_local_field_tag field_name(field), default_options(field, options)
134
- end
135
-
136
- def date_field(field, options={})
137
- @template.date_field_tag field_name(field), default_options(field, options)
138
- end
139
-
140
- def month_field(field, options={})
141
- @template.month_field_tag field_name(field), default_options(field, options)
142
- end
143
-
144
- def week_field(field, options={})
145
- @template.week_field_tag field_name(field), default_options(field, options)
146
- end
147
-
148
- def time_field(field, options={})
149
- @template.time_field_tag field_name(field), default_options(field, options)
150
- end
151
-
152
- def color_field(field, options={})
153
- @template.color_field_tag field_name(field), default_options(field, options)
154
- end
155
-
156
120
  ##
157
121
  # Supports nested fields for a child model within a form.
158
122
  # f.fields_for :addresses
@@ -179,24 +143,7 @@ module Padrino
179
143
 
180
144
  # Returns the known field types for a Formbuilder.
181
145
  def self.field_types
182
- [:hidden_field, :text_field, :text_area, :password_field, :file_field, :radio_button, :check_box, :select,
183
- :number_field, :telephone_field, :email_field, :search_field, :url_field,
184
- :datetime_field, :datetime_local_field, :date_field, :month_field, :week_field, :time_field, :color_field,
185
- ]
186
- end
187
-
188
- ##
189
- # Returns the human name of the field. Look that use builtin I18n.
190
- #
191
- def field_human_name(field)
192
- I18n.translate("#{object_model_name}.attributes.#{field}", :count => 1, :default => field.to_s.humanize, :scope => :models)
193
- end
194
-
195
- ##
196
- # Returns the object's models name.
197
- #
198
- def object_model_name(explicit_object=object)
199
- explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_')
146
+ [:hidden_field, :text_field, :text_area, :password_field, :file_field, :radio_button, :check_box, :select]
200
147
  end
201
148
 
202
149
  ##
@@ -17,7 +17,7 @@ module Padrino
17
17
  (self.field_types - [ :hidden_field, :radio_button ]).each do |field_type|
18
18
  class_eval <<-EOF
19
19
  def #{field_type}_block(field, options={}, label_options={})
20
- label_options = { :caption => options[:caption] }.update(label_options) if options[:caption]
20
+ label_options.reverse_merge!(:caption => options.delete(:caption)) if options[:caption]
21
21
  field_html = label(field, label_options)
22
22
  field_html << #{field_type}(field, options)
23
23
  @template.content_tag(:p, field_html)
@@ -45,9 +45,7 @@ module Padrino
45
45
  instance = builder_instance(object, options)
46
46
  # this can erect instance.multipart flag if the block calls instance.file_field
47
47
  html = capture_html(instance, &block)
48
- options = { :multipart => instance.multipart }.update(options)
49
- options.delete(:as)
50
- options.delete(:namespace)
48
+ options = { :multipart => instance.multipart }.update(options.except(:namespace, :as))
51
49
  form_tag(url, options) { html }
52
50
  end
53
51
 
@@ -92,7 +90,7 @@ module Padrino
92
90
  #
93
91
  def form_tag(url, options={}, &block)
94
92
  options = {
95
- :action => escape_link(url),
93
+ :action => url,
96
94
  :protect_from_csrf => is_protected_from_csrf?,
97
95
  'accept-charset' => 'UTF-8'
98
96
  }.update(options)
@@ -400,7 +398,8 @@ module Padrino
400
398
  #
401
399
  def text_area_tag(name, options={})
402
400
  inner_html = TagHelpers::NEWLINE + options.delete(:value).to_s
403
- content_tag(:textarea, inner_html, { :name => name }.update(options))
401
+ options = { :name => name, :rows => "", :cols => "" }.update(options)
402
+ content_tag(:textarea, inner_html, options)
404
403
  end
405
404
 
406
405
  ##
@@ -581,13 +580,17 @@ module Padrino
581
580
  # # </form>
582
581
  #
583
582
  def button_to(*args, &block)
584
- warn 'Warning: method button_to with block will change behavior on Padrino 0.13.0 release and will wrap the content of the block with <button></button> tag.' if block_given?
585
583
  options = args.extract_options!.dup
586
584
  name, url = *args
587
585
  options['data-remote'] = 'true' if options.delete(:remote)
588
586
  submit_options = options.delete(:submit_options) || {}
589
- block ||= proc { submit_tag(name, submit_options) }
590
- form_tag(url || name, options, &block)
587
+ form_tag(url || name, options) do
588
+ if block_given?
589
+ content_tag(:button, capture_html(&block), submit_options)
590
+ else
591
+ submit_tag(name, submit_options)
592
+ end
593
+ end
591
594
  end
592
595
 
593
596
  ##
@@ -617,185 +620,6 @@ module Padrino
617
620
  input_tag(:range, options)
618
621
  end
619
622
 
620
- DATETIME_ATTRIBUTES = [:value, :max, :min].freeze
621
- COLOR_CODE_REGEXP = /\A#([0-9a-fA-F]{3}){1,2}\z/.freeze
622
-
623
- ##
624
- # Constructs a datetime tag from the given options.
625
- #
626
- # @example
627
- # datetime_field_tag('datetime_with_min_max', :min => DateTime.new(1993, 2, 24, 12, 30, 45),
628
- # :max => DateTime.new(2000, 4, 1, 12, 0, 0))
629
- # datetime_field_tag('datetime_with_value', :value => DateTime.new(2000, 4, 1, 12, 0, 0))
630
- #
631
- # @param [String] name
632
- # The name of the datetime field.
633
- # @param [Hash] options
634
- # The html options for the datetime field.
635
- # @option options [DateTime, String] :min
636
- # The min date time of the datetime field.
637
- # @option options [DateTime, String] :max
638
- # The max date time of the datetime field.
639
- # @option options [DateTime, String] :value
640
- # The value of the datetime field. See examples for details.
641
- # @return [String] The html datetime field
642
- #
643
- def datetime_field_tag(name, options = {})
644
- options = { :name => name }.update(options)
645
- options = convert_attributes_into_datetime("%Y-%m-%dT%T.%L%z", options)
646
- input_tag(:datetime, options)
647
- end
648
-
649
- ##
650
- # Constructs a datetime-local tag from the given options.
651
- #
652
- # @example
653
- # datetime_local_field_tag('datetime_local_with_min_max', :min => DateTime.new(1993, 2, 24, 12, 30, 45),
654
- # :max => DateTime.new(2000, 4, 1, 12, 0, 0))
655
- # datetime_local_field_tag('datetime_local_with_value', :value => DateTime.new(2000, 4, 1, 12, 0, 0))
656
- #
657
- # @param [String] name
658
- # The name of the datetime local field.
659
- # @param [Hash] options
660
- # The html options for the datetime-local field.
661
- # @option options [DateTime, String] :min
662
- # The min date time of the datetime-local field.
663
- # @option options [DateTime, String] :max
664
- # The max date time of the datetime-local field.
665
- # @option options [DateTime, String] :value
666
- # The value of the datetime field. See examples for details.
667
- # @return [String] The html datetime-local field
668
- #
669
- def datetime_local_field_tag(name, options = {})
670
- options = { :name => name }.update(options)
671
- options = convert_attributes_into_datetime("%Y-%m-%dT%T", options)
672
- input_tag(:"datetime-local", options)
673
- end
674
-
675
- ##
676
- # Constructs a date tag from the given options.
677
- #
678
- # @example
679
- # date_field_tag('date_with_min_max', :min => DateTime.new(1993, 2, 24),
680
- # :max => DateTime.new(2000, 4, 1))
681
- # date_field_tag('date_with_value', :value => DateTime.new(2000, 4, 1))
682
- #
683
- # @param [String] name
684
- # The name of the date field.
685
- # @param [Hash] options
686
- # The html options for the date field.
687
- # @option options [DateTime, String] :min
688
- # The min date time of the date field.
689
- # @option options [DateTime, String] :max
690
- # The max date time of the date field.
691
- # @option options [DateTime, String] :value
692
- # The value of the date field. See examples for details.
693
- # @return [String] The html date field
694
- #
695
- def date_field_tag(name, options = {})
696
- options = { :name => name }.update(options)
697
- options = convert_attributes_into_datetime("%Y-%m-%d", options)
698
- input_tag(:date, options)
699
- end
700
-
701
- ##
702
- # Constructs a month tag from the given options.
703
- #
704
- # @example
705
- # month_field_tag('month_with_min_max', :min => DateTime.new(1993, 2, 24),
706
- # :max => DateTime.new(2000, 4, 1))
707
- # month_field_tag('month_with_value', :value => DateTime.new(2000, 4, 1))
708
- #
709
- # @param [String] name
710
- # The name of the month field.
711
- # @param [Hash] options
712
- # The html options for the month field.
713
- # @option options [DateTime, String] :min
714
- # The min month time of the month field.
715
- # @option options [DateTime, String] :max
716
- # The max month time of the month field.
717
- # @option options [DateTime, String] :value
718
- # The value of the month field. See examples for details.
719
- # @return [String] The html month field
720
- #
721
- def month_field_tag(name, options = {})
722
- options = { :name => name }.update(options)
723
- options = convert_attributes_into_datetime("%Y-%m", options)
724
- input_tag(:month, options)
725
- end
726
-
727
- ##
728
- # Constructs a week tag from the given options.
729
- #
730
- # @example
731
- # week_field_tag('week_with_min_max', :min => DateTime.new(1993, 2, 24),
732
- # :max => DateTime.new(2000, 4, 1))
733
- # week_field_tag('week_with_value', :value => DateTime.new(2000, 4, 1))
734
- #
735
- # @param [String] name
736
- # The name of the week field.
737
- # @param [Hash] options
738
- # The html options for the week field.
739
- # @option options [DateTime, String] :min
740
- # The min week time of the week field.
741
- # @option options [DateTime, String] :max
742
- # The max week time of the week field.
743
- # @option options [DateTime, String] :value
744
- # The value of the week field. See examples for details.
745
- # @return [String] The html week field
746
- #
747
- def week_field_tag(name, options = {})
748
- options = { :name => name }.update(options)
749
- options = convert_attributes_into_datetime("%Y-W%W", options)
750
- input_tag(:week, options)
751
- end
752
-
753
- ##
754
- # Constructs a time tag from the given options.
755
- #
756
- # @example
757
- # time_field_tag('time_with_min_max', :max => Time.new(1993, 2, 24, 1, 19, 12),
758
- # :min => Time.new(2008, 6, 21, 13, 30, 0))
759
- # time_field_tag('time_with_value', :value => Time.new(2008, 6, 21, 13, 30, 0))
760
- #
761
- # @param [String] name
762
- # The name of the time field.
763
- # @param [Hash] options
764
- # The html options for the time field.
765
- # @option options [Time, DateTime, String] :min
766
- # The min time of the time field.
767
- # @option options [Time, DateTime, String] :max
768
- # The max time of the time field.
769
- # @option options [Time, DateTime, String] :value
770
- # The value of the time field. See examples for details.
771
- # @return [String] The html time field
772
- #
773
- def time_field_tag(name, options = {})
774
- options = { :name => name }.update(options)
775
- options = convert_attributes_into_datetime("%T.%L", options)
776
- input_tag(:time, options)
777
- end
778
-
779
- ##
780
- # Constructs a color tag from the given options.
781
- #
782
- # @example
783
- # color_field_tag('color', :value => "#ff0000")
784
- # color_field_tag('color', :value => "#f00")
785
- #
786
- # @param [String] name
787
- # The name of the color field.
788
- # @param [Hash] options
789
- # The html options for the color field.
790
- # @option options [String] :value
791
- # The value of the color field. See examples for details.
792
- #
793
- def color_field_tag(name, options = {})
794
- options = { :name => name }.update(options)
795
- options[:value] = adjust_color(options[:value])
796
- input_tag(:color, options)
797
- end
798
-
799
623
  private
800
624
 
801
625
  ##
@@ -810,46 +634,6 @@ module Padrino
810
634
  builder_class = "Padrino::Helpers::FormBuilder::#{builder_class}".constantize if builder_class.is_a?(String)
811
635
  builder_class.new(self, object, options)
812
636
  end
813
-
814
- ##
815
- # Converts value into DateTime.
816
- #
817
- # @example
818
- # datetime_value('1993-02-24T12:30:45') #=> #<DateTime: 1993-02-24T12:30:45+00:00>
819
- #
820
- def datetime_value(value)
821
- if value.kind_of?(String)
822
- DateTime.parse(value) rescue nil
823
- else
824
- value
825
- end
826
- end
827
-
828
- ##
829
- # Converts special attributes into datetime format strings that conforms to RFC 3399.
830
- #
831
- def convert_attributes_into_datetime(format, options)
832
- DATETIME_ATTRIBUTES.each_with_object(options) do |attribute|
833
- value = datetime_value(options[attribute])
834
- options[attribute] = value.strftime(format) if value.respond_to?(:strftime)
835
- end
836
- end
837
-
838
- ##
839
- # Adjusts color code for the given color.
840
- #
841
- # @example
842
- # adust_color("#000") #=> "#000000"
843
- # adust_color("#ff0000") #=> "#ff0000"
844
- # adust_color("#foobar") #=> "#000000"
845
- #
846
- def adjust_color(color)
847
- return "#000000" unless color =~ COLOR_CODE_REGEXP
848
- return color if (color_size = color.size) == 7
849
- color.slice(1, color_size - 1).each_char.with_object("#") do |chr, obj|
850
- obj << chr * 2
851
- end
852
- end
853
637
  end
854
638
  end
855
639
  end