<commit_before>require 'rubygems'
require 'nokogiri'

module RubyXL
module Writer
  class AppWriter < GenericWriter

    def filepath
      File.join('docProps', 'app.xml')
    end

    def write()

      contents = build_xml do |xml|
        xml.Properties('xmlns' => 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
        'xmlns:vt'=>'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes') {
          xml.Application @workbook.application
          xml.DocSecurity '0'
          xml.ScaleCrop 'false'
          xml.HeadingPairs {
            xml['vt'].vector(:size => '2', :baseType => 'variant') {
              xml['vt'].variant {
                xml['vt'].lpstr 'Worksheets'
              }
              xml['vt'].variant {
                xml['vt'].i4 @workbook.worksheets.size.to_s()
              }
            }
          }
          xml.TitlesOfParts {
            xml['vt'].vector(:size=>@workbook.worksheets.size.to_s(), :baseType=>"lpstr") {
              @workbook.worksheets.each do |sheet|
                xml['vt'].lpstr sheet.sheet_name
              end
            }
          }
          xml.Company @workbook.company
          xml.LinksUpToDate 'false'
          xml.SharedDoc 'false'
          xml.HyperlinksChanged 'false'
          xml.AppVersion @workbook.appversion
        }
      end

      if(contents =~ /xmlns:vt=\"(.*)\" xmlns=\"(.*)\"/)
        contents.sub(/xmlns:vt=\"(.*)\" xmlns=\"(.*)\"<A/,'xmlns="'+$2+'" xmlns:vt="'+$1+'"<A')
      end

      contents
    end

  end
end
end<commit_msg>Code comment for future generations...<commit_after>require 'rubygems'
require 'nokogiri'

module RubyXL
module Writer
  class AppWriter < GenericWriter

    def filepath
      File.join('docProps', 'app.xml')
    end

    def write()

      contents = build_xml do |xml|
        xml.Properties('xmlns' => 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties',
        'xmlns:vt'=>'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes') {
          xml.Application @workbook.application
          xml.DocSecurity '0'
          xml.ScaleCrop 'false'
          xml.HeadingPairs {
            xml['vt'].vector(:size => '2', :baseType => 'variant') {
              xml['vt'].variant {
                xml['vt'].lpstr 'Worksheets'
              }
              xml['vt'].variant {
                xml['vt'].i4 @workbook.worksheets.size.to_s()
              }
            }
          }
          xml.TitlesOfParts {
            xml['vt'].vector(:size=>@workbook.worksheets.size.to_s(), :baseType=>"lpstr") {
              @workbook.worksheets.each do |sheet|
                xml['vt'].lpstr sheet.sheet_name
              end
            }
          }
          xml.Company @workbook.company
          xml.LinksUpToDate 'false'
          xml.SharedDoc 'false'
          xml.HyperlinksChanged 'false'
          xml.AppVersion @workbook.appversion
        }
      end

      # This block isn't doing anything, as results of contents.sub are not assigned to anything
      if(contents =~ /xmlns:vt=\"(.*)\" xmlns=\"(.*)\"/)
        contents.sub(/xmlns:vt=\"(.*)\" xmlns=\"(.*)\"<A/,'xmlns="'+$2+'" xmlns:vt="'+$1+'"<A')
      end

      contents
    end

  end
end
end
{'fraction_non_alphanumeric': 0.15250611246943765, 'fraction_numerical': 0.007946210268948655, 'mean_word_length': 1.8862433862433863, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 62}, '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': '5426428', 'n_tokens_mistral': 1042, 'n_tokens_neox': 980, 'n_words': 165}