cloudcannon-jekyll 1.5.3 → 1.5.4

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: 1622ca2b9f7eef0279882f94f4364c67ffdd9c403dbfc345bc882268ecd0f998
4
- data.tar.gz: e3dab9c9f8fb8090c16c4c3c963566143bfe9a7d4fc18f674c1b33691c377575
3
+ metadata.gz: 176cf49b411a0986cc9b6ac1721ce6fcf2b7be830e39a28a4ecefd932d1bc393
4
+ data.tar.gz: 1528f083504f444305ad7361b3d9f3bd3638259271a9e71b27dc0711e4348078
5
5
  SHA512:
6
- metadata.gz: 748183e00870b67a650ce2cd0386519faffc651750504804bd66d0dd133576a714221d64405d7afc9729558ec6eb8719e3105ee349b4155c53c87af3fffc3351
7
- data.tar.gz: e3d770a079ae5a349b7ceec3c1dc4db930bd294a3856c991520bdfe8624a901d00749f37b4fb825dbdfa1e56f67934179c8b0f0ac585968ec9cc30483e50d96b
6
+ metadata.gz: 39dc2b3e26908d529d95b76789b147eb6c6f3265fb6d86f179faa96e6620897275c638a6f86f4fe6eb6411006debfac3f4f6e53280aff736aa4c8263cf9bd2ef
7
+ data.tar.gz: eb61277cf35e5729631962cd3e66162ee3d202d38e69f134b56f28d539d238b83daf1781167031bab059f46b86dba7154560824996bc456b45a253f62f11ea62
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.5.4
2
+
3
+ * Rework fallback for older versions of Jekyll when reading data, posts and drafts again
4
+
1
5
  # 1.5.3
2
6
 
3
7
  * Rework fallback for older versions of Jekyll when reading data, posts and drafts
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "jekyll"
4
-
5
- begin
6
- require_relative "readers/data-reader"
7
- rescue NameError
8
- require_relative "readers/old-data-reader"
9
- end
4
+ require_relative "readers/old-data-reader"
5
+ require_relative "readers/data-reader"
10
6
 
11
7
  module CloudCannonJekyll
12
8
  # Wraps read functions into one class
@@ -18,21 +14,30 @@ module CloudCannonJekyll
18
14
  end
19
15
 
20
16
  def read_data(dir = "_data")
21
- CloudCannonJekyll::DataReader.new(@site).read(dir)
22
- rescue NameError # DataReader doesn't exist in old versions of Jekyll
23
- CloudCannonJekyll::OldDataReader.new(@site).read(dir)
17
+ # DataReader doesn't exist in old versions of Jekyll
18
+ if Jekyll::VERSION.start_with? "2."
19
+ CloudCannonJekyll::OldDataReader.new(@site).read(dir)
20
+ else
21
+ CloudCannonJekyll::DataReader.new(@site).read(dir)
22
+ end
24
23
  end
25
24
 
26
25
  def read_drafts(dir = "")
27
- Jekyll::PostReader.new(@site).read_drafts(dir)
28
- rescue NameError # PostReader doesn't exist in old versions of Jekyll
29
- @site.read_content(dir, "_drafts", Jekyll::Draft)
26
+ # PostReader doesn't exist in old versions of Jekyll
27
+ if Jekyll::VERSION.start_with? "2."
28
+ @site.read_content(dir, "_drafts", Jekyll::Draft)
29
+ else
30
+ Jekyll::PostReader.new(@site).read_drafts(dir)
31
+ end
30
32
  end
31
33
 
32
34
  def read_posts(dir = "")
33
- Jekyll::PostReader.new(@site).read_posts(dir)
34
- rescue NameError # PostReader doesn't exist in old versions of Jekyll
35
- @site.read_content(dir, "_posts", Jekyll::Post)
35
+ # PostReader doesn't exist in old versions of Jekyll
36
+ if Jekyll::VERSION.start_with? "2."
37
+ @site.read_content(dir, "_posts", Jekyll::Post)
38
+ else
39
+ Jekyll::PostReader.new(@site).read_posts(dir)
40
+ end
36
41
  end
37
42
  end
38
43
  end
