Module: Jekyll::Tasks::Menus
Overview
Obtain menus information
Instance Method Summary collapse
- #per_collection(properties = ['name']) ⇒ Object
- #search_conflicts ⇒ Object
- #search_conflicts_with_properties ⇒ Object
- #search_conflicts_without_properties ⇒ Object
- #search_properties(collection, properties, result = []) ⇒ Object
- #search_without_properties(collection) ⇒ Object
Instance Method Details
#per_collection(properties = ['name']) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/jekyll/tasks/menus.rb', line 44 def per_collection(properties = ['name']) result = [] Collections.get.each do |collection| data = search_properties(collection, properties) hash = { 'collection' => collection, 'properties' => data } result << hash unless data.empty? end result end |
#search_conflicts ⇒ Object
9 10 11 12 13 |
# File 'lib/jekyll/tasks/menus.rb', line 9 def search_conflicts conflicts = [] conflicts << (search_conflicts_with_properties | search_conflicts_without_properties) conflicts.flatten! end |
#search_conflicts_with_properties ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll/tasks/menus.rb', line 15 def search_conflicts_with_properties conflicts = [] per_collection(%w[name father]).each do |el| properties = el['properties'] index = search_hash(properties, 'name') name = index.nil? ? '' : properties[index]['name'] index = search_hash(properties, 'father') father = index.nil? ? '' : properties[index]['father'] conflicts << analyze_conflicts(el['collection'], name, father) if name != father end conflicts end |
#search_conflicts_without_properties ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jekyll/tasks/menus.rb', line 33 def search_conflicts_without_properties conflicts = [] Collections.get.each do |collection| data = search_without_properties(collection) unless collection == 'pages' conflicts << data unless data.nil? end conflicts end |
#search_properties(collection, properties, result = []) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jekyll/tasks/menus.rb', line 66 def search_properties(collection, properties, result = []) files = markdown_files collection files.each do |file| data = YAML.load_file(file, permitted_classes: [Date]) properties.each do |property| search_property result, data, property end end order_properties(result, properties) end |
#search_without_properties(collection) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jekyll/tasks/menus.rb', line 54 def search_without_properties(collection) conflicts = [] files = markdown_files collection files.each do |file| data = YAML.load_file(file, permitted_classes: [Date]) conflicts << analyze_conflicts_without_properties(data) end conflicts end |