jekyll-tasks 0.2.0 → 0.3.0
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 +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +2 -2
- data/_collection1/collection1.md +3 -0
- data/_collection1/subfolder/product-lost.md +3 -0
- data/_collection1/subfolder/subfolder1.md +4 -0
- data/_collection2/collection2.md +3 -0
- data/_collection2/subfolder/subfolder2.md +4 -0
- data/jekyll-tasks.gemspec +2 -2
- data/lib/jekyll/tasks.rb +3 -0
- data/lib/jekyll/tasks/collections.rb +24 -0
- data/lib/jekyll/tasks/menus.rb +98 -0
- data/lib/jekyll/tasks/products.rb +5 -5
- data/lib/jekyll/tasks/related.rb +3 -3
- data/lib/jekyll/tasks/version.rb +1 -1
- metadata +11 -8
- data/.github/dependabot.yml +0 -15
- data/_data/api/hana/products/product-1.yml +0 -1
- data/_data/api/hana/products/product-2.yml +0 -1
- data/_data/api/hana/products/product-3.yml +0 -1
- data/_data/api/yaml/related/products.yml +0 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 30f43274444ff755c93a38ff085384a0c924c4106eb281fb52de490f9c378e1f
         | 
| 4 | 
            +
              data.tar.gz: b29c4d4abfe88a7e53b8dba06637a60b6806bb1d9b5db25388fa2e681deca9b4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fcd79960a18e88fb90babb45a9ac5ab9556548602726a4953729bad456aa176ed441a88e634d721219f1475f31367836496ecf72463edf17f2828ab7eaf62fd5
         | 
