<commit_before>module Squib
  class Deck

    # Saves the given range of cards to either PNG or PDF
    #
    # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [Symbol] format (:png)  the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]`
    # @option opts [String] prefix (card_) the prefix of the file name to be printed
    # @option opts [Boolean] rotate (false) PNG saving only. If true, the saved cards will be rotated 90 degrees clockwise. Intended to rendering landscape instead of portrait.
    # @return self
    # @api public
    def save(opts = {})
      opts = needs(opts, [:range, :creatable_dir, :formats, :prefix, :rotate])
      save_png(opts) if opts[:format].include? :png
      save_pdf(opts) if opts[:format].include? :pdf
      self
    end

    # Saves the given range of cards to a PNG
    #
    # @example
    #   save range: 1..8, dir: '_pnp', prefix: 'bw_'
    #
    # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [String] prefix (card_) the prefix of the file name to be printed.
    # @option opts [Boolean, :clockwise, :counterclockwise] rotate (false) if true, the saved cards will be rotated 90 degrees clockwise. Or, rotate by the number of radians. Intended to rendering landscape instead of portrait.
    # @return [nil] Returns nothing
    # @api public
    def save_png(opts = {})
      opts = needs(opts,[:range, :creatable_dir, :prefix, :rotate])
      @progress_bar.start("Saving PNGs to #{opts[:dir]}/#{opts[:prefix]}*", @cards.size) do |bar|
        opts[:range].each do |i|
          @cards[i].save_png(i, opts[:dir], opts[:prefix], opts[:rotate], opts[:angle])
          bar.increment
        end
      end
    end

    # Renders a range of files in a showcase as if they are sitting on a reflective surface
    # See {file:samples/showcase.rb} for full example
    #
    # @example
    #   showcase file: 'showcase_output.png', trim: 78, trim_radius: 32
    #
    # @option opts [Enumerable, :all] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [Fixnum] trim (0) the margin around the card to trim before putting into the showcase
    # @option opts [Fixnum] trim_radius (38) the rounded rectangle radius around the card to trim before putting into the showcase
    # @option opts [Fixnum] margin (75) the margin around the entire showcase
    # @option opts [Fixnum] scale (0.8) percentage of original width of each (trimmed) card to scale to. Must be between 0.0 and 1.0, but starts looking bad around 0.6.
    # @option opts [Fixnum] offset (1.1) percentage of the scaled width of each card to shift each offset. e.g. 1.1 is a 10% shift, and 0.95 is overlapping by 5%
    # @option opts [String, Color] fill_color (:white) backdrop color. Usually black or white.
    # @option opts [Fixnum] reflect_offset (15) the number of pixels between the bottom of the card and the reflection
    # @option opts [Fixnum] reflect_strength (0.2) the starting alpha transparency of the reflection (at the top of the card). Percentage between 0 and 1. Looks more realistic at low values since even shiny surfaces lose a lot of light.
    # @option opts [Fixnum] reflect_percent (0.25) the length of the reflection in percentage of the card. Larger values tend to make the reflection draw just as much attention as the card, which is not good.
    # @option opts [:left, :right] face (:left) which direction the cards face. Anything but `:right` will face left
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [String] file ('showcase.png') the file to save in dir. Will be overwritten.
    def showcase(opts = {})
      opts = {file: 'showcase.png', fill_color: :white}.merge(opts)<commit_msg>Fixing docs<commit_after>module Squib
  class Deck

    # Saves the given range of cards to either PNG or PDF
    #
    # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [Symbol] format (:png)  the format that this will be rendered too. Options `:pdf, :png`. Array of both is allowed: `[:pdf, :png]`
    # @option opts [String] prefix (card_) the prefix of the file name to be printed
    # @option opts [Boolean] rotate (false) PNG saving only. If true, the saved cards will be rotated 90 degrees clockwise. Intended to rendering landscape instead of portrait.
    # @return self
    # @api public
    def save(opts = {})
      opts = needs(opts, [:range, :creatable_dir, :formats, :prefix, :rotate])
      save_png(opts) if opts[:format].include? :png
      save_pdf(opts) if opts[:format].include? :pdf
      self
    end

    # Saves the given range of cards to a PNG
    #
    # @example
    #   save range: 1..8, dir: '_pnp', prefix: 'bw_'
    #
    # @option opts [Enumerable] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [String] prefix (card_) the prefix of the file name to be printed.
    # @option opts [Boolean, :clockwise, :counterclockwise] rotate (false) if true, the saved cards will be rotated 90 degrees clockwise. Or, rotate by the number of radians. Intended to rendering landscape instead of portrait.
    # @return [nil] Returns nothing
    # @api public
    def save_png(opts = {})
      opts = needs(opts,[:range, :creatable_dir, :prefix, :rotate])
      @progress_bar.start("Saving PNGs to #{opts[:dir]}/#{opts[:prefix]}*", @cards.size) do |bar|
        opts[:range].each do |i|
          @cards[i].save_png(i, opts[:dir], opts[:prefix], opts[:rotate], opts[:angle])
          bar.increment
        end
      end
    end

    # Renders a range of files in a showcase as if they are sitting on a reflective surface
    # See {file:samples/showcase.rb} for full example
    #
    # @example
    #   showcase file: 'showcase_output.png', trim: 78, trim_radius: 32
    #
    # @option opts [Enumerable, :all] range (:all) the range of cards over which this will be rendered. See {file:README.md#Specifying_Ranges Specifying Ranges}
    # @option opts [Fixnum] trim (0) the margin around the card to trim before putting into the showcase
    # @option opts [Fixnum] trim_radius (38) the rounded rectangle radius around the card to trim before putting into the showcase
    # @option opts [Fixnum] margin (75) the margin around the entire showcase
    # @option opts [Fixnum] scale (0.8) percentage of original width of each (trimmed) card to scale to. Must be between 0.0 and 1.0, but starts looking bad around 0.6.
    # @option opts [Fixnum] offset (1.1) percentage of the scaled width of each card to shift each offset. e.g. 1.1 is a 10% shift, and 0.95 is overlapping by 5%
    # @option opts [String, Color] fill_color (:white) backdrop color. Usually black or white.
    # @option opts [Fixnum] reflect_offset (15) the number of pixels between the bottom of the card and the reflection
    # @option opts [Fixnum] reflect_strength (0.2) the starting alpha transparency of the reflection (at the top of the card). Percentage between 0 and 1. Looks more realistic at low values since even shiny surfaces lose a lot of light.
    # @option opts [Fixnum] reflect_percent (0.25) the length of the reflection in percentage of the card. Larger values tend to make the reflection draw just as much attention as the card, which is not good.
    # @option opts [:left, :right] face (:left) which direction the cards face. Anything but `:right` will face left
    # @option opts [String] dir (_output) the directory for the output to be sent to. Will be created if it doesn't exist.
    # @option opts [String] file ('showcase.png') the file to save in dir. Will be overwritten.
    # @return [nil] Returns nothing.
    # @api public
    def showcase(opts = {})
      opts = {file: 'showcase.png', fill_color: :white}.merge(opts)
{'fraction_non_alphanumeric': 0.09597169918977519, 'fraction_numerical': 0.009585758301951387, 'mean_word_length': 3.4782830863566683, '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': '2186516', 'n_tokens_mistral': 2593, 'n_tokens_neox': 2478, 'n_words': 1188}