shimmer 0.0.35 → 0.0.36

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: 7d9b9d1bd99fe6bb2a19bc53f2a9e90dbaf2df881ac553fbd5414ae8f0d18c5a
4
- data.tar.gz: 3a2103d4da0fa8997caa6d7303d2db8b01c66509d686de8e26ec321de64c3316
3
+ metadata.gz: 2b44ee90fa35afdc7109b5b40b10a6e182618f9f16c9764ca18f24f4b4b7e166
4
+ data.tar.gz: 1f0d2ac79b80f5374ce2bc18d1b61ab56b8f1c386ad6ab3240ec7795dcfb2568
5
5
  SHA512:
6
- metadata.gz: 4690bde20ccc420ac645a77ee3345c5bcc1170182d568b829ef1cced2f1be3acde2ecfd76e9d31f6583eb8d5c52d47ecea59ca37a98536e727ebb9911315dcff
7
- data.tar.gz: d6718256d8e38d611ac2a716f15e2875e106e3a7477119a242832bd2eab729ad077e766c754544ad49874a1f08c1c5461d4658d7478cdd24fdf1e10a7c83a39b
6
+ metadata.gz: 4c0f2a198e6566ff325ed5496a36620cac3fb206a8555d44e5c9b050eb60661d9f9f752cc9b0815c90ae6e7ed9088818e5c8abc744a313fd2a5a6a02490ec162
7
+ data.tar.gz: e8764515081a667da62d2858ae5753440e74a955448939b5edf9f359aa950c2655d12900a05eb10a342bd52f3554723bf077aa96e6dbc4cc2674b29ddcbdf271
data/.rubocop.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  inherit_from: config/rubocop_base.yml
2
2
 
3
3
  AllCops:
4
+ TargetRubyVersion: 3.1
4
5
  Exclude:
5
6
  - "bin/**/*"
6
7
  - "spec/rails_app/bin/**/*"
@@ -14,3 +15,6 @@ Rails/ApplicationController:
14
15
  # Allow jobs created in this library to inherit directly from ActiveJob::Base.
15
16
  Rails/ApplicationJob:
16
17
  Enabled: false
18
+
19
+ Style/HashSyntax:
20
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.7
1
+ 3.1.6
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "rails"
9
9
  gem "propshaft"
10
- gem "sqlite3"
10
+ gem "sqlite3", "~> 1.6"
11
11
  gem "puma"
12
12
  gem "jsbundling-rails"
13
13
  gem "turbo-rails"
@@ -20,7 +20,6 @@ gem "slim-rails"
20
20
  gem "awesome_print"
21
21
  gem "dotenv-rails"
22
22
  gem "image_processing"
23
- gem "mini_magick"
24
23
 
25
24
  group :development, :test do
26
25
  gem "debug", platforms: [:mri, :mingw, :x64_mingw]
data/Gemfile.lock CHANGED
@@ -6,67 +6,67 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (7.0.4.2)
10
- actionpack (= 7.0.4.2)
11
- activesupport (= 7.0.4.2)
9
+ actioncable (7.0.8.4)
10
+ actionpack (= 7.0.8.4)
11
+ activesupport (= 7.0.8.4)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (7.0.4.2)
15
- actionpack (= 7.0.4.2)
16
- activejob (= 7.0.4.2)
17
- activerecord (= 7.0.4.2)
18
- activestorage (= 7.0.4.2)
19
- activesupport (= 7.0.4.2)
14
+ actionmailbox (7.0.8.4)
15
+ actionpack (= 7.0.8.4)
16
+ activejob (= 7.0.8.4)
17
+ activerecord (= 7.0.8.4)
18
+ activestorage (= 7.0.8.4)
19
+ activesupport (= 7.0.8.4)
20
20
  mail (>= 2.7.1)
21
21
  net-imap
22
22
  net-pop
23
23
  net-smtp
24
- actionmailer (7.0.4.2)
25
- actionpack (= 7.0.4.2)
26
- actionview (= 7.0.4.2)
27
- activejob (= 7.0.4.2)
28
- activesupport (= 7.0.4.2)
24
+ actionmailer (7.0.8.4)
25
+ actionpack (= 7.0.8.4)
26
+ actionview (= 7.0.8.4)
27
+ activejob (= 7.0.8.4)
28
+ activesupport (= 7.0.8.4)
29
29
  mail (~> 2.5, >= 2.5.4)
30
30
  net-imap
31
31
  net-pop
32
32
  net-smtp
33
33
  rails-dom-testing (~> 2.0)
34
- actionpack (7.0.4.2)
35
- actionview (= 7.0.4.2)
36
- activesupport (= 7.0.4.2)
37
- rack (~> 2.0, >= 2.2.0)
34
+ actionpack (7.0.8.4)
35
+ actionview (= 7.0.8.4)
36
+ activesupport (= 7.0.8.4)
37
+ rack (~> 2.0, >= 2.2.4)
38
38
  rack-test (>= 0.6.3)
39
39
  rails-dom-testing (~> 2.0)
40
40
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
- actiontext (7.0.4.2)
42
- actionpack (= 7.0.4.2)
43
- activerecord (= 7.0.4.2)
44
- activestorage (= 7.0.4.2)
45
- activesupport (= 7.0.4.2)
41
+ actiontext (7.0.8.4)
42
+ actionpack (= 7.0.8.4)
43
+ activerecord (= 7.0.8.4)
44
+ activestorage (= 7.0.8.4)
45
+ activesupport (= 7.0.8.4)
46
46
  globalid (>= 0.6.0)
47
47
  nokogiri (>= 1.8.5)
48
- actionview (7.0.4.2)
49
- activesupport (= 7.0.4.2)
48
+ actionview (7.0.8.4)
49
+ activesupport (= 7.0.8.4)
50
50
  builder (~> 3.1)
51
51
  erubi (~> 1.4)
52
52
  rails-dom-testing (~> 2.0)
53
53
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
- activejob (7.0.4.2)
55
- activesupport (= 7.0.4.2)
54
+ activejob (7.0.8.4)
55
+ activesupport (= 7.0.8.4)
56
56
  globalid (>= 0.3.6)
57
- activemodel (7.0.4.2)
58
- activesupport (= 7.0.4.2)
59
- activerecord (7.0.4.2)
60
- activemodel (= 7.0.4.2)
61
- activesupport (= 7.0.4.2)
62
- activestorage (7.0.4.2)
63
- actionpack (= 7.0.4.2)
64
- activejob (= 7.0.4.2)
65
- activerecord (= 7.0.4.2)
66
- activesupport (= 7.0.4.2)
57
+ activemodel (7.0.8.4)
58
+ activesupport (= 7.0.8.4)
59
+ activerecord (7.0.8.4)
60
+ activemodel (= 7.0.8.4)
61
+ activesupport (= 7.0.8.4)
62
+ activestorage (7.0.8.4)
63
+ actionpack (= 7.0.8.4)
64
+ activejob (= 7.0.8.4)
65
+ activerecord (= 7.0.8.4)
66
+ activesupport (= 7.0.8.4)
67
67
  marcel (~> 1.0)
68
68
  mini_mime (>= 1.1.0)
69
- activesupport (7.0.4.2)
69
+ activesupport (7.0.8.4)
70
70
  concurrent-ruby (~> 1.0, >= 1.0.2)
71
71
  i18n (>= 1.6, < 2)
72
72
  minitest (>= 5.1)
@@ -81,7 +81,7 @@ GEM
81
81
  bindex (0.8.1)
82
82
  bootsnap (1.16.0)
83
83
  msgpack (~> 1.2)
84
- builder (3.2.4)
84
+ builder (3.3.0)
85
85
  byebug (11.1.3)
86
86
  capybara (3.38.0)
87
87
  addressable
@@ -93,14 +93,14 @@ GEM
93
93
  regexp_parser (>= 1.5, < 3.0)
94
94
  xpath (~> 3.2)
95
95
  coderay (1.1.3)
96
- concurrent-ruby (1.2.0)
96
+ concurrent-ruby (1.3.3)
97
97
  crass (1.0.6)
98
98
  cssbundling-rails (1.1.2)
99
99
  railties (>= 6.0.0)
100
100
  cuprite (0.14.3)
101
101
  capybara (~> 3.0)
102
102
  ferrum (~> 0.13.0)
103
- date (3.3.3)
103
+ date (3.3.4)
104
104
  debug (1.7.1)
105
105
  irb (>= 1.5.0)
106
106
  reline (>= 0.3.1)
@@ -109,7 +109,7 @@ GEM
109
109
  dotenv-rails (2.8.1)
110
110
  dotenv (= 2.8.1)
111
111
  railties (>= 3.2)
112
- erubi (1.12.0)
112
+ erubi (1.13.0)
113
113
  ferrum (0.13)
114
114
  addressable (~> 2.5)
115
115
  concurrent-ruby (~> 1.1)
@@ -117,8 +117,8 @@ GEM
117
117
  websocket-driver (>= 0.6, < 0.8)
118
118
  ffi (1.15.5)
119
119
  formatador (1.1.0)
120
- globalid (1.1.0)
121
- activesupport (>= 5.0)
120
+ globalid (1.2.1)
121
+ activesupport (>= 6.1)
122
122
  guard (2.18.0)
123
123
  formatador (>= 0.2.4)
124
124
  listen (>= 2.7, < 4.0)
@@ -133,7 +133,7 @@ GEM
133
133
  guard (~> 2.1)
134
134
  guard-compat (~> 1.1)
135
135
  rspec (>= 2.99.0, < 4.0)
136
- i18n (1.12.0)
136
+ i18n (1.14.5)
137
137
  concurrent-ruby (~> 1.0)
138
138
  image_processing (1.12.2)
139
139
  mini_magick (>= 4.9.5, < 5)
@@ -152,42 +152,42 @@ GEM
152
152
  listen (3.8.0)
153
153
  rb-fsevent (~> 0.10, >= 0.10.3)
154
154
  rb-inotify (~> 0.9, >= 0.9.10)
155
- loofah (2.19.1)
155
+ loofah (2.22.0)
156
156
  crass (~> 1.0.2)
157
- nokogiri (>= 1.5.9)
157
+ nokogiri (>= 1.12.0)
158
158
  lumberjack (1.2.8)
159
159
  mail (2.8.1)
160
160
  mini_mime (>= 0.1.1)
161
161
  net-imap
162
162
  net-pop
163
163
  net-smtp
164
- marcel (1.0.2)
164
+ marcel (1.0.4)
165
165
  matrix (0.4.2)
166
- method_source (1.0.0)
166
+ method_source (1.1.0)
167
167
  mini_magick (4.12.0)
168
- mini_mime (1.1.2)
169
- mini_portile2 (2.8.6)
170
- minitest (5.17.0)
168
+ mini_mime (1.1.5)
169
+ mini_portile2 (2.8.7)
170
+ minitest (5.24.1)
171
171
  msgpack (1.6.0)
172
172
  nenv (0.3.0)
173
- net-imap (0.3.4)
173
+ net-imap (0.4.14)
174
174
  date
175
175
  net-protocol
176
176
  net-pop (0.1.2)
177
177
  net-protocol
178
- net-protocol (0.2.1)
178
+ net-protocol (0.2.2)
179
179
  timeout
180
- net-smtp (0.3.3)
180
+ net-smtp (0.5.0)
181
181
  net-protocol
182
- nio4r (2.5.8)
183
- nokogiri (1.14.1)
184
- mini_portile2 (~> 2.8.0)
182
+ nio4r (2.7.3)
183
+ nokogiri (1.16.6)
184
+ mini_portile2 (~> 2.8.2)
185
185
  racc (~> 1.4)
186
- nokogiri (1.14.1-arm64-darwin)
186
+ nokogiri (1.16.6-arm64-darwin)
187
187
  racc (~> 1.4)
188
- nokogiri (1.14.1-x86_64-darwin)
188
+ nokogiri (1.16.6-x86_64-darwin)
189
189
  racc (~> 1.4)
190
- nokogiri (1.14.1-x86_64-linux)
190
+ nokogiri (1.16.6-x86_64-linux)
191
191
  racc (~> 1.4)
192
192
  notiffany (0.1.3)
193
193
  nenv (~> 0.1)
@@ -214,41 +214,43 @@ GEM
214
214
  public_suffix (5.0.1)
215
215
  puma (6.0.2)
216
216
  nio4r (~> 2.0)
217
- racc (1.6.2)
218
- rack (2.2.6.2)
219
- rack-test (2.0.2)
217
+ racc (1.8.0)
218
+ rack (2.2.9)
219
+ rack-test (2.1.0)
220
220
  rack (>= 1.3)
221
221
  rack_session_access (0.2.0)
222
222
  builder (>= 2.0.0)
223
223
  rack (>= 1.0.0)
224
- rails (7.0.4.2)
225
- actioncable (= 7.0.4.2)
226
- actionmailbox (= 7.0.4.2)
227
- actionmailer (= 7.0.4.2)
228
- actionpack (= 7.0.4.2)
229
- actiontext (= 7.0.4.2)
230
- actionview (= 7.0.4.2)
231
- activejob (= 7.0.4.2)
232
- activemodel (= 7.0.4.2)
233
- activerecord (= 7.0.4.2)
234
- activestorage (= 7.0.4.2)
235
- activesupport (= 7.0.4.2)
224
+ rails (7.0.8.4)
225
+ actioncable (= 7.0.8.4)
226
+ actionmailbox (= 7.0.8.4)
227
+ actionmailer (= 7.0.8.4)
228
+ actionpack (= 7.0.8.4)
229
+ actiontext (= 7.0.8.4)
230
+ actionview (= 7.0.8.4)
231
+ activejob (= 7.0.8.4)
232
+ activemodel (= 7.0.8.4)
233
+ activerecord (= 7.0.8.4)
234
+ activestorage (= 7.0.8.4)
235
+ activesupport (= 7.0.8.4)
236
236
  bundler (>= 1.15.0)
237
- railties (= 7.0.4.2)
238
- rails-dom-testing (2.0.3)
239
- activesupport (>= 4.2.0)
237
+ railties (= 7.0.8.4)
238
+ rails-dom-testing (2.2.0)
239
+ activesupport (>= 5.0.0)
240
+ minitest
240
241
  nokogiri (>= 1.6)
241
- rails-html-sanitizer (1.5.0)
242
- loofah (~> 2.19, >= 2.19.1)
243
- railties (7.0.4.2)
244
- actionpack (= 7.0.4.2)
245
- activesupport (= 7.0.4.2)
242
+ rails-html-sanitizer (1.6.0)
243
+ loofah (~> 2.21)
244
+ nokogiri (~> 1.14)
245
+ railties (7.0.8.4)
246
+ actionpack (= 7.0.8.4)
247
+ activesupport (= 7.0.8.4)
246
248
  method_source
247
249
  rake (>= 12.2)
248
250
  thor (~> 1.0)
249
251
  zeitwerk (~> 2.5)
250
252
  rainbow (3.1.1)
251
- rake (13.0.6)
253
+ rake (13.2.1)
252
254
  rb-fsevent (0.11.2)
253
255
  rb-inotify (0.10.1)
254
256
  ffi (~> 1.0)
@@ -316,11 +318,11 @@ GEM
316
318
  actionpack (>= 3.1)
317
319
  railties (>= 3.1)
318
320
  slim (>= 3.0, < 5.0)
319
- sqlite3 (1.6.0)
321
+ sqlite3 (1.7.3)
320
322
  mini_portile2 (~> 2.8.0)
321
- sqlite3 (1.6.0-arm64-darwin)
322
- sqlite3 (1.6.0-x86_64-darwin)
323
- sqlite3 (1.6.0-x86_64-linux)
323
+ sqlite3 (1.7.3-arm64-darwin)
324
+ sqlite3 (1.7.3-x86_64-darwin)
325
+ sqlite3 (1.7.3-x86_64-linux)
324
326
  standard (1.28.0)
325
327
  language_server-protocol (~> 3.17.0.2)
326
328
  lint_roller (~> 1.0)
@@ -335,9 +337,9 @@ GEM
335
337
  stimulus-rails (1.2.1)
336
338
  railties (>= 6.0.0)
337
339
  temple (0.8.2)
338
- thor (1.2.1)
340
+ thor (1.3.1)
339
341
  tilt (2.0.11)
340
- timeout (0.3.1)
342
+ timeout (0.4.1)
341
343
  turbo-rails (1.3.3)
342
344
  actionpack (>= 6.0.0)
343
345
  activejob (>= 6.0.0)
@@ -351,13 +353,13 @@ GEM
351
353
  bindex (>= 0.4.0)
352
354
  railties (>= 6.0.0)
353
355
  webrick (1.8.1)
354
- websocket-driver (0.7.5)
356
+ websocket-driver (0.7.6)
355
357
  websocket-extensions (>= 0.1.0)
356
358
  websocket-extensions (0.1.5)
357
359
  xpath (3.2.0)
358
360
  nokogiri (~> 1.8)
359
361
  yard (0.9.26)
360
- zeitwerk (2.6.6)
362
+ zeitwerk (2.6.16)
361
363
 
362
364
  PLATFORMS
363
365
  arm64-darwin-22
@@ -380,7 +382,6 @@ DEPENDENCIES
380
382
  image_processing
381
383
  jbuilder
382
384
  jsbundling-rails
383
- mini_magick
384
385
  propshaft
385
386
  pry
386
387
  pry-byebug
@@ -399,7 +400,7 @@ DEPENDENCIES
399
400
  rubocop-rspec
400
401
  shimmer!
401
402
  slim-rails
402
- sqlite3
403
+ sqlite3 (~> 1.6)
403
404
  standard
404
405
  stimulus-rails
405
406
  turbo-rails
data/README.md CHANGED
@@ -138,14 +138,29 @@ Then, if there are specific cops you want to use in the specific project you are
138
138
 
139
139
  ### Static File Serving
140
140
 
141
- `ActiveStorage` is great, but serving of files, especially behind a CDN, can be complicated to get right. This can be fixed easily:
141
+ `ActiveStorage` is great, but serving of files, especially behind a CDN, can be complicated to get right. Shimmer has your back.
142
+
143
+ It overrides `image_tag` and automatically resizes your image and creates a static, cacheable URL.
142
144
 
143
145
  ```ruby
144
146
  # use an image tag
145
- image_tag user.avatar, width: 300
147
+ image_tag(user.avatar, width: 300, height: 400)
148
+ image_tag(user.avatar, width: 300) # This will keep the aspect ratio and infer height
149
+ ```
150
+
151
+ If you need more control, you can also use `image_file_path` and `image_file_url` directly. They have a similar interface, but only return the path/URL.
152
+
153
+ ```ruby
154
+ image_file_path(user.avatar, width: 300, height: 400)
155
+ image_file_url(user.avatar, width: 300, height: 400)
146
156
  ```
147
157
 
148
- This extension overrides `image_tag` and also supplies a matching `image_file_url` that automatically resizes your image and creates a static, cacheable url.
158
+ Shimmer will only ever scale your images down, not up.
159
+
160
+ The URL of the image will point to the Rails app, where it will be generated on the fly. You should cache these routes with a CDN like Cloudflare.
161
+
162
+ This is in contrast to ActiveStorage variants, where the transformation happens when the URL for the image is built. This can slow down rendering or even prevent HTML to be generated if just one image can't be resized. With Shimmer, only the broken image will be broken.
163
+
149
164
 
150
165
  ### Modals
151
166
 
@@ -356,9 +371,7 @@ This library is tested using _RSpec_.
356
371
  bin/rspec
357
372
  ```
358
373
 
359
- A **system test** suite is included and is performed against a demo _Rails_ application in `spec/rails_app`. This
360
- application can be started in development mode for "playing around" with _Shimmer_ during its development and add
361
- more system tests. The `bin/dev` script starts that demo application.
374
+ A system test suite is included and is performed against a demo Rails application located in in `spec/rails_app`. This application can be started in development mode for "playing around" with Shimmer during its development and add more system tests. The `bin/dev` script starts that demo application.
362
375
 
363
376
  The first time, you want to initialize the database and seed it some data.
364
377
 
@@ -20,7 +20,6 @@ gem "slim-rails"
20
20
  gem "awesome_print"
21
21
  gem "dotenv-rails"
22
22
  gem "image_processing"
23
- gem "mini_magick"
24
23
 
25
24
  group :development, :test do
26
25
  gem "debug", platforms: %i[mri mingw x64_mingw]
@@ -6,67 +6,67 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actioncable (7.0.4.2)
10
- actionpack (= 7.0.4.2)
11
- activesupport (= 7.0.4.2)
9
+ actioncable (7.0.8.4)
10
+ actionpack (= 7.0.8.4)
11
+ activesupport (= 7.0.8.4)
12
12
  nio4r (~> 2.0)
13
13
  websocket-driver (>= 0.6.1)
14
- actionmailbox (7.0.4.2)
15
- actionpack (= 7.0.4.2)
16
- activejob (= 7.0.4.2)
17
- activerecord (= 7.0.4.2)
18
- activestorage (= 7.0.4.2)
19
- activesupport (= 7.0.4.2)
14
+ actionmailbox (7.0.8.4)
15
+ actionpack (= 7.0.8.4)
16
+ activejob (= 7.0.8.4)
17
+ activerecord (= 7.0.8.4)
18
+ activestorage (= 7.0.8.4)
19
+ activesupport (= 7.0.8.4)
20
20
  mail (>= 2.7.1)
21
21
  net-imap
22
22
  net-pop
23
23
  net-smtp
24
- actionmailer (7.0.4.2)
25
- actionpack (= 7.0.4.2)
26
- actionview (= 7.0.4.2)
27
- activejob (= 7.0.4.2)
28
- activesupport (= 7.0.4.2)
24
+ actionmailer (7.0.8.4)
25
+ actionpack (= 7.0.8.4)
26
+ actionview (= 7.0.8.4)
27
+ activejob (= 7.0.8.4)
28
+ activesupport (= 7.0.8.4)
29
29
  mail (~> 2.5, >= 2.5.4)
30
30
  net-imap
31
31
  net-pop
32
32
  net-smtp
33
33
  rails-dom-testing (~> 2.0)
34
- actionpack (7.0.4.2)
35
- actionview (= 7.0.4.2)
36
- activesupport (= 7.0.4.2)
37
- rack (~> 2.0, >= 2.2.0)
34
+ actionpack (7.0.8.4)
35
+ actionview (= 7.0.8.4)
36
+ activesupport (= 7.0.8.4)
37
+ rack (~> 2.0, >= 2.2.4)
38
38
  rack-test (>= 0.6.3)
39
39
  rails-dom-testing (~> 2.0)
40
40
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
- actiontext (7.0.4.2)
42
- actionpack (= 7.0.4.2)
43
- activerecord (= 7.0.4.2)
44
- activestorage (= 7.0.4.2)
45
- activesupport (= 7.0.4.2)
41
+ actiontext (7.0.8.4)
42
+ actionpack (= 7.0.8.4)
43
+ activerecord (= 7.0.8.4)
44
+ activestorage (= 7.0.8.4)
45
+ activesupport (= 7.0.8.4)
46
46
  globalid (>= 0.6.0)
47
47
  nokogiri (>= 1.8.5)
48
- actionview (7.0.4.2)
49
- activesupport (= 7.0.4.2)
48
+ actionview (7.0.8.4)
49
+ activesupport (= 7.0.8.4)
50
50
  builder (~> 3.1)
51
51
  erubi (~> 1.4)
52
52
  rails-dom-testing (~> 2.0)
53
53
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
- activejob (7.0.4.2)
55
- activesupport (= 7.0.4.2)
54
+ activejob (7.0.8.4)
55
+ activesupport (= 7.0.8.4)
56
56
  globalid (>= 0.3.6)
57
- activemodel (7.0.4.2)
58
- activesupport (= 7.0.4.2)
59
- activerecord (7.0.4.2)
60
- activemodel (= 7.0.4.2)
61
- activesupport (= 7.0.4.2)
62
- activestorage (7.0.4.2)
63
- actionpack (= 7.0.4.2)
64
- activejob (= 7.0.4.2)
65
- activerecord (= 7.0.4.2)
66
- activesupport (= 7.0.4.2)
57
+ activemodel (7.0.8.4)
58
+ activesupport (= 7.0.8.4)
59
+ activerecord (7.0.8.4)
60
+ activemodel (= 7.0.8.4)
61
+ activesupport (= 7.0.8.4)
62
+ activestorage (7.0.8.4)
63
+ actionpack (= 7.0.8.4)
64
+ activejob (= 7.0.8.4)
65
+ activerecord (= 7.0.8.4)
66
+ activesupport (= 7.0.8.4)
67
67
  marcel (~> 1.0)
68
68
  mini_mime (>= 1.1.0)
69
- activesupport (7.0.4.2)
69
+ activesupport (7.0.8.4)
70
70
  concurrent-ruby (~> 1.0, >= 1.0.2)
71
71
  i18n (>= 1.6, < 2)
72
72
  minitest (>= 5.1)
@@ -81,7 +81,7 @@ GEM
81
81
  bindex (0.8.1)
82
82
  bootsnap (1.16.0)
83
83
  msgpack (~> 1.2)
84
- builder (3.2.4)
84
+ builder (3.3.0)
85
85
  byebug (11.1.3)
86
86
  capybara (3.38.0)
87
87
  addressable
@@ -93,14 +93,14 @@ GEM
93
93
  regexp_parser (>= 1.5, < 3.0)
94
94
  xpath (~> 3.2)
95
95
  coderay (1.1.3)
96
- concurrent-ruby (1.2.0)
96
+ concurrent-ruby (1.3.3)
97
97
  crass (1.0.6)
98
98
  cssbundling-rails (1.1.2)
99
99
  railties (>= 6.0.0)
100
100
  cuprite (0.14.3)
101
101
  capybara (~> 3.0)
102
102
  ferrum (~> 0.13.0)
103
- date (3.3.3)
103
+ date (3.3.4)
104
104
  debug (1.7.1)
105
105
  irb (>= 1.5.0)
106
106
  reline (>= 0.3.1)
@@ -109,7 +109,7 @@ GEM
109
109
  dotenv-rails (2.8.1)
110
110
  dotenv (= 2.8.1)
111
111
  railties (>= 3.2)
112
- erubi (1.12.0)
112
+ erubi (1.13.0)
113
113
  ferrum (0.13)
114
114
  addressable (~> 2.5)
115
115
  concurrent-ruby (~> 1.1)
@@ -117,8 +117,8 @@ GEM
117
117
  websocket-driver (>= 0.6, < 0.8)
118
118
  ffi (1.15.5)
119
119
  formatador (1.1.0)
120
- globalid (1.1.0)
121
- activesupport (>= 5.0)
120
+ globalid (1.2.1)
121
+ activesupport (>= 6.1)
122
122
  guard (2.18.0)
123
123
  formatador (>= 0.2.4)
124
124
  listen (>= 2.7, < 4.0)
@@ -133,7 +133,7 @@ GEM
133
133
  guard (~> 2.1)
134
134
  guard-compat (~> 1.1)
135
135
  rspec (>= 2.99.0, < 4.0)
136
- i18n (1.12.0)
136
+ i18n (1.14.5)
137
137
  concurrent-ruby (~> 1.0)
138
138
  image_processing (1.12.2)
139
139
  mini_magick (>= 4.9.5, < 5)
@@ -152,42 +152,42 @@ GEM
152
152
  listen (3.8.0)
153
153
  rb-fsevent (~> 0.10, >= 0.10.3)
154
154
  rb-inotify (~> 0.9, >= 0.9.10)
155
- loofah (2.19.1)
155
+ loofah (2.22.0)
156
156
  crass (~> 1.0.2)
157
- nokogiri (>= 1.5.9)
157
+ nokogiri (>= 1.12.0)
158
158
  lumberjack (1.2.8)
159
159
  mail (2.8.1)
160
160
  mini_mime (>= 0.1.1)
161
161
  net-imap
162
162
  net-pop
163
163
  net-smtp
164
- marcel (1.0.2)
164
+ marcel (1.0.4)
165
165
  matrix (0.4.2)
166
- method_source (1.0.0)
166
+ method_source (1.1.0)
167
167
  mini_magick (4.12.0)
168
- mini_mime (1.1.2)
169
- mini_portile2 (2.8.6)
170
- minitest (5.17.0)
168
+ mini_mime (1.1.5)
169
+ mini_portile2 (2.8.7)
170
+ minitest (5.24.1)
171
171
  msgpack (1.6.0)
172
172
  nenv (0.3.0)
173
- net-imap (0.3.4)
173
+ net-imap (0.4.14)
174
174
  date
175
175
  net-protocol
176
176
  net-pop (0.1.2)
177
177
  net-protocol
178
- net-protocol (0.2.1)
178
+ net-protocol (0.2.2)
179
179
  timeout
180
- net-smtp (0.3.3)
180
+ net-smtp (0.5.0)
181
181
  net-protocol
182
- nio4r (2.5.8)
183
- nokogiri (1.14.1)
184
- mini_portile2 (~> 2.8.0)
182
+ nio4r (2.7.3)
183
+ nokogiri (1.16.6)
184
+ mini_portile2 (~> 2.8.2)
185
185
  racc (~> 1.4)
186
- nokogiri (1.14.1-arm64-darwin)
186
+ nokogiri (1.16.6-arm64-darwin)
187
187
  racc (~> 1.4)
188
- nokogiri (1.14.1-x86_64-darwin)
188
+ nokogiri (1.16.6-x86_64-darwin)
189
189
  racc (~> 1.4)
190
- nokogiri (1.14.1-x86_64-linux)
190
+ nokogiri (1.16.6-x86_64-linux)
191
191
  racc (~> 1.4)
192
192
  notiffany (0.1.3)
193
193
  nenv (~> 0.1)
@@ -214,41 +214,43 @@ GEM
214
214
  public_suffix (5.0.1)
215
215
  puma (6.0.2)
216
216
  nio4r (~> 2.0)
217
- racc (1.6.2)
218
- rack (2.2.6.2)
219
- rack-test (2.0.2)
217
+ racc (1.8.0)
218
+ rack (2.2.9)
219
+ rack-test (2.1.0)
220
220
  rack (>= 1.3)
221
221
  rack_session_access (0.2.0)
222
222
  builder (>= 2.0.0)
223
223
  rack (>= 1.0.0)
224
- rails (7.0.4.2)
225
- actioncable (= 7.0.4.2)
226
- actionmailbox (= 7.0.4.2)
227
- actionmailer (= 7.0.4.2)
228
- actionpack (= 7.0.4.2)
229
- actiontext (= 7.0.4.2)
230
- actionview (= 7.0.4.2)
231
- activejob (= 7.0.4.2)
232
- activemodel (= 7.0.4.2)
233
- activerecord (= 7.0.4.2)
234
- activestorage (= 7.0.4.2)
235
- activesupport (= 7.0.4.2)
224
+ rails (7.0.8.4)
225
+ actioncable (= 7.0.8.4)
226
+ actionmailbox (= 7.0.8.4)
227
+ actionmailer (= 7.0.8.4)
228
+ actionpack (= 7.0.8.4)
229
+ actiontext (= 7.0.8.4)
230
+ actionview (= 7.0.8.4)
231
+ activejob (= 7.0.8.4)
232
+ activemodel (= 7.0.8.4)
233
+ activerecord (= 7.0.8.4)
234
+ activestorage (= 7.0.8.4)
235
+ activesupport (= 7.0.8.4)
236
236
  bundler (>= 1.15.0)
237
- railties (= 7.0.4.2)
238
- rails-dom-testing (2.0.3)
239
- activesupport (>= 4.2.0)
237
+ railties (= 7.0.8.4)
238
+ rails-dom-testing (2.2.0)
239
+ activesupport (>= 5.0.0)
240
+ minitest
240
241
  nokogiri (>= 1.6)
241
- rails-html-sanitizer (1.5.0)
242
- loofah (~> 2.19, >= 2.19.1)
243
- railties (7.0.4.2)
244
- actionpack (= 7.0.4.2)
245
- activesupport (= 7.0.4.2)
242
+ rails-html-sanitizer (1.6.0)
243
+ loofah (~> 2.21)
244
+ nokogiri (~> 1.14)
245
+ railties (7.0.8.4)
246
+ actionpack (= 7.0.8.4)
247
+ activesupport (= 7.0.8.4)
246
248
  method_source
247
249
  rake (>= 12.2)
248
250
  thor (~> 1.0)
249
251
  zeitwerk (~> 2.5)
250
252
  rainbow (3.1.1)
251
- rake (13.0.6)
253
+ rake (13.2.1)
252
254
  rb-fsevent (0.11.2)
253
255
  rb-inotify (0.10.1)
254
256
  ffi (~> 1.0)
@@ -316,11 +318,11 @@ GEM
316
318
  actionpack (>= 3.1)
317
319
  railties (>= 3.1)
318
320
  slim (>= 3.0, < 5.0)
319
- sqlite3 (1.6.0)
321
+ sqlite3 (1.7.3)
320
322
  mini_portile2 (~> 2.8.0)
321
- sqlite3 (1.6.0-arm64-darwin)
322
- sqlite3 (1.6.0-x86_64-darwin)
323
- sqlite3 (1.6.0-x86_64-linux)
323
+ sqlite3 (1.7.3-arm64-darwin)
324
+ sqlite3 (1.7.3-x86_64-darwin)
325
+ sqlite3 (1.7.3-x86_64-linux)
324
326
  standard (1.28.0)
325
327
  language_server-protocol (~> 3.17.0.2)
326
328
  lint_roller (~> 1.0)
@@ -335,9 +337,9 @@ GEM
335
337
  stimulus-rails (1.2.1)
336
338
  railties (>= 6.0.0)
337
339
  temple (0.8.2)
338
- thor (1.2.1)
340
+ thor (1.3.1)
339
341
  tilt (2.0.11)
340
- timeout (0.3.1)
342
+ timeout (0.4.1)
341
343
  turbo-rails (1.3.3)
342
344
  actionpack (>= 6.0.0)
343
345
  activejob (>= 6.0.0)
@@ -351,13 +353,13 @@ GEM
351
353
  bindex (>= 0.4.0)
352
354
  railties (>= 6.0.0)
353
355
  webrick (1.8.1)
354
- websocket-driver (0.7.5)
356
+ websocket-driver (0.7.6)
355
357
  websocket-extensions (>= 0.1.0)
356
358
  websocket-extensions (0.1.5)
357
359
  xpath (3.2.0)
358
360
  nokogiri (~> 1.8)
359
361
  yard (0.9.26)
360
- zeitwerk (2.6.6)
362
+ zeitwerk (2.6.16)
361
363
 
362
364
  PLATFORMS
363
365
  arm64-darwin-22
@@ -380,7 +382,6 @@ DEPENDENCIES
380
382
  image_processing
381
383
  jbuilder
382
384
  jsbundling-rails
383
- mini_magick
384
385
  propshaft
385
386
  pry
386
387
  pry-byebug
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Shimmer
4
4
  class FileProxy
5
- attr_reader :blob_id, :resize
5
+ attr_reader :blob_id
6
6
 
7
7
  delegate :message_verifier, to: :class
8
8
  delegate :content_type, :filename, to: :blob
@@ -10,28 +10,38 @@ module Shimmer
10
10
  class << self
11
11
  def restore(id)
12
12
  blob_id, resize = message_verifier.verified(id)
13
- new blob_id: blob_id, resize: resize
14
- end
15
- end
16
13
 
17
- def initialize(blob_id:, resize: nil, width: nil, height: nil)
18
- @blob_id = blob_id
19
- if !resize && width
20
- resize = if height
21
- "#{width}x#{height}>"
22
- else
23
- "#{width}x>"
14
+ if resize.is_a?(String)
15
+ width, height = legacy_resize_string_to_tuple(resize)
16
+ elsif resize.is_a?(Array)
17
+ width, height = resize
24
18
  end
19
+
20
+ new(blob_id: blob_id, width: width, height: height)
21
+ end
22
+
23
+ # In the past, we generated the IDs with ImageMagick style "200x200>" strings. We don't do that anymore, but to prevent all old URLs breaking and caches invalidating at once, we grandfather these URLs in.
24
+ def legacy_resize_string_to_tuple(resize)
25
+ return if resize.blank?
26
+
27
+ matches = resize.match(/(?<width>\d*)x(?<height>\d*)/)
28
+
29
+ [
30
+ matches[:width].presence&.to_i,
31
+ matches[:height].presence&.to_i
32
+ ]
25
33
  end
26
- @resize = resize
27
- end
28
34
 
29
- class << self
30
35
  def message_verifier
31
36
  @message_verifier ||= ApplicationRecord.signed_id_verifier
32
37
  end
33
38
  end
34
39
 
40
+ def initialize(blob_id:, width: nil, height: nil)
41
+ @blob_id = blob_id
42
+ @resize = [width, height] if width || height
43
+ end
44
+
35
45
  def path
36
46
  Rails.application.routes.url_helpers.file_path(id, locale: nil)
37
47
  end
@@ -44,12 +54,12 @@ module Shimmer
44
54
  @blob ||= ActiveStorage::Blob.find(blob_id)
45
55
  end
46
56
 
47
- def resizeable
48
- resize.present? && blob.content_type.exclude?("svg")
57
+ def resizeable?
58
+ @resize.present? && blob.content_type.exclude?("svg")
49
59
  end
50
60
 
51
61
  def variant
52
- @variant ||= resizeable ? blob.representation(resize: resize).processed : blob
62
+ @variant ||= resizeable? ? blob.representation(resize_to_limit: @resize).processed : blob
53
63
  end
54
64
 
55
65
  def file
@@ -59,7 +69,7 @@ module Shimmer
59
69
  private
60
70
 
61
71
  def id
62
- @id ||= message_verifier.generate([blob_id, resize])
72
+ @id ||= message_verifier.generate([blob_id, @resize])
63
73
  end
64
74
  end
65
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.35"
4
+ VERSION = "0.0.36"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-03 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.1.6
139
+ rubygems_version: 3.3.27
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Shimmer brings all the bells and whistles of a hotwired application, right