| 7 | 
            +
              data.tar.gz: 0e263a7d776f02b2c4667d75dc3f16b3c218a385ea7cbdd1e3a0d81f107420907ef71ef9137a56b451d716c20eb8b74bb4e0fa810c40d30d87b2a3ad95f80c89
         | 
    
        data/.rubocop.yml
    ADDED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                jekyll-tasks (0. | 
| 4 | 
            +
                jekyll-tasks (0.3.0)
         | 
| 5 5 |  | 
| 6 6 | 
             
            GEM
         | 
| 7 7 | 
             
              remote: https://rubygems.org/
         | 
| @@ -15,7 +15,7 @@ GEM | |
| 15 15 | 
             
                parser (3.0.1.0)
         | 
| 16 16 | 
             
                  ast (~> 2.4.1)
         | 
| 17 17 | 
             
                rainbow (3.0.0)
         | 
| 18 | 
            -
                rake (13.0. | 
| 18 | 
            +
                rake (13.0.6)
         | 
| 19 19 | 
             
                regexp_parser (2.1.1)
         | 
| 20 20 | 
             
                rexml (3.2.5)
         | 
| 21 21 | 
             
                rubocop (1.12.1)
         | 
    
        data/jekyll-tasks.gemspec
    CHANGED
    
    | @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| | |
| 11 11 | 
             
              spec.summary       = 'A set of rake tasks to help you on your Jekyll sites.'
         | 
| 12 12 | 
             
              spec.homepage      = 'https://github.com/grupopv/jekyll-tasks/'
         | 
| 13 13 | 
             
              spec.license       = 'MIT'
         | 
| 14 | 
            -
              spec.required_ruby_version = Gem::Requirement.new('>= 2. | 
| 14 | 
            +
              spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
         | 
| 15 15 |  | 
| 16 16 | 
             
              spec.metadata['homepage_uri'] = spec.homepage
         | 
| 17 17 | 
             
              spec.metadata['source_code_uri'] = 'https://github.com/grupopv/jekyll-tasks/'
         | 
| @@ -24,7 +24,7 @@ Gem::Specification.new do |spec| | |
| 24 24 | 
             
              all_files          = `git ls-files -z`.split("\x0")
         | 
| 25 25 | 
             
              spec.files         = Dir.chdir(File.expand_path(__dir__)) do
         | 
| 26 26 | 
             
                all_files.reject do |f|
         | 
| 27 | 
            -
                  excluded_files = %r{^(bin| | 
| 27 | 
            +
                  excluded_files = %r{^(_data|.github|bin|test|spec|features)/}
         | 
| 28 28 | 
             
                  f.match(excluded_files)
         | 
| 29 29 | 
             
                end
         | 
| 30 30 | 
             
              end
         | 
    
        data/lib/jekyll/tasks.rb
    CHANGED
    
    
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Jekyll
         | 
| 4 | 
            +
              module Tasks
         | 
| 5 | 
            +
                # Obtain collections information
         | 
| 6 | 
            +
                module Collections
         | 
| 7 | 
            +
                  extend self
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def get
         | 
| 10 | 
            +
                    collections = []
         | 
| 11 | 
            +
                    folders_starting_with_underscore.each do |collection|
         | 
| 12 | 
            +
                      collections << collection[3..]
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
                    collections
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  private
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def folders_starting_with_underscore
         | 
| 20 | 
            +
                    Dir.glob('./_*').to_a.sort
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,98 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Jekyll
         | 
| 4 | 
            +
              module Tasks
         | 
| 5 | 
            +
                # Obtain menus information
         | 
| 6 | 
            +
                module Menus
         | 
| 7 | 
            +
                  extend self
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  def print_conflicts
         | 
| 10 | 
            +
                    conflicts = search_conflicts
         | 
| 11 | 
            +
                    puts conflicts
         | 
| 12 | 
            +
                    conflicts.empty?
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def search_conflicts
         | 
| 16 | 
            +
                    conflicts = []
         | 
| 17 | 
            +
                    per_collection(%w[name father]).each do |el|
         | 
| 18 | 
            +
                      properties = el['properties']
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                      index = search_hash(properties, 'name')
         | 
| 21 | 
            +
                      name = index.nil? ? '' : properties[index]['name']
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                      index = search_hash(properties, 'father')
         | 
| 24 | 
            +
                      father = index.nil? ? '' : properties[index]['father']
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                      analyze_conflicts el['collection'], conflicts, name, father if name != father
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                    conflicts
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def per_collection(properties = ['name'])
         | 
| 32 | 
            +
                    result = []
         | 
| 33 | 
            +
                    Collections.get.each do |collection|
         | 
| 34 | 
            +
                      data = search_properties(collection, properties)
         | 
| 35 | 
            +
                      hash = { 'collection' => collection, 'properties' => data }
         | 
| 36 | 
            +
                      result << hash unless data.empty?
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
                    result
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  def search_properties(collection, properties)
         | 
| 42 | 
            +
                    result = []
         | 
| 43 | 
            +
                    files = markdown_files collection
         | 
| 44 | 
            +
                    files.each do |file|
         | 
| 45 | 
            +
                      data = YAML.load_file(file)
         | 
| 46 | 
            +
                      properties.each do |property|
         | 
| 47 | 
            +
                        search_property result, data, property
         | 
| 48 | 
            +
                      end
         | 
| 49 | 
            +
                    end
         | 
| 50 | 
            +
                    order_properties(result, properties)
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  private
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def analyze_conflicts(collection, conflicts, name, father)
         | 
| 56 | 
            +
                    array = name - father
         | 
| 57 | 
            +
                    conflicts << "There are some unused menus at #{collection} collection: #{array}" unless array.empty?
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    array = father - name
         | 
| 60 | 
            +
                    unless array.empty?
         | 
| 61 | 
            +
                      conflicts << "There are some products pointed to non-existent menus at #{collection} collection: #{array}"
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    conflicts
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  def search_property(result, data, property)
         | 
| 68 | 
            +
                    value = data["menu-#{property}"]
         | 
| 69 | 
            +
                    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
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  def order_properties(result, properties)
         | 
| 79 | 
            +
                    properties.each do |property|
         | 
| 80 | 
            +
                      index = search_hash(result, property)
         | 
| 81 | 
            +
                      result[index][property] = result[index][property].sort.uniq unless index.nil?
         | 
| 82 | 
            +
                    end
         | 
| 83 | 
            +
                    result
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  def search_hash(list, property)
         | 
| 87 | 
            +
                    list.each_with_index do |hash, index|
         | 
| 88 | 
            +
                      return index if hash[property]
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
                    nil
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  def markdown_files(colecction)
         | 
| 94 | 
            +
                    Dir.glob("./_#{colecction}/**/*.md").to_a.sort
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
              end
         | 
| 98 | 
            +
            end
         | 
| @@ -6,9 +6,9 @@ module Jekyll | |
| 6 6 | 
             
                module Products
         | 
| 7 7 | 
             
                  extend self
         | 
| 8 8 |  | 
| 9 | 
            -
                  def  | 
| 9 | 
            +
                  def filename_list
         | 
| 10 10 | 
             
                    products = []
         | 
| 11 | 
            -
                     | 
| 11 | 
            +
                    path_list.each do |product|
         | 
| 12 12 | 
             
                      product = product
         | 
| 13 13 | 
             
                                .gsub('./_data/api/hana/products/', '')
         | 
| 14 14 | 
             
                                .gsub('.yml', '')
         | 
| @@ -17,9 +17,9 @@ module Jekyll | |
| 17 17 | 
             
                    products
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 |  | 
| 20 | 
            -
                  def  | 
| 20 | 
            +
                  def model_list
         | 
| 21 21 | 
             
                    products = []
         | 
| 22 | 
            -
                     | 
| 22 | 
            +
                    path_list.each do |product|
         | 
| 23 23 | 
             
                      data = YAML.load_file(product)
         | 
| 24 24 | 
             
                      products << data['title']
         | 
| 25 25 | 
             
                    end
         | 
| @@ -28,7 +28,7 @@ module Jekyll | |
| 28 28 |  | 
| 29 29 | 
             
                  private
         | 
| 30 30 |  | 
| 31 | 
            -
                  def  | 
| 31 | 
            +
                  def path_list
         | 
| 32 32 | 
             
                    Dir.glob('./_data/api/hana/products/*.yml').to_a.sort
         | 
| 33 33 | 
             
                  end
         | 
| 34 34 | 
             
                end
         | 
    
        data/lib/jekyll/tasks/related.rb
    CHANGED
    
    | @@ -10,8 +10,8 @@ module Jekyll | |
| 10 10 |  | 
| 11 11 | 
             
                  def all_products_with_related
         | 
| 12 12 | 
             
                    errors = []
         | 
| 13 | 
            -
                    api =  | 
| 14 | 
            -
                    Products. | 
| 13 | 
            +
                    api = api_data
         | 
| 14 | 
            +
                    Products.model_list.each do |product|
         | 
| 15 15 | 
             
                      if api[product]
         | 
| 16 16 | 
             
                        count = api[product].count
         | 
| 17 17 | 
             
                        errors << "Only has #{count} related products: #{product}" if count < MINIMUM_RELATED_PRODUCTS
         | 
| @@ -23,7 +23,7 @@ module Jekyll | |
| 23 23 |  | 
| 24 24 | 
             
                  private
         | 
| 25 25 |  | 
| 26 | 
            -
                  def  | 
| 26 | 
            +
                  def api_data
         | 
| 27 27 | 
             
                    YAML.load_file('./_data/api/yaml/related/products.yml')
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 | 
             
                end
         | 
    
        data/lib/jekyll/tasks/version.rb
    CHANGED
    
    
    
        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. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 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- | 
| 11 | 
            +
            date: 2021-07-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description:
         | 
| 14 14 | 
             
            email:
         | 
| @@ -17,8 +17,8 @@ executables: [] | |
| 17 17 | 
             
            extensions: []
         | 
| 18 18 | 
             
            extra_rdoc_files: []
         | 
| 19 19 | 
             
            files:
         | 
| 20 | 
            -
            - ".github/dependabot.yml"
         | 
| 21 20 | 
             
            - ".gitignore"
         | 
| 21 | 
            +
            - ".rubocop.yml"
         | 
| 22 22 | 
             
            - ".travis.yml"
         | 
| 23 23 | 
             
            - CODEOWNERS
         | 
| 24 24 | 
             
            - CODE_OF_CONDUCT.md
         | 
| @@ -27,13 +27,16 @@ files: | |
| 27 27 | 
             
            - LICENSE.txt
         | 
| 28 28 | 
             
            - README.md
         | 
| 29 29 | 
             
            - Rakefile
         | 
| 30 | 
            -
            -  | 
| 31 | 
            -
            -  | 
| 32 | 
            -
            -  | 
| 33 | 
            -
            -  | 
| 30 | 
            +
            - _collection1/collection1.md
         | 
| 31 | 
            +
            - _collection1/subfolder/product-lost.md
         | 
| 32 | 
            +
            - _collection1/subfolder/subfolder1.md
         | 
| 33 | 
            +
            - _collection2/collection2.md
         | 
| 34 | 
            +
            - _collection2/subfolder/subfolder2.md
         | 
| 34 35 | 
             
            - jekyll-tasks.gemspec
         | 
| 35 36 | 
             
            - lib/jekyll/tasks.rb
         | 
| 37 | 
            +
            - lib/jekyll/tasks/collections.rb
         | 
| 36 38 | 
             
            - lib/jekyll/tasks/dates.rb
         | 
| 39 | 
            +
            - lib/jekyll/tasks/menus.rb
         | 
| 37 40 | 
             
            - lib/jekyll/tasks/products.rb
         | 
| 38 41 | 
             
            - lib/jekyll/tasks/related.rb
         | 
| 39 42 | 
             
            - lib/jekyll/tasks/version.rb
         | 
| @@ -52,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 52 55 | 
             
              requirements:
         | 
| 53 56 | 
             
              - - ">="
         | 
| 54 57 | 
             
                - !ruby/object:Gem::Version
         | 
| 55 | 
            -
                  version: 2. | 
| 58 | 
            +
                  version: 2.7.0
         | 
| 56 59 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 57 60 | 
             
              requirements:
         | 
| 58 61 | 
             
              - - ">="
         | 
    
        data/.github/dependabot.yml
    DELETED
    
    | @@ -1,15 +0,0 @@ | |
| 1 | 
            -
            version: 2
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            updates:
         | 
| 4 | 
            -
              - package-ecosystem: bundler
         | 
| 5 | 
            -
                directory: "/"
         | 
| 6 | 
            -
                schedule:
         | 
| 7 | 
            -
                  interval: weekly
         | 
| 8 | 
            -
                  day: thursday
         | 
| 9 | 
            -
                  time: "09:00"
         | 
| 10 | 
            -
                  timezone: "America/Chihuahua"
         | 
| 11 | 
            -
                open-pull-requests-limit: 10
         | 
| 12 | 
            -
                reviewers: ["mlopez-grupopv"]
         | 
| 13 | 
            -
                labels:
         | 
| 14 | 
            -
                  - dependencies
         | 
| 15 | 
            -
                  - ruby
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            title: PRODUCT/1
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            title: PRODUCT/2
         | 
| @@ -1 +0,0 @@ | |
| 1 | 
            -
            title: PRODUCT/3
         |