jekyll-timeago 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,6 +2,8 @@ Jekyll-Timeago
2
2
  ==============
3
3
  Custom and simple implementation of `timeago` date filter. Futures supported.
4
4
 
5
+ In fact, `jekyll-timeago` is an extension of [Liquid](https://github.com/Shopify/liquid) filters, so you can use it in all your Liquid templates.
6
+
5
7
  ## Installation
6
8
  Add this gem to your Gemfile and run bundle:
7
9
  ```
@@ -23,5 +25,23 @@ You can copy this [file](https://github.com/markets/jekyll-timeago/blob/master/l
23
25
  </div>
24
26
  ```
25
27
 
28
+ ## Output samples
29
+ ```
30
+ > timeago(Date.today)
31
+ => "today"
32
+ > timeago(Date.today - 1.day)
33
+ => "yesterday"
34
+ > timeago(Date.today - 10.days)
35
+ => "1 week ago"
36
+ > timeago(Date.today - 100.days)
37
+ => "3 months ago"
38
+ > timeago(Date.today - 400.days)
39
+ => "1 year ago"
40
+ > timeago(Date.today + 1.days)
41
+ => "tomorrow"
42
+ > timeago(Date.today + 10.days)
43
+ => "in 1 week"
44
+ ```
45
+
26
46
  ## License
27
47
  Copyright (c) 2013 Marc Anguera. Unscoped Associations is released under the [MIT](http://opensource.org/licenses/MIT) License.
@@ -18,6 +18,10 @@ module Jekyll
18
18
  private
19
19
 
20
20
  def time_ago_to_now(date)
21
+ unless date.is_a?(Date) || date.is_a?(Time)
22
+ raise "Invalid input: #{date.inspect}"
23
+ end
24
+
21
25
  days_passed = (Date.today - Date.parse(date.to_s)).to_i
22
26
 
23
27
  case days_passed.abs
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Timeago
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-timeago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  segments:
90
90
  - 0
91
- hash: -411462545
91
+ hash: -605481779
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  none: false
94
94
  requirements:
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  segments:
99
99
  - 0
100
- hash: -411462545
100
+ hash: -605481779
101
101
  requirements: []
102
102
  rubyforge_project:
103
103
  rubygems_version: 1.8.24