<commit_before>module Mapnik
  class Map
    include Mapnik::FFI

    attr_accessor :width, :height, :ptr

    def initialize(width, height)
      @width = width
      @height = height
      ptr = mapnik_map width, height
      @ptr = ::FFI::AutoPointer.new ptr, self.class.method(:release)
      @ptr.autorelease = false
    end

    def self.release;end

    def free
      mapnik_map_free @ptr
    end

    def load(style)
      style = File.expand_path style
      mapnik_map_load @ptr, style
    end

    def zoom_all
      mapnik_map_zoom_all @ptr
    end

    def zoom_to(bounds)
      mapnik_map_zoom_to_box @ptr, bounds.ptr
    end

    def to_file(file)
      file = File.expand_path file
      mapnik_map_render_to_file @ptr, file
    end
  end
end
<commit_msg>Add support for in memory PNG output<commit_after>module Mapnik
  class Map
    include Mapnik::FFI

    attr_accessor :width, :height, :ptr

    def initialize(width, height)
      @width = width
      @height = height
      ptr = mapnik_map width, height
      @ptr = ::FFI::AutoPointer.new ptr, self.class.method(:release)
      @ptr.autorelease = false
    end

    def self.release;end

    def free
      mapnik_map_free @ptr
    end

    def load(style)
      style = File.expand_path style
      mapnik_map_load @ptr, style
    end

    def zoom_all
      mapnik_map_zoom_all @ptr
    end

    def zoom_to(bounds)
      mapnik_map_zoom_to_box @ptr, bounds.ptr
    end

    def to_image
      mapnik_map_render_to_image @ptr
    end

    def to_png
      mapnik_image_to_png_blob to_image
    end

    def to_file(file)
      file = File.expand_path file
      mapnik_map_render_to_file @ptr, file
    end
  end
end

{'fraction_non_alphanumeric': 0.06666666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 2.4124748490945676, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3179634', 'n_tokens_mistral': 587, 'n_tokens_neox': 567, 'n_words': 148}