<commit_before>require 'rubygems'
require 'json'

module TachikomaAi
  module Strategies
    class Bundler
      class Gem
        STRING_PATTERN = /[-|\+]\s+(\S+)\s\((.+?)\)/
        major, minor = RUBY_VERSION.split('.')
        SPECS_PATH = "vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
        URLS = JSON.parse(File.read(File.expand_path('urls.json', __dir__)))

        attr_reader :name, :version
        attr_accessor :from

        def self.parse(s)
          m = s.match STRING_PATTERN
          new m[1], m[2]
        end

        def initialize(name, version)
          @name = name
          @version = version
        end

        def github_url?
          !github_url.nil?
        end

        def github_url
          if URLS.key?(name)
            URLS[name]
          elsif homepage && homepage.include?('github')
            homepage
          end
        end

        def homepage
          @homepage ||= if spec
                          spec.homepage
                        else
                          "#{name}-#{version}"
                        end
        end

        def compare_url
          Repository.new(github_url).compare(from, version)
        end

        private

        def spec
          ::Gem::Specification.load(spec_path)
        end

        def spec_path
          "#{SPECS_PATH}/#{name}-#{version}.gemspec"
        end
      end
    end
  end
end
<commit_msg>:recycle: Simplify<commit_after>require 'rubygems'
require 'json'

module TachikomaAi
  module Strategies
    class Bundler
      class Gem
        STRING_PATTERN = /[-|\+]\s+(\S+)\s\((.+?)\)/
        major, minor = RUBY_VERSION.split('.')
        SPECS_PATH = "vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
        URLS = JSON.parse(File.read(File.expand_path('urls.json', __dir__)))

        attr_reader :name, :version
        attr_accessor :from

        def self.parse(s)
          m = s.match STRING_PATTERN
          new m[1], m[2]
        end

        def initialize(name, version)
          @name = name
          @version = version
        end

        def github_url?
          !github_url.nil?
        end

        def github_url
          if URLS.key?(name)
            URLS[name]
          elsif homepage.include?('github.com')
            homepage
          end
        end

        def homepage
          @homepage ||= if spec
                          spec.homepage
                        else
                          "#{name}-#{version}"
                        end
        end

        def compare_url
          Repository.new(github_url).compare(from, version)
        end

        private

        def spec
          ::Gem::Specification.load(spec_path)
        end

        def spec_path
          "#{SPECS_PATH}/#{name}-#{version}.gemspec"
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10705510705510705, 'fraction_numerical': 0.002106002106002106, 'mean_word_length': 1.388935456831517, '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': '1777166', 'n_tokens_mistral': 867, 'n_tokens_neox': 834, 'n_words': 174}