rails-timeago 2.9.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5d941da1caf43169e63ec9f60eb39d62944c400
4
- data.tar.gz: 8999cb11c165d2476f3f9be8876c146c4030810b
3
+ metadata.gz: 8ddf7879b5c06eddc5a7dffb3ccb98e54b1fc0c4
4
+ data.tar.gz: dd2a443a4422c94ce1118270068d4f0405fc7573
5
5
  SHA512:
6
- metadata.gz: 03bb5efa3e4004a110617651ebbfa328f138fc1f4a2bdf0367643522b84c231e83f3b6f4fe4b12d350c5231b49c26efbb729c4790c2ee2471d5993add0c081b1
7
- data.tar.gz: 1584e598999e31124e6015943e619d90fcd16462b8ff6e72be3821a922842265d86c270f420d7bf348a37e545d7e338aa469aef05f60c4657b1b5d32b2198e77
6
+ metadata.gz: 7951655d4c6cf65ab5280b34ffc0f38e9760ce161458b045f1c28ed4c623db995e770a79d461b43ee72e8efcc23b65103a44f79cfe0d15753434c96031b3661e
7
+ data.tar.gz: 89e7bd80087ca1def02a99d8fd77c24272de8598742f57a8661d42f4716553a8e7aa89121db81027f49197bb4a43f3da4bfa34987ae9193744f36c437025790e
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ test/version_tmp
19
19
  tmp
20
20
  .rvmrc
21
21
  .ruby-version
22
+ tags
@@ -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
- if time_options[:force] or time_options[:limit].nil? or time_options[:limit] < time
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
@@ -2,7 +2,7 @@ module Rails
2
2
  module Timeago
3
3
  module VERSION
4
4
  MAJOR = 2
5
- MINOR = 9
5
+ MINOR = 10
6
6
  PATCH = 0
7
7
  STAGE = nil
8
8
 
data/spec/spec_helper.rb CHANGED
@@ -6,3 +6,6 @@ require File.dirname(__FILE__) + '/support/stub.rb'
6
6
  RSpec.configure do |config|
7
7
  config.mock_with :rspec
8
8
  end
9
+
10
+ # Use UTC timezone for the duration of the tests
11
+ Time.zone = 'UTC'
@@ -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.9.0
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-13 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport