jekyll-tasks 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f43274444ff755c93a38ff085384a0c924c4106eb281fb52de490f9c378e1f
4
- data.tar.gz: b29c4d4abfe88a7e53b8dba06637a60b6806bb1d9b5db25388fa2e681deca9b4
3
+ metadata.gz: 0daec4cd29ddca6e7c68b64b0ade2f1ff018e52f2e374f5d5c6660fe7b36acb9
4
+ data.tar.gz: ccad93b3f4c10d3473701d88e335e6832c758b1cbd022f7a6156926b03a0e235
5
5
  SHA512:
6
- metadata.gz: fcd79960a18e88fb90babb45a9ac5ab9556548602726a4953729bad456aa176ed441a88e634d721219f1475f31367836496ecf72463edf17f2828ab7eaf62fd5
7
- data.tar.gz: 0e263a7d776f02b2c4667d75dc3f16b3c218a385ea7cbdd1e3a0d81f107420907ef71ef9137a56b451d716c20eb8b74bb4e0fa810c40d30d87b2a3ad95f80c89
6
+ metadata.gz: d7716006decd4fdd3ba6e871928fc88a9f3e488fcefb158e6209dd4bc22d469c46ff0328c448997ce92bd7e5794ecf38039045388ad0e7e9cfbacb0b318fa34f
7
+ data.tar.gz: 505a6f93bea6ae83acdd534790f495be7a27f88d2d9775ed84048400c74919bc26f6c9376a9e7eb92b964d2c1a903d494d2b107afd0a774c63029d3476303a2c
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ group :test do
7
7
  gem 'codecov', '~> 0.5', require: false
8
8
  gem 'minitest', '~> 5.14'
9
9
  gem 'rake', '~> 13.0'
