<commit_before>module Onebox
  module Engine
    class GithubCommitOnebox
      include Engine
      include JSON

      matches do
        http
        maybe("www.")
        domain("github")
        tld("com")
        anything
        with("/commit/")
      end

      def url
        "https://api.github.com/repos/#{match[:owner]}/#{match[:repo]}/commits/#{match[:number]}"
      end

      private

      def match
        @url.match(/github\.com\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/commit\/(?<number>[^\/]+)/)
      end

      def data
        {
          url: @url,
          owner: match[:owner],
          repo: match[:repo],
          sha: raw["sha"],
          gravatar: raw["author"]["avatar_url"],
          message: raw["commit"]["message"],
          author: raw["author"]["login"],
          time_date: raw["commit"]["committer"]["date"],<commit_msg>We want to memoize the match result to improve performance<commit_after>module Onebox
  module Engine
    class GithubCommitOnebox
      include Engine
      include JSON

      matches do
        http
        maybe("www.")
        domain("github")
        tld("com")
        anything
        with("/commit/")
      end

      def url
        "https://api.github.com/repos/#{match[:owner]}/#{match[:repo]}/commits/#{match[:number]}"
      end

      private

      def match
        @match ||= @url.match(/github\.com\/(?<owner>[^\/]+)\/(?<repo>[^\/]+)\/commit\/(?<number>[^\/]+)/)
      end

      def data
        {
          url: @url,
          owner: match[:owner],
          repo: match[:repo],
          sha: raw["sha"],
          gravatar: raw["author"]["avatar_url"],
          message: raw["commit"]["message"],
          author: raw["author"]["login"],
          time_date: raw["commit"]["committer"]["date"],
{'fraction_non_alphanumeric': 0.18721973094170405, 'fraction_numerical': 0.0, 'mean_word_length': 1.9166666666666667, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '119989', 'n_tokens_mistral': 535, 'n_tokens_neox': 538, 'n_words': 101}