<commit_before>require 'RMagick'

module Dragonfly
  module Analysis
    
    class RMagickAnalyser
      
      def width(image)
        rmagick_image(image).columns
      end
      
      def height(image)
        rmagick_image(image).rows
      end
      
      def aspect_ratio(image)
        rmagick_data = rmagick_image(image)
        rmagick_data.columns.to_f / rmagick_data.rows
      end
      
      def depth(image)
        rmagick_image(image).depth
      end
      
      def number_of_colours(image)
        rmagick_image(image).number_colors
      end
      alias number_of_colors number_of_colours

      def format(image)
        rmagick_image(image).format.downcase.to_sym
      end
      
      private
      
      def rmagick_image(image)
        Magick::Image.from_blob(image.data).first
      rescue Magick::ImageMagickError => e
        log.warn("Unable to handle content in #{self.class} - got:\n#{e}")
        throw :unable_to_handle
      end
      
    end
    
  end
end<commit_msg>RMagickAnalyser was throwing errors because it wasn't loggable<commit_after>require 'RMagick'

module Dragonfly
  module Analysis
    class RMagickAnalyser

      include Loggable

      def width(image)
        rmagick_image(image).columns
      end
      
      def height(image)
        rmagick_image(image).rows
      end
      
      def aspect_ratio(image)
        rmagick_data = rmagick_image(image)
        rmagick_data.columns.to_f / rmagick_data.rows
      end
      
      def depth(image)
        rmagick_image(image).depth
      end
      
      def number_of_colours(image)
        rmagick_image(image).number_colors
      end
      alias number_of_colors number_of_colours

      def format(image)
        rmagick_image(image).format.downcase.to_sym
      end
      
      private
      
      def rmagick_image(image)
        Magick::Image.from_blob(image.data).first
      rescue Magick::ImageMagickError => e
        log.warn("Unable to handle content in #{self.class} - got:\n#{e}")
        throw :unable_to_handle
      end
      
    end
  end
end
{'fraction_non_alphanumeric': 0.06782106782106782, 'fraction_numerical': 0.0, 'mean_word_length': 2.0453879941434847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '402628', 'n_tokens_mistral': 658, 'n_tokens_neox': 661, 'n_words': 124}