<commit_before>require 'image'
require 'link'
require 'resource'

module ResumeGenerator
  module ResumeHelper
    private

    def bullet_list(*items)
      table_data = []
      items.each do |item|
        table_data << ['•', d(item)]
      end
      table(table_data, cell_style: { borders: [] })
    end

    def social_media_links
      resources = social_media_resources
      x_position = 0
      bounding_box_for(resources.first, x_position)
      x_position += 45
      resources[1..-1].each do |image_link|
        move_up 46.25
        bounding_box_for(image_link, x_position)
        x_position += 45
      end
    end

    def bounding_box_for(image_link, x_position)
      bounding_box([x_position, cursor], width: 35) do
        image image_link.image, fit: [35, 35], align: :center
        move_up 35
        transparent(0) do
          formatted_text([{
            text: '|||',
            size: 40,
            link: image_link.link
          }], align: :center)
        end
      end
    end

    def social_media_resources
      %w(email linked_in github stackoverflow
         speakerdeck vimeo code_school blog).map do |item|
        Resource.for(item)
      end
    end

    def heading(string)
      formatted_text([{ text: d(string), styles: [:bold], color: '666666' }])
    end

    def name(string)
      font('Times-Roman', size: 20) { text d(string) }
    end

    def description(ruby, rest)
      formatted_text(
        [
          { text: d(ruby), color: '85200C' },
          { text: d(rest) }
        ],
        size: 14
      )
    end

    def position(title, options = {})
      if options.has_key?(:at)
        formatted_text_box(
          [{ text: d(title), styles: [:bold] }], at: [options[:at], cursor]
        )
      else
        formatted_text([{ text: d(title), styles: [:bold] }])
      end
    end

    def organisation(name, options = {})
      if options.has_key?(:at)
        formatted_text_box(
          [{ text: d(name), styles: [:bold], size: 11 }],
          at: [options[:at], cursor]
        )
      else
        formatted_text([{ text: d(name), styles: [:bold], size: 11 }])
      end
    end

    def period_and_location(options)
      if options.has_key?(:at)
        formatted_text_box(
          [
            { text: d(options[:period]), color: '666666', size: 10 },
            {
              text: d(options[:location]),
              link: d(options[:link]),
              color: '666666', size: 10
            }
          ],
          at: [options[:at], cursor]
        )
      else
        formatted_text([
          { text: d(options[:period]) },
          {
            text: d(options[:location]),
            link: d(options[:link])
          }
        ], color: '666666', size: 10)
      end
    end

    def organisation_logo(options)
      bounding_box([options[:origin], cursor],
                   width: options[:width],
                   height: options[:height]) do
        image Image.for(options[:organisation]),
              fit: options[:fit],
              align: :center
        move_up options[:move_up]
        transparent(0) do
          formatted_text([{<commit_msg>Minor method refactor<commit_after>require 'image'
require 'link'
require 'resource'

module ResumeGenerator
  module ResumeHelper
    private

    def bullet_list(*items)
      table_data = []
      items.each do |item|
        table_data << ['•', d(item)]
      end
      table(table_data, cell_style: { borders: [] })
    end

    def social_media_links
      resources = social_media_resources
      x_position = 0
      bounding_box_for(resources.first, x_position)
      x_position += 45
      resources[1..-1].each do |image_link|
        move_up 46.25
        bounding_box_for(image_link, x_position)
        x_position += 45
      end
    end

    def bounding_box_for(image_link, x_position)
      bounding_box([x_position, cursor], width: 35) do
        image image_link.image, fit: [35, 35], align: :center
        move_up 35
        transparent(0) do
          formatted_text([{
            text: '|||',
            size: 40,
            link: image_link.link
          }], align: :center)
        end
      end
    end

    def social_media_resources
      %w(email linked_in github stackoverflow
         speakerdeck vimeo code_school blog).map do |item|
        Resource.for(item)
      end
    end

    def heading(string)
      formatted_text([{ text: d(string), styles: [:bold], color: '666666' }])
    end

    def name(string)
      font('Times-Roman', size: 20) { text d(string) }
    end

    def description(ruby, rest)
      formatted_text(
        [
          { text: d(ruby), color: '85200C' },
          { text: d(rest) }
        ],
        size: 14
      )
    end

    def position(title, options = {})
      if options.has_key?(:at)
        formatted_text_box(
          [{ text: d(title), styles: [:bold] }], at: [options[:at], cursor]
        )
      else
        formatted_text([{ text: d(title), styles: [:bold] }])
      end
    end

    def organisation(name, options = {})
      if options.has_key?(:at)
        formatted_text_box(
          [{ text: d(name), styles: [:bold], size: 11 }],
          at: [options[:at], cursor]
        )
      else
        formatted_text([{ text: d(name), styles: [:bold], size: 11 }])
      end
    end

    def period_and_location(options)
      if options.has_key?(:at)
        period_and_location_formatted_text_box(options)
      else
        period_and_location_formatted_text(options)
      end
    end

    def period_and_location_formatted_text(options)
      formatted_text([
        { text: d(options[:period]) },
        {
          text: d(options[:location]),
          link: d(options[:link])
        }
      ], color: '666666', size: 10)
    end

    def period_and_location_formatted_text_box(options)
      formatted_text_box(
        [
          { text: d(options[:period]), color: '666666', size: 10 },
          {
            text: d(options[:location]),
            link: d(options[:link]),
            color: '666666', size: 10
          }
        ],
        at: [options[:at], cursor]
      )
    end

    def organisation_logo(options)
      bounding_box([options[:origin], cursor],
                   width: options[:width],
                   height: options[:height]) do
        image Image.for(options[:organisation]),
              fit: options[:fit],
              align: :center
        move_up options[:move_up]
        transparent(0) do
          formatted_text([{
{'fraction_non_alphanumeric': 0.12216778934476424, 'fraction_numerical': 0.02020820575627679, 'mean_word_length': 1.936179775280899, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5920888', 'n_tokens_mistral': 2121, 'n_tokens_neox': 1992, 'n_words': 457}