jekyll-timeago 0.9.1 → 0.9.2

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: 534bfa373797db655ca8c1c99ee7fd5d3384aab7
4
- data.tar.gz: bcd74e33c76fe04d39b4835ef1ade56017143767
3
+ metadata.gz: 83655f4748686c8e8eacc7a5ca7334f5a8bc0ada
4
+ data.tar.gz: 634b32d997525a8f06d2dd1f7fc73476b74b7608
5
5
  SHA512:
6
- metadata.gz: a6e3faef952bf144f33841300603ae96d7be487072b49424bdd09468c65016e3985d9b34f38f57f10d5eadb898ff0083b5e85b4416d421d690b363c0a3dff97d
7
- data.tar.gz: 848257b166e211eafa2e7637071f48c7630a2fda9c9f92e74a705cd21c4cb9836baf7412e2325a2f0d9d5c9eb8c317b3585f67fbb2783b50396cc73957ae81c6
6
+ metadata.gz: 662a10474c372620681c94591b10f04fa6e0d7b80a600a627c81ebca387b8d8665e300979fafe172ec3b61ab7e97929e579444cf279ac71db768cc2fd9486ae4
7
+ data.tar.gz: 33790183dd1a4c81b13d97a2041044cb72d5d8d22fc7e86b678c353c3c20256d867c16f3e1e74c349b9164af132e4b746843dafdfc90178aa3ea2def1a114e56
data/.travis.yml CHANGED
@@ -5,11 +5,11 @@ cache: bundler
5
5
  sudo: false
6
6
 
7
7
  rvm:
8
- - 2.3.1
8
+ - 2.4.0
9
+ - 2.3.3
9
10
  - 2.2
10
11
  - 2.1
11
12
  - 2.0
12
- - 1.9.3
13
13
 
14
14
  gemfile:
15
15
  - gemfiles/jekyll_v1.gemfile
@@ -20,3 +20,7 @@ matrix:
20
20
  exclude:
21
21
  - rvm: 1.9.3
22
22
  gemfile: gemfiles/jekyll_v3.gemfile
23
+ - rvm: 2.4.0
24
+ gemfile: gemfiles/jekyll_v1.gemfile
25
+ - rvm: 2.4.0
26
+ gemfile: gemfiles/jekyll_v2.gemfile
data/Appraisals CHANGED
@@ -4,10 +4,10 @@ end
4
4
 
5
5
  appraise 'jekyll-v2' do
6
6
  gem 'jekyll', '~> 2.5'
7
- gem 'listen', '< 3.1.0' if RUBY_VERSION <= "2.2"
7
+ gem 'listen', '< 3.1.0' if RUBY_VERSION <= '2.2'
8
8
  end
9
9
 
10
10
  appraise 'jekyll-v3' do
11
11
  gem 'jekyll', '~> 3.1'
12
- gem 'listen', '< 3.1.0' if RUBY_VERSION <= "2.2"
12
+ gem 'listen', '< 3.1.0' if RUBY_VERSION <= '2.2'
13
13
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013-2016 Marc Anguera Insa
1
+ Copyright 2013-2017 Marc Anguera Insa
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -109,10 +109,10 @@ jekyll_timeago:
109
109
 
110
110
  You are able to change the level of detail (from 1 up to 4, 2 by default) to get higher or lower granularity. This option is setted via the `config` file (see sample in previous section). Examples:
111
111
 
112
- * Depht => 1 `1 year ago`
113
- * Depht => 2 `1 year and 4 months ago` (default)
114
- * Depht => 3 `1 year, 4 months and 1 week ago`
115
- * Depht => 4 `1 year, 4 months, 1 week and 4 days ago`
112
+ * Depth => 1 `1 year ago`
113
+ * Depth => 2 `1 year and 4 months ago` (default)
114
+ * Depth => 3 `1 year, 4 months and 1 week ago`
115
+ * Depth => 4 `1 year, 4 months, 1 week and 4 days ago`
116
116
 
117
117
  ## Usage outside Jekyll
118
118
 
@@ -122,7 +122,18 @@ You just need to install the gem to your application (add `gem 'jekyll-timeago'`
122
122
  Jekyll::Timeago::Core.timeago(from, to, options)
123
123
  ```
124
124
 
125
- Note, that you can use the `options` parameter to override the default localization or the level of detail.
125
+ Note, that you can use the `options` parameter (must be a `Hash` and be passed as the last parameter) to override the default localization or the level of detail, e.g.:
126
+
127
+ ```ruby
128
+ options = {
129
+ "depth" => 3,
130
+ "prefix" => "hace",
131
+ "months" => "meses",
132
+ "and" => "y",
133
+ "week" => "semana",
134
+ "suffix" => nil
135
+ }
136
+ ```
126
137
 
127
138
  Or if you have the gem installed in your system and you're not using Bundler:
128
139
 
@@ -145,30 +156,30 @@ Run `$ jekyll-timeago --console` to start a custom IRB session and play with the
145
156
  ```ruby
146
157
  >> timeago(Date.today)
147
158
  => "today"
148
- >> timeago(Date.today - 1.day)
159
+ >> timeago(Date.today.prev_day)
149
160
  => "yesterday"
150
- >> timeago(Date.today - 10.days)
161
+ >> timeago(Date.today.prev_day(10))
151
162
  => "1 week and 3 days ago"
152
- >> timeago(Date.today - 100.days)
163
+ >> timeago(Date.today.prev_day(100))
153
164
  => "3 months and 1 week ago"
154
- >> timeago(Date.today - 500.days)
165
+ >> timeago(Date.today.prev_day(500))
155
166
  => "1 year and 4 months ago"
156
167
  >> timeago('2010-1-1', '2012-1-1')
157
168
  => "2 years ago"
158
- >> timeago(Date.today + 1.days)
169
+ >> timeago(Date.today.next_day)
159
170
  => "tomorrow"
160
- >> timeago(Date.today + 7.days)
171
+ >> timeago(Date.today.next_day(7))
161
172
  => "in 1 week"
162
- >> timeago(Date.today + 1000.days)
173
+ >> timeago(Date.today.next_day(1000))
163
174
  => "in 2 years and 8 months"
164
175
  ```
165
176
 
166
- Play with `options`:
177
+ You can modify globally, via the `configure` method, all the available options:
167
178
 
168
179
  ```ruby
169
- >> configure "yesterday" => "ayer"
180
+ >> configure({ "yesterday" => "ayer" })
170
181
  => "ayer"
171
- >> timeago(Date.today - 1.day)
182
+ >> timeago(Date.today.prev_day)
172
183
  => "ayer"
173
184
  ```
174
185
 
@@ -186,4 +197,4 @@ bundle exec appraisal rake
186
197
 
187
198
  ## License
188
199
 
189
- Copyright (c) 2013-2016 Marc Anguera. Jekyll-Timeago is released under the [MIT](LICENSE) License.
200
+ Copyright (c) Marc Anguera. Jekyll-Timeago is released under the [MIT](LICENSE) License.
@@ -19,6 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency "bundler", "~> 1.3"
20
20
  spec.add_development_dependency "rake"
21
21
  spec.add_development_dependency "rspec"
22
- spec.add_development_dependency "activesupport"
23
22
  spec.add_development_dependency "appraisal"
24
23
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Timeago
3
- VERSION = "0.9.1"
3
+ VERSION = "0.9.2"
4
4
  end
5
5
  end
@@ -18,6 +18,7 @@ describe Jekyll::Timeago do
18
18
  end
19
19
 
20
20
  it 'process successfully the site using filters and tags' do
21
+ allow(Date).to receive(:today) { Date.new(2016, 1, 1) }
21
22
  expect { site.process }.to_not raise_error
22
23
 
23
24
  lines = [
@@ -47,38 +48,39 @@ describe Jekyll::Timeago do
47
48
  end
48
49
 
49
50
  it 'yesterday, today and tomorrow' do
50
- expect(timeago(today - 1.day)).to eql("yesterday")
51
+ expect(timeago(today.prev_day)).to eql("yesterday")
51
52
  expect(timeago(today)).to eql("today")
52
- expect(timeago(today + 1.day)).to eql("tomorrow")
53
+ expect(timeago(today.next_day)).to eql("tomorrow")
53
54
  end
54
55
 
55
56
  it 'past time' do
56
- expect(timeago(sample_date - 10.days, sample_date)).to eql('1 week and 3 days ago')
57
- expect(timeago(sample_date - 100.days, sample_date)).to eql('3 months and 1 week ago')
58
- expect(timeago(sample_date - 500.days, sample_date)).to eql('1 year and 4 months ago')
57
+ expect(timeago(sample_date.prev_day(10), sample_date)).to eql('1 week and 3 days ago')
58
+ expect(timeago(sample_date.prev_day(100), sample_date)).to eql('3 months and 1 week ago')
59
+ expect(timeago(sample_date.prev_day(500), sample_date)).to eql('1 year and 4 months ago')
59
60
  end
60
61
 
61
62
  it 'future time' do
62
- expect(timeago(sample_date + 7.days, sample_date)).to eql('in 1 week')
63
- expect(timeago(sample_date + 1000.days, sample_date)).to eql('in 2 years and 9 months')
63
+ expect(timeago(sample_date.next_day(7), sample_date)).to eql('in 1 week')
64
+ expect(timeago(sample_date.next_day(1000), sample_date)).to eql('in 2 years and 9 months')
64
65
  end
65
66
 
66
67
  it 'allow different date formats' do
67
68
  expect(timeago('2010-1-1', '2012-1-1')).to eql('2 years ago')
68
69
  expect(timeago('2010/1/1', '2012/1/1')).to eql('2 years ago')
69
70
  expect(timeago('Jan 2010, 1', 'Jan 2012, 1')).to eql('2 years ago')
71
+ expect(timeago('20100101', '20120101')).to eql('2 years ago')
70
72
  expect(timeago('2014-10-06 20:00:00', '2014-10-07 20:00:00')).to eql('yesterday')
71
73
  end
72
74
 
73
75
  it 'allow to change defaults at global level' do
74
76
  Jekyll::Timeago::Core.configure("year" => nil, "depth" => 1, "suffix" => nil)
75
- expect(timeago(sample_date - 500.days, sample_date)).to eql('1')
77
+ expect(timeago(sample_date.prev_day(500), sample_date)).to eql('1')
76
78
  end
77
79
 
78
80
  it 'allow to change level of detail' do
79
- expect(timeago(sample_date - 500.days, sample_date, "depth" => 1)).to eql('1 year ago')
80
- expect(timeago(sample_date - 500.days, sample_date, "depth" => 3)).to eql('1 year, 4 months and 2 weeks ago')
81
- expect(timeago(sample_date - 500.days, sample_date, "depth" => 4)).to eql('1 year, 4 months, 2 weeks and 1 day ago')
81
+ expect(timeago(sample_date.prev_day(500), sample_date, "depth" => 1)).to eql('1 year ago')
82
+ expect(timeago(sample_date.prev_day(500), sample_date, "depth" => 3)).to eql('1 year, 4 months and 2 weeks ago')
83
+ expect(timeago(sample_date.prev_day(500), sample_date, "depth" => 4)).to eql('1 year, 4 months, 2 weeks and 1 day ago')
82
84
  end
83
85
 
84
86
  it 'allow localization' do
@@ -90,7 +92,7 @@ describe Jekyll::Timeago do
90
92
  "suffix" => nil
91
93
  }
92
94
 
93
- expect(timeago(sample_date - 100.days, sample_date, new_options)).to eql('hace 3 meses y 1 semana')
95
+ expect(timeago(sample_date.prev_day(100), sample_date, new_options)).to eql('hace 3 meses y 1 semana')
94
96
  end
95
97
  end
96
98
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'fileutils'
2
- require 'active_support/all'
3
2
  require 'jekyll'
4
3
  require File.expand_path('lib/jekyll-timeago')
5
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-timeago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - markets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-08 00:00:00.000000000 Z
11
+ date: 2017-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: activesupport
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: appraisal
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
133
  version: '0'
148
134
  requirements: []
149
135
  rubyforge_project:
150
- rubygems_version: 2.2.2
136
+ rubygems_version: 2.5.2
151
137
  signing_key:
152
138
  specification_version: 4
153
139
  summary: A date helper to compute distance of dates in words.