rails-timeago 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-timeago/helper.rb +1 -0
- data/lib/rails-timeago/version.rb +1 -1
- data/spec/timeago/helper_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6a5ec2b2a6078a5b302596b569133ba990e31a
|
4
|
+
data.tar.gz: 680f018cc7472edd832ed6bd8b72929b960ba159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e547679e0d0d3b77c3eca102758db679787516f28cf335680861835e493319f6f71234ea7a81574c647dd3bc5c0455ae2a286b1b475065777345426796ab835b
|
7
|
+
data.tar.gz: 2b040ccf5925e1f47f1f19c3a8f2a776a54c8400bdcee0dd5b861eba1cabc4cf4afb6e68878f59abf2d161927dd7e2bda276a00953ed60326a50b7396a5e5a4c
|
data/lib/rails-timeago/helper.rb
CHANGED
@@ -39,6 +39,7 @@ module Rails
|
|
39
39
|
time_options = time_options.merge html_options.extract!(*time_options.keys.select{|k| html_options.include?(k)})
|
40
40
|
return time_options[:default] if time.nil?
|
41
41
|
|
42
|
+
time_options[:format] = time_options[:format].call(time, time_options) if time_options[:format].is_a?(Proc)
|
42
43
|
if time_options[:title]
|
43
44
|
html_options.merge! :title => time_options[:title].is_a?(Proc) ? time_options[:title].call(time, time_options) : time_options[:title]
|
44
45
|
end
|
data/spec/timeago/helper_spec.rb
CHANGED
@@ -23,6 +23,10 @@ describe Rails::Timeago::Helper do
|
|
23
23
|
@stub.timeago_tag(time, :format => :short).should include("title=\"#{I18n.l time, :format => :short}\"")
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'should have human readable datetime as title attribute with given format' do
|
27
|
+
@stub.timeago_tag(time, :format => proc { |time, options| :long }).should include("title=\"#{I18n.l time, :format => :long}\"")
|
28
|
+
end
|
29
|
+
|
26
30
|
it 'should have human readable datetime as title attribute with global format' do
|
27
31
|
Rails::Timeago.default_options :format => :short
|
28
32
|
@stub.timeago_tag(time).should include("title=\"#{I18n.l time, :format => :short}\"")
|
@@ -48,6 +52,11 @@ describe Rails::Timeago::Helper do
|
|
48
52
|
:title => proc { |time, options| options[:format] }).should =~ /<time.*title="long".*>.*<\/time>/
|
49
53
|
end
|
50
54
|
|
55
|
+
it 'should have format attribute with proc value locally' do
|
56
|
+
@stub.timeago_tag(time,
|
57
|
+
:format => proc { |time, options| :long }).should include(">#{I18n.l time.to_date, :format => :long}<")
|
58
|
+
end
|
59
|
+
|
51
60
|
it 'should have data-time-ago attribute' do
|
52
61
|
@stub.timeago_tag(time).should =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
53
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-timeago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|