jekyll_img 0.2.9 → 0.2.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fceb334580b84bf7a4238093ab6fb718d1b5fc84a087b1f554764be2ddae477
4
- data.tar.gz: b0a489a01ee502e0bb4c6006610a8d82faf3561086fa4f57ce752158e0b9770a
3
+ metadata.gz: 0bf22b4d9439342fea87c4cbd46191ffa1b526f6cb81a8115e141743dc14edaf
4
+ data.tar.gz: cecd9148040040a37c0ff019abe2e220c007fad94e46f95e0da7c598702fe1de
5
5
  SHA512:
6
- metadata.gz: 14a147fe5e8ee74caffa3c4919d31fc28389ed9c4d5571357fc4797f1efaba10960eb2cefe9a3ebc68a85e76a339acdc9916d1191df11a2f9d1381412fff085a
7
- data.tar.gz: 9e7b3b29ea91638fd8f54e5320c9fc14ceef0456057cbd40d7b1d5e9c6803cfa65a01c7c76567e147be5cefcf270ce9721c328e65944b8c873ae63591956a180
6
+ metadata.gz: 03a02214d8c74971a8f846263aefab3e07e874682cebf3ff91ead8a3a62f74074d547512963dc7e96342700888742f75b4673eee89f71285879c4081226bece3
7
+ data.tar.gz: 799ee3a6925c9f5c38fd1588350784ed7bcc392928c6861308376d0238fba141a225da046c8be23c26127320b65bcde602cab0868c571b5d8ff7065ef3f03cbc
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  # - rubocop-jekyll
3
3
  - rubocop-md
4
4
  - rubocop-performance
@@ -64,6 +64,9 @@ Metrics/PerceivedComplexity:
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,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.2.12 /2026-09-18
4
+
5
+ * Got tangled up with LLMs running in circles. Hopefully better now.
6
+
7
+ ## 0.2.11 /2026-09-11
8
+
9
+ Not fixed yet:
10
+
11
+ * Fixed bug related to max-width percentage specification
12
+
13
+ ## 0.2.10 /2026-07-04
14
+
15
+ * Pry is no longer a production dependency
16
+
3
17
  ## 0.2.9 / 2025-05-19
4
18
 
5
19
  * `max-width` option added.
@@ -36,7 +50,7 @@
36
50
  * Corrected `README.md#Configuration` and fixed demo `_config.yml`
37
51
  so they correctly specify error handling for this plugin:
38
52
 
39
- ```ruby
53
+ ```yaml
40
54
  img:
41
55
  die_on_img_error: false
42
56
  pry_on_img_error: false
data/README.md CHANGED
@@ -345,7 +345,7 @@ end
345
345
  And then execute:
346
346
 
347
347
  ```shell
348
- $ bundle
348
+ $ bundle install
349
349
  ```
350
350
 
351
351
 
data/lib/img_builder.rb CHANGED
@@ -33,7 +33,7 @@ class ImgBuilder
33
33
  <<~END_IMG
34
34
  <img #{@props.attr_alt}
35
35
  class="imgImg #{img_classes.squish}"
36
- src="#{@source.src_fallback}"
36
+ src="#{@props.src}"
37
37
  #{@props.attr_style_img}
38
38
  #{@props.attr_title}
39
39
  #{@props.lazy}
@@ -84,8 +84,9 @@ class ImgBuilder
84
84
  end
85
85
 
86
86
  def generate_wrapper
87
- classes = ("imgWrapper #{@props.img_display} #{@props.align} #{@props.attr_size_class} " +
88
- "#{@props.attr_max_width_class} #{@props.wrapper_class}").squish
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
89
90
  styles = "#{@props.attr_width_style} #{@props.attr_max_width_style} #{@props.wrapper_style}".squish
90
91
  <<~END_HTML.remove_blank_lines
91
92
  <div class='#{classes}' style='#{styles}'>
data/lib/img_props.rb CHANGED
@@ -9,8 +9,8 @@ class ImgProperties
9
9
  :id, :img_display, :lazy, :local_src, :max_width, :nofollow, :priority, :src, :size, :style,
10
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,16 +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
32
34
  def attr_max_width_class
33
35
  return nil if @max_width == false || @max_width.nil? || max_width_unit_specified?
34
36
 
35
- unless SIZES.include?(@max_width)
37
+ unless SIZES.include?(@max_width) || @max_width.end_with?('%')
36
38
  msg = "'#{@max_width}' is not a recognized size; must be one of #{SIZES.join(', ')}, or an explicit unit."
37
39
  raise Jekyll::ImgError, msg
38
40
  end
39
- "max_#{@max_width}"
41
+ "max_#{@max_width}" # FIXME: this only works with fullsize, halfsize, quartersize and not % or units
40
42
  end
41
43
 
44
+ # FIXME: this method does not work when width is specified as a unit such as 15em
42
45
  def attr_size_class
43
46
  return nil if @size == false || @size.nil? || size_unit_specified?
44
47
 
@@ -1,3 +1,3 @@
1
1
  module JekyllImgVersion
2
- VERSION = '0.2.9'.freeze
2
+ VERSION = '0.2.12'.freeze
3
3
  end
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'
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.count == 1
44
+ return files[0] if files.one?
45
45
 
46
46
  files.each do |filename|
47
47
  ext = File.extname filename
@@ -3,54 +3,64 @@ require_relative '../lib/img_builder'
3
3
  require_relative '../lib/img_props'
4
4
  require_relative '../lib/source'
