<commit_before>require "./base"
require "./semantic_version"
require "xml"
require "http/request"

module Depwatcher
  class JRuby < Base
    class Release
      JSON.mapping(
        ref: String,
        url: String,
        sha256: String,
      )
      def initialize(@ref : String, @url : String, @sha256 : String)
      end
    end

    private def get_versions() : Array(String)
      response = client.get("http://jruby.org/download").body
      doc = XML.parse_html(response)
      elements = doc.xpath_nodes("//a[starts-with(@href,'https://repo1.maven.org/maven2/org/jruby/jruby-dist/')]")
      elements.map { |e|
        m = /https:\/\/repo1.maven.org\/maven2\/org\/jruby\/jruby-dist\/([\d.]+)\/jruby-dist-([\d.]+)-src.zip/.match(e["href"])
        if !m.nil?
          m[1]
        end
      }.compact.uniq
    end

    def check() : Array(Internal)
      get_versions.map { |v|
        Internal.new(v)
      }.sort_by { |i| SemanticVersion.new(i.ref) }
    end

    def in(ref : String) : Release
      sha = client.get("https://s3.amazonaws.com/jruby.org/downloads/#{ref}/jruby-src-#{ref}.tar.gz.sha256").body.strip<commit_msg>Fix jruby depwatcher check URL<commit_after>require "./base"
require "./semantic_version"
require "xml"
require "http/request"

module Depwatcher
  class JRuby < Base
    class Release
      JSON.mapping(
        ref: String,
        url: String,
        sha256: String,
      )
      def initialize(@ref : String, @url : String, @sha256 : String)
      end
    end

    private def get_versions() : Array(String)
      response = client.get("https://www.jruby.org/download").body
      doc = XML.parse_html(response)
      elements = doc.xpath_nodes("//a[starts-with(@href,'https://repo1.maven.org/maven2/org/jruby/jruby-dist/')]")
      elements.map { |e|
        m = /https:\/\/repo1.maven.org\/maven2\/org\/jruby\/jruby-dist\/([\d.]+)\/jruby-dist-([\d.]+)-src.zip/.match(e["href"])
        if !m.nil?
          m[1]
        end
      }.compact.uniq
    end

    def check() : Array(Internal)
      get_versions.map { |v|
        Internal.new(v)
      }.sort_by { |i| SemanticVersion.new(i.ref) }
    end

    def in(ref : String) : Release
      sha = client.get("https://s3.amazonaws.com/jruby.org/downloads/#{ref}/jruby-src-#{ref}.tar.gz.sha256").body.strip
{'fraction_non_alphanumeric': 0.1740451388888889, 'fraction_numerical': 0.013020833333333334, 'mean_word_length': 2.3698830409356724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6532162', 'n_tokens_mistral': 853, 'n_tokens_neox': 801, 'n_words': 137}