<commit_before>require 'crack'
require 'json'
require_relative 'character_card'
require_relative 'melee_weapon_card'
require_relative 'ranged_weapon_card'
require_relative 'armor_card'
require_relative 'tracked_resource_card'
require_relative 'spell_card'
require_relative 'skill_card'
require_relative 'defensive_ability_card'
require_relative 'feat_card'
require_relative 'trait_card'
require_relative 'special_ability_card'
require_relative 'special_attack_card'
require_relative 'deck'

class Compiler
  attr_accessor :deck
  attr_reader :setup_cards, :file_path, :myXML

  def initialize(file_path)
    @file_path = file_path
  end
  
  def is_party?
    Crack::XML.parse(File.read(@file_path))["document"]["public"]["character"].class == Array
  end

  def compile_individual
    read_file_path

    build_cards

    save_deck("#{@deck.cards.first[:title]}"+".json")
  end

  def compile_party
    read_file_path
    @myXML["document"]["public"]["character"].each_with_index do |fun_stuff, index|

      build_cards(index)

      save_deck("#{fun_stuff["name"]}"+".json")
    end
  end

  def prepare_for_s3
    read_file_path
    
    build_cards
<commit_msg>better naming of block-level variable<commit_after>require 'crack'
require 'json'
require_relative 'character_card'
require_relative 'melee_weapon_card'
require_relative 'ranged_weapon_card'
require_relative 'armor_card'
require_relative 'tracked_resource_card'
require_relative 'spell_card'
require_relative 'skill_card'
require_relative 'defensive_ability_card'
require_relative 'feat_card'
require_relative 'trait_card'
require_relative 'special_ability_card'
require_relative 'special_attack_card'
require_relative 'deck'

class Compiler
  attr_accessor :deck
  attr_reader :setup_cards, :file_path, :myXML

  def initialize(file_path)
    @file_path = file_path
  end
  
  def is_party?
    Crack::XML.parse(File.read(@file_path))["document"]["public"]["character"].class == Array
  end

  def compile_individual
    read_file_path

    build_cards

    save_deck("#{@deck.cards.first[:title]}"+".json")
  end

  def compile_party
    read_file_path
    @myXML["document"]["public"]["character"].each_with_index do |character, index|

      build_cards(index)

      save_deck("#{character["name"]}"+".json")
    end
  end

  def prepare_for_s3
    read_file_path
    
    build_cards

{'fraction_non_alphanumeric': 0.10144312393887946, 'fraction_numerical': 0.0008488964346349745, 'mean_word_length': 5.812138728323699, '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': '5167547', 'n_tokens_mistral': 789, 'n_tokens_neox': 784, 'n_words': 142}