<commit_before>require 'bosh/dev/pipeline'
require 'bosh/stemcell/stemcell'
require 'bosh/stemcell/aws/light_stemcell'

module Bosh::Dev
  class StemcellPublisher
    def initialize(environment)
      @environment = environment
    end

    def publish
      stemcell = Bosh::Stemcell::Stemcell.new(stemcell_filename)

      publish_light_stemcell(stemcell) if environment.infrastructure == 'aws'

      Pipeline.new.publish_stemcell(stemcell)
    end

    private

    attr_reader :environment

    def publish_light_stemcell(stemcell)
      light_stemcell = Bosh::Stemcell::Aws::LightStemcell.new(stemcell)
      light_stemcell.write_archive
      light_stemcell_stemcell = Bosh::Stemcell::Stemcell.new(light_stemcell.path)

      Pipeline.new.publish_stemcell(light_stemcell_stemcell)
    end

    def stemcell_filename # FIXME: Should be returned by StemcellBuilder#micro or StemcellBuilder#basic
      @stemcell_filename ||= Dir.glob("#{environment.directory}/work/work/*.tgz").first # see: stemcell_builder/stages/stemcell/apply.sh:48
    end
  end
end
<commit_msg>Instantiate pipeline once to make it injectable<commit_after>require 'bosh/dev/pipeline'
require 'bosh/stemcell/stemcell'
require 'bosh/stemcell/aws/light_stemcell'

module Bosh::Dev
  class StemcellPublisher
    def initialize(environment)
      @environment = environment
      @pipeline = Pipeline.new
    end

    def publish
      stemcell = Bosh::Stemcell::Stemcell.new(stemcell_filename)

      publish_light_stemcell(stemcell) if environment.infrastructure == 'aws'

      pipeline.publish_stemcell(stemcell)
    end

    private

    attr_reader :environment, :pipeline

    def publish_light_stemcell(stemcell)
      light_stemcell = Bosh::Stemcell::Aws::LightStemcell.new(stemcell)
      light_stemcell.write_archive
      light_stemcell_stemcell = Bosh::Stemcell::Stemcell.new(light_stemcell.path)

      pipeline.publish_stemcell(light_stemcell_stemcell)
    end

    def stemcell_filename # FIXME: Should be returned by StemcellBuilder#micro or StemcellBuilder#basic
      @stemcell_filename ||= Dir.glob("#{environment.directory}/work/work/*.tgz").first # see: stemcell_builder/stages/stemcell/apply.sh:48
    end
  end
end

{'fraction_non_alphanumeric': 0.09004524886877828, 'fraction_numerical': 0.0018099547511312218, 'mean_word_length': 4.392682926829268, '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': '6877565', 'n_tokens_mistral': 756, 'n_tokens_neox': 691, 'n_words': 117}