Unified · Split
| @@ -11,20 +11,22 @@ module Docs · 10 unmodified lines | ||
| 11 | 11 | @image_optim.optimize_image_data(data) |
| 12 | 12 | end |
| 13 | 13 | |
| 14 | + def self.cache | |
| 15 | + @cache ||= {} | |
| 16 | + end | |
| 17 | + | |
| 14 | 18 | def call |
| 15 | 19 | return doc if context[:download_images] == false |
| 16 | 20 | |
| 17 | − @@cache ||= {} | |
| 18 | − | |
| 19 | 21 | doc.css('img[src]').each do |node| |
| 20 | 22 | src = node['src'] |
| 21 | 23 | |
| 22 | − if @@cache.key?(src) | |
| 23 | − node['src'] = @@cache[src] unless @@cache[src] == false | |
| 24 | + if self.class.cache.key?(src) | |
| 25 | + node['src'] = self.class.cache[src] unless self.class.cache[src] == false | |
| 24 | 26 | next |
| 25 | 27 | end |
| 26 | 28 | |
| 27 | − @@cache[src] = false | |
| 29 | + self.class.cache[src] = false | |
| 28 | 30 | |
| 29 | 31 | url = Docs::URL.parse(src) |
| 30 | 32 | url.scheme = 'https' if url.scheme.nil? |
| @@ -57,7 +59,7 @@ module Docs · 26 unmodified lines | ||
| 57 | 59 | |
| 58 | 60 | image = Base64.strict_encode64(image) |
| 59 | 61 | image.prepend "data:#{response.mime_type};base64," |
| 60 | − node['src'] = @@cache[src] = image | |
| 62 | + node['src'] = self.class.cache[src] = image | |
| 61 | 63 | end |
| 62 | 64 | rescue => exception |
| 63 | 65 | instrument 'error.image', url: url, exception: exception |