padrino-helpers 0.13.1 → 0.13.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.
- checksums.yaml +4 -4
- data/lib/padrino-helpers.rb +1 -7
- data/lib/padrino-helpers/asset_tag_helpers.rb +17 -5
- data/lib/padrino-helpers/form_builder/abstract_form_builder.rb +14 -6
- data/lib/padrino-helpers/form_builder/standard_form_builder.rb +4 -1
- data/lib/padrino-helpers/form_helpers.rb +2 -3
- data/lib/padrino-helpers/format_helpers.rb +29 -30
- data/padrino-helpers.gemspec +1 -1
- data/test/helper.rb +3 -2
- data/test/test_asset_tag_helpers.rb +14 -1
- data/test/test_format_helpers.rb +17 -37
- data/test/test_helpers.rb +8 -0
- metadata +22 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4cd07c5d69526e5a313ac66077c95232f9897c4
|
4
|
+
data.tar.gz: 2d729f064bd09f49fcd7d580a9c0d0efb0a71bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a811845a52c9d07a6d3344ded444856705e35ee1460e257b9cbe3e1d95698556677709e504ca96c2bf2f18313b32edfd06b9df4c11b1430f74eefafaf19cddc
|
7
|
+
data.tar.gz: 5686b30bbbf57ea22e28bdfc7afc8fba531a4658a1426dae8d4774afde8181bc43c558ffa6b1de595d1794815ccbef1c8a3ae7198f208d7969681c9c3c96bc11
|
data/lib/padrino-helpers.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
require 'padrino-support'
|
2
2
|
require 'i18n'
|
3
3
|
require 'enumerator'
|
4
|
-
require 'active_support/time_with_zone' # next extension depends on this
|
5
|
-
require 'active_support/core_ext/string/conversions' # to_date
|
6
|
-
require 'active_support/option_merger' # with_options
|
7
|
-
require 'active_support/core_ext/object/with_options' # with_options
|
8
|
-
require 'active_support/inflector' # humanize
|
9
|
-
require 'active_support/core_ext/hash/except' # Hash#except
|
10
4
|
require 'padrino/rendering'
|
11
5
|
|
12
6
|
FileSet.glob_require('padrino-helpers/**/*.rb', __FILE__)
|
@@ -43,7 +37,7 @@ module Padrino
|
|
43
37
|
#
|
44
38
|
def registered(app)
|
45
39
|
app.register Padrino::Rendering
|
46
|
-
app.set :default_builder, 'StandardFormBuilder'
|
40
|
+
app.set :default_builder, 'StandardFormBuilder' unless app.respond_to?(:default_builder)
|
47
41
|
included(app)
|
48
42
|
end
|
49
43
|
|
@@ -85,7 +85,7 @@ module Padrino
|
|
85
85
|
options = args.extract_options!
|
86
86
|
name = block_given? ? '' : args.shift
|
87
87
|
href = args.first
|
88
|
-
options
|
88
|
+
options = { :href => href || '#' }.update(options)
|
89
89
|
return name unless parse_conditions(href, options)
|
90
90
|
block_given? ? content_tag(:a, options, &block) : content_tag(:a, name, options)
|
91
91
|
end
|
@@ -116,7 +116,7 @@ module Padrino
|
|
116
116
|
#
|
117
117
|
def feed_tag(mime, url, options={})
|
118
118
|
full_mime = (mime == :atom) ? 'application/atom+xml' : 'application/rss+xml'
|
119
|
-
tag(:link,
|
119
|
+
tag(:link, { :rel => 'alternate', :type => full_mime, :title => mime, :href => url }.update(options))
|
120
120
|
end
|
121
121
|
|
122
122
|
##
|
@@ -167,7 +167,7 @@ module Padrino
|
|
167
167
|
# # Generates: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
168
168
|
#
|
169
169
|
def meta_tag(content, options={})
|
170
|
-
options
|
170
|
+
options = { "content" => content }.update(options)
|
171
171
|
tag(:meta, options)
|
172
172
|
end
|
173
173
|
|
@@ -189,7 +189,7 @@ module Padrino
|
|
189
189
|
#
|
190
190
|
def favicon_tag(source, options={})
|
191
191
|
type = File.extname(source).sub('.','')
|
192
|
-
options =
|
192
|
+
options = { :href => image_path(source), :rel => 'icon', :type => "image/#{type}" }.update(options)
|
193
193
|
tag(:link, options)
|
194
194
|
end
|
195
195
|
|
@@ -207,10 +207,22 @@ module Padrino
|
|
207
207
|
# image_tag('icons/avatar.png')
|
208
208
|
#
|
209
209
|
def image_tag(url, options={})
|
210
|
-
options
|
210
|
+
options = { :src => image_path(url) }.update(options)
|
211
|
+
options[:alt] ||= image_alt(url) unless url.to_s =~ /\A(?:cid|data):|\A\Z/
|
211
212
|
tag(:img, options)
|
212
213
|
end
|
213
214
|
|
215
|
+
##
|
216
|
+
# Returns a string suitable for an alt attribute of img element.
|
217
|
+
#
|
218
|
+
# @param [String] src
|
219
|
+
# The source path for the image tag.
|
220
|
+
# @return [String] The alt attribute value.
|
221
|
+
#
|
222
|
+
def image_alt(src)
|
223
|
+
File.basename(src, '.*').sub(/-[[:xdigit:]]{32,64}\z/, '').tr('-_', ' ').capitalize
|
224
|
+
end
|
225
|
+
|
214
226
|
##
|
215
227
|
# Returns a html link tag for each of the sources provided.
|
216
228
|
# You can pass in the filename without extension or a symbol and we search it in your +appname.public_folder+
|
@@ -31,9 +31,7 @@ module Padrino
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def label(field, options={}, &block)
|
34
|
-
|
35
|
-
options[:caption] ||= I18n.t("#{model_name}.attributes.#{field}", :count => 1, :default => field.to_s.humanize, :scope => :models) + ': '
|
36
|
-
@template.label_tag(field_id(field), default_options(field, options), &block)
|
34
|
+
@template.label_tag(field_id(field), { :caption => "#{field_human_name(field)}: " }.update(options), &block)
|
37
35
|
end
|
38
36
|
|
39
37
|
def hidden_field(field, options={})
|
@@ -106,7 +104,7 @@ module Padrino
|
|
106
104
|
|
107
105
|
def file_field(field, options={})
|
108
106
|
self.multipart = true
|
109
|
-
@template.file_field_tag field_name(field), default_options(field, options).
|
107
|
+
@template.file_field_tag field_name(field), default_options(field, options).reject{ |key, _| key == :value }
|
110
108
|
end
|
111
109
|
|
112
110
|
def submit(*args)
|
@@ -171,14 +169,24 @@ module Padrino
|
|
171
169
|
|
172
170
|
# Returns the known field types for a Formbuilder.
|
173
171
|
def self.field_types
|
174
|
-
[:hidden_field, :text_field, :text_area, :password_field, :file_field, :radio_button, :check_box, :select
|
172
|
+
[:hidden_field, :text_field, :text_area, :password_field, :file_field, :radio_button, :check_box, :select,
|
173
|
+
:number_field, :telephone_field, :email_field, :search_field, :url_field,
|
174
|
+
:datetime_field, :datetime_local_field, :date_field, :month_field, :week_field, :time_field, :color_field,
|
175
|
+
]
|
175
176
|
end
|
176
177
|
|
177
178
|
##
|
178
179
|
# Returns the human name of the field. Look that use builtin I18n.
|
179
180
|
#
|
180
181
|
def field_human_name(field)
|
181
|
-
I18n.translate("#{
|
182
|
+
I18n.translate("#{model_name}.attributes.#{field}", :count => 1, :default => field.to_s.humanize, :scope => :models)
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# Returns the object's models name.
|
187
|
+
#
|
188
|
+
def object_model_name(explicit_object=object)
|
189
|
+
explicit_object.is_a?(Symbol) ? explicit_object : explicit_object.class.to_s.underscore.gsub(/\//, '_')
|
182
190
|
end
|
183
191
|
|
184
192
|
##
|
@@ -17,7 +17,10 @@ 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
|
-
|
20
|
+
if options[:caption]
|
21
|
+
options = options.dup
|
22
|
+
label_options = { :caption => options.delete(:caption) }.update(label_options)
|
23
|
+
end
|
21
24
|
field_html = label(field, label_options)
|
22
25
|
field_html << #{field_type}(field, options)
|
23
26
|
@template.content_tag(:p, field_html)
|
@@ -45,7 +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.
|
48
|
+
options = { :multipart => instance.multipart }.update(options.reject{ |key,_| [:namespace, :as].include?(key) })
|
49
49
|
form_tag(url, options) { html }
|
50
50
|
end
|
51
51
|
|
@@ -398,8 +398,7 @@ module Padrino
|
|
398
398
|
#
|
399
399
|
def text_area_tag(name, options={})
|
400
400
|
inner_html = TagHelpers::NEWLINE + options.delete(:value).to_s
|
401
|
-
|
402
|
-
content_tag(:textarea, inner_html, options)
|
401
|
+
content_tag(:textarea, inner_html, { :name => name }.update(options))
|
403
402
|
end
|
404
403
|
|
405
404
|
##
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
module Padrino
|
3
2
|
module Helpers
|
4
3
|
###
|
@@ -126,7 +125,7 @@ module Padrino
|
|
126
125
|
# truncate("Once upon a time in a world far far away", :length => 8) => "Once upon..."
|
127
126
|
#
|
128
127
|
def truncate(text, options={})
|
129
|
-
options
|
128
|
+
options = { :length => 30, :omission => "..." }.update(options)
|
130
129
|
if text
|
131
130
|
len = options[:length] - options[:omission].length
|
132
131
|
chars = text
|
@@ -153,7 +152,7 @@ module Padrino
|
|
153
152
|
# truncate_words("Once upon a time in a world far far away", :length => 8) => "Once upon a time in a world far..."
|
154
153
|
#
|
155
154
|
def truncate_words(text, options={})
|
156
|
-
options
|
155
|
+
options = { :length => 30, :omission => "..." }.update(options)
|
157
156
|
if text
|
158
157
|
words = text.split()
|
159
158
|
words[0..(options[:length]-1)].join(' ') + (words.length > options[:length] ? options[:omission] : '')
|
@@ -182,7 +181,7 @@ module Padrino
|
|
182
181
|
unless args.blank?
|
183
182
|
options[:line_width] = args[0] || 80
|
184
183
|
end
|
185
|
-
options
|
184
|
+
options = { :line_width => 80 }.update(options)
|
186
185
|
|
187
186
|
text.split("\n").map do |line|
|
188
187
|
line.length > options[:line_width] ? line.gsub(/(.{1,#{options[:line_width]}})(\s+|$)/, "\\1\n").strip : line
|
@@ -215,8 +214,7 @@ module Padrino
|
|
215
214
|
# # => Lorem ipsum <strong class="custom">dolor</strong> sit amet
|
216
215
|
#
|
217
216
|
def highlight(text, words, *args)
|
218
|
-
options = args.extract_options!
|
219
|
-
options.reverse_merge!(:highlighter => '<strong class="highlight">\1</strong>')
|
217
|
+
options = { :highlighter => '<strong class="highlight">\1</strong>' }.update(args.extract_options!)
|
220
218
|
|
221
219
|
if text.blank? || words.blank?
|
222
220
|
text
|
@@ -291,42 +289,43 @@ module Padrino
|
|
291
289
|
distance_in_minutes = (((to_time.to_i - from_time.to_i).abs)/60).round
|
292
290
|
distance_in_seconds = ((to_time.to_i - from_time.to_i).abs).round
|
293
291
|
|
294
|
-
|
292
|
+
phrase, locals =
|
295
293
|
case distance_in_minutes
|
296
294
|
when 0..1
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
295
|
+
if include_seconds
|
296
|
+
case distance_in_seconds
|
297
|
+
when 0..4 then [:less_than_x_seconds, :count => 5 ]
|
298
|
+
when 5..9 then [:less_than_x_seconds, :count => 10]
|
299
|
+
when 10..19 then [:less_than_x_seconds, :count => 20]
|
300
|
+
when 20..39 then [:half_a_minute ]
|
301
|
+
when 40..59 then [:less_than_x_minutes, :count => 1 ]
|
302
|
+
else [:x_minutes, :count => 1 ]
|
303
|
+
end
|
304
|
+
else
|
305
|
+
distance_in_minutes == 0 ?
|
306
|
+
[:less_than_x_minutes, :count => 1] :
|
307
|
+
[:x_minutes, :count => distance_in_minutes]
|
308
308
|
end
|
309
|
-
|
310
|
-
when
|
311
|
-
when
|
312
|
-
when
|
313
|
-
when
|
314
|
-
when
|
315
|
-
when
|
316
|
-
when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
|
309
|
+
when 2..44 then [:x_minutes, :count => distance_in_minutes ]
|
310
|
+
when 45..89 then [:about_x_hours, :count => 1 ]
|
311
|
+
when 90..1439 then [:about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round ]
|
312
|
+
when 1440..2529 then [:x_days, :count => 1 ]
|
313
|
+
when 2530..43199 then [:x_days, :count => (distance_in_minutes.to_f / 1440.0).round ]
|
314
|
+
when 43200..86399 then [:about_x_months, :count => 1 ]
|
315
|
+
when 86400..525599 then [:x_months, :count => (distance_in_minutes.to_f / 43200.0).round]
|
317
316
|
else
|
318
317
|
distance_in_years = distance_in_minutes / 525600
|
319
318
|
minute_offset_for_leap_year = (distance_in_years / 4) * 1440
|
320
319
|
remainder = ((distance_in_minutes - minute_offset_for_leap_year) % 525600)
|
321
320
|
if remainder < 131400
|
322
|
-
|
321
|
+
[:about_x_years, :count => distance_in_years]
|
323
322
|
elsif remainder < 394200
|
324
|
-
|
323
|
+
[:over_x_years, :count => distance_in_years]
|
325
324
|
else
|
326
|
-
|
325
|
+
[:almost_x_years, :count => distance_in_years + 1]
|
327
326
|
end
|
328
327
|
end
|
329
|
-
|
328
|
+
I18n.translate phrase, locals.merge(:locale => options[:locale], :scope => :'datetime.distance_in_words')
|
330
329
|
end
|
331
330
|
|
332
331
|
##
|
data/padrino-helpers.gemspec
CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
25
25
|
|
26
26
|
s.add_dependency("padrino-support", Padrino.version)
|
27
|
-
s.add_dependency("tilt", "
|
27
|
+
s.add_dependency("tilt", ">= 1.4.1", "< 3")
|
28
28
|
s.add_dependency("i18n", "~> 0.6", ">= 0.6.7")
|
29
29
|
end
|
data/test/helper.rb
CHANGED
@@ -5,9 +5,10 @@ require 'minitest/pride'
|
|
5
5
|
require 'mocha/setup'
|
6
6
|
require 'rack/test'
|
7
7
|
require 'webrat'
|
8
|
-
require 'active_support/time'
|
9
8
|
require 'builder'
|
10
9
|
require 'padrino-helpers'
|
10
|
+
require 'tilt/liquid'
|
11
|
+
require 'tilt/builder'
|
11
12
|
|
12
13
|
require 'ext/minitest-spec'
|
13
14
|
require 'ext/rack-test-methods'
|
@@ -32,7 +33,7 @@ class MiniTest::Spec
|
|
32
33
|
|
33
34
|
# mock_model("Business", :new_record? => true) => <Business>
|
34
35
|
def mock_model(klazz, options={})
|
35
|
-
options
|
36
|
+
options = { :class => klazz, :new_record? => false, :id => 20, :errors => {}}.update(options)
|
36
37
|
record = stub(options)
|
37
38
|
record.stubs(:to_ary => [record])
|
38
39
|
record
|
@@ -76,6 +76,19 @@ describe "AssetTagHelpers" do
|
|
76
76
|
assert_has_tag('img', :src => "/my/fancy/image.png") { actual_link }
|
77
77
|
end
|
78
78
|
|
79
|
+
it 'should render alt text by default' do
|
80
|
+
actual_tag = image_tag("/my/fancy/image.png")
|
81
|
+
assert_has_tag('img', :src => "/my/fancy/image.png", :alt => "Image") { actual_tag }
|
82
|
+
|
83
|
+
actual_tag = image_tag("/my/fancy/image_white.png")
|
84
|
+
assert_has_tag('img', :src => "/my/fancy/image_white.png", :alt => "Image white") { actual_tag }
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should remove hash value from src path' do
|
88
|
+
actual_tag = image_tag("/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png")
|
89
|
+
assert_has_tag('img', :src => "/my/fancy/sprite-47bce5c74f589f4867dbd57e9ca9f808.png", :alt => "Sprite") { actual_tag }
|
90
|
+
end
|
91
|
+
|
79
92
|
it 'should display link block element in haml' do
|
80
93
|
visit '/haml/link_to'
|
81
94
|
assert_have_selector :a, :content => "Test 1 No Block", :href => '/test1', :class => 'test', :id => 'test1'
|
@@ -223,7 +236,7 @@ describe "AssetTagHelpers" do
|
|
223
236
|
end
|
224
237
|
|
225
238
|
it 'should have xhtml convention tag' do
|
226
|
-
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" />'
|
239
|
+
assert_equal image_tag('/absolute/pic.gif'), '<img src="/absolute/pic.gif" alt="Pic" />'
|
227
240
|
end
|
228
241
|
end
|
229
242
|
|
data/test/test_format_helpers.rb
CHANGED
@@ -57,25 +57,6 @@ describe "FormatHelpers" do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe 'for #pluralize method' do
|
61
|
-
it 'should return singular count for 1 item collections' do
|
62
|
-
actual_text = pluralize(1, 'person')
|
63
|
-
assert_equal '1 person', actual_text
|
64
|
-
end
|
65
|
-
it 'should return plural count for empty collections' do
|
66
|
-
actual_text = pluralize(0, 'person')
|
67
|
-
assert_equal '0 people', actual_text
|
68
|
-
end
|
69
|
-
it 'should return plural count for many collections' do
|
70
|
-
actual_text = pluralize(2, 'person')
|
71
|
-
assert_equal '2 people', actual_text
|
72
|
-
end
|
73
|
-
it 'should return pluralized word specified as argument' do
|
74
|
-
actual_text = pluralize(3, 'person', 'users')
|
75
|
-
assert_equal '3 users', actual_text
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
60
|
describe 'for #word_wrap method' do
|
80
61
|
it 'should return proper formatting for 8 max width' do
|
81
62
|
actual_text = word_wrap('Once upon a time', :line_width => 8)
|
@@ -158,6 +139,8 @@ describe "FormatHelpers" do
|
|
158
139
|
end
|
159
140
|
|
160
141
|
describe 'for #time_ago_in_words method' do
|
142
|
+
_DAY = 24*60*60
|
143
|
+
|
161
144
|
it 'should less than 5 seconds' do
|
162
145
|
assert_equal 'less than 5 seconds', time_ago_in_words(Time.now, true)
|
163
146
|
end
|
@@ -177,52 +160,49 @@ describe "FormatHelpers" do
|
|
177
160
|
assert_equal 'less than a minute', time_ago_in_words(Time.now)
|
178
161
|
end
|
179
162
|
it 'should display yesterday' do
|
180
|
-
assert_equal '1 day', time_ago_in_words(
|
163
|
+
assert_equal '1 day', time_ago_in_words(Time.now - _DAY)
|
181
164
|
end
|
182
165
|
it 'should display tomorrow' do
|
183
|
-
assert_equal '1 day', time_ago_in_words(
|
166
|
+
assert_equal '1 day', time_ago_in_words(Time.now + _DAY)
|
184
167
|
end
|
185
168
|
it 'should return future number of days' do
|
186
|
-
assert_equal '4 days', time_ago_in_words(4
|
169
|
+
assert_equal '4 days', time_ago_in_words(Time.now + 4*_DAY)
|
187
170
|
end
|
188
171
|
it 'should return past days ago' do
|
189
|
-
assert_equal '4 days', time_ago_in_words(4
|
172
|
+
assert_equal '4 days', time_ago_in_words(Time.now - 4*_DAY)
|
190
173
|
end
|
191
174
|
it 'should return formatted archived date' do
|
192
|
-
assert_equal '3 months', time_ago_in_words(100
|
175
|
+
assert_equal '3 months', time_ago_in_words(Time.now - 100*_DAY)
|
193
176
|
end
|
194
177
|
it 'should return formatted archived year date' do
|
195
|
-
assert_equal 'over 1 year', time_ago_in_words(500
|
178
|
+
assert_equal 'over 1 year', time_ago_in_words(Time.now - 500*_DAY)
|
196
179
|
end
|
197
180
|
it 'should display now as a minute ago' do
|
198
|
-
assert_equal '1 minute', time_ago_in_words(
|
181
|
+
assert_equal '1 minute', time_ago_in_words(Time.now - 60)
|
199
182
|
end
|
200
183
|
it 'should display a few minutes ago' do
|
201
|
-
assert_equal '4 minutes', time_ago_in_words(4
|
184
|
+
assert_equal '4 minutes', time_ago_in_words(Time.now - 4*60)
|
202
185
|
end
|
203
186
|
it 'should display an hour ago' do
|
204
|
-
assert_equal 'about 1 hour', time_ago_in_words(
|
187
|
+
assert_equal 'about 1 hour', time_ago_in_words(Time.now - 60*60 + 5)
|
205
188
|
end
|
206
189
|
it 'should display a few hours ago' do
|
207
|
-
assert_equal 'about 3 hours', time_ago_in_words(
|
208
|
-
end
|
209
|
-
it 'should display a day ago' do
|
210
|
-
assert_equal '1 day', time_ago_in_words(1.day.ago)
|
190
|
+
assert_equal 'about 3 hours', time_ago_in_words(Time.now - 3*60*60 + 5*60)
|
211
191
|
end
|
212
192
|
it 'should display a few days ago' do
|
213
|
-
assert_equal '5 days', time_ago_in_words(
|
193
|
+
assert_equal '5 days', time_ago_in_words(Time.now - 5*_DAY - 5*60)
|
214
194
|
end
|
215
195
|
it 'should display a month ago' do
|
216
|
-
assert_equal 'about 1 month', time_ago_in_words(
|
196
|
+
assert_equal 'about 1 month', time_ago_in_words(Time.now - 32*_DAY + 5*60)
|
217
197
|
end
|
218
198
|
it 'should display a few months ago' do
|
219
|
-
assert_equal '6 months', time_ago_in_words(
|
199
|
+
assert_equal '6 months', time_ago_in_words(Time.now - 180*_DAY - 5*60)
|
220
200
|
end
|
221
201
|
it 'should display a year ago' do
|
222
|
-
assert_equal 'about 1 year', time_ago_in_words(
|
202
|
+
assert_equal 'about 1 year', time_ago_in_words(Time.now - 365*_DAY - 5*60)
|
223
203
|
end
|
224
204
|
it 'should display a few years ago' do
|
225
|
-
assert_equal 'over 7 years', time_ago_in_words(
|
205
|
+
assert_equal 'over 7 years', time_ago_in_words(Time.now - 2800*_DAY - 5*60)
|
226
206
|
end
|
227
207
|
end
|
228
208
|
|
data/test/test_helpers.rb
CHANGED
@@ -7,4 +7,12 @@ describe "Padrino::Helpers" do
|
|
7
7
|
end
|
8
8
|
assert_equal '<div>bar</div>', Foo.new.content_tag(:div, 'bar')
|
9
9
|
end
|
10
|
+
|
11
|
+
it 'should not overwrite default_builder setting' do
|
12
|
+
mock_app do
|
13
|
+
set :default_builder, 'FancyBuilder'
|
14
|
+
register Padrino::Helpers
|
15
|
+
end
|
16
|
+
assert_equal 'FancyBuilder', @app.default_builder
|
17
|
+
end
|
10
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Padrino Team
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: padrino-support
|
@@ -19,46 +19,52 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.13.
|
22
|
+
version: 0.13.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.13.
|
29
|
+
version: 0.13.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: tilt
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 1.4.1
|
37
|
+
- - "<"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3'
|
37
40
|
type: :runtime
|
38
41
|
prerelease: false
|
39
42
|
version_requirements: !ruby/object:Gem::Requirement
|
40
43
|
requirements:
|
41
|
-
- -
|
44
|
+
- - ">="
|
42
45
|
- !ruby/object:Gem::Version
|
43
46
|
version: 1.4.1
|
47
|
+
- - "<"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3'
|
44
50
|
- !ruby/object:Gem::Dependency
|
45
51
|
name: i18n
|
46
52
|
requirement: !ruby/object:Gem::Requirement
|
47
53
|
requirements:
|
48
|
-
- - ~>
|
54
|
+
- - "~>"
|
49
55
|
- !ruby/object:Gem::Version
|
50
56
|
version: '0.6'
|
51
|
-
- -
|
57
|
+
- - ">="
|
52
58
|
- !ruby/object:Gem::Version
|
53
59
|
version: 0.6.7
|
54
60
|
type: :runtime
|
55
61
|
prerelease: false
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
57
63
|
requirements:
|
58
|
-
- - ~>
|
64
|
+
- - "~>"
|
59
65
|
- !ruby/object:Gem::Version
|
60
66
|
version: '0.6'
|
61
|
-
- -
|
67
|
+
- - ">="
|
62
68
|
- !ruby/object:Gem::Version
|
63
69
|
version: 0.6.7
|
64
70
|
description: Tag helpers, asset helpers, form helpers, form builders and many more
|
@@ -69,9 +75,9 @@ extensions: []
|
|
69
75
|
extra_rdoc_files:
|
70
76
|
- README.rdoc
|
71
77
|
files:
|
72
|
-
- .document
|
73
|
-
- .gitignore
|
74
|
-
- .yardopts
|
78
|
+
- ".document"
|
79
|
+
- ".gitignore"
|
80
|
+
- ".yardopts"
|
75
81
|
- LICENSE.txt
|
76
82
|
- README.rdoc
|
77
83
|
- Rakefile
|
@@ -224,17 +230,17 @@ licenses:
|
|
224
230
|
metadata: {}
|
225
231
|
post_install_message:
|
226
232
|
rdoc_options:
|
227
|
-
- --charset=UTF-8
|
233
|
+
- "--charset=UTF-8"
|
228
234
|
require_paths:
|
229
235
|
- lib
|
230
236
|
required_ruby_version: !ruby/object:Gem::Requirement
|
231
237
|
requirements:
|
232
|
-
- -
|
238
|
+
- - ">="
|
233
239
|
- !ruby/object:Gem::Version
|
234
240
|
version: '0'
|
235
241
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
242
|
requirements:
|
237
|
-
- -
|
243
|
+
- - ">="
|
238
244
|
- !ruby/object:Gem::Version
|
239
245
|
version: 1.3.6
|
240
246
|
requirements: []
|