jekyll-ical-tag 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: 0d234777e1efb40a2d7a4d2c3ece936a21a9b22521f691db615cbefa693e94f9
4
- data.tar.gz: 27ec683fdeb6598ccc15604e3426e101efc94d210dd030d075a1fb90bf907853
3
+ metadata.gz: f0aa8b610c5113e232c010134e97b4ba1af55e07f92bba29cd820f1c2daaa0e1
4
+ data.tar.gz: fe4a3829d1a32311f773ab8c3825de673dec80586f2e49a569a57748d5475ff4
5
5
  SHA512:
6
- metadata.gz: 47e65509012af13fe385cbdba02675819d1ba82ff361e9be6aa23dd26f587f9b17a13b8e2d5f82c5b08bbf8e0cf0cc6a348a9039e6e3c3f199bebadee6bb3444
7
- data.tar.gz: 8efcb4b61f6589721b242595b855992478985ec57b3915da68d5e9c09056991066039ed22485b8ac1b35f9469a2598aacc97e45e6929b723331064646ce4a1ed
6
+ metadata.gz: 5848157e8929d51d128d372dd1d037f997ec74240ccf437bfe593deb70ec41b9299ef9364555dd2a290d235f984d413c9621706d012b38ab720e5f6aae9aeba3
7
+ data.tar.gz: ee10e4e946fd367ee92ae463f44a8873d7d834b60b1eb8b27f939e3acb2296077440992db42967f84658d854ce7832da40d974745903a9da9bca8832fb8d4413
data/_plugins/ical_tag.rb CHANGED
@@ -46,6 +46,8 @@ class CalendarLimiter
46
46
  parser.events.select do |event|
47
47
  event.dtstart.to_time < options[:before_date]
48
48
  end
49
+ when options[:limit]
50
+ parser.events.first(options[:limit].to_i)
49
51
  else
50
52
  parser.events
51
53
  end
@@ -150,8 +152,7 @@ module Jekyll
150
152
  only_past = @attributes["only_past"] == "true"
151
153
 
152
154
  raise "Set only_future OR only_past, not both" if only_future && only_past
153
- @only =
154
- case
155
+ @only = case
155
156
  when only_future
156
157
  :future
157
158
  when only_past
@@ -162,8 +163,7 @@ module Jekyll
162
163
  end
163
164
 
164
165
  def set_before_date!
165
- @before_date =
166
- begin
166
+ @before_date = begin
167
167
  if @attributes["before_date"]
168
168
  Time.parse(@attributes["before_date"])
169
169
  end
@@ -173,8 +173,7 @@ module Jekyll
173
173
  end
174
174
 
175
175
  def set_after_date!
176
- @after_date =
177
- begin
176
+ @after_date = begin
178
177
  if @attributes["after_date"]
179
178
  Time.parse(@attributes["after_date"])
180
179
  end
@@ -3,17 +3,17 @@
3
3
  lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
- require 'jekyll'
6
+ require "jekyll"
7
7
  require "jekyll-ical-tag/version"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
- spec.name = "jekyll-ical-tag"
11
- spec.version = Jekyll::IcalTag::VERSION
12
- spec.authors = ["Ricky Chilcott"]
13
- spec.email = ["ricky@rakefire.io"]
14
- spec.summary = "A Jekyll plugin to pull ICS feed and provide a for-like loop of calendar events"
15
- spec.homepage = "https://github.com/rakefire/jekyll-ical-tag"
16
- spec.license = "MIT"
10
+ spec.name = "jekyll-ical-tag"
11
+ spec.version = Jekyll::IcalTag::VERSION
12
+ spec.authors = ["Ricky Chilcott"]
13
+ spec.email = ["ricky@rakefire.io"]
14
+ spec.summary = "A Jekyll plugin to pull ICS feed and provide a for-like loop of calendar events"
15
+ spec.homepage = "https://github.com/rakefire/jekyll-ical-tag"
16
+ spec.license = "MIT"
17
17
 
18
18
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
19
  # delete this section to allow pushing this gem to any host.
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.required_ruby_version = ">= 2.3.0"
27
27
 
28
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
28
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "jekyll", "~> 4"
33
+ spec.add_dependency "jekyll", "~> 3"
34
34
  spec.add_dependency "api_cache"
35
35
  spec.add_dependency "activesupport"
36
36
  spec.add_dependency "icalendar"
@@ -31,6 +31,8 @@ module Jekyll
31
31
  parser.events.select do |event|
32
32
  event.dtstart.to_time < options[:before_date]
33
33
  end
34
+ when options[:limit]
35
+ parser.events.first(options[:limit])
34
36
  else
35
37
  parser.events
36
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  class IcalTag < Liquid::Block
5
- VERSION = "1.0.8"
5
+ VERSION = "1.0.9"
6
6
  end
7
7
  end
@@ -3,7 +3,6 @@
3
3
 
4
4
  require "jekyll"
5
5
  require "jekyll-ical-tag/version"
6
- require "pry"
7
6
 
8
7
  module Jekyll
9
8
  class IcalTag < Liquid::Block
@@ -31,16 +30,19 @@ module Jekyll
31
30
 
32
31
  result = []
33
32
 
33
+ set_url_from_assigned_value!(context)
34
+ set_url_from_page_attributes!(context)
35
+
36
+ raise "No URL provided or in innapropriate form '#{@url}'" unless has_valid_url?
37
+
34
38
  parser = CalendarParser.new(@url)
35
39
  parser = CalendarLimiter.new(parser, only: @only)
36
40
  parser = CalendarLimiter.new(parser, reverse: @reverse)
37
41
  parser = CalendarLimiter.new(parser, before_date: @before_date)
38
42
  parser = CalendarLimiter.new(parser, after_date: @after_date)
43
+ parser = CalendarLimiter.new(parser, limit: @limit)
39
44
 
40
45
  events = parser.events
41
- if @limit
42
- events = events.first(@limit)
43
- end
44
46
  length = events.length
45
47
 
46
48
  context.stack do
@@ -84,6 +86,30 @@ module Jekyll
84
86
 
85
87
  private
86
88
 
89
+ def has_valid_url?
90
+ !!(@url =~ URI::regexp)
91
+ end
92
+
93
+ def set_url_from_page_attributes!(context)
94
+ return if has_valid_url?
95
+
96
+ # Dereference @url from something like "page.calender_url" to the page's calendar_url
97
+
98
+ dig_attrs = @url.split(".")
99
+ dig_attrs[0] = dig_attrs[0].to_sym if dig_attrs[0].present?
100
+ if dug_result = context.registers.dig(*dig_attrs)
101
+ @url = dug_result
102
+ end
103
+ end
104
+
105
+ def set_url_from_assigned_value!(context)
106
+ return if has_valid_url?
107
+ return unless context.scopes.first[@url]
108
+
109
+ # Dereference the URL if we were passed a variable name.
110
+ @url = context.scopes.first[@url]
111
+ end
112
+
87
113
  def as_utf8(str)
88
114
  return unless str
89
115
 
@@ -98,11 +124,8 @@ module Jekyll
98
124
  end
99
125
 
100
126
  def set_limit!
101
- if @attributes["limit"]
102
- @limit = @attributes["limit"].to_i
103
- else
104
- @limit = nil
105
- end
127
+ @limit = nil
128
+ @limit = @attributes["limit"].to_i if @attributes["limit"]
106
129
  end
107
130
 
108
131
  def set_reverse!
@@ -111,7 +134,6 @@ module Jekyll
111
134
 
112
135
  def set_url!
113
136
  @url = @attributes["url"]
114
- raise "No URL provided" unless @url
115
137
  end
116
138
 
117
139
  def set_only!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-ical-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricky Chilcott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4'
19
+ version: '3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4'
26
+ version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: api_cache
29
29
  requirement: !ruby/object:Gem::Requirement