<commit_before>require 'fileutils'
require 'logger'

class Sync
  
  class << self
  
    def sync
      FileUtils.mkdir_p('/tmp/installd/')
      @logger = Logger.new('/tmp/installd/app.log')
      
      FileUtils.rm_rf('/tmp/installd/unzipped')
      FileUtils.mkdir_p('/tmp/installd/unzipped')
      
      apps_pattern = File.join(ENV['HOME'], 'Music', 'iTunes', 'Mobile Applications', '*.ipa')
      
      doc = ''
      Dir[apps_pattern].each do |app_file|
        app_name = File.basename(app_file, '.ipa')
        unzip_dir = File.join('/tmp/installd/unzipped', app_name)
        plist = File.join(unzip_dir, 'iTunesMetadata.plist')
        
        execute %{/usr/bin/unzip -d "#{unzip_dir}" "#{app_file}" iTunesMetadata.plist}
        execute %{/bin/chmod +rw "#{plist}"}
        execute %{/usr/bin/plutil -convert xml1 "#{plist}"}
        
        File.open(plist) do |file|
          file.readline
          file.readline
          doc << file.read
        end
      end
      
      FileUtils.rm_rf('/tmp/installd/unzipped')
      
      require 'net/http'
      require 'uri'
      
      @logger.info "*** Sync begins ***"
      
      username = "floehopper"
      password = "password"
      url = "http://#{username}:#{password}@installd.local/users/floehopper/installs/synchronize"
      response = Net::HTTP.post_form(URI.parse(url), { '_method' => 'put', 'doc' => doc })
      unless response.code == '200'
        raise "Unexpected response code: #{response.code}"
      end
      
      @logger.info "*** Sync ends ***"
    rescue => exception
      @logger.error exception
    end
    
    def execute(command)
      @logger.info command
      @logger.info `#{command}`
      unless $?.success?
        message = "Error executing command: #{command}"
        @logger.error message
        raise message
      end
    end
  
  end
  
end<commit_msg>Interpolate username into URL path as well as authentication credential headers.<commit_after>require 'fileutils'
require 'logger'

class Sync
  
  class << self
  
    def sync
      FileUtils.mkdir_p('/tmp/installd/')
      @logger = Logger.new('/tmp/installd/app.log')
      
      FileUtils.rm_rf('/tmp/installd/unzipped')
      FileUtils.mkdir_p('/tmp/installd/unzipped')
      
      apps_pattern = File.join(ENV['HOME'], 'Music', 'iTunes', 'Mobile Applications', '*.ipa')
      
      doc = ''
      Dir[apps_pattern].each do |app_file|
        app_name = File.basename(app_file, '.ipa')
        unzip_dir = File.join('/tmp/installd/unzipped', app_name)
        plist = File.join(unzip_dir, 'iTunesMetadata.plist')
        
        execute %{/usr/bin/unzip -d "#{unzip_dir}" "#{app_file}" iTunesMetadata.plist}
        execute %{/bin/chmod +rw "#{plist}"}
        execute %{/usr/bin/plutil -convert xml1 "#{plist}"}
        
        File.open(plist) do |file|
          file.readline
          file.readline
          doc << file.read
        end
      end
      
      FileUtils.rm_rf('/tmp/installd/unzipped')
      
      require 'net/http'
      require 'uri'
      
      @logger.info "*** Sync begins ***"
      
      username = 'floehopper'
      password = 'password'
      url = "http://#{username}:#{password}@installd.local/users/#{username}/installs/synchronize"
      response = Net::HTTP.post_form(URI.parse(url), { '_method' => 'put', 'doc' => doc })
      unless response.code == '200'
        raise "Unexpected response code: #{response.code}"
      end
      
      @logger.info "*** Sync ends ***"
    rescue => exception
      @logger.error exception
    end
    
    def execute(command)
      @logger.info command
      @logger.info `#{command}`
      unless $?.success?
        message = "Error executing command: #{command}"
        @logger.error message
        raise message
      end
    end
  
  end
  
end
{'fraction_non_alphanumeric': 0.14360587002096437, 'fraction_numerical': 0.0020964360587002098, 'mean_word_length': 2.1914715719063547, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1006381', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1227, 'n_words': 243}