<commit_before>require 'fileutils'
require 'tmpdir'
require 'bosh/director'

module Bosh::Director
  class CompiledReleaseDownloader
    def initialize(compiled_packages_group, templates, blobstore_client)
      @compiled_packages_group = compiled_packages_group
      @templates = templates
      @blobstore_client = blobstore_client
    end

    def download
      @download_dir = Dir.mktmpdir

      path = File.join(@download_dir, 'compiled_packages')
      FileUtils.mkpath(path)

      compiled_packages = @compiled_packages_group.compiled_packages
      event_log.begin_stage("copying packages", compiled_packages.size)

      compiled_packages.each do |compiled_package|
        desc = "#{compiled_package.package.name}/#{compiled_package.package.version}"
        event_log.track(desc) do
          blobstore_id = compiled_package.blobstore_id
          File.open(File.join(path, "#{compiled_package.package.name}.tgz"), 'w') do |f|
            @blobstore_client.get(blobstore_id, f, sha1: compiled_package.sha1)
          end
        end
      end

      path = File.join(@download_dir, 'jobs')
      FileUtils.mkpath(path)

      event_log.begin_stage("copying jobs", @templates.size)
      @templates.each do |template|<commit_msg>fix the how the size of the templates and packages are calculated to make it work with ruby 1.9<commit_after>require 'fileutils'
require 'tmpdir'
require 'bosh/director'

module Bosh::Director
  class CompiledReleaseDownloader
    def initialize(compiled_packages_group, templates, blobstore_client)
      @compiled_packages_group = compiled_packages_group
      @templates = templates
      @blobstore_client = blobstore_client
    end

    def download
      @download_dir = Dir.mktmpdir

      path = File.join(@download_dir, 'compiled_packages')
      FileUtils.mkpath(path)

      compiled_packages = @compiled_packages_group.compiled_packages
      event_log.begin_stage("copying packages", compiled_packages.count)

      compiled_packages.each do |compiled_package|
        desc = "#{compiled_package.package.name}/#{compiled_package.package.version}"
        event_log.track(desc) do
          blobstore_id = compiled_package.blobstore_id
          File.open(File.join(path, "#{compiled_package.package.name}.tgz"), 'w') do |f|
            @blobstore_client.get(blobstore_id, f, sha1: compiled_package.sha1)
          end
        end
      end

      path = File.join(@download_dir, 'jobs')
      FileUtils.mkpath(path)

      event_log.begin_stage("copying jobs", @templates.count)
      @templates.each do |template|
{'fraction_non_alphanumeric': 0.09299610894941635, 'fraction_numerical': 0.0023346303501945525, 'mean_word_length': 3.574733096085409, '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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6344752', 'n_tokens_mistral': 777, 'n_tokens_neox': 737, 'n_words': 147}