rails-timeago 2.9.0 → 2.10.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 +4 -4
- data/.gitignore +1 -0
- data/lib/rails-timeago/helper.rb +11 -1
- data/lib/rails-timeago/version.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/timeago/helper_spec.rb +15 -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: 8ddf7879b5c06eddc5a7dffb3ccb98e54b1fc0c4
|
4
|
+
data.tar.gz: dd2a443a4422c94ce1118270068d4f0405fc7573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7951655d4c6cf65ab5280b34ffc0f38e9760ce161458b045f1c28ed4c623db995e770a79d461b43ee72e8efcc23b65103a44f79cfe0d15753434c96031b3661e
|
7
|
+
data.tar.gz: 89e7bd80087ca1def02a99d8fd77c24272de8598742f57a8661d42f4716553a8e7aa89121db81027f49197bb4a43f3da4bfa34987ae9193744f36c437025790e
|
data/.gitignore
CHANGED
data/lib/rails-timeago/helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/time'
|
2
|
+
|
1
3
|
module Rails
|
2
4
|
module Timeago
|
3
5
|
module Helper
|
@@ -45,7 +47,15 @@ module Rails
|
|
45
47
|
end
|
46
48
|
time_options[:limit] = time_options[:limit].call if time_options[:limit].is_a?(Proc)
|
47
49
|
|
48
|
-
|
50
|
+
time_range = unless time_options[:limit].nil?
|
51
|
+
now = Time.zone.now
|
52
|
+
limit = time_options[:limit]
|
53
|
+
limit < now ? limit...now : now...limit
|
54
|
+
else
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
if time_options[:force] or time_range.nil? or time_range.cover?(time)
|
49
59
|
html_options.merge!('data-time-ago' => time.iso8601)
|
50
60
|
end
|
51
61
|
time_tag time, timeago_tag_content(time, time_options), html_options
|
data/spec/spec_helper.rb
CHANGED
data/spec/timeago/helper_spec.rb
CHANGED
@@ -75,6 +75,21 @@ describe Rails::Timeago::Helper do
|
|
75
75
|
should_not =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
76
76
|
end
|
77
77
|
|
78
|
+
it 'should have data-time-ago attribute for times before given limit if limit is in the future' do
|
79
|
+
@stub.timeago_tag(5.days.from_now, :limit => 6.days.from_now).
|
80
|
+
should =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should have not data-time-ago attribute for times in the past if limit is in the future' do
|
84
|
+
@stub.timeago_tag(1.days.ago, :limit => 5.days.from_now).
|
85
|
+
should_not =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should have not data-time-ago attribute for times after given limit if limit is in the future' do
|
89
|
+
@stub.timeago_tag(6.days.from_now, :limit => 5.days.from_now).
|
90
|
+
should_not =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
91
|
+
end
|
92
|
+
|
78
93
|
it 'should have data-time-ago attribute for times before limit if forced' do
|
79
94
|
@stub.timeago_tag(6.days.ago, :force => true).
|
80
95
|
should =~ /<time.*data-time-ago=".*".*>.*<\/time>/
|
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.10.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: 2014-03-
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|