10
- gem 'rubocop', '~> 1.12'
10
+ gem 'rubocop', '~> 1.18'
11
11
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-tasks (0.3.0)
4
+ jekyll-tasks (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,23 +12,23 @@ GEM
12
12
  docile (1.3.5)
13
13
  minitest (5.14.4)
14
14
  parallel (1.20.1)
15
- parser (3.0.1.0)
15
+ parser (3.0.2.0)
16
16
  ast (~> 2.4.1)
17
17
  rainbow (3.0.0)
18
18
  rake (13.0.6)
19
19
  regexp_parser (2.1.1)
20
20
  rexml (3.2.5)
21
- rubocop (1.12.1)
21
+ rubocop (1.18.3)
22
22
  parallel (~> 1.10)
23
23
  parser (>= 3.0.0.0)
24
24
  rainbow (>= 2.2.2, < 4.0)
25
25
  regexp_parser (>= 1.8, < 3.0)
26
26
  rexml
27
- rubocop-ast (>= 1.2.0, < 2.0)
27
+ rubocop-ast (>= 1.7.0, < 2.0)
28
28
  ruby-progressbar (~> 1.7)
29
29
  unicode-display_width (>= 1.4.0, < 3.0)
30
- rubocop-ast (1.4.1)
31
- parser (>= 2.7.1.5)
30
+ rubocop-ast (1.8.0)
31
+ parser (>= 3.0.1.1)
32
32
  ruby-progressbar (1.11.0)
33
33
  simplecov (0.18.5)
34
34
  docile (~> 1.1)
@@ -44,7 +44,7 @@ DEPENDENCIES
44
44
  jekyll-tasks!
45
45
  minitest (~> 5.14)
46
46
  rake (~> 13.0)
47
- rubocop (~> 1.12)
47
+ rubocop (~> 1.18)
48
48
 
49
49
  BUNDLED WITH
50
50
  2.1.4
@@ -1,3 +1,5 @@
1
1
  ---
2
+ layout: grid
2
3
  menu-name: menu-1
4
+ permalink: /collection1/
3
5
  ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: grid
3
+ title: Menu without father
4
+ menu-name: submenu-1
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Menu without name
3
+ layout: grid
4
+ menu-father: menu-1
5
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: model1
3
+ ---
@@ -1,3 +1,5 @@
1
1
  ---
2
+ layout: grid
2
3
  menu-name: menu-2
4
+ permalink: /collection2/
3
5
  ---
@@ -6,14 +6,15 @@ module Jekyll
6
6
  module Menus
7
7
  extend self
8
8
 
9
- def print_conflicts
10
- conflicts = search_conflicts
11
- puts conflicts
12
- conflicts.empty?
9
+ def search_conflicts
10
+ conflicts = []
11
+ conflicts << (search_conflicts_with_properties | search_conflicts_without_properties)
12
+ conflicts.flatten!
13
13
  end
14
14
 
15
- def search_conflicts
15
+ def search_conflicts_with_properties
16
16
  conflicts = []
17
+
17
18
  per_collection(%w[name father]).each do |el|
18
19
  properties = el['properties']
19
20
 
@@ -23,8 +24,20 @@ module Jekyll
23
24
  index = search_hash(properties, 'father')
24
25
  father = index.nil? ? '' : properties[index]['father']
25
26
 
26
- analyze_conflicts el['collection'], conflicts, name, father if name != father
27
+ conflicts << analyze_conflicts(el['collection'], name, father) if name != father
27
28
  end
29
+
30
+ conflicts
31
+ end
32
+
33
+ def search_conflicts_without_properties
34
+ conflicts = []
35
+
36
+ Collections.get.each do |collection|
37
+ data = search_without_properties(collection) unless collection == 'pages'
38
+ conflicts << data unless data.nil?
39
+ end
40
+
28
41
  conflicts
29
42
  end
30
43
 
@@ -38,8 +51,19 @@ module Jekyll
38
51
  result
39
52
  end
40
53
 
41
- def search_properties(collection, properties)
42
- result = []
54
+ def search_without_properties(collection)
55
+ conflicts = []
56
+
57
+ files = markdown_files collection
58
+ files.each do |file|
59
+ data = YAML.load_file(file)
60
+ conflicts << analyze_conflicts_without_properties(data)
61
+ end
62
+
63
+ conflicts
64
+ end
65
+
66
+ def search_properties(collection, properties, result = [])
43
67
  files = markdown_files collection
44
68
  files.each do |file|
45
69
  data = YAML.load_file(file)
@@ -52,7 +76,22 @@ module Jekyll
52
76
 
53
77
  private
54
78
 
55
- def analyze_conflicts(collection, conflicts, name, father)
79
+ def analyze_conflicts_without_properties(data, conflicts = [])
80
+ conflicts << "Product without father: '#{data['title']}'" if Products.product_without_father data
81
+ conflicts << "Menu without name: '#{data['title']}'" if menu_without_name data
82
+ conflicts << "Menu without father: '#{data['title']}'" if menu_without_father data
83
+ conflicts
84
+ end
85
+
86
+ def menu_without_name(data)
87
+ data['layout'] == 'grid' && data['menu-name'].nil?
88
+ end
89
+
90
+ def menu_without_father(data)
91
+ data['layout'] == 'grid' && data['menu-father'].nil? && data['permalink'].nil?
92
+ end
93
+
94
+ def analyze_conflicts(collection, name, father, conflicts = [])
56
95
  array = name - father
57
96
  conflicts << "There are some unused menus at #{collection} collection: #{array}" unless array.empty?
58
97
 
@@ -67,12 +106,9 @@ module Jekyll
67
106
  def search_property(result, data, property)
68
107
  value = data["menu-#{property}"]
69
108
  index = search_hash(result, property)
70
- if index
71
- result[index][property] << value unless value.nil?
72
- else
73
- hash = { property => value.nil? ? [] : [value] }
74
- result << hash
75
- end
109
+
110
+ (result[index][property] << value unless value.nil?) if index
111
+ (result << { property => value.nil? ? [] : [value] }) unless index
76
112
  end
77
113
 
78
114
  def order_properties(result, properties)
@@ -26,6 +26,10 @@ module Jekyll
26
26
  products
27
27
  end
28
28
 
29
+ def product_without_father(data)
30
+ data['layout'].nil? && data['menu-father'].nil?
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def path_list
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Tasks
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Tinajero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-21 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -28,8 +28,11 @@ files:
28
28
  - README.md
29
29
  - Rakefile
30
30
  - _collection1/collection1.md
31
- - _collection1/subfolder/product-lost.md
32
- - _collection1/subfolder/subfolder1.md
31
+ - _collection1/subfolder-without-father/menu-without-father.md
32
+ - _collection1/subfolder-without-name/menu-without-name.md
33
+ - _collection1/subfolder1/product-lost.md
34
+ - _collection1/subfolder1/product-without-father.md
35
+ - _collection1/subfolder1/subfolder1.md
33
36
  - _collection2/collection2.md
34
37
  - _collection2/subfolder/subfolder2.md
35
38
  - jekyll-tasks.gemspec