<commit_before>require 'jenkins_api_client'
require 'baustelle/cloud_formation/ebenvironment'

module Baustelle
  module Jenkins
    class ApplicationJobs
      def initialize(stack_name, region, jenkins_options, environment, application, app_config, application_version_source)
        @environment = environment
        @application = application
        @jenkins_options = jenkins_options
        @app_config = app_config
        @name = stack_name
        @region = region
        @application_version_source = application_version_source
      end

      def generate_jobs
        jobs = {}
        if generate_systemtests?
          jobs.merge!(generate_systemtests)
        end
        jobs.merge!(generate_pipeline)
      end

      def identifier
        "baustelle"
      end

      def job_name_prefix
        "#{identifier}-#{@name}-#{@region}-#{@environment}-#{@application}-"
      end

      def template_file(template_type)
        {
          :systemtests => "jobs/#{@app_config['stack']}.systemtests.groovy.erb",
          :pipeline => "jobs/#{@app_config['stack']}.groovy.erb"
        }[template_type]
      end

      def generate_systemtests?
        @app_config.fetch('systemtests', false).is_a?(Hash)
      end

      private

      def generate_systemtests
        create_template(
          template_file(:systemtests)
        )
      end

      def generate_pipeline
        create_template(
          template_file(:pipeline),
          systemtest_job_name(@app_config.fetch('systemtests', {}))
        )
      end

      def systemtest_job_name(systemtests_config)
        if systemtests_config.is_a? Hash
          "#{job_name_prefix}systemtests"<commit_msg>Rename generate_systemests? to avoid confusion<commit_after>require 'jenkins_api_client'
require 'baustelle/cloud_formation/ebenvironment'

module Baustelle
  module Jenkins
    class ApplicationJobs
      def initialize(stack_name, region, jenkins_options, environment, application, app_config, application_version_source)
        @environment = environment
        @application = application
        @jenkins_options = jenkins_options
        @app_config = app_config
        @name = stack_name
        @region = region
        @application_version_source = application_version_source
      end

      def generate_jobs
        jobs = {}
        if should_generate_systemtests?
          jobs.merge!(generate_systemtests)
        end
        jobs.merge!(generate_pipeline)
      end

      def identifier
        "baustelle"
      end

      def job_name_prefix
        "#{identifier}-#{@name}-#{@region}-#{@environment}-#{@application}-"
      end

      def template_file(template_type)
        {
          :systemtests => "jobs/#{@app_config['stack']}.systemtests.groovy.erb",
          :pipeline => "jobs/#{@app_config['stack']}.groovy.erb"
        }[template_type]
      end

      def should_generate_systemtests?
        @app_config.fetch('systemtests', false).is_a?(Hash)
      end

      private

      def generate_systemtests
        create_template(
          template_file(:systemtests)
        )
      end

      def generate_pipeline
        create_template(
          template_file(:pipeline),
          systemtest_job_name(@app_config.fetch('systemtests', {}))
        )
      end

      def systemtest_job_name(systemtests_config)
        if systemtests_config.is_a? Hash
          "#{job_name_prefix}systemtests"
{'fraction_non_alphanumeric': 0.09037730330505996, 'fraction_numerical': 0.0, 'mean_word_length': 2.5662148070907196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '349183', 'n_tokens_mistral': 968, 'n_tokens_neox': 957, 'n_words': 165}