about summary refs log tree commit diff
path: root/lib/paperclip
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
commit7452a959989f1259b68d08814437bab53ee89bb0 (patch)
tree389c2be7b7a326729e4687019a58950a07bd2dde /lib/paperclip
parent4c68189d2b8b6a9a74fc13862b11bf6c6d523409 (diff)
parentfef6c59b3abe349132dbe910b6aa243e59b732bb (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.github/dependabot.yml`:
  Upstream made changes while we have dropped this file.
  Keep the file deleted.
- `.prettierignore`:
  Upstream made changes at the end of the file, where we
  had our extra lines.
  Just moved our extra lines back at the end.
- `app/serializers/initial_state_serializer.rb`:
  Upstream code style changes.
  Applied them.
- `app/services/backup_service.rb`:
  Upstream code style changes.
  Applied them.
Diffstat (limited to 'lib/paperclip')
-rw-r--r--lib/paperclip/attachment_extensions.rb10
-rw-r--r--lib/paperclip/color_extractor.rb34
2 files changed, 21 insertions, 23 deletions
diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb
index d66a17623..7f82138aa 100644
--- a/lib/paperclip/attachment_extensions.rb
+++ b/lib/paperclip/attachment_extensions.rb
@@ -8,7 +8,7 @@ module Paperclip
 
     # monkey-patch to avoid unlinking too avoid unlinking source file too early
     # see https://github.com/kreeti/kt-paperclip/issues/64
-    def post_process_style(name, style) #:nodoc:
+    def post_process_style(name, style) # :nodoc:
       raise "Style #{name} has no processors defined." if style.processors.blank?
 
       intermediate_files = []
@@ -16,16 +16,16 @@ module Paperclip
       # if we're processing the original, close + unlink the source tempfile
       intermediate_files << original if name == :original
 
-      @queued_for_write[name] = style.processors.
-                                inject(original) do |file, processor|
+      @queued_for_write[name] = style.processors
+                                     .inject(original) do |file, processor|
         file = Paperclip.processor(processor).make(file, style.processor_options, self)
         intermediate_files << file unless file == original
         file
       end
 
       unadapted_file = @queued_for_write[name]
-      @queued_for_write[name] = Paperclip.io_adapters.
-                                for(@queued_for_write[name], @options[:adapter_options])
+      @queued_for_write[name] = Paperclip.io_adapters
+                                         .for(@queued_for_write[name], @options[:adapter_options])
       unadapted_file.close if unadapted_file.respond_to?(:close)
       @queued_for_write[name]
     rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e
diff --git a/lib/paperclip/color_extractor.rb b/lib/paperclip/color_extractor.rb
index d3b8e1022..733dcba80 100644
--- a/lib/paperclip/color_extractor.rb
+++ b/lib/paperclip/color_extractor.rb
@@ -79,8 +79,8 @@ module Paperclip
     private
 
     def w3c_contrast(color1, color2)
-      luminance1 = color1.to_xyz.y * 0.01 + 0.05
-      luminance2 = color2.to_xyz.y * 0.01 + 0.05
+      luminance1 = (color1.to_xyz.y * 0.01) + 0.05
+      luminance2 = (color2.to_xyz.y * 0.01) + 0.05
 
       if luminance1 > luminance2
         luminance1 / luminance2
@@ -109,11 +109,11 @@ module Paperclip
 
         case max
         when r
-          h = (g - b) / d + (g < b ? 6.0 : 0)
+          h = ((g - b) / d) + (g < b ? 6.0 : 0)
         when g
-          h = (b - r) / d + 2.0
+          h = ((b - r) / d) + 2.0
         when b
-          h = (r - g) / d + 4.0
+          h = ((r - g) / d) + 4.0
         end
 
         h /= 6.0
@@ -126,9 +126,9 @@ module Paperclip
       t += 1 if t.negative?
       t -= 1 if t > 1
 
-      return (p + (q - p) * 6 * t) if t < 1 / 6.0
+      return (p + ((q - p) * 6 * t)) if t < 1 / 6.0
       return q if t < 1 / 2.0
-      return (p + (q - p) * (2 / 3.0 - t) * 6) if t < 2 / 3.0
+      return (p + ((q - p) * ((2 / 3.0) - t) * 6)) if t < 2 / 3.0
 
       p
     end
@@ -147,11 +147,11 @@ module Paperclip
         g = l.to_f
         b = l.to_f # achromatic
       else
-        q = l < 0.5 ? l * (s + 1) : l + s - l * s
-        p = 2 * l - q
-        r = hue_to_rgb(p, q, h + 1 / 3.0)
+        q = l < 0.5 ? l * (s + 1) : l + s - (l * s)
+        p = (2 * l) - q
+        r = hue_to_rgb(p, q, h + (1 / 3.0))
         g = hue_to_rgb(p, q, h)
-        b = hue_to_rgb(p, q, h - 1 / 3.0)
+        b = hue_to_rgb(p, q, h - (1 / 3.0))
       end
 
       [(r * 255).round, (g * 255).round, (b * 255).round]
@@ -161,13 +161,11 @@ module Paperclip
     def lighten_or_darken(color, by)
       hue, saturation, light = rgb_to_hsl(color.r, color.g, color.b)
 
-      light = begin
-        if light < 50
-          [100, light + by].min
-        else
-          [0, light - by].max
-        end
-      end
+      light = if light < 50
+                [100, light + by].min
+              else
+                [0, light - by].max
+              end
 
       ColorDiff::Color::RGB.new(*hsl_to_rgb(hue, saturation, light))
     end