@@ -1,18 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "jekyll"
3
+ unless Jekyll::VERSION.start_with? "2."
4
+ require "jekyll"
4
5
 
5
- module CloudCannonJekyll
6
- # Reads data files and creates a collections-style hash representation
7
- class DataReader < Jekyll::DataReader
8
- # Determines how to read a data file.
9
- # This is overridden return a hash instead of reading the file.
10
- #
11
- # Returns a hash with the path to the data file.
12
- def read_data_file(path)
13
- {
14
- "path" => path,
15
- }
6
+ module CloudCannonJekyll
7
+ # Reads data files and creates a collections-style hash representation
8
+ class DataReader < Jekyll::DataReader
9
+ # Determines how to read a data file.
10
+ # This is overridden return a hash instead of reading the file.
11
+ #
12
+ # Returns a hash with the path to the data file.
13
+ def read_data_file(path)
14
+ {
15
+ "path" => path,
16
+ }
17
+ end
16
18
  end
17
19
  end
18
20
  end
@@ -1,55 +1,57 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "jekyll"
4
-
5
- module CloudCannonJekyll
6
- # Reads data files and creates a collections-style hash representation
7
- # Aims to replicate the data reading logic in Jekyll 2.5
8
- class OldDataReader
9
- attr_reader :site
10
-
11
- def initialize(site)
12
- @site = site
13
- @safe = site.safe
14
- @content = {}
15
- end
3
+ if Jekyll::VERSION.start_with? "2."
4
+ require "jekyll"
5
+
6
+ module CloudCannonJekyll
7
+ # Reads data files and creates a collections-style hash representation
8
+ # Aims to replicate the data reading logic in Jekyll 2.5
9
+ class OldDataReader
10
+ attr_reader :site
11
+
12
+ def initialize(site)
13
+ @site = site
14
+ @safe = site.safe
15
+ @content = {}
16
+ end
16
17
 
17
- def read(dir)
18
- base = Jekyll.sanitized_path(@site.source, dir)
19
- read_data_to(base, @content)
20
- @content
21
- end
18
+ def read(dir)
19
+ base = Jekyll.sanitized_path(@site.source, dir)
20
+ read_data_to(base, @content)
21
+ @content
22
+ end
22
23
 
23
- def read_data_to(dir, data)
24
- return unless File.directory?(dir) && (!@safe || !File.symlink?(dir))
24
+ def read_data_to(dir, data)
25
+ return unless File.directory?(dir) && (!@safe || !File.symlink?(dir))
25
26
 
26
- entries = Dir.chdir(dir) do
27
- Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
28
- end
27
+ entries = Dir.chdir(dir) do
28
+ Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
29
+ end
29
30
 
30
- entries.each do |entry|
31
- path = Jekyll.sanitized_path(dir, entry)
32
- next if File.symlink?(path) && @safe
31
+ entries.each do |entry|
32
+ path = Jekyll.sanitized_path(dir, entry)
33
+ next if File.symlink?(path) && @safe
33
34
 
34
- key = sanitize_filename(File.basename(entry, ".*"))
35
- if File.directory?(path)
36
- read_data_to(path, data[key] = {})
37
- else
38
- data[key] = read_data_file(path)
35
+ key = sanitize_filename(File.basename(entry, ".*"))
36
+ if File.directory?(path)
37
+ read_data_to(path, data[key] = {})
38
+ else
39
+ data[key] = read_data_file(path)
40
+ end
39
41
  end
40
42
  end
41
- end
42
43
 
43
- def read_data_file(path)
44
- {
45
- "path" => path,
46
- }
47
- end
44
+ def read_data_file(path)
45
+ {
46
+ "path" => path,
47
+ }
48
+ end
48
49
 
49
- def sanitize_filename(name)
50
- name.gsub!(%r![^\w\s_-]+!, "")
51
- name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
52
- name.gsub(%r!\s+!, "_")
50
+ def sanitize_filename(name)
51
+ name.gsub!(%r![^\w\s_-]+!, "")
52
+ name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
53
+ name.gsub(%r!\s+!, "_")
54
+ end
53
55
  end
54
56
  end
55
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudCannonJekyll
4
- VERSION = "1.5.3"
4
+ VERSION = "1.5.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudcannon-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - CloudCannon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll