jekyll_sort_natural 1.0.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 +7 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +7 -0
- data/jekyll_sort_natural.gemspec +48 -0
- data/lib/jekyll_sort_natural/version.rb +5 -0
- data/lib/jekyll_sort_natural.rb +21 -0
- data/spec/jekyll_sort_natural.rb +21 -0
- data/spec/spec_helper.rb +10 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1fe51f4d898e72a6fbb324eba525fdcc0d78288395304ab30b2117629878303f
|
4
|
+
data.tar.gz: 4fe3bd88bb9b6544351036b2c65dbeb4308f325e41fb52f3ee0383d37cae38c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14dd4c5440f35f6ada650eda5e0e40a78bc9422fe68c6a357f30149745fe04d9f0d930b784866510cdf2aedb6b55da854ede1b9c98962fde43fce73f11db0ad0
|
7
|
+
data.tar.gz: c52a16b238bba2d40da6840479bf808a74d95f77e1fa18a9e54e160c63cd8e6fbe6dfebacca54a5d9ba21a14d18868addf007fc64d4163f0079643011a43b7f8
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require: rubocop-jekyll
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-jekyll: .rubocop.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
Exclude:
|
7
|
+
- vendor/**/*
|
8
|
+
- Gemfile*
|
9
|
+
- '*.gemspec' # This does nothing. Why?
|
10
|
+
NewCops: enable
|
11
|
+
TargetRubyVersion: 2.6
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 150
|
15
|
+
|
16
|
+
# Gemspec/RequireMFA:
|
17
|
+
# enable: false
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Mike Slinn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
`jekyll_sort_natural`
|
2
|
+
[](https://badge.fury.io/rb/jekyll_sort_natural)
|
3
|
+
===========
|
4
|
+
|
5
|
+
`jekyll_sort_natural` is a Jekyll plugin that sorts hashes using `String#casecmp`, the case-insensitive version of `String#<=>`.
|
6
|
+
|
7
|
+
This plugin contains code modified from [tkrotoff](https://github.com/tkrotoff/osteo15.com/blob/b0c8bf66a75fe8b52ef38d94e5f5e1c9469c1957/_plugins/filters.rb#L13-L18).
|
8
|
+
|
9
|
+
By default, `Enumerable#sort` uses `<=>` for comparisons
|
10
|
+
|
11
|
+
See [Add sort_natural to jekyll/filters.rb](https://github.com/jekyll/jekyll/issues/6290).
|
12
|
+
This plugin overrides [`sort_natural`](https://shopify.github.io/liquid/filters/sort_natural/) provided by Liquid 4.
|
13
|
+
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your Jekyll project's Gemfile, within the `jekyll_plugins` group:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
group :jekyll_plugins do
|
21
|
+
gem 'jekyll_sort_natural'
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
Also add it to `_config.yml`:
|
26
|
+
```yaml
|
27
|
+
plugins:
|
28
|
+
- jekyll_sort_natural
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle install
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install jekyll_sort_natural
|
38
|
+
|
39
|
+
|
40
|
+
## Additional Information
|
41
|
+
More information is available on
|
42
|
+
[Mike Slinn’s website](https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html).
|
43
|
+
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
48
|
+
|
49
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
|
52
|
+
To build and install this gem onto your local machine, run:
|
53
|
+
```shell
|
54
|
+
$ bundle exec rake install
|
55
|
+
jekyll_sort_natural 1.0.0 built to pkg/jekyll_sort_natural-0.1.0.gem.
|
56
|
+
jekyll_sort_natural (1.0.0) installed.
|
57
|
+
```
|
58
|
+
|
59
|
+
Examine the newly built gem:
|
60
|
+
```shell
|
61
|
+
$ gem info jekyll_sort_natural
|
62
|
+
|
63
|
+
*** LOCAL GEMS ***
|
64
|
+
|
65
|
+
jekyll_sort_natural (1.0.0)
|
66
|
+
Author: Mike Slinn
|
67
|
+
Homepage:
|
68
|
+
https://github.com/mslinn/jekyll_sort_natural
|
69
|
+
License: MIT
|
70
|
+
Installed at: /home/mslinn/.gems
|
71
|
+
|
72
|
+
Generates Jekyll logger with colored output.
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
### Build and Push to RubyGems
|
77
|
+
To release a new version,
|
78
|
+
1. Update the version number in `version.rb`.
|
79
|
+
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
|
80
|
+
3. Run the following:
|
81
|
+
```shell
|
82
|
+
$ bundle exec rake release
|
83
|
+
```
|
84
|
+
The above creates a git tag for the version, commits the created tag,
|
85
|
+
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
|
86
|
+
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
1. Fork the project
|
91
|
+
2. Create a descriptively named feature branch
|
92
|
+
3. Add your feature
|
93
|
+
4. Submit a pull request
|
94
|
+
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll_sort_natural/version"
|
4
|
+
|
5
|
+
# rubocop:disable Metrics/BlockLength
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
github = "https://github.com/mslinn/jekyll_sort_natural"
|
8
|
+
|
9
|
+
spec.bindir = "exe"
|
10
|
+
spec.authors = ["Mike Slinn"]
|
11
|
+
spec.email = ["mslinn@mslinn.com"]
|
12
|
+
spec.files = Dir[".rubocop.yml", "LICENSE.*", "Rakefile", "{lib,spec}/**/*", "*.gemspec", "*.md"]
|
13
|
+
spec.homepage = "https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#sort"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.metadata = {
|
16
|
+
"allowed_push_host" => "https://rubygems.org",
|
17
|
+
"bug_tracker_uri" => "#{github}/issues",
|
18
|
+
"changelog_uri" => "#{github}/CHANGELOG.md",
|
19
|
+
"homepage_uri" => spec.homepage,
|
20
|
+
"source_code_uri" => github,
|
21
|
+
}
|
22
|
+
spec.name = "jekyll_sort_natural"
|
23
|
+
spec.post_install_message = <<~END_MESSAGE
|
24
|
+
|
25
|
+
Thanks for installing #{spec.name}!
|
26
|
+
|
27
|
+
END_MESSAGE
|
28
|
+
spec.post_install_message = <<~END_MESSAGE
|
29
|
+
|
30
|
+
Thanks for installing #{spec.name}!
|
31
|
+
|
32
|
+
END_MESSAGE
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
spec.required_ruby_version = ">= 2.6.0"
|
35
|
+
spec.summary = "Provides a Jekyll filter that provides case-insensitive hash key sorting."
|
36
|
+
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
37
|
+
spec.version = JekyllSortNatural::VERSION
|
38
|
+
|
39
|
+
spec.add_dependency "jekyll", ">= 3.5.0"
|
40
|
+
spec.add_dependency "jekyll_plugin_logger"
|
41
|
+
|
42
|
+
spec.add_development_dependency "debase"
|
43
|
+
# spec.add_development_dependency "rubocop-jekyll"
|
44
|
+
# spec.add_development_dependency "rubocop-rake"
|
45
|
+
# spec.add_development_dependency "rubocop-rspec"
|
46
|
+
spec.add_development_dependency "ruby-debug-ide"
|
47
|
+
end
|
48
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require "jekyll_plugin_logger"
|
5
|
+
require_relative "jekyll_sort_natural/version"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module SortNatural
|
9
|
+
# Sort a hash using String#casecmp the case-insensitive version of String#<=>
|
10
|
+
# Modified from https://github.com/tkrotoff/osteo15.com/blob/b0c8bf66a75fe8b52ef38d94e5f5e1c9469c1957/_plugins/filters.rb#L13-L18
|
11
|
+
# By default, Enumerable#sort uses <=>
|
12
|
+
# See Add sort_natural to jekyll/filters.rb https://github.com/jekyll/jekyll/issues/6290
|
13
|
+
# This overrides sort_natural provided by Liquid 4 (https://shopify.github.io/liquid/filters/sort_natural/)
|
14
|
+
def sort_natural(input)
|
15
|
+
input.sort { |a, b| a.first.casecmp(b.first) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
PluginMetaLogger.instance.info { "Loaded jekyll_sort_natural v#{JekyllSortNatural::VERSION} plugin." }
|
21
|
+
Liquid::Template.register_filter(Jekyll::SortNatural)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require_relative "../lib/jekyll_sort_natural"
|
5
|
+
|
6
|
+
RSpec.describe(Jekyll) do
|
7
|
+
include Jekyll
|
8
|
+
|
9
|
+
let(:config) { instance_double("Configuration") }
|
10
|
+
let(:context) {
|
11
|
+
context_ = instance_double("Liquid::Context")
|
12
|
+
context_.config = config
|
13
|
+
context_
|
14
|
+
}
|
15
|
+
|
16
|
+
it "is created properly" do
|
17
|
+
run_tag = RunTag.new("run", "echo asdf")
|
18
|
+
output = run_tag.render(context)
|
19
|
+
expect(output).to eq("asdf")
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll_sort_natural
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Slinn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: jekyll_plugin_logger
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debase
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-debug-ide
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- mslinn@mslinn.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".rubocop.yml"
|
77
|
+
- CHANGELOG.md
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- jekyll_sort_natural.gemspec
|
82
|
+
- lib/jekyll_sort_natural.rb
|
83
|
+
- lib/jekyll_sort_natural/version.rb
|
84
|
+
- spec/jekyll_sort_natural.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
homepage: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#sort
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata:
|
90
|
+
allowed_push_host: https://rubygems.org
|
91
|
+
bug_tracker_uri: https://github.com/mslinn/jekyll_sort_natural/issues
|
92
|
+
changelog_uri: https://github.com/mslinn/jekyll_sort_natural/CHANGELOG.md
|
93
|
+
homepage_uri: https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html#sort
|
94
|
+
source_code_uri: https://github.com/mslinn/jekyll_sort_natural
|
95
|
+
post_install_message: |2+
|
96
|
+
|
97
|
+
Thanks for installing jekyll_sort_natural!
|
98
|
+
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 2.6.0
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.1.4
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Provides a Jekyll filter that provides case-insensitive hash key sorting.
|
117
|
+
test_files:
|
118
|
+
- spec/jekyll_sort_natural.rb
|
119
|
+
- spec/spec_helper.rb
|