jekyll_img 0.2.8 → 0.2.11
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 +9 -3
- data/CHANGELOG.md +21 -1
- data/README.md +10 -4
- data/lib/img_builder.rb +7 -4
- data/lib/img_props.rb +36 -7
- data/lib/jekyll_img/version.rb +1 -1
- data/lib/jekyll_img.rb +4 -2
- data/lib/source.rb +1 -1
- data/spec/img_builder_spec.rb +25 -15
- data/spec/img_props_spec.rb +63 -10
- data/spec/jekyll_img_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/status_persistence.txt +7 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6665da5a9ea0fb8a14413e6bbcb177802b4419ead9470bdc3bbacdee5fafce73
|
|
4
|
+
data.tar.gz: 055d42f74d2c6361672132652779eb2a3a05e01d1e6d706932f03248ff9dca84
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4196b6105ee1f9c449440d9d134ef63db4196d839257bc1e333214c414785cacb9bef906074adbf532b470aa85e7df48a0231d8c556b3b54137b9a9b1233a20
|
|
7
|
+
data.tar.gz: d6585eb0051f441eaa9d00aec48e05e4a23e34045843feeb2e2d6a2255c6439229ce99c8c532deade048726af4b60d441d4c88521f30ab7b731cfcf4f013d4c2
|
data/.rubocop.yml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
plugins:
|
|
2
2
|
# - rubocop-jekyll
|
|
3
3
|
- rubocop-md
|
|
4
4
|
- rubocop-performance
|
|
@@ -53,17 +53,20 @@ Metrics/BlockLength:
|
|
|
53
53
|
- spec/img_props_spec.rb
|
|
54
54
|
|
|
55
55
|
Metrics/CyclomaticComplexity:
|
|
56
|
-
Max:
|
|
56
|
+
Max: 15
|
|
57
57
|
|
|
58
58
|
Metrics/MethodLength:
|
|
59
59
|
Max: 40
|
|
60
60
|
|
|
61
61
|
Metrics/PerceivedComplexity:
|
|
62
|
-
Max:
|
|
62
|
+
Max: 15
|
|
63
63
|
|
|
64
64
|
Naming/FileName:
|
|
65
65
|
Exclude:
|
|
66
66
|
- Rakefile
|
|
67
|
+
- Gemfile
|
|
68
|
+
- README.md
|
|
69
|
+
- CHANGELOG.md
|
|
67
70
|
|
|
68
71
|
Naming/MemoizedInstanceVariableName:
|
|
69
72
|
Enabled: false
|
|
@@ -86,6 +89,9 @@ Style/Documentation:
|
|
|
86
89
|
Style/FrozenStringLiteralComment:
|
|
87
90
|
Enabled: false
|
|
88
91
|
|
|
92
|
+
Style/OneClassPerFile:
|
|
93
|
+
Enabled: false
|
|
94
|
+
|
|
89
95
|
Style/StringConcatenation:
|
|
90
96
|
Exclude:
|
|
91
97
|
- spec/**/*
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.2.11 /2026-09-11
|
|
4
|
+
|
|
5
|
+
Not fixed yet:
|
|
6
|
+
|
|
7
|
+
* Fixed bug related to max-width percentage specification
|
|
8
|
+
|
|
9
|
+
## 0.2.10 /2026-07-04
|
|
10
|
+
|
|
11
|
+
* Pry is no longer a production dependency
|
|
12
|
+
|
|
13
|
+
## 0.2.9 / 2025-05-19
|
|
14
|
+
|
|
15
|
+
* `max-width` option added.
|
|
16
|
+
* `width` option added as an alias for `size`.
|
|
17
|
+
This requires new CSS classes to be defined:
|
|
18
|
+
`max_eighthsize`, `max_fullsize`, `max_halfsize`, and `max_quartersize`.
|
|
19
|
+
* More CSS classes defined and more tests added to the Demo app to support `max-width`.
|
|
20
|
+
* `width='calc(something)'` added.
|
|
21
|
+
|
|
22
|
+
|
|
3
23
|
## 0.2.8 / 2025-05-16
|
|
4
24
|
|
|
5
25
|
* An image can now be lazily loaded by providing the `lazy` keyword.
|
|
@@ -26,7 +46,7 @@
|
|
|
26
46
|
* Corrected `README.md#Configuration` and fixed demo `_config.yml`
|
|
27
47
|
so they correctly specify error handling for this plugin:
|
|
28
48
|
|
|
29
|
-
```
|
|
49
|
+
```yaml
|
|
30
50
|
img:
|
|
31
51
|
die_on_img_error: false
|
|
32
52
|
pry_on_img_error: false
|
data/README.md
CHANGED
|
@@ -249,12 +249,17 @@ $ demo/_bin/debug -r
|
|
|
249
249
|
- `caption="A caption"` No default value
|
|
250
250
|
- `classes="class1 class2 classN"` Extra <img> classes; default is `rounded shadow`
|
|
251
251
|
- `id="someId"` No default value
|
|
252
|
-
- `
|
|
253
|
-
- `size='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
|
252
|
+
- `max-width='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
|
254
253
|
Defines width of image.
|
|
255
254
|
- `initial` is the default behavior.
|
|
256
255
|
- `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
|
|
257
256
|
- CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
|
|
257
|
+
- `nofollow` Generates `rel='nofollow'`; only applicable when `url` is specified
|
|
258
|
+
- `width='eighthsize|fullsize|halfsize|initial|quartersize|XXXYY|XXX%'`
|
|
259
|
+
Defines width of image (alias for `size`).
|
|
260
|
+
- `initial` is the default behavior.
|
|
261
|
+
- `eighthsize`, `fullsize`, `halfsize`, and `quartersize` are relative to the enclosing tag's width.
|
|
262
|
+
- CSS units can also be used, for those cases `XXX` is a float and `YY` is `unit` (see below)
|
|
258
263
|
- `style='css goes here'` CSS style for <img>; no default
|
|
259
264
|
- `target='none|whatever'` Only applicable when `url` is specified; default value is `_blank`
|
|
260
265
|
- `title="A title"` Default value is `caption` text, if provided
|
|
@@ -314,8 +319,9 @@ Within the wrapper `<div />`, the embedded `<img />` is displayed with `width=10
|
|
|
314
319
|
If a caption is required, the generated `<figure />` only makes the space taken by the generated HTML longer;
|
|
315
320
|
the image’s width and height are not affected.
|
|
316
321
|
|
|
317
|
-
The wrapper will not exceed the width of the tag that encloses it if the `
|
|
322
|
+
The wrapper will not exceed the width of the tag that encloses it if the `width` parameter has values
|
|
318
323
|
`eighthsize`, `fullsize`, `halfsize`, `initial` or `quartersize`.
|
|
324
|
+
You can also use the `max-width` option.
|
|
319
325
|
|
|
320
326
|
The wrapper's width can be defined independently of its enclosing tag by using
|
|
321
327
|
[CSS units](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages)
|
|
@@ -339,7 +345,7 @@ end
|
|
|
339
345
|
And then execute:
|
|
340
346
|
|
|
341
347
|
```shell
|
|
342
|
-
$ bundle
|
|
348
|
+
$ bundle install
|
|
343
349
|
```
|
|
344
350
|
|
|
345
351
|
|
data/lib/img_builder.rb
CHANGED
|
@@ -44,10 +44,10 @@ class ImgBuilder
|
|
|
44
44
|
|
|
45
45
|
# See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
|
|
46
46
|
def generate_picture
|
|
47
|
-
if @props.lazy && @props.size
|
|
47
|
+
if @props.lazy && (@props.size || @props.max_width)
|
|
48
48
|
@img.logger.warn do
|
|
49
49
|
<<~END_MSG.squish
|
|
50
|
-
Warning: lazy loading was specified, but the size attribute was specified for the href tag
|
|
50
|
+
Warning: lazy loading was specified, but the size or max_width attribute was specified for the href tag
|
|
51
51
|
on line #{@img.line_number} (after front matter) of #{@img.page['path']}.
|
|
52
52
|
Specify dimensions via style or class attributes instead.
|
|
53
53
|
END_MSG
|
|
@@ -84,9 +84,12 @@ class ImgBuilder
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def generate_wrapper
|
|
87
|
-
classes = "imgWrapper #{@props.img_display} #{@props.align} #{@props.attr_size_class}
|
|
87
|
+
classes = "imgWrapper #{@props.img_display} #{@props.align} #{@props.attr_size_class} " \
|
|
88
|
+
"#{@props.attr_max_width_class} #{@props.wrapper_class}"
|
|
89
|
+
classes = classes.squish
|
|
90
|
+
styles = "#{@props.attr_width_style} #{@props.attr_max_width_style} #{@props.wrapper_style}".squish
|
|
88
91
|
<<~END_HTML.remove_blank_lines
|
|
89
|
-
<div class='#{classes}' style='#{
|
|
92
|
+
<div class='#{classes}' style='#{styles}'>
|
|
90
93
|
#{"<figure>\n" if @props.caption}
|
|
91
94
|
#{@props.url ? generate_url_wrapper : generate_picture}
|
|
92
95
|
#{generate_figcaption if @props.caption}
|
data/lib/img_props.rb
CHANGED
|
@@ -6,11 +6,11 @@ require 'uri'
|
|
|
6
6
|
# All methods except compute_dependant_properties can be called in any order
|
|
7
7
|
class ImgProperties
|
|
8
8
|
attr_accessor :align, :alt, :attr_wrapper_align_class, :attribute, :attribution, :caption, :classes, :die_on_img_error,
|
|
9
|
-
:id, :img_display, :lazy, :local_src, :nofollow, :priority, :src, :size, :style,
|
|
10
|
-
:url, :wrapper_class, :wrapper_style
|
|
9
|
+
:id, :img_display, :lazy, :local_src, :max_width, :nofollow, :priority, :src, :size, :style,
|
|
10
|
+
:target, :title, :url, :wrapper_class, :wrapper_style
|
|
11
11
|
|
|
12
|
-
SIZES = %w[eighthsize fullsize halfsize initial quartersize].freeze
|
|
13
|
-
UNITS = %w[Q ch cm em dvh dvw ex in lh lvh lvw mm pc px pt rem rlh svh svw vb vh vi vmax vmin vw %].freeze
|
|
12
|
+
SIZES = %w[eighthsize fullsize halfsize initial quartersize].freeze unless const_defined?(:SIZES)
|
|
13
|
+
UNITS = %w[Q ch cm em dvh dvw ex in lh lvh lvw mm pc px pt rem rlh svh svw vb vh vi vmax vmin vw %].freeze unless const_defined?(:UNITS)
|
|
14
14
|
|
|
15
15
|
def attr_alt
|
|
16
16
|
"alt='#{@alt}'" if @alt
|
|
@@ -29,6 +29,19 @@ class ImgProperties
|
|
|
29
29
|
" rel='nofollow'" if @nofollow
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# FIXME: this method does not work when max-width is specified as a % or a unit such as 15em
|
|
33
|
+
# @return class name: max_fullsize, max_halfsize, max_quartersize
|
|
34
|
+
def attr_max_width_class
|
|
35
|
+
return nil if @max_width == false || @max_width.nil? || max_width_unit_specified?
|
|
36
|
+
|
|
37
|
+
unless SIZES.include?(@max_width) || @max_width.end_with?('%')
|
|
38
|
+
msg = "'#{@max_width}' is not a recognized size; must be one of #{SIZES.join(', ')}, or an explicit unit."
|
|
39
|
+
raise Jekyll::ImgError, msg
|
|
40
|
+
end
|
|
41
|
+
"max_#{@max_width}" # FIXME: this only works with fullsize, halfsize, quartersize and not % or units
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# FIXME: this method does not work when width is specified as a unit such as 15em
|
|
32
45
|
def attr_size_class
|
|
33
46
|
return nil if @size == false || @size.nil? || size_unit_specified?
|
|
34
47
|
|
|
@@ -40,7 +53,11 @@ class ImgProperties
|
|
|
40
53
|
end
|
|
41
54
|
|
|
42
55
|
def attr_style_img
|
|
43
|
-
|
|
56
|
+
if size_unit_specified?
|
|
57
|
+
"width: #{@size};"
|
|
58
|
+
else
|
|
59
|
+
"style='width: 100%; #{@style}'".squish
|
|
60
|
+
end
|
|
44
61
|
end
|
|
45
62
|
|
|
46
63
|
def attr_target
|
|
@@ -54,6 +71,10 @@ class ImgProperties
|
|
|
54
71
|
"title='#{@title}'" if @title && !@title.empty?
|
|
55
72
|
end
|
|
56
73
|
|
|
74
|
+
def attr_max_width_style
|
|
75
|
+
"max-width: #{@max_width};" if max_width_unit_specified?
|
|
76
|
+
end
|
|
77
|
+
|
|
57
78
|
def attr_width_style
|
|
58
79
|
"width: #{@size};" if size_unit_specified?
|
|
59
80
|
end
|
|
@@ -98,10 +119,18 @@ class ImgProperties
|
|
|
98
119
|
# raise Jekyll::ImgError, "#{@src} does not exist" unless File.exist?(src)
|
|
99
120
|
end
|
|
100
121
|
|
|
122
|
+
def max_width_unit_specified?
|
|
123
|
+
max_width_not_specified = @max_width == false || @max_width.to_s.strip.empty?
|
|
124
|
+
return false if max_width_not_specified
|
|
125
|
+
|
|
126
|
+
@max_width&.end_with?(*UNITS) || @max_width&.start_with?('calc')
|
|
127
|
+
end
|
|
128
|
+
|
|
101
129
|
def size_unit_specified?
|
|
102
|
-
|
|
130
|
+
size_not_specified = @size == false || @size.to_s.strip.empty?
|
|
131
|
+
return false if size_not_specified
|
|
103
132
|
|
|
104
|
-
@size
|
|
133
|
+
@size&.end_with?(*UNITS) || @size&.start_with?('calc')
|
|
105
134
|
end
|
|
106
135
|
|
|
107
136
|
def url?(src)
|
data/lib/jekyll_img/version.rb
CHANGED
data/lib/jekyll_img.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'jekyll_plugin_support'
|
|
2
2
|
require 'helper/jekyll_plugin_helper'
|
|
3
|
-
require 'pry'
|
|
4
3
|
require_relative 'img_builder'
|
|
5
4
|
require_relative 'img_props'
|
|
6
5
|
require_relative 'source'
|
|
@@ -36,9 +35,12 @@ module Jekyll
|
|
|
36
35
|
props.die_on_img_error = @die_on_img_error
|
|
37
36
|
props.id = @helper.parameter_specified? 'id'
|
|
38
37
|
props.lazy = ' loading="lazy"' if @helper.parameter_specified?('lazy')
|
|
38
|
+
props.max_width = @helper.parameter_specified?('max-width')
|
|
39
39
|
props.nofollow = @helper.parameter_specified? 'nofollow'
|
|
40
40
|
props.priority = ' fetchpriority="high"' if @helper.parameter_specified?('priority')
|
|
41
|
-
props.size = @helper.parameter_specified?('size') ||
|
|
41
|
+
props.size = @helper.parameter_specified?('size') ||
|
|
42
|
+
@helper.parameter_specified?('_size') ||
|
|
43
|
+
@helper.parameter_specified?('width')
|
|
42
44
|
props.src = @helper.parameter_specified? 'src'
|
|
43
45
|
props.style = @helper.parameter_specified? 'style'
|
|
44
46
|
props.target = @helper.parameter_specified? 'target'
|
data/lib/source.rb
CHANGED
|
@@ -41,7 +41,7 @@ class Source
|
|
|
41
41
|
return result unless result.end_with? '.webp' # we know @path will be a webp after this
|
|
42
42
|
|
|
43
43
|
files = sorted_files
|
|
44
|
-
return files[0] if files.
|
|
44
|
+
return files[0] if files.one?
|
|
45
45
|
|
|
46
46
|
files.each do |filename|
|
|
47
47
|
ext = File.extname filename
|
data/spec/img_builder_spec.rb
CHANGED
|
@@ -3,33 +3,43 @@ require_relative '../lib/img_builder'
|
|
|
3
3
|
require_relative '../lib/img_props'
|
|
4
4
|
require_relative '../lib/source'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
class ImgTest
|
|
7
|
+
attr_accessor :page, :cite, :url
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@page = { 'path' => 'mypage.html' }
|
|
11
|
+
@cite = 'this is a cite'
|
|
12
|
+
@url = 'http://localhost:4001/mypage.html'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
7
16
|
class ImgPropertiesTest
|
|
8
17
|
RSpec.describe ImgBuilder do
|
|
9
18
|
Dir.chdir("demo")
|
|
10
19
|
props = ImgProperties.new
|
|
11
20
|
props.src = '/assets/images/jekyll.webp'
|
|
12
|
-
|
|
21
|
+
img = ImgTest.new
|
|
22
|
+
builder = described_class.new(img, props)
|
|
13
23
|
|
|
14
24
|
it 'generates sources' do
|
|
15
25
|
actual = builder.source.generate
|
|
16
|
-
|
|
26
|
+
expected = [
|
|
17
27
|
'<source srcset="/assets/images/jekyll.webp" type="image/webp">',
|
|
18
28
|
'<source srcset="/assets/images/jekyll.png" type="image/png">'
|
|
19
29
|
]
|
|
20
|
-
expect(actual).to match_array(
|
|
30
|
+
expect(actual).to match_array(expected)
|
|
21
31
|
end
|
|
22
32
|
|
|
23
33
|
it 'generates a figcaption' do
|
|
24
|
-
|
|
34
|
+
expected = <<~END_STRING
|
|
25
35
|
<figcaption class='imgFigCaption '>
|
|
26
36
|
</figcaption>
|
|
27
37
|
END_STRING
|
|
28
|
-
expect(builder.generate_figcaption).to match_ignoring_whitespace(
|
|
38
|
+
expect(builder.generate_figcaption).to match_ignoring_whitespace(expected)
|
|
29
39
|
end
|
|
30
40
|
|
|
31
41
|
it 'generates a picture' do
|
|
32
|
-
|
|
42
|
+
expected = <<~END_DESIRED
|
|
33
43
|
<picture class='imgPicture'>
|
|
34
44
|
<source srcset="/assets/images/jekyll.webp" type="image/webp">
|
|
35
45
|
<source srcset="/assets/images/jekyll.png" type="image/png">
|
|
@@ -40,12 +50,12 @@ class ImgPropertiesTest
|
|
|
40
50
|
</picture>
|
|
41
51
|
END_DESIRED
|
|
42
52
|
actual = builder.generate_picture
|
|
43
|
-
expect(actual).to match_ignoring_whitespace(
|
|
53
|
+
expect(actual).to match_ignoring_whitespace(expected)
|
|
44
54
|
end
|
|
45
55
|
|
|
46
56
|
it 'generates a default img' do
|
|
47
|
-
|
|
48
|
-
<div class='imgWrapper imgFlex' style='
|
|
57
|
+
expected = <<~END_IMG
|
|
58
|
+
<div class='imgWrapper imgFlex' style=''>
|
|
49
59
|
<picture class='imgPicture'>
|
|
50
60
|
<source srcset="/assets/images/jekyll.webp" type="image/webp">
|
|
51
61
|
<source srcset="/assets/images/jekyll.png" type="image/png">
|
|
@@ -58,13 +68,13 @@ class ImgPropertiesTest
|
|
|
58
68
|
END_IMG
|
|
59
69
|
|
|
60
70
|
actual = builder.generate_wrapper
|
|
61
|
-
expect(actual).to match_ignoring_whitespace(
|
|
71
|
+
expect(actual).to match_ignoring_whitespace(expected)
|
|
62
72
|
end
|
|
63
73
|
|
|
64
74
|
it 'generates an img wrapper with size and caption' do
|
|
65
75
|
props.caption = 'This is a caption'
|
|
66
76
|
props.size = '123px'
|
|
67
|
-
builder = described_class.new(props)
|
|
77
|
+
builder = described_class.new(img, props)
|
|
68
78
|
|
|
69
79
|
caption = <<~END_CAPTION
|
|
70
80
|
<figcaption class='imgFigCaption '>
|
|
@@ -72,8 +82,8 @@ class ImgPropertiesTest
|
|
|
72
82
|
</figcaption>
|
|
73
83
|
END_CAPTION
|
|
74
84
|
|
|
75
|
-
|
|
76
|
-
<div class='imgWrapper imgBlock' style='width: 123px;
|
|
85
|
+
expected = <<~END_IMG
|
|
86
|
+
<div class='imgWrapper imgBlock' style='width: 123px;'>
|
|
77
87
|
<figure>
|
|
78
88
|
<picture class='imgPicture'>
|
|
79
89
|
<source srcset="/assets/images/jekyll.webp" type="image/webp">
|
|
@@ -91,7 +101,7 @@ class ImgPropertiesTest
|
|
|
91
101
|
END_IMG
|
|
92
102
|
|
|
93
103
|
actual = builder.generate_wrapper
|
|
94
|
-
expect(actual).to match_ignoring_whitespace(
|
|
104
|
+
expect(actual).to match_ignoring_whitespace(expected)
|
|
95
105
|
end
|
|
96
106
|
end
|
|
97
107
|
end
|
data/spec/img_props_spec.rb
CHANGED
|
@@ -71,30 +71,83 @@ class ImgPropertiesTest
|
|
|
71
71
|
props.size = 'initial'
|
|
72
72
|
expect(props.attr_size_class).to eq('initial')
|
|
73
73
|
|
|
74
|
+
props.target = 'moon'
|
|
75
|
+
expect(props.attr_target).to eq(" target='moon'")
|
|
76
|
+
|
|
77
|
+
props.title = 'The End'
|
|
78
|
+
expect(props.attr_title).to eq("title='The End'")
|
|
79
|
+
|
|
74
80
|
props.size = '100px'
|
|
81
|
+
props.caption = 'A caption'
|
|
75
82
|
expect(props.attr_size_class).to be_nil
|
|
76
|
-
expect(props.attr_style_img).to eq("style='width: 100%; '")
|
|
77
83
|
expect(props.attr_width_style).to eq('width: 100px;')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'generates widths' do
|
|
87
|
+
props = described_class.new
|
|
88
|
+
|
|
89
|
+
props.size = '100px'
|
|
90
|
+
expect(props.attr_size_class).to be_nil
|
|
91
|
+
expect(props.attr_style_img).to eq('width: 100px;')
|
|
92
|
+
expect(props.attr_width_style).to eq('width: 100px;')
|
|
93
|
+
|
|
94
|
+
props.size = '100em'
|
|
95
|
+
expect(props.attr_size_class).to be_nil
|
|
96
|
+
expect(props.attr_style_img).to eq('width: 100em;')
|
|
97
|
+
expect(props.attr_width_style).to eq('width: 100em;')
|
|
78
98
|
|
|
79
99
|
props.size = '10%'
|
|
80
100
|
expect(props.attr_size_class).to be_nil
|
|
81
101
|
expect(props.attr_width_style).to eq('width: 10%;')
|
|
82
|
-
expect(props.attr_style_img).to eq(
|
|
102
|
+
expect(props.attr_style_img).to eq('width: 10%;')
|
|
83
103
|
|
|
84
104
|
props.size = 'fullsize'
|
|
85
105
|
expect(props.attr_size_class).to eq('fullsize')
|
|
86
106
|
expect(props.attr_width_style).to be_nil
|
|
87
107
|
|
|
88
|
-
props.
|
|
89
|
-
expect(props.
|
|
108
|
+
props.size = 'halfsize'
|
|
109
|
+
expect(props.attr_size_class).to eq('halfsize')
|
|
110
|
+
expect(props.attr_width_style).to be_nil
|
|
90
111
|
|
|
91
|
-
props.
|
|
92
|
-
expect(props.
|
|
112
|
+
props.size = 'quartersize'
|
|
113
|
+
expect(props.attr_size_class).to eq('quartersize')
|
|
114
|
+
expect(props.attr_width_style).to be_nil
|
|
93
115
|
|
|
94
|
-
props.size = '
|
|
95
|
-
props.
|
|
96
|
-
expect(props.
|
|
97
|
-
|
|
116
|
+
props.size = 'eighthsize'
|
|
117
|
+
expect(props.attr_size_class).to eq('eighthsize')
|
|
118
|
+
expect(props.attr_width_style).to be_nil
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'generates max_widths' do
|
|
122
|
+
props = described_class.new
|
|
123
|
+
|
|
124
|
+
props.max_width = '100px'
|
|
125
|
+
expect(props.attr_max_width_class).to be_nil
|
|
126
|
+
expect(props.attr_max_width_style).to eq('max-width: 100px;')
|
|
127
|
+
|
|
128
|
+
props.max_width = '100em'
|
|
129
|
+
expect(props.attr_max_width_class).to be_nil
|
|
130
|
+
expect(props.attr_max_width_style).to eq('max-width: 100em;')
|
|
131
|
+
|
|
132
|
+
props.max_width = '10%'
|
|
133
|
+
expect(props.attr_max_width_class).to be_nil
|
|
134
|
+
expect(props.attr_max_width_style).to eq('max-width: 10%;')
|
|
135
|
+
|
|
136
|
+
props.max_width = 'fullsize'
|
|
137
|
+
expect(props.attr_max_width_class).to eq('max_fullsize')
|
|
138
|
+
expect(props.attr_max_width_style).to be_nil
|
|
139
|
+
|
|
140
|
+
props.max_width = 'halfsize'
|
|
141
|
+
expect(props.attr_max_width_class).to eq('max_halfsize')
|
|
142
|
+
expect(props.attr_max_width_style).to be_nil
|
|
143
|
+
|
|
144
|
+
props.max_width = 'quartersize'
|
|
145
|
+
expect(props.attr_max_width_class).to eq('max_quartersize')
|
|
146
|
+
expect(props.attr_max_width_style).to be_nil
|
|
147
|
+
|
|
148
|
+
props.max_width = 'eighthsize'
|
|
149
|
+
expect(props.attr_max_width_class).to eq('max_eighthsize')
|
|
150
|
+
expect(props.attr_max_width_style).to be_nil
|
|
98
151
|
end
|
|
99
152
|
end
|
|
100
153
|
end
|
data/spec/jekyll_img_spec.rb
CHANGED
|
@@ -5,7 +5,7 @@ require 'jekyll_plugin_support'
|
|
|
5
5
|
require 'rspec/match_ignoring_whitespace'
|
|
6
6
|
require_relative '../lib/jekyll_img'
|
|
7
7
|
|
|
8
|
-
Registers = Struct.new(:page, :site) unless defined?
|
|
8
|
+
Registers = Struct.new(:page, :site) unless defined? Registers
|
|
9
9
|
|
|
10
10
|
# Mock for Collections
|
|
11
11
|
class Collections
|
|
@@ -56,7 +56,7 @@ class MyTest
|
|
|
56
56
|
)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
it 'has no cite or url', skip: 'unfinished' do
|
|
60
60
|
helper.reinitialize('src="./blah.webp"')
|
|
61
61
|
img = described_class.send(
|
|
62
62
|
:new,
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,7 +3,7 @@ require_relative '../lib/jekyll_img'
|
|
|
3
3
|
|
|
4
4
|
RSpec.configure do |config|
|
|
5
5
|
config.filter_run_when_matching focus: true
|
|
6
|
-
config.order = 'random'
|
|
6
|
+
# config.order = 'random'
|
|
7
7
|
|
|
8
8
|
# See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
|
|
9
9
|
config.example_status_persistence_file_path = 'spec/status_persistence.txt'
|
data/spec/status_persistence.txt
CHANGED
|
@@ -3,11 +3,13 @@ example_id | status | run_time |
|
|
|
3
3
|
./spec/img_builder_spec.rb[1:1] | failed | 14.37 seconds |
|
|
4
4
|
./spec/img_builder_spec.rb[1:2] | failed | 0.01498 seconds |
|
|
5
5
|
./spec/img_builder_spec.rb[1:3] | failed | 0.00093 seconds |
|
|
6
|
-
./spec/img_props_spec.rb[1:1] | passed | 0.
|
|
7
|
-
./spec/img_props_spec.rb[1:2] | passed | 0.
|
|
8
|
-
./spec/img_props_spec.rb[1:3] | passed | 0.
|
|
9
|
-
./spec/img_props_spec.rb[1:4] | passed |
|
|
10
|
-
./spec/img_props_spec.rb[1:5] | passed | 0.
|
|
6
|
+
./spec/img_props_spec.rb[1:1] | passed | 0.00174 seconds |
|
|
7
|
+
./spec/img_props_spec.rb[1:2] | passed | 0.00005 seconds |
|
|
8
|
+
./spec/img_props_spec.rb[1:3] | passed | 0.00189 seconds |
|
|
9
|
+
./spec/img_props_spec.rb[1:4] | passed | 0.00126 seconds |
|
|
10
|
+
./spec/img_props_spec.rb[1:5] | passed | 0.00006 seconds |
|
|
11
|
+
./spec/img_props_spec.rb[1:6] | passed | 0.00005 seconds |
|
|
12
|
+
./spec/img_props_spec.rb[1:7] | passed | 0.00005 seconds |
|
|
11
13
|
./spec/jekyll_img_spec.rb[1:1] | failed | 40.84 seconds |
|
|
12
14
|
./spec/source_spec.rb[1:1] | passed | 0.00089 seconds |
|
|
13
15
|
./spec/source_spec.rb[1:2] | passed | 0.0045 seconds |
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll_img
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Slinn
|
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: '0'
|
|
103
103
|
requirements: []
|
|
104
|
-
rubygems_version:
|
|
104
|
+
rubygems_version: 4.0.21
|
|
105
105
|
specification_version: 4
|
|
106
106
|
summary: Provides a Jekyll tag that generates images.
|
|
107
107
|
test_files:
|