5
5
 
6
- # Test ImgProperties
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
- builder = described_class.new(props)
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
- desired = [
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(desired)
30
+ expect(actual).to match_array(expected)
21
31
  end
22
32
 
23
33
  it 'generates a figcaption' do
24
- desired = <<~END_STRING
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(desired)
38
+ expect(builder.generate_figcaption).to match_ignoring_whitespace(expected)
29
39
  end
30
40
 
31
41
  it 'generates a picture' do
32
- desired = <<~END_DESIRED
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">
36
46
  <img class="imgImg rounded shadow"
37
- src="/assets/images/jekyll.png"
47
+ src="/assets/images/jekyll.webp"
38
48
  style='width: 100%; '
39
49
  />
40
50
  </picture>
41
51
  END_DESIRED
42
52
  actual = builder.generate_picture
43
- expect(actual).to match_ignoring_whitespace(desired)
53
+ expect(actual).to match_ignoring_whitespace(expected)
44
54
  end
45
55
 
46
56
  it 'generates a default img' do
47
- desired = <<~END_IMG
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">
52
62
  <img class="imgImg rounded shadow"
53
- src="/assets/images/jekyll.png"
63
+ src="/assets/images/jekyll.webp"
54
64
  style='width: 100%; '
55
65
  />
56
66
  </picture>
@@ -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(desired)
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,15 +82,15 @@ class ImgPropertiesTest
72
82
  </figcaption>
73
83
  END_CAPTION
74
84
 
75
- desired = <<~END_IMG
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">
80
90
  <source srcset="/assets/images/jekyll.png" type="image/png">
81
91
  <img alt='This is a caption'
82
92
  class="imgImg rounded shadow"
83
- src="/assets/images/jekyll.png"
93
+ src="/assets/images/jekyll.webp"
84
94
  style='width: 100%; '
85
95
  title='This is a caption'
86
96
  />
@@ -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(desired)
104
+ expect(actual).to match_ignoring_whitespace(expected)
95
105
  end
96
106
  end
97
107
  end
@@ -71,6 +71,21 @@ 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
+
80
+ props.size = '100px'
81
+ props.caption = 'A caption'
82
+ expect(props.attr_size_class).to be_nil
83
+ expect(props.attr_width_style).to eq('width: 100px;')
84
+ end
85
+
86
+ it 'generates widths' do
87
+ props = described_class.new
88
+
74
89
  props.size = '100px'
75
90
  expect(props.attr_size_class).to be_nil
76
91
  expect(props.attr_style_img).to eq("style='width: 100%; '")
@@ -85,16 +100,45 @@ class ImgPropertiesTest
85
100
  expect(props.attr_size_class).to eq('fullsize')
86
101
  expect(props.attr_width_style).to be_nil
87
102
 
88
- props.target = 'moon'
89
- expect(props.attr_target).to eq(" target='moon'")
103
+ props.size = 'halfsize'
104
+ expect(props.attr_size_class).to eq('halfsize')
105
+ expect(props.attr_width_style).to be_nil
90
106
 
91
- props.title = 'The End'
92
- expect(props.attr_title).to eq("title='The End'")
107
+ props.size = 'quartersize'
108
+ expect(props.attr_size_class).to eq('quartersize')
109
+ expect(props.attr_width_style).to be_nil
93
110
 
94
- props.size = '100px'
95
- props.caption = 'A caption'
96
- expect(props.attr_size_class).to be_nil
97
- expect(props.attr_width_style).to eq('width: 100px;')
111
+ props.size = 'eighthsize'
112
+ expect(props.attr_size_class).to eq('eighthsize')
113
+ expect(props.attr_width_style).to be_nil
114
+ end
115
+
116
+ it 'generates max_widths' do
117
+ props = described_class.new
118
+
119
+ props.max_width = '100px'
120
+ expect(props.attr_max_width_class).to be_nil
121
+ expect(props.attr_max_width_style).to eq('max-width: 100px;')
122
+
123
+ props.max_width = '10%'
124
+ expect(props.attr_max_width_class).to be_nil
125
+ expect(props.attr_max_width_style).to eq('max-width: 10%;')
126
+
127
+ props.max_width = 'fullsize'
128
+ expect(props.attr_max_width_class).to eq('max_fullsize')
129
+ expect(props.attr_max_width_style).to be_nil
130
+
131
+ props.max_width = 'halfsize'
132
+ expect(props.attr_max_width_class).to eq('max_halfsize')
133
+ expect(props.attr_max_width_style).to be_nil
134
+
135
+ props.max_width = 'quartersize'
136
+ expect(props.attr_max_width_class).to eq('max_quartersize')
137
+ expect(props.attr_max_width_style).to be_nil
138
+
139
+ props.max_width = 'eighthsize'
140
+ expect(props.attr_max_width_class).to eq('max_eighthsize')
141
+ expect(props.attr_max_width_style).to be_nil
98
142
  end
99
143
  end
100
144
  end
@@ -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? :Registers
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
- xit 'has no cite or url' do
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'
@@ -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.00393 seconds |
7
- ./spec/img_props_spec.rb[1:2] | passed | 0.00006 seconds |
8
- ./spec/img_props_spec.rb[1:3] | passed | 0.00673 seconds |
9
- ./spec/img_props_spec.rb[1:4] | passed | 4.65 seconds |
10
- ./spec/img_props_spec.rb[1:5] | passed | 0.00009 seconds |
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.9
4
+ version: 0.2.12
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: 3.7.1
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: