shimmer 0.0.34 → 0.0.36

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: 2597efc97555e0fdaf706da74c2287ca8391cf11812c804af9ed642a25758d50
4
- data.tar.gz: 981525a3ada939df8284439fbc0faef48541866b20a1a144fc8c62d089b5059a
3
+ metadata.gz: 2b44ee90fa35afdc7109b5b40b10a6e182618f9f16c9764ca18f24f4b4b7e166
4
+ data.tar.gz: 1f0d2ac79b80f5374ce2bc18d1b61ab56b8f1c386ad6ab3240ec7795dcfb2568
5
5
  SHA512:
6
- metadata.gz: 627e3cc5b828c91686a3feb585f583530e0d97fde15204a111aefe015484ad8e235c016667db24349d3e9a9799bf13b82c07e6e3724269eb208f6cce42a966d8
7
- data.tar.gz: 5fbeb933c67cdf2ff8d4d216af5074f455c9ffaf1da5c5f791907f1be2d85c59f642a23dd5505ca8505e68eb03a7a73699475770e9293a4c6facd4f0081da16e
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,34 +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
- minitest (5.17.0)
168
+ mini_mime (1.1.5)
169
+ mini_portile2 (2.8.7)
170
+ minitest (5.24.1)
170
171
  msgpack (1.6.0)
171
172
  nenv (0.3.0)
172
- net-imap (0.3.4)
173
+ net-imap (0.4.14)
173
174
  date
174
175
  net-protocol
175
176
  net-pop (0.1.2)
176
177
  net-protocol
177
- net-protocol (0.2.1)
178
+ net-protocol (0.2.2)
178
179
  timeout
179
- net-smtp (0.3.3)
180
+ net-smtp (0.5.0)
180
181
  net-protocol
181
- nio4r (2.5.8)
182
- nokogiri (1.14.1-x86_64-darwin)
182
+ nio4r (2.7.3)
183
+ nokogiri (1.16.6)
184
+ mini_portile2 (~> 2.8.2)
185
+ racc (~> 1.4)
186
+ nokogiri (1.16.6-arm64-darwin)
187
+ racc (~> 1.4)
188
+ nokogiri (1.16.6-x86_64-darwin)
189
+ racc (~> 1.4)
190
+ nokogiri (1.16.6-x86_64-linux)
183
191
  racc (~> 1.4)
184
192
  notiffany (0.1.3)
185
193
  nenv (~> 0.1)
@@ -206,41 +214,43 @@ GEM
206
214
  public_suffix (5.0.1)
207
215
  puma (6.0.2)
208
216
  nio4r (~> 2.0)
209
- racc (1.6.2)
210
- rack (2.2.6.2)
211
- rack-test (2.0.2)
217
+ racc (1.8.0)
218
+ rack (2.2.9)
219
+ rack-test (2.1.0)
212
220
  rack (>= 1.3)
213
221
  rack_session_access (0.2.0)
214
222
  builder (>= 2.0.0)
215
223
  rack (>= 1.0.0)
216
- rails (7.0.4.2)
217
- actioncable (= 7.0.4.2)
218
- actionmailbox (= 7.0.4.2)
219
- actionmailer (= 7.0.4.2)
220
- actionpack (= 7.0.4.2)
221
- actiontext (= 7.0.4.2)
222
- actionview (= 7.0.4.2)
223
- activejob (= 7.0.4.2)
224
- activemodel (= 7.0.4.2)
225
- activerecord (= 7.0.4.2)
226
- activestorage (= 7.0.4.2)
227
- 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)
228
236
  bundler (>= 1.15.0)
229
- railties (= 7.0.4.2)
230
- rails-dom-testing (2.0.3)
231
- activesupport (>= 4.2.0)
237
+ railties (= 7.0.8.4)
238
+ rails-dom-testing (2.2.0)
239
+ activesupport (>= 5.0.0)
240
+ minitest
232
241
  nokogiri (>= 1.6)
233
- rails-html-sanitizer (1.5.0)
234
- loofah (~> 2.19, >= 2.19.1)
235
- railties (7.0.4.2)
236
- actionpack (= 7.0.4.2)
237
- 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)
238
248
  method_source
239
249
  rake (>= 12.2)
240
250
  thor (~> 1.0)
241
251
  zeitwerk (~> 2.5)
242
252
  rainbow (3.1.1)
243
- rake (13.0.6)
253
+ rake (13.2.1)
244
254
  rb-fsevent (0.11.2)
245
255
  rb-inotify (0.10.1)
246
256
  ffi (~> 1.0)
@@ -308,7 +318,11 @@ GEM
308
318
  actionpack (>= 3.1)
309
319
  railties (>= 3.1)
310
320
  slim (>= 3.0, < 5.0)
311
- sqlite3 (1.6.0-x86_64-darwin)
321
+ sqlite3 (1.7.3)
322
+ mini_portile2 (~> 2.8.0)
323
+ sqlite3 (1.7.3-arm64-darwin)
324
+ sqlite3 (1.7.3-x86_64-darwin)
325
+ sqlite3 (1.7.3-x86_64-linux)
312
326
  standard (1.28.0)
313
327
  language_server-protocol (~> 3.17.0.2)
314
328
  lint_roller (~> 1.0)
@@ -323,9 +337,9 @@ GEM
323
337
  stimulus-rails (1.2.1)
324
338
  railties (>= 6.0.0)
325
339
  temple (0.8.2)
326
- thor (1.2.1)
340
+ thor (1.3.1)
327
341
  tilt (2.0.11)
328
- timeout (0.3.1)
342
+ timeout (0.4.1)
329
343
  turbo-rails (1.3.3)
330
344
  actionpack (>= 6.0.0)
331
345
  activejob (>= 6.0.0)
@@ -339,16 +353,19 @@ GEM
339
353
  bindex (>= 0.4.0)
340
354
  railties (>= 6.0.0)
341
355
  webrick (1.8.1)
342
- websocket-driver (0.7.5)
356
+ websocket-driver (0.7.6)
343
357
  websocket-extensions (>= 0.1.0)
344
358
  websocket-extensions (0.1.5)
345
359
  xpath (3.2.0)
346
360
  nokogiri (~> 1.8)
347
361
  yard (0.9.26)
348
- zeitwerk (2.6.6)
362
+ zeitwerk (2.6.16)
349
363
 
350
364
  PLATFORMS
365
+ arm64-darwin-22
366
+ ruby
351
367
  x86_64-darwin-22
368
+ x86_64-linux
352
369
 
353
370
  DEPENDENCIES
354
371
  annotate
@@ -365,7 +382,6 @@ DEPENDENCIES
365
382
  image_processing
366
383
  jbuilder
367
384
  jsbundling-rails
368
- mini_magick
369
385
  propshaft
370
386
  pry
371
387
  pry-byebug
@@ -384,7 +400,7 @@ DEPENDENCIES
384
400
  rubocop-rspec
385
401
  shimmer!
386
402
  slim-rails
387
- sqlite3
403
+ sqlite3 (~> 1.6)
388
404
  standard
389
405
  stimulus-rails
390
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
 
@@ -7,7 +7,7 @@ gemspec path: ".."
7
7
 
8
8
  gem "rails", "~> 7.0.0"
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: %i[mri mingw x64_mingw]
@@ -0,0 +1,410 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ shimmer (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (7.0.8.4)
10
+ actionpack (= 7.0.8.4)
11
+ activesupport (= 7.0.8.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
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
+ mail (>= 2.7.1)
21
+ net-imap
22
+ net-pop
23
+ net-smtp
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
+ mail (~> 2.5, >= 2.5.4)
30
+ net-imap
31
+ net-pop
32
+ net-smtp
33
+ rails-dom-testing (~> 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
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.0)
40
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
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
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (7.0.8.4)
49
+ activesupport (= 7.0.8.4)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.4)
52
+ rails-dom-testing (~> 2.0)
53
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
+ activejob (7.0.8.4)
55
+ activesupport (= 7.0.8.4)
56
+ globalid (>= 0.3.6)
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
+ marcel (~> 1.0)
68
+ mini_mime (>= 1.1.0)
69
+ activesupport (7.0.8.4)
70
+ concurrent-ruby (~> 1.0, >= 1.0.2)
71
+ i18n (>= 1.6, < 2)
72
+ minitest (>= 5.1)
73
+ tzinfo (~> 2.0)
74
+ addressable (2.8.1)
75
+ public_suffix (>= 2.0.2, < 6.0)
76
+ annotate (3.2.0)
77
+ activerecord (>= 3.2, < 8.0)
78
+ rake (>= 10.4, < 14.0)
79
+ ast (2.4.2)
80
+ awesome_print (1.9.2)
81
+ bindex (0.8.1)
82
+ bootsnap (1.16.0)
83
+ msgpack (~> 1.2)
84
+ builder (3.3.0)
85
+ byebug (11.1.3)
86
+ capybara (3.38.0)
87
+ addressable
88
+ matrix
89
+ mini_mime (>= 0.1.3)
90
+ nokogiri (~> 1.8)
91
+ rack (>= 1.6.0)
92
+ rack-test (>= 0.6.3)
93
+ regexp_parser (>= 1.5, < 3.0)
94
+ xpath (~> 3.2)
95
+ coderay (1.1.3)
96
+ concurrent-ruby (1.3.3)
97
+ crass (1.0.6)
98
+ cssbundling-rails (1.1.2)
99
+ railties (>= 6.0.0)
100
+ cuprite (0.14.3)
101
+ capybara (~> 3.0)
102
+ ferrum (~> 0.13.0)
103
+ date (3.3.4)
104
+ debug (1.7.1)
105
+ irb (>= 1.5.0)
106
+ reline (>= 0.3.1)
107
+ diff-lcs (1.5.0)
108
+ dotenv (2.8.1)
109
+ dotenv-rails (2.8.1)
110
+ dotenv (= 2.8.1)
111
+ railties (>= 3.2)
112
+ erubi (1.13.0)
113
+ ferrum (0.13)
114
+ addressable (~> 2.5)
115
+ concurrent-ruby (~> 1.1)
116
+ webrick (~> 1.7)
117
+ websocket-driver (>= 0.6, < 0.8)
118
+ ffi (1.15.5)
119
+ formatador (1.1.0)
120
+ globalid (1.2.1)
121
+ activesupport (>= 6.1)
122
+ guard (2.18.0)
123
+ formatador (>= 0.2.4)
124
+ listen (>= 2.7, < 4.0)
125
+ lumberjack (>= 1.0.12, < 2.0)
126
+ nenv (~> 0.1)
127
+ notiffany (~> 0.0)
128
+ pry (>= 0.13.0)
129
+ shellany (~> 0.0)
130
+ thor (>= 0.18.1)
131
+ guard-compat (1.2.1)
132
+ guard-rspec (4.7.3)
133
+ guard (~> 2.1)
134
+ guard-compat (~> 1.1)
135
+ rspec (>= 2.99.0, < 4.0)
136
+ i18n (1.14.5)
137
+ concurrent-ruby (~> 1.0)
138
+ image_processing (1.12.2)
139
+ mini_magick (>= 4.9.5, < 5)
140
+ ruby-vips (>= 2.0.17, < 3)
141
+ io-console (0.6.0)
142
+ irb (1.6.2)
143
+ reline (>= 0.3.0)
144
+ jbuilder (2.11.5)
145
+ actionview (>= 5.0.0)
146
+ activesupport (>= 5.0.0)
147
+ jsbundling-rails (1.1.1)
148
+ railties (>= 6.0.0)
149
+ json (2.6.3)
150
+ language_server-protocol (3.17.0.3)
151
+ lint_roller (1.0.0)
152
+ listen (3.8.0)
153
+ rb-fsevent (~> 0.10, >= 0.10.3)
154
+ rb-inotify (~> 0.9, >= 0.9.10)
155
+ loofah (2.22.0)
156
+ crass (~> 1.0.2)
157
+ nokogiri (>= 1.12.0)
158
+ lumberjack (1.2.8)
159
+ mail (2.8.1)
160
+ mini_mime (>= 0.1.1)
161
+ net-imap
162
+ net-pop
163
+ net-smtp
164
+ marcel (1.0.4)
165
+ matrix (0.4.2)
166
+ method_source (1.1.0)
167
+ mini_magick (4.12.0)
168
+ mini_mime (1.1.5)
169
+ mini_portile2 (2.8.7)
170
+ minitest (5.24.1)
171
+ msgpack (1.6.0)
172
+ nenv (0.3.0)
173
+ net-imap (0.4.14)
174
+ date
175
+ net-protocol
176
+ net-pop (0.1.2)
177
+ net-protocol
178
+ net-protocol (0.2.2)
179
+ timeout
180
+ net-smtp (0.5.0)
181
+ net-protocol
182
+ nio4r (2.7.3)
183
+ nokogiri (1.16.6)
184
+ mini_portile2 (~> 2.8.2)
185
+ racc (~> 1.4)
186
+ nokogiri (1.16.6-arm64-darwin)
187
+ racc (~> 1.4)
188
+ nokogiri (1.16.6-x86_64-darwin)
189
+ racc (~> 1.4)
190
+ nokogiri (1.16.6-x86_64-linux)
191
+ racc (~> 1.4)
192
+ notiffany (0.1.3)
193
+ nenv (~> 0.1)
194
+ shellany (~> 0.0)
195
+ parallel (1.23.0)
196
+ parser (3.2.2.1)
197
+ ast (~> 2.4.1)
198
+ propshaft (0.6.4)
199
+ actionpack (>= 7.0.0)
200
+ activesupport (>= 7.0.0)
201
+ rack
202
+ railties (>= 7.0.0)
203
+ pry (0.14.2)
204
+ coderay (~> 1.1)
205
+ method_source (~> 1.0)
206
+ pry-byebug (3.10.1)
207
+ byebug (~> 11.0)
208
+ pry (>= 0.13, < 0.15)
209
+ pry-doc (1.4.0)
210
+ pry (~> 0.11)
211
+ yard (~> 0.9.11)
212
+ pry-rails (0.3.9)
213
+ pry (>= 0.10.4)
214
+ public_suffix (5.0.1)
215
+ puma (6.0.2)
216
+ nio4r (~> 2.0)
217
+ racc (1.8.0)
218
+ rack (2.2.9)
219
+ rack-test (2.1.0)
220
+ rack (>= 1.3)
221
+ rack_session_access (0.2.0)
222
+ builder (>= 2.0.0)
223
+ rack (>= 1.0.0)
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
+ bundler (>= 1.15.0)
237
+ railties (= 7.0.8.4)
238
+ rails-dom-testing (2.2.0)
239
+ activesupport (>= 5.0.0)
240
+ minitest
241
+ nokogiri (>= 1.6)
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)
248
+ method_source
249
+ rake (>= 12.2)
250
+ thor (~> 1.0)
251
+ zeitwerk (~> 2.5)
252
+ rainbow (3.1.1)
253
+ rake (13.2.1)
254
+ rb-fsevent (0.11.2)
255
+ rb-inotify (0.10.1)
256
+ ffi (~> 1.0)
257
+ regexp_parser (2.8.0)
258
+ reline (0.3.2)
259
+ io-console (~> 0.5)
260
+ rexml (3.2.5)
261
+ rspec (3.12.0)
262
+ rspec-core (~> 3.12.0)
263
+ rspec-expectations (~> 3.12.0)
264
+ rspec-mocks (~> 3.12.0)
265
+ rspec-core (3.12.1)
266
+ rspec-support (~> 3.12.0)
267
+ rspec-expectations (3.12.2)
268
+ diff-lcs (>= 1.2.0, < 2.0)
269
+ rspec-support (~> 3.12.0)
270
+ rspec-mocks (3.12.3)
271
+ diff-lcs (>= 1.2.0, < 2.0)
272
+ rspec-support (~> 3.12.0)
273
+ rspec-rails (6.0.1)
274
+ actionpack (>= 6.1)
275
+ activesupport (>= 6.1)
276
+ railties (>= 6.1)
277
+ rspec-core (~> 3.11)
278
+ rspec-expectations (~> 3.11)
279
+ rspec-mocks (~> 3.11)
280
+ rspec-support (~> 3.11)
281
+ rspec-retry (0.6.2)
282
+ rspec-core (> 3.3)
283
+ rspec-support (3.12.0)
284
+ rubocop (1.50.2)
285
+ json (~> 2.3)
286
+ parallel (~> 1.10)
287
+ parser (>= 3.2.0.0)
288
+ rainbow (>= 2.2.2, < 4.0)
289
+ regexp_parser (>= 1.8, < 3.0)
290
+ rexml (>= 3.2.5, < 4.0)
291
+ rubocop-ast (>= 1.28.0, < 2.0)
292
+ ruby-progressbar (~> 1.7)
293
+ unicode-display_width (>= 2.4.0, < 3.0)
294
+ rubocop-ast (1.28.0)
295
+ parser (>= 3.2.1.0)
296
+ rubocop-capybara (2.18.0)
297
+ rubocop (~> 1.41)
298
+ rubocop-performance (1.16.0)
299
+ rubocop (>= 1.7.0, < 2.0)
300
+ rubocop-ast (>= 0.4.0)
301
+ rubocop-rails (2.17.4)
302
+ activesupport (>= 4.2.0)
303
+ rack (>= 1.1)
304
+ rubocop (>= 1.33.0, < 2.0)
305
+ rubocop-rake (0.6.0)
306
+ rubocop (~> 1.0)
307
+ rubocop-rspec (2.20.0)
308
+ rubocop (~> 1.33)
309
+ rubocop-capybara (~> 2.17)
310
+ ruby-progressbar (1.13.0)
311
+ ruby-vips (2.1.4)
312
+ ffi (~> 1.12)
313
+ shellany (0.0.1)
314
+ slim (4.1.0)
315
+ temple (>= 0.7.6, < 0.9)
316
+ tilt (>= 2.0.6, < 2.1)
317
+ slim-rails (3.5.1)
318
+ actionpack (>= 3.1)
319
+ railties (>= 3.1)
320
+ slim (>= 3.0, < 5.0)
321
+ sqlite3 (1.7.3)
322
+ mini_portile2 (~> 2.8.0)
323
+ sqlite3 (1.7.3-arm64-darwin)
324
+ sqlite3 (1.7.3-x86_64-darwin)
325
+ sqlite3 (1.7.3-x86_64-linux)
326
+ standard (1.28.0)
327
+ language_server-protocol (~> 3.17.0.2)
328
+ lint_roller (~> 1.0)
329
+ rubocop (~> 1.50.2)
330
+ standard-custom (~> 1.0.0)
331
+ standard-performance (~> 1.0.1)
332
+ standard-custom (1.0.0)
333
+ lint_roller (~> 1.0)
334
+ standard-performance (1.0.1)
335
+ lint_roller (~> 1.0)
336
+ rubocop-performance (~> 1.16.0)
337
+ stimulus-rails (1.2.1)
338
+ railties (>= 6.0.0)
339
+ temple (0.8.2)
340
+ thor (1.3.1)
341
+ tilt (2.0.11)
342
+ timeout (0.4.1)
343
+ turbo-rails (1.3.3)
344
+ actionpack (>= 6.0.0)
345
+ activejob (>= 6.0.0)
346
+ railties (>= 6.0.0)
347
+ tzinfo (2.0.6)
348
+ concurrent-ruby (~> 1.0)
349
+ unicode-display_width (2.4.2)
350
+ web-console (4.2.0)
351
+ actionview (>= 6.0.0)
352
+ activemodel (>= 6.0.0)
353
+ bindex (>= 0.4.0)
354
+ railties (>= 6.0.0)
355
+ webrick (1.8.1)
356
+ websocket-driver (0.7.6)
357
+ websocket-extensions (>= 0.1.0)
358
+ websocket-extensions (0.1.5)
359
+ xpath (3.2.0)
360
+ nokogiri (~> 1.8)
361
+ yard (0.9.26)
362
+ zeitwerk (2.6.16)
363
+
364
+ PLATFORMS
365
+ arm64-darwin-22
366
+ ruby
367
+ x86_64-darwin-22
368
+ x86_64-linux
369
+
370
+ DEPENDENCIES
371
+ annotate
372
+ awesome_print
373
+ bootsnap
374
+ capybara
375
+ cssbundling-rails
376
+ cuprite
377
+ debug
378
+ dotenv
379
+ dotenv-rails
380
+ guard
381
+ guard-rspec
382
+ image_processing
383
+ jbuilder
384
+ jsbundling-rails
385
+ propshaft
386
+ pry
387
+ pry-byebug
388
+ pry-doc
389
+ pry-rails
390
+ puma
391
+ rack_session_access
392
+ rails (~> 7.0.0)
393
+ rake
394
+ rspec-rails
395
+ rspec-retry
396
+ rubocop
397
+ rubocop-performance
398
+ rubocop-rails
399
+ rubocop-rake
400
+ rubocop-rspec
401
+ shimmer!
402
+ slim-rails
403
+ sqlite3 (~> 1.6)
404
+ standard
405
+ stimulus-rails
406
+ turbo-rails
407
+ web-console
408
+
409
+ BUNDLED WITH
410
+ 2.4.9
@@ -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.34"
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.34
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: 2023-11-24 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -48,6 +48,7 @@ files:
48
48
  - config/rubocop_extensions/rails.yml
49
49
  - config/rubocop_extensions/rspec.yml
50
50
  - gemfiles/Gemfile-rails-7-0
51
+ - gemfiles/Gemfile-rails-7-0.lock
51
52
  - lib/shimmer.rb
52
53
  - lib/shimmer/auth.rb
53
54
  - lib/shimmer/auth/apple_provider.rb
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  requirements: []
138
- rubygems_version: 3.1.6
139
+ rubygems_version: 3.3.27
139
140
  signing_key:
140
141
  specification_version: 4
141
142
  summary: Shimmer brings all the bells and whistles of a hotwired application, right