jekyll_all_collections 0.3.2 → 0.3.3
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 +15 -11
- data/CHANGELOG.md +4 -0
- data/README.md +52 -36
- data/jekyll_all_collections.gemspec +2 -2
- data/lib/all_collections_hooks.rb +9 -9
- data/lib/all_collections_tag.rb +39 -28
- data/lib/jekyll_all_collections/version.rb +1 -1
- data/spec/all_collections_tag_sort_spec.rb +13 -19
- metadata +6 -7
- data/spec/status_persistence.txt +0 -20
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d7f7fa2e1b1ca3dc3ee52ef85f6b1f55db8710bca3fed39386469d686bd6341f
         | 
| 4 | 
            +
              data.tar.gz: 3827c3d5b908b972fb2d4efb3b6c0f703d84fbd710d5887485f1f6e0810718f9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fed15d67819f65a6711f9b4a3550fd4d309184f06e774cffe4ba9e9a4673f04e422e785a62c17c4151f12e1e98685f8317bec2e02542cfebac87ec94c9557a0c
         | 
| 7 | 
            +
              data.tar.gz: 750f6e7f00532dc66bd992269c6cc0651deaebf2e10b385883c29010e4032a52ea7a925de12d55ecc064cdc2c604c919d6eb1a0807a641a31e7055f99a588048
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -27,7 +27,7 @@ Layout/LineLength: | |
| 27 27 | 
             
              Max: 150
         | 
| 28 28 |  | 
| 29 29 | 
             
            Metrics/AbcSize:
         | 
| 30 | 
            -
              Max:  | 
| 30 | 
            +
              Max: 45
         | 
| 31 31 |  | 
| 32 32 | 
             
            Metrics/BlockLength:
         | 
| 33 33 | 
             
              Exclude:
         | 
| @@ -47,21 +47,25 @@ Naming/FileName: | |
| 47 47 | 
             
              Exclude:
         | 
| 48 48 | 
             
                - Rakefile
         | 
| 49 49 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
               | 
| 52 | 
            -
             | 
| 53 | 
            -
            Style/FrozenStringLiteralComment:
         | 
| 54 | 
            -
              Enabled: false
         | 
| 55 | 
            -
             | 
| 56 | 
            -
            Style/TrailingCommaInHashLiteral:
         | 
| 57 | 
            -
              EnforcedStyleForMultiline: comma
         | 
| 50 | 
            +
            RSpec/ExampleLength:
         | 
| 51 | 
            +
              Max: 30
         | 
| 58 52 |  | 
| 59 53 | 
             
            RSpec/FilePath:
         | 
| 54 | 
            +
              Enabled: false
         | 
| 60 55 | 
             
              IgnoreMethods: true
         | 
| 61 56 | 
             
              SpecSuffixOnly: true
         | 
| 62 57 |  | 
| 63 | 
            -
            RSpec/ | 
| 64 | 
            -
               | 
| 58 | 
            +
            RSpec/IndexedLet:
         | 
| 59 | 
            +
              Enabled: false
         | 
| 65 60 |  | 
| 66 61 | 
             
            RSpec/MultipleExpectations:
         | 
| 67 62 | 
             
              Max: 15
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            Style/Documentation:
         | 
| 65 | 
            +
              Enabled: false
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            Style/FrozenStringLiteralComment:
         | 
| 68 | 
            +
              Enabled: false
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            Style/TrailingCommaInHashLiteral:
         | 
| 71 | 
            +
              EnforcedStyleForMultiline: comma
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -15,25 +15,39 @@ The collection consists of an array of objects with the following properties: | |
| 15 15 | 
             
            Pages that are not in any collection are not included.
         | 
| 16 16 |  | 
| 17 17 |  | 
| 18 | 
            +
            ## Installation
         | 
| 19 | 
            +
            Add this line to your application's Gemfile:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ```ruby
         | 
| 22 | 
            +
            group :jekyll_plugins do
         | 
| 23 | 
            +
              gem 'jekyll_all_collections'
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
            ```
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            And then execute:
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                $ bundle
         | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 18 32 | 
             
            ## Requirements
         | 
| 19 33 | 
             
            All the pages in the Jekyll website must have an implicit date (for example, all posts are assigned this property by Jekyll),
         | 
| 20 34 | 
             
            or an explicit `date` set in front matter, like this:
         | 
| 21 35 | 
             
               ```
         | 
| 22 36 | 
             
               ---
         | 
| 23 | 
            -
               date | 
| 37 | 
            +
               date: 2022-01-01
         | 
| 24 38 | 
             
               ---
         | 
| 25 39 | 
             
               ```
         | 
| 26 40 | 
             
            If a front matter variable called `last_modified` or `last_modified_at` exists, its value will be converted to a Ruby `Date`:
         | 
| 27 41 | 
             
               ```
         | 
| 28 42 | 
             
               ---
         | 
| 29 | 
            -
               last_modified | 
| 43 | 
            +
               last_modified: 2023-01-01
         | 
| 30 44 | 
             
               ---
         | 
| 31 45 | 
             
               ```
         | 
| 32 46 |  | 
| 33 47 | 
             
               Or:
         | 
| 34 48 | 
             
               ```
         | 
| 35 49 | 
             
               ---
         | 
| 36 | 
            -
               last_modified_at | 
| 50 | 
            +
               last_modified_at: 2023-01-01
         | 
| 37 51 | 
             
               ---
         | 
| 38 52 | 
             
               ```
         | 
| 39 53 |  | 
| @@ -79,7 +93,12 @@ exclude_from_all: true | |
| 79 93 | 
             
            #### General Form
         | 
| 80 94 | 
             
            The general form of the Jekyll tag is:
         | 
| 81 95 | 
             
            ```
         | 
| 82 | 
            -
            {% all_collections | 
| 96 | 
            +
            {% all_collections
         | 
| 97 | 
            +
              date_column='date|last_modified'
         | 
| 98 | 
            +
              heading='All Posts'
         | 
| 99 | 
            +
              id='asdf'
         | 
| 100 | 
            +
              sort_by='SORT_KEYS'
         | 
| 101 | 
            +
            %}
         | 
| 83 102 | 
             
            ```
         | 
| 84 103 |  | 
| 85 104 | 
             
            #### `date_column` Attribute
         | 
| @@ -89,19 +108,6 @@ or `last_modified`. | |
| 89 108 | 
             
            The default value for the `date_column` attribute is `date`.
         | 
| 90 109 |  | 
| 91 110 |  | 
| 92 | 
            -
            #### `id` Attribute
         | 
| 93 | 
            -
            If your Jekyll layout employs [`jekyll-toc`](https://github.com/allejo/jekyll-toc), then `id` attributes are important.
         | 
| 94 | 
            -
            The `jekyll-toc` include checks for `id` attributes in `h2` ... `h6` tags, and if found, and if the attribute value is enclosed in double quotes (`id="my_id"`, not `id='my_id'`),
         | 
| 95 | 
            -
            then the heading is included in the table of contents.
         | 
| 96 | 
            -
             | 
| 97 | 
            -
            To suppress an `id` from being generated,
         | 
| 98 | 
            -
            and thereby preventing the heading from appearing in the automatically generated table of contents from `jekyll-toc`,
         | 
| 99 | 
            -
            specify an empty string for the value of `id`, like this:
         | 
| 100 | 
            -
            ```
         | 
| 101 | 
            -
            {% all_collections id='' %}
         | 
| 102 | 
            -
            ```
         | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 111 | 
             
            #### `heading` Attribute
         | 
| 106 112 | 
             
            If no `heading` attribute is specified, a heading will automatically be generated, which contains the `sort_by` values, for example:
         | 
| 107 113 | 
             
            ```
         | 
| @@ -109,7 +115,7 @@ If no `heading` attribute is specified, a heading will automatically be generate | |
| 109 115 | 
             
            ```
         | 
| 110 116 | 
             
            Generates a heading like:
         | 
| 111 117 | 
             
            ```
         | 
| 112 | 
            -
            <h2 id="abcdef">All Posts Sorted By  | 
| 118 | 
            +
            <h2 id="abcdef">All Posts Sorted By last_modified</h2>
         | 
| 113 119 | 
             
            ```
         | 
| 114 120 |  | 
| 115 121 | 
             
            To suppress both a `h2` heading (and the enclosed `id`) from being generated,
         | 
| @@ -119,13 +125,39 @@ specify an empty string for the value of `heading`: | |
| 119 125 | 
             
            ```
         | 
| 120 126 |  | 
| 121 127 |  | 
| 128 | 
            +
            #### `id` Attribute
         | 
| 129 | 
            +
            If your Jekyll layout employs [`jekyll-toc`](https://github.com/allejo/jekyll-toc), then `id` attributes are important.
         | 
| 130 | 
            +
            The `jekyll-toc` include checks for `id` attributes in `h2` ... `h6` tags, and if found, and if the attribute value is enclosed in double quotes (`id="my_id"`, not `id='my_id'`),
         | 
| 131 | 
            +
            then the heading is included in the table of contents.
         | 
| 132 | 
            +
             | 
| 133 | 
            +
            To suppress an `id` from being generated,
         | 
| 134 | 
            +
            and thereby preventing the heading from appearing in the automatically generated table of contents from `jekyll-toc`,
         | 
| 135 | 
            +
            specify an empty string for the value of `id`, like this:
         | 
| 136 | 
            +
            ```
         | 
| 137 | 
            +
            {% all_collections id='' %}
         | 
| 138 | 
            +
            ```
         | 
| 139 | 
            +
             | 
| 140 | 
            +
             | 
| 122 141 | 
             
            #### `SORT_KEYS` Values
         | 
| 123 142 | 
             
            `SORT_KEYS` specifies how to sort the collection.
         | 
| 124 143 | 
             
            Values can include one or more of the following attributes:
         | 
| 125 | 
            -
            `date`, `destination`, `draft`, `label`, `last_modified`, `path`, `relative_path`, `title`, `type`, and `url`.
         | 
| 144 | 
            +
            `date`, `destination`, `draft`, `label`, `last_modified`, `last_modified_at`, `path`, `relative_path`, `title`, `type`, and `url`.
         | 
| 126 145 | 
             
            Ascending sorts are the default, however a descending sort can be achieved by prepending `-` before an attribute.
         | 
| 127 146 |  | 
| 128 | 
            -
            To specify more than one sort key, provide  | 
| 147 | 
            +
            To specify more than one sort key, provide a comma-delimited string of values.
         | 
| 148 | 
            +
            Included spaces are ignored.
         | 
| 149 | 
            +
            For example, specify the primary sort key as <code>draft</code>,
         | 
| 150 | 
            +
            the secondary sort key as <code>last_modified</code>,
         | 
| 151 | 
            +
            and the tertiary key as <code>label</code>:
         | 
| 152 | 
            +
             | 
| 153 | 
            +
            ```
         | 
| 154 | 
            +
            {% all_collections
         | 
| 155 | 
            +
              date_column='last_modified'
         | 
| 156 | 
            +
              heading='All Posts'
         | 
| 157 | 
            +
              id='asdf'
         | 
| 158 | 
            +
              sort_by='draft, last_modified, label'
         | 
| 159 | 
            +
            %}
         | 
| 160 | 
            +
            ```
         | 
| 129 161 |  | 
| 130 162 |  | 
| 131 163 | 
             
            #### Usage Examples
         | 
| @@ -237,22 +269,6 @@ More information is available on Mike Slinn's website about | |
| 237 269 | 
             
            [Jekyll plugins](https://www.mslinn.com/blog/index.html#Jekyll).
         | 
| 238 270 |  | 
| 239 271 |  | 
| 240 | 
            -
            ## Installation
         | 
| 241 | 
            -
            This has already been done for the demo;
         | 
| 242 | 
            -
            these instructions are for incorporating the plugin(s) into other Jekyll websites.
         | 
| 243 | 
            -
            Add this line to your application's Gemfile:
         | 
| 244 | 
            -
             | 
| 245 | 
            -
            ```ruby
         | 
| 246 | 
            -
            group :jekyll_plugins do
         | 
| 247 | 
            -
              gem 'jekyll_all_collections'
         | 
| 248 | 
            -
            end
         | 
| 249 | 
            -
            ```
         | 
| 250 | 
            -
             | 
| 251 | 
            -
            And then execute:
         | 
| 252 | 
            -
             | 
| 253 | 
            -
                $ bundle install
         | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 272 | 
             
            ## Development
         | 
| 257 273 |  | 
| 258 274 | 
             
            After checking out the repo, run `bin/setup` to install dependencies.
         | 
| @@ -14,7 +14,7 @@ Gem::Specification.new do |spec| | |
| 14 14 | 
             
              # Specify which files should be added to the gem when it is released.
         | 
| 15 15 | 
             
              spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
         | 
| 16 16 |  | 
| 17 | 
            -
              spec.homepage =  | 
| 17 | 
            +
              spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_all_collections.html'
         | 
| 18 18 | 
             
              spec.license = 'MIT'
         | 
| 19 19 | 
             
              spec.metadata = {
         | 
| 20 20 | 
             
                'allowed_push_host' => 'https://rubygems.org',
         | 
| @@ -31,5 +31,5 @@ Gem::Specification.new do |spec| | |
| 31 31 |  | 
| 32 32 | 
             
              spec.add_dependency 'jekyll', '>= 3.5.0'
         | 
| 33 33 | 
             
              spec.add_dependency 'jekyll_draft', '~> 1.1.1'
         | 
| 34 | 
            -
              spec.add_dependency 'jekyll_plugin_support', '>= 0. | 
| 34 | 
            +
              spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
         | 
| 35 35 | 
             
            end
         | 
| @@ -73,15 +73,15 @@ module AllCollectionsHooks | |
| 73 73 | 
             
                def initialize(obj) # rubocop:disable Metrics/AbcSize
         | 
| 74 74 | 
             
                  @data = obj.data if obj.respond_to? :data
         | 
| 75 75 |  | 
| 76 | 
            -
                  @categories = @data['categories'] if  | 
| 76 | 
            +
                  @categories = @data['categories'] if @data.key? 'categories'
         | 
| 77 77 | 
             
                  @content = obj.content if obj.respond_to? :content
         | 
| 78 | 
            -
                  @date = @data['date'].to_date if  | 
| 79 | 
            -
                  @description = @data['description'] if  | 
| 78 | 
            +
                  @date = (@data['date'].to_date if @data&.key?('date')) || Date.today
         | 
| 79 | 
            +
                  @description = @data['description'] if @data.key? 'description'
         | 
| 80 80 | 
             
                  @destination = obj.destination('') if obj.respond_to? :destination # TODO: What _config.yml setting should be passed to destination()?
         | 
| 81 81 | 
             
                  @draft = Jekyll::Draft.draft?(obj)
         | 
| 82 | 
            -
                  @excerpt = @data['excerpt'] if  | 
| 83 | 
            -
                  @ext = @data['ext'] if  | 
| 84 | 
            -
                  @label = obj.collection.label if obj.respond_to? :label
         | 
| 82 | 
            +
                  @excerpt = @data['excerpt'] if @data.key? 'excerpt'
         | 
| 83 | 
            +
                  @ext = @data['ext'] if @data.key? 'ext'
         | 
| 84 | 
            +
                  @label = obj.collection.label if obj&.collection.respond_to? :label
         | 
| 85 85 | 
             
                  @last_modified = @data['last_modified'] || @data['last_modified_at'] || @date
         | 
| 86 86 | 
             
                  @last_modified_field = case @data
         | 
| 87 87 | 
             
                                         when @data.key?('last_modified')
         | 
| @@ -89,11 +89,11 @@ module AllCollectionsHooks | |
| 89 89 | 
             
                                         when @data.key?('last_modified_at')
         | 
| 90 90 | 
             
                                           'last_modified_at'
         | 
| 91 91 | 
             
                                         end
         | 
| 92 | 
            -
                  @layout = @data['layout'] if  | 
| 92 | 
            +
                  @layout = @data['layout'] if @data.key? 'layout'
         | 
| 93 93 | 
             
                  @path = obj.path if obj.respond_to? :path
         | 
| 94 94 | 
             
                  @relative_path = obj.relative_path if obj.respond_to? :relative_path
         | 
| 95 | 
            -
                  @tags = @data['tags'] if  | 
| 96 | 
            -
                  @title = @data['title'] if  | 
| 95 | 
            +
                  @tags = @data['tags'] if @data.key? 'tags'
         | 
| 96 | 
            +
                  @title = @data['title'] if @data.key? 'title'
         | 
| 97 97 | 
             
                  @type = obj.type if obj.respond_to? :type
         | 
| 98 98 | 
             
                  @url = obj.url
         | 
| 99 99 | 
             
                end
         | 
    
        data/lib/all_collections_tag.rb
    CHANGED
    
    | @@ -18,6 +18,7 @@ end | |
| 18 18 | 
             
            module AllCollectionsTag
         | 
| 19 19 | 
             
              PLUGIN_NAME = 'all_collections'.freeze
         | 
| 20 20 | 
             
              CRITERIA = %w[date destination draft label last_modified last_modified_at path relative_path title type url].freeze
         | 
| 21 | 
            +
              DRAFT_HTML = '<i class="jekyll_draft">Draft</i>'.freeze
         | 
| 21 22 |  | 
| 22 23 | 
             
              class AllCollectionsTag < JekyllSupport::JekyllTag
         | 
| 23 24 | 
             
                include JekyllAllCollectionsVersion
         | 
| @@ -28,18 +29,22 @@ module AllCollectionsTag | |
| 28 29 | 
             
                  AllCollectionsHooks.compute(@site) unless @site.class.method_defined? :all_collections
         | 
| 29 30 |  | 
| 30 31 | 
             
                  @date_column = @helper.parameter_specified?('date_column') || 'date'
         | 
| 31 | 
            -
                   | 
| 32 | 
            -
                     | 
| 33 | 
            -
             | 
| 32 | 
            +
                  unless %w[date last_modified].include?(@date_column)
         | 
| 33 | 
            +
                    # TODO: should this just issue a warning and return instead of dieing?
         | 
| 34 | 
            +
                    abort "Error: the date_column attribute must either have value 'date' or 'last_modified', " \
         | 
| 35 | 
            +
                          "but '#{@date_column}' was specified"
         | 
| 36 | 
            +
                  end
         | 
| 34 37 | 
             
                  @id = @helper.parameter_specified?('id') || SecureRandom.hex(10)
         | 
| 35 | 
            -
                  sort_by_param = @helper.parameter_specified? | 
| 38 | 
            +
                  sort_by_param = @helper.parameter_specified? 'sort_by'
         | 
| 36 39 | 
             
                  sort_by = (sort_by_param&.gsub(' ', '')&.split(',') if sort_by_param != false) || ['-date']
         | 
| 37 40 | 
             
                  @heading = @helper.parameter_specified?('heading') || self.class.default_head(sort_by)
         | 
| 38 41 | 
             
                  sort_lambda_string = self.class.create_lambda_string(sort_by)
         | 
| 39 | 
            -
                  @logger.debug  | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
                   | 
| 42 | 
            +
                  @logger.debug do
         | 
| 43 | 
            +
                    "#{@page['path']} sort_by_param=#{sort_by_param}  " \
         | 
| 44 | 
            +
                      "sort_lambda_string = #{sort_lambda_string}\n"
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                  sort_lambda = self.class.evaluate sort_lambda_string
         | 
| 47 | 
            +
                  generate_output sort_lambda
         | 
| 43 48 | 
             
                end
         | 
| 44 49 |  | 
| 45 50 | 
             
                def self.default_head(sort_by)
         | 
| @@ -57,9 +62,9 @@ module AllCollectionsTag | |
| 57 62 | 
             
                  criteria_lhs_array = []
         | 
| 58 63 | 
             
                  criteria_rhs_array = []
         | 
| 59 64 | 
             
                  verify_sort_by_type(criteria).each do |c|
         | 
| 60 | 
            -
                    descending_sort = c.start_with? | 
| 65 | 
            +
                    descending_sort = c.start_with? '-'
         | 
| 61 66 | 
             
                    c.delete_prefix! '-'
         | 
| 62 | 
            -
                    abort("Error: '#{c}' is not a valid sort field. Valid field names are: #{CRITERIA.join | 
| 67 | 
            +
                    abort("Error: '#{c}' is not a valid sort field. Valid field names are: #{CRITERIA.join ', '}") \
         | 
| 63 68 | 
             
                      unless CRITERIA.include?(c)
         | 
| 64 69 | 
             
                    criteria_lhs_array << (descending_sort ? "b.#{c}" : "a.#{c}")
         | 
| 65 70 | 
             
                    criteria_rhs_array << (descending_sort ? "a.#{c}" : "b.#{c}")
         | 
| @@ -92,32 +97,38 @@ module AllCollectionsTag | |
| 92 97 |  | 
| 93 98 | 
             
                private
         | 
| 94 99 |  | 
| 100 | 
            +
                def last_modified_value(post)
         | 
| 101 | 
            +
                  @logger.debug { "  post.last_modified='#{post.last_modified}'; post.last_modified_at='#{post.last_modified_at}'; @date_column='#{@date_column}'" }
         | 
| 102 | 
            +
                  last_modified = if @date_column == 'last_modified' && post.respond_to?(:last_modified)
         | 
| 103 | 
            +
                                    post.last_modified
         | 
| 104 | 
            +
                                  elsif post.respond_to? :last_modified_at
         | 
| 105 | 
            +
                                    post.last_modified_at
         | 
| 106 | 
            +
                                  else
         | 
| 107 | 
            +
                                    post.date
         | 
| 108 | 
            +
                                  end
         | 
| 109 | 
            +
                  last_modified ||= post.date || Date.today
         | 
| 110 | 
            +
                  last_modified
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 95 113 | 
             
                def generate_output(sort_lambda)
         | 
| 96 | 
            -
                  id = @id.to_s.empty? ? '' : " id='#{@id}'"
         | 
| 97 | 
            -
                  heading = @heading.to_s.empty? ? '' : "<h2#{id}>#{@heading}</h2>"
         | 
| 98 | 
            -
                  @site.all_collections.each do |post|
         | 
| 99 | 
            -
                    # @logger.debug do
         | 
| 100 | 
            -
                    #   "#{post.relative_path}: last_modified=#{post.last_modified}(#{post.last_modified.class}) date=#{post.date}(#{post.date.class})"
         | 
| 101 | 
            -
                    # end
         | 
| 102 | 
            -
                    @logger.debug { "Error: #{post.relative_path} has no value for last_modified" if post.last_modified.to_s.empty? }
         | 
| 103 | 
            -
                  end
         | 
| 114 | 
            +
                  id = @id.to_s.strip.empty? ? '' : " id='#{@id}'"
         | 
| 115 | 
            +
                  heading = @heading.strip.to_s.empty? ? '' : "<h2#{id}>#{@heading}</h2>"
         | 
| 104 116 | 
             
                  collection = @site.all_collections.sort(&sort_lambda)
         | 
| 105 117 | 
             
                  <<~END_TEXT
         | 
| 106 118 | 
             
                    #{heading}
         | 
| 107 119 | 
             
                    <div class="posts">
         | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 120 | 
            +
                      #{(collection.map do |post|
         | 
| 121 | 
            +
                           last_modified = last_modified_value post
         | 
| 122 | 
            +
                           date = last_modified.strftime '%Y-%m-%d'
         | 
| 123 | 
            +
                           draft = post.draft ? DRAFT_HTML : ''
         | 
| 124 | 
            +
                           href = "<a href='#{post.url}'>#{post.title}</a>"
         | 
| 125 | 
            +
                           @logger.debug { "  date='#{date}' #{post.title}\n" }
         | 
| 126 | 
            +
                           "  <span>#{date}</span><span>#{href}#{draft}</span>"
         | 
| 127 | 
            +
                         end).join "\n"}
         | 
| 116 128 | 
             
                    </div>
         | 
| 117 129 | 
             
                  END_TEXT
         | 
| 118 130 | 
             
                rescue ArgumentError => e
         | 
| 119 | 
            -
                   | 
| 120 | 
            -
                  @logger.warn { e.backtrace.join("\n") }
         | 
| 131 | 
            +
                  warn_short_trace e
         | 
| 121 132 | 
             
                end
         | 
| 122 133 |  | 
| 123 134 | 
             
                JekyllPluginHelper.register(self, PLUGIN_NAME)
         | 
| @@ -20,7 +20,7 @@ def show(lambda_string, result, expected) | |
| 20 20 | 
             
            end
         | 
| 21 21 |  | 
| 22 22 | 
             
            # See https://stackoverflow.com/a/75388137/553865
         | 
| 23 | 
            -
            RSpec.describe(AllCollectionsTag) do
         | 
| 23 | 
            +
            RSpec.describe(AllCollectionsTag::AllCollectionsTag) do
         | 
| 24 24 | 
             
              let(:o1) { APageStub.new('2020-01-01', '2020-01-01', 'a_A') }
         | 
| 25 25 | 
             
              let(:o2) { APageStub.new('2021-01-01', '2020-01-01', 'b_A') }
         | 
| 26 26 | 
             
              let(:o3) { APageStub.new('2021-01-01', '2023-01-01', 'b_B') }
         | 
| @@ -40,12 +40,6 @@ RSpec.describe(AllCollectionsTag) do | |
| 40 40 | 
             
                expect(result).to eq([o1, o2, o3, o4])
         | 
| 41 41 | 
             
              end
         | 
| 42 42 |  | 
| 43 | 
            -
              it 'defines sort_by lambda with array of last_modified' do
         | 
| 44 | 
            -
                sort_lambda = ->(a, b) { [a.last_modified] <=> [b.last_modified] }
         | 
| 45 | 
            -
                result = objs.sort(&sort_lambda)
         | 
| 46 | 
            -
                expect(result).to eq([o1, o2, o3, o4])
         | 
| 47 | 
            -
              end
         | 
| 48 | 
            -
             | 
| 49 43 | 
             
              it 'makes sort_by lambdas from stringified array of last_modified' do
         | 
| 50 44 | 
             
                sort_lambda = eval '->(a, b) { [a.last_modified] <=> [b.last_modified] }',
         | 
| 51 45 | 
             
                                   NullBinding.new.min_binding, __FILE__, __LINE__ - 1
         | 
| @@ -62,8 +56,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 62 56 | 
             
              end
         | 
| 63 57 |  | 
| 64 58 | 
             
              it 'create_lambda with 1 date key, descending' do
         | 
| 65 | 
            -
                lambda_string =  | 
| 66 | 
            -
                sort_lambda =  | 
| 59 | 
            +
                lambda_string = described_class.create_lambda_string('-last_modified')
         | 
| 60 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 67 61 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 68 62 | 
             
                expected = [o3, o4, o1, o2]
         | 
| 69 63 | 
             
                # show(lambda_string, result, expected)
         | 
| @@ -71,8 +65,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 71 65 | 
             
              end
         | 
| 72 66 |  | 
| 73 67 | 
             
              it 'create_lambda with 1 date key, ascending' do
         | 
| 74 | 
            -
                lambda_string =  | 
| 75 | 
            -
                sort_lambda =  | 
| 68 | 
            +
                lambda_string = described_class.create_lambda_string('date')
         | 
| 69 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 76 70 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 77 71 | 
             
                expected = [o1, o2, o3, o4]
         | 
| 78 72 | 
             
                # show(lambda_string, result, expected)
         | 
| @@ -80,8 +74,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 80 74 | 
             
              end
         | 
| 81 75 |  | 
| 82 76 | 
             
              it 'create_lambda with 2 date keys, both ascending' do
         | 
| 83 | 
            -
                lambda_string =  | 
| 84 | 
            -
                sort_lambda =  | 
| 77 | 
            +
                lambda_string = described_class.create_lambda_string(%w[date last_modified])
         | 
| 78 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 85 79 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 86 80 | 
             
                expected = [o1, o2, o3, o4]
         | 
| 87 81 | 
             
                # show(lambda_string, result, expected)
         | 
| @@ -89,8 +83,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 89 83 | 
             
              end
         | 
| 90 84 |  | 
| 91 85 | 
             
              it 'create_lambda with 2 date keys, both descending' do
         | 
| 92 | 
            -
                lambda_string =  | 
| 93 | 
            -
                sort_lambda =  | 
| 86 | 
            +
                lambda_string = described_class.create_lambda_string(['-date', '-last_modified'])
         | 
| 87 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 94 88 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 95 89 | 
             
                expected = [o4, o3, o2, o1]
         | 
| 96 90 | 
             
                # show(lambda_string, result, expected)
         | 
| @@ -98,8 +92,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 98 92 | 
             
              end
         | 
| 99 93 |  | 
| 100 94 | 
             
              it 'create_lambda with 2 date keys, first descending and second ascending' do
         | 
| 101 | 
            -
                lambda_string =  | 
| 102 | 
            -
                sort_lambda =  | 
| 95 | 
            +
                lambda_string = described_class.create_lambda_string(['-date', 'last_modified'])
         | 
| 96 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 103 97 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 104 98 | 
             
                expected = [o4, o2, o3, o1]
         | 
| 105 99 | 
             
                # show(lambda_string, result, expected)
         | 
| @@ -107,8 +101,8 @@ RSpec.describe(AllCollectionsTag) do | |
| 107 101 | 
             
              end
         | 
| 108 102 |  | 
| 109 103 | 
             
              it 'create_lambda with 2 date keys, first ascending and second descending' do
         | 
| 110 | 
            -
                lambda_string =  | 
| 111 | 
            -
                sort_lambda =  | 
| 104 | 
            +
                lambda_string = described_class.create_lambda_string(['date', '-last_modified'])
         | 
| 105 | 
            +
                sort_lambda = described_class.evaluate(lambda_string)
         | 
| 112 106 | 
             
                result = objs.sort(&sort_lambda)
         | 
| 113 107 | 
             
                expected = [o1, o3, o2, o4]
         | 
| 114 108 | 
             
                # show(lambda_string, result, expected)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: jekyll_all_collections
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Mike Slinn
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-07-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: jekyll
         | 
| @@ -44,14 +44,14 @@ dependencies: | |
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - ">="
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: 0. | 
| 47 | 
            +
                    version: 0.7.0
         | 
| 48 48 | 
             
              type: :runtime
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - ">="
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: 0. | 
| 54 | 
            +
                    version: 0.7.0
         | 
| 55 55 | 
             
            description: 'Provides a collection of all collections in site.all_collections.
         | 
| 56 56 |  | 
| 57 57 | 
             
              '
         | 
| @@ -74,15 +74,14 @@ files: | |
| 74 74 | 
             
            - spec/all_collections_tag_sort_spec.rb
         | 
| 75 75 | 
             
            - spec/date_sort_spec.rb
         | 
| 76 76 | 
             
            - spec/spec_helper.rb
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            homepage: https://github.com/mslinn/jekyll_all_collections
         | 
| 77 | 
            +
            homepage: https://www.mslinn.com/jekyll_plugins/jekyll_all_collections.html
         | 
| 79 78 | 
             
            licenses:
         | 
| 80 79 | 
             
            - MIT
         | 
| 81 80 | 
             
            metadata:
         | 
| 82 81 | 
             
              allowed_push_host: https://rubygems.org
         | 
| 83 82 | 
             
              bug_tracker_uri: https://github.com/mslinn/jekyll_all_collections/issues
         | 
| 84 83 | 
             
              changelog_uri: https://github.com/mslinn/jekyll_all_collections/CHANGELOG.md
         | 
| 85 | 
            -
              homepage_uri: https:// | 
| 84 | 
            +
              homepage_uri: https://www.mslinn.com/jekyll_plugins/jekyll_all_collections.html
         | 
| 86 85 | 
             
              source_code_uri: https://github.com/mslinn/jekyll_all_collections
         | 
| 87 86 | 
             
            post_install_message:
         | 
| 88 87 | 
             
            rdoc_options: []
         | 
    
        data/spec/status_persistence.txt
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
            example_id                                 | status | run_time        |
         | 
| 2 | 
            -
            ------------------------------------------ | ------ | --------------- |
         | 
| 3 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:1] | passed | 0.00268 seconds |
         | 
| 4 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:2] | passed | 0.00018 seconds |
         | 
| 5 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:3] | passed | 0.00008 seconds |
         | 
| 6 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:4] | passed | 0.00007 seconds |
         | 
| 7 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:5] | passed | 0.00008 seconds |
         | 
| 8 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:6] | passed | 0.00006 seconds |
         | 
| 9 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:7] | passed | 0.00006 seconds |
         | 
| 10 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:8] | passed | 0.00008 seconds |
         | 
| 11 | 
            -
            ./spec/jekyll_all_collections_spec.rb[1:9] | passed | 0.00006 seconds |
         | 
| 12 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:1] | passed | 0.00037 seconds |
         | 
| 13 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:2] | passed | 0.00019 seconds |
         | 
| 14 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:3] | passed | 0.00028 seconds |
         | 
| 15 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:4] | failed | 0.0493 seconds  |
         | 
| 16 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:5] | passed | 0.00026 seconds |
         | 
| 17 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:6] | passed | 0.00017 seconds |
         | 
| 18 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:7] | failed | 0.01092 seconds |
         | 
| 19 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:8] | failed | 0.01013 seconds |
         | 
| 20 | 
            -
            ./spec/jekyll_all_collections_spec.rb[2:9] | failed | 0.01195 seconds |
         |