sutty-liquid 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bd8433b8f97fbe8879c39058fc087ae949633ab565d4d939065b50723b70ee3
4
- data.tar.gz: 9fd4f7706057a9d200a843ee8496a02c2a2464c7a3bcd218f59646007997d08b
3
+ metadata.gz: 0a57d48060de63b47e4d6f1f8dc2ad27f733ee725b7a55bf4d97a77f6be1db94
4
+ data.tar.gz: dc74a6339cd2069f9f1ea796de1ee6965cc6955b19be601ad0b1d1da2187feea
5
5
  SHA512:
6
- metadata.gz: 4a67f0e87622f14d7cf6c00aa88fbfd4e8ac970bc33f4d47a4b9838eaec8169747dc2e6ced49057be52796097151953edc3b43f3ba3ba47b98d42dfe705cd55f
7
- data.tar.gz: 48ad31dc479ed967a74c3aa73113f689959fc03a57af9a38d74fe323b00033c655f559c878c93644dc9043b6dbe577c490f8906d4fe9b7c3528b37155df561d2
6
+ metadata.gz: 8c64593338e53641d348e365496b7d800e34d987a16076e1829f25d76874fe7883c7ef3171839b0c4c424882ce5e5ee28fe425012775510d4f4c6173e6639b0a
7
+ data.tar.gz: df1e86422ae685a43619b0586a2bf654b9b6697fddec9b8ce9c9c12d3d7b0a209c3c7bc27ea305156bfe489a53af3d22884bb74ef4ba3bf9838c8d61ae622757
@@ -103,10 +103,10 @@ module Jekyll
103
103
  liquid_input = input.to_liquid
104
104
  liquid_posts = posts.map(&:to_liquid)
105
105
  index = find_in_stack(liquid_input, liquid_posts)
106
- liquid_posts[index - 1] if index && index >= 0
106
+ liquid_posts[index - 1] if index&.positive?
107
107
  end
108
108
 
109
- alias_method :previous, :prev
109
+ alias previous prev
110
110
 
111
111
  private
112
112
 
@@ -120,7 +120,7 @@ module Jekyll
120
120
  next if a
121
121
  next unless @context.strict_filters
122
122
 
123
- raise Liquid::ArgumentError.new('needs an array argument')
123
+ raise Liquid::ArgumentError, 'needs an array argument'
124
124
  end
125
125
  end
126
126
 
@@ -139,7 +139,7 @@ module Jekyll
139
139
  p['title'] || p['id'] || 'no title'
140
140
  end
141
141
 
142
- raise Liquid::ArgumentError.new("can't find #{title} in #{titles.join(', ')}")
142
+ raise Liquid::ArgumentError, "can't find #{title} in #{titles.join(', ')}"
143
143
  end
144
144
  end
145
145
  end
@@ -118,7 +118,7 @@ module Jekyll
118
118
  when Integer then false
119
119
  when Float then false
120
120
  when Time then false
121
- when String then
121
+ when String
122
122
  require 'fast_blank'
123
123
  input.blank?
124
124
  when Array then input.compact.empty?
@@ -36,7 +36,7 @@ module Jekyll
36
36
  toc[id] = {
37
37
  'level' => h.name[1].to_i,
38
38
  'title' => h.text,
39
- 'id' => id
39
+ 'id' => id
40
40
  }
41
41
  end
42
42
  end.to_s
@@ -50,7 +50,7 @@ module Jekyll
50
50
  #
51
51
  # @example Create a table of contents
52
52
  # {% assign toc = content | table_of_contents: 2 %}
53
- #
53
+ #
54
54
  # {% unless toc == empty %}
55
55
  # {% for item in toc %}
56
56
  # {% assign heading = "h" | append: item.level %}
@@ -68,7 +68,7 @@ module Jekyll
68
68
  def table_of_contents(input, max_level = 2, prefix = nil)
69
69
  canonicalize_headings(input, prefix)
70
70
 
71
- toc(input).select do |id, item|
71
+ toc(input).select do |_id, item|
72
72
  item['level'] <= max_level
73
73
  end.values
74
74
  end
@@ -54,7 +54,7 @@ module Jekyll
54
54
  end
55
55
 
56
56
  def i18n
57
- @i18n ||= site.data.dig site.config['lang']
57
+ @i18n ||= site.data[site.config['lang']]
58
58
  end
59
59
  end
60
60
  end
@@ -20,7 +20,7 @@ module Jekyll
20
20
  # @param [String] The URL to be verified
21
21
  # @return [String] The item URL
22
22
  def menu_active_item(page_url)
23
- site_menu&.find do |key, value|
23
+ site_menu&.find do |key, _value|
24
24
  key == page_url || page_url.start_with?(key)
25
25
  end&.last
26
26
  end
@@ -47,7 +47,7 @@ module Jekyll
47
47
  end
48
48
 
49
49
  # Ignore empty or anchor items
50
- next menu if item['href'].nil? || item['href'].empty? || item['href']&.start_with?('#')
50
+ next menu if item['href'].nil? || item['href']&.empty? || item['href']&.start_with?('#')
51
51
 
52
52
  menu[item['href']] = item['href']
53
53
 
@@ -15,7 +15,7 @@ module Jekyll
15
15
  def numbers(input)
16
16
  return unless input.respond_to? :gsub
17
17
 
18
- input.gsub(%r{[^0-9]}, '')
18
+ input.gsub(/[^0-9]/, '')
19
19
  end
20
20
  end
21
21
  end
@@ -54,12 +54,12 @@ module Jekyll
54
54
  #
55
55
  # 5. Recover original stars
56
56
  input.to_s
57
- .gsub('\*', escaped_delimiter)
58
- .gsub('**', star_delimiter * 2)
59
- .gsub(/^(\s*)\*/, "\\1#{star_delimiter}")
60
- .gsub('*', '\*')
61
- .gsub(star_delimiter, '*')
62
- .gsub(escaped_delimiter, '\*')
57
+ .gsub('\*', escaped_delimiter)
58
+ .gsub('**', star_delimiter * 2)
59
+ .gsub(/^(\s*)\*/, "\\1#{star_delimiter}")
60
+ .gsub('*', '\*')
61
+ .gsub(star_delimiter, '*')
62
+ .gsub(escaped_delimiter, '\*')
63
63
  end
64
64
 
65
65
  def unescape(input)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Filters
5
+ # YAML to SCSS
6
+ module YamlToScss
7
+ # Converts a YAML object into SCSS. Only supports one level
8
+ # values.
9
+ #
10
+ # @param :yaml [Hash]
11
+ # @return [String]
12
+ def yaml_to_scss(yaml)
13
+ yaml.map do |key, value|
14
+ key = key_to_scss key
15
+
16
+ case value
17
+ when Array
18
+ "$#{key}: (#{value.join(',')},);"
19
+ when Hash
20
+ values =
21
+ value.map do |k, v|
22
+ "\"#{key_to_scss k}\": #{v}"
23
+ end
24
+
25
+ "$#{key}: (#{values.join(',')},);"
26
+ else
27
+ "$#{key}: #{value};"
28
+ end
29
+ end.join("\n")
30
+ end
31
+
32
+ private
33
+
34
+ # Dasherize key
35
+ #
36
+ # @param :key [String]
37
+ # @return [String]
38
+ def key_to_scss(key)
39
+ key.tr '_', '-'
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ Liquid::Template.register_filter(Jekyll::Filters::YamlToScss)
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - f
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-20 00:00:00.000000000 Z
11
+ date: 2022-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jekyll
14
+ name: fast_blank
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: fast_blank
28
+ name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.14'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '13'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '13'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.13'
83
83
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -132,6 +146,7 @@ files:
132
146
  - lib/jekyll/filters/pry.rb
133
147
  - lib/jekyll/filters/social_network.rb
134
148
  - lib/jekyll/filters/strings.rb
149
+ - lib/jekyll/filters/yaml_to_scss.rb
135
150
  - lib/jekyll/tags/pry.rb
136
151
  - lib/sutty-liquid.rb
137
152
  homepage: https://0xacab.org/sutty/jekyll/sutty-liquid
@@ -156,16 +171,16 @@ require_paths:
156
171
  - lib
157
172
  required_ruby_version: !ruby/object:Gem::Requirement
158
173
  requirements:
159
- - - ">="
174
+ - - ">"
160
175
  - !ruby/object:Gem::Version
161
- version: 2.6.0
176
+ version: 2.7.0
162
177
  required_rubygems_version: !ruby/object:Gem::Requirement
163
178
  requirements:
164
179
  - - ">="
165
180
  - !ruby/object:Gem::Version
166
181
  version: '0'
167
182
  requirements: []
168
- rubygems_version: 3.3.15
183
+ rubygems_version: 3.3.19
169
184
  signing_key:
170
185
  specification_version: 4
171
186
  summary: Liquid filters