rails-timeago 2.3.0 → 2.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 286fa0f5a4b2883116b7be8c2adc65d625599107
4
- data.tar.gz: 191039195eb205496bd5f72df652a02883c0aa9e
3
+ metadata.gz: 9a6a5ec2b2a6078a5b302596b569133ba990e31a
4
+ data.tar.gz: 680f018cc7472edd832ed6bd8b72929b960ba159
5
5
  SHA512:
6
- metadata.gz: 961e46c152c7485b2d90107b52c507392e5bbc2c75ad4498538f3ffd9d0a3d3c59dd3587d3453b5b15d2a10e37b560b8b5873309ad14fc6176051fb4378cad5f
7
- data.tar.gz: 5b18185280ccff069955b24276dfed295a19ecbd2f868d3ff8cbfd4fe0c9d4d6b9dc6de1c93991297b08fd18f9a197b22059591134fa296215d6ed3a51c6f4ab
6
+ metadata.gz: e547679e0d0d3b77c3eca102758db679787516f28cf335680861835e493319f6f71234ea7a81574c647dd3bc5c0455ae2a286b1b475065777345426796ab835b
7
+ data.tar.gz: 2b040ccf5925e1f47f1f19c3a8f2a776a54c8400bdcee0dd5b861eba1cabc4cf4afb6e68878f59abf2d161927dd7e2bda276a00953ed60326a50b7396a5e5a4c
@@ -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
@@ -2,7 +2,7 @@ module Rails
2
2
  module Timeago
3
3
  module VERSION
4
4
  MAJOR = 2
5
- MINOR = 3
5
+ MINOR = 4
6
6
  PATCH = 0
7
7
  STAGE = nil
8
8
 
@@ -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.3.0
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-04-30 00:00:00.000000000 Z
11
+ date: 2013-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport