jekyll-age 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/jekyll-age.rb +28 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7dde951884618a490e5632e60273fe9ed0378a450bc72387782b52921af3834b
4
+ data.tar.gz: c260a92e48dfd12679a98faaafd978738a78189e0ba34ea1de1066b5c2c7d33a
5
+ SHA512:
6
+ metadata.gz: 27ebc99b58c34efe2aeed4ed695a0e5cc4690e86f55055cfc22373613c1e0dbcabda09e48159c616c1c8687ffb59f3cbe01545237528fefd7458a10a9ff7ed07
7
+ data.tar.gz: fece280ec8305a0ba8b2c0e99542e2a161c1fe36048867ae3a9cfe8cb2456816b07ccfba4ed950b881f6efa91043bd123b999c534633c75634ac69467b8dc304
data/lib/jekyll-age.rb ADDED
@@ -0,0 +1,28 @@
1
+ module Jekyll
2
+ class RenderAgeTag < Liquid::Tag
3
+
4
+ def initialize(tag_name, date, tokens)
5
+ super
6
+ @date = validate_date(date)
7
+ end
8
+
9
+ def render(context)
10
+ age = getAge(@date)
11
+ "#{age}"
12
+ end
13
+
14
+ def validate_date(date)
15
+ Date.parse(date.to_s)
16
+ end
17
+
18
+ def getAge(from, to = Date.today)
19
+ years = to.year - from.year
20
+ if to.yday < from.yday
21
+ years -= 1
22
+ end
23
+ return years;
24
+ end
25
+ end
26
+ end
27
+
28
+ Liquid::Template.register_tag('age', Jekyll::RenderAgeTag)
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-age
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Johannes Kühnel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides an age tag for jekyll/liquid
14
+ email: johannes@kuehnel.co.at
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/jekyll-age.rb
20
+ homepage: https://github.com/JohannesKuehnel/jekyll-age
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.7.6.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Age tag for jekyll
44
+ test_files: []