<commit_before>require 'httparty'

module WebNotifier
  class HttpMonitor
    UrlRequiredException = Class.new(StandardError)

    attr_reader :url, :notifier, :content, :http_client
    attr_accessor :content

    def initialize(
      url: nil, http_client: HTTParty, notifier: MacOSNotifier.new
    )
      raise UrlRequiredException if url.nil?
      @url = url
      @http_client = http_client
      @notifier = notifier
    end

    def notify
      notifier.notify if content_changed?
    end

    def content_changed?
      old_content = @content
      @content = fetch_content
      old_content != @content
    end

    def fetch_content
      http_client.get(url).body
    end
  end

  class MacOSNotifier
  end
end
<commit_msg>Add monitor method for active monitoring<commit_after>require 'httparty'

module WebNotifier
  class HttpMonitor
    UrlRequiredException = Class.new(StandardError)

    attr_reader :url, :notifier, :content, :http_client, :interval
    attr_accessor :content

    def initialize(
      url: nil, http_client: HTTParty, notifier: MacOSNotifier.new, interval: 1
    )
      raise UrlRequiredException if url.nil?
      @url = url
      @http_client = http_client
      @notifier = notifier
      @interval = interval
    end

    def monitor
      while true
        notify
        sleep interval
      end
    end

    def notify
      notifier.notify if content_changed?
    end

    def content_changed?
      old_content = @content
      @content = fetch_content
      old_content != @content
    end

    def fetch_content
      http_client.get(url).body
    end
  end

  class MacOSNotifier
  end
end

{'fraction_non_alphanumeric': 0.06082725060827251, 'fraction_numerical': 0.0006082725060827251, 'mean_word_length': 2.6233480176211454, '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': '3288622', 'n_tokens_mistral': 500, 'n_tokens_neox': 483, 'n_words': 135}