<commit_before>require 'json'
require 'base64'

module StringRefinements
  # Determine if a given String is contains only a number.
  refine String do
    def number?
      /\A[-+]?\d+\z/ === self
    end
  end
end

module Lita
  module Handlers
    class Jenkins < Handler
      using StringRefinements

      class << self
        attr_accessor :jobs

        def jobs
          @jobs ||= {}
        end
      end

      def self.default_config(config)
        config.url = nil
      end

      route /j(?:enkins)? list( (.+))?/i, :jenkins_list, command: true, help: {
        'jenkins list <filter>' => 'lists Jenkins jobs'
      }

      route /j(?:enkins)? b(?:uild)? ([\w\.\-_ ]+)/i, :jenkins_build, command: true, help: {
        'jenkins b(uild) <job_id or job_name>' => 'builds the job specified by ID or name. List jobs to get ID.'
      }

      def jenkins_build(response)
        requested_job = response.matches.last.last

        job = if requested_job.number?
                jobs[requested_job.to_i - 1]
              else
                jobs.select { |j| j['name'] == requested_job }.last<commit_msg>Replace deprecated default_config method<commit_after>require 'json'
require 'base64'

module StringRefinements
  # Determine if a given String is contains only a number.
  refine String do
    def number?
      /\A[-+]?\d+\z/ === self
    end
  end
end

module Lita
  module Handlers
    class Jenkins < Handler
      using StringRefinements

      class << self
        attr_accessor :jobs

        def jobs
          @jobs ||= {}
        end
      end

      config :auth
      config :url

      route /j(?:enkins)? list( (.+))?/i, :jenkins_list, command: true, help: {
        'jenkins list <filter>' => 'lists Jenkins jobs'
      }

      route /j(?:enkins)? b(?:uild)? ([\w\.\-_ ]+)/i, :jenkins_build, command: true, help: {
        'jenkins b(uild) <job_id or job_name>' => 'builds the job specified by ID or name. List jobs to get ID.'
      }

      def jenkins_build(response)
        requested_job = response.matches.last.last

        job = if requested_job.number?
                jobs[requested_job.to_i - 1]
              else
                jobs.select { |j| j['name'] == requested_job }.last
{'fraction_non_alphanumeric': 0.12068192014356213, 'fraction_numerical': 0.0026917900403768506, 'mean_word_length': 2.0801104972375692, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '491403', 'n_tokens_mistral': 726, 'n_tokens_neox': 686, 'n_words': 211}