<commit_before>class JenkinsXmlPayload < Payload

  def initialize(build_name)
    super()
    @build_name = build_name
  end

  def building?
    selector = XPath.descendant(:project)[XPath.attr(:name) == @build_name.downcase].to_s
    p_element = build_status_content.xpath selector
    p_element.present? && p_element.attribute('activity').value == 'building'
  end

  private

  def convert_content!(content)
    parsed_content = parse_content(content.downcase)
    parsed_content.css('feed entry').to_a
  end

  def convert_build_content!(content)
    parse_content(content)
  end

  def parse_content(content)
    parsed_content = Nokogiri::XML.parse(content.downcase)
    if parsed_content.root
      return parsed_content
    else
      raise Payload::InvalidContentException, "Error parsing content for build name #{@build_name}"
      self.processable = false
    end
  end

  def parse_success(content)
    if (title = content.css('title')).present?
      !!(title.first.content.downcase =~ /success|stable|back to normal/)
    end
  end

  def parse_url(content)
    if link = content.css('link').first
      link.attribute('href').value
    end
  end

  def parse_build_id(content)
    if url = parse_url(content)
      url.split('/').last
    end
  end

  def parse_published_at(content)
    pub_date = Time.parse(content.css('published').first.content)
    (pub_date == Time.at(0) ? Time.now : pub_date).localtime
  end

end
<commit_msg>add content ready to jenkins xml payload<commit_after>class JenkinsXmlPayload < Payload

  def initialize(build_name)
    super()
    @build_name = build_name
  end

  def building?
    selector = XPath.descendant(:project)[XPath.attr(:name) == @build_name.downcase].to_s
    p_element = build_status_content.xpath selector
    p_element.present? && p_element.attribute('activity').value == 'building'
  end

  private

  def content_ready?(content)
    content.css('title').present?
  end

  def convert_content!(content)
    parsed_content = parse_content(content.downcase)
    parsed_content.css('feed entry').to_a
  end

  def convert_build_content!(content)
    parse_content(content)
  end

  def parse_content(content)
    parsed_content = Nokogiri::XML.parse(content.downcase)
    if parsed_content.root
      return parsed_content
    else
      raise Payload::InvalidContentException, "Error parsing content for build name #{@build_name}"
      self.processable = false
    end
  end

  def parse_success(content)
    !!(content.css('title').first.content.downcase =~ /success|stable|back to normal/)
  end

  def parse_url(content)
    if link = content.css('link').first
      link.attribute('href').value
    end
  end

  def parse_build_id(content)
    if url = parse_url(content)
      url.split('/').last
    end
  end

  def parse_published_at(content)
    pub_date = Time.parse(content.css('published').first.content)
    (pub_date == Time.at(0) ? Time.now : pub_date).localtime
  end

end

{'fraction_non_alphanumeric': 0.10844594594594595, 'fraction_numerical': 0.0006756756756756757, 'mean_word_length': 3.714968152866242, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '1864499', 'n_tokens_mistral': 947, 'n_tokens_neox': 929, 'n_words': 190}