<commit_before>require 'rack/livereload'
require 'em-websocket'
require 'multi_json'

module Middleman
  module LiveReload
    class << self
      def registered(app, options={})
        options = {
          :api_version => '1.6',
          :host => '0.0.0.0',
          :port => '35729',
          :apply_js_live => true,
          :apply_css_live => true,
          :grace_period => 0
        }.merge(options)

        app.ready do
          # Doesn't make sense in build
          if environment == :build
            reactor = Reactor.new(options)

            files.changed { |file| reactor.reload_browser(file) }
            files.deleted { |file| reactor.reload_browser(file) }

            use ::Rack::LiveReload
          end
        end
      end
      alias :included :registered
    end

    class Reactor
      attr_reader :thread, :web_sockets

      def initialize(options)
        @web_sockets = []
        @options     = options
        @thread      = start_threaded_reactor(options)
      end

      def stop
        thread.kill
      end

      def reload_browser(paths = [])
        paths = Array(paths)
        puts "Reloading browser: #{paths.join(' ')}"<commit_msg>Incorrectly recreated previous patch<commit_after>require 'rack/livereload'
require 'em-websocket'
require 'multi_json'

module Middleman
  module LiveReload
    class << self
      def registered(app, options={})
        options = {
          :api_version => '1.6',
          :host => '0.0.0.0',
          :port => '35729',
          :apply_js_live => true,
          :apply_css_live => true,
          :grace_period => 0
        }.merge(options)

        app.ready do
          # Doesn't make sense in build
          if environment != :build
            reactor = Reactor.new(options)

            files.changed { |file| reactor.reload_browser(file) }
            files.deleted { |file| reactor.reload_browser(file) }

            use ::Rack::LiveReload
          end
        end
      end
      alias :included :registered
    end

    class Reactor
      attr_reader :thread, :web_sockets

      def initialize(options)
        @web_sockets = []
        @options     = options
        @thread      = start_threaded_reactor(options)
      end

      def stop
        thread.kill
      end

      def reload_browser(paths = [])
        paths = Array(paths)
        puts "Reloading browser: #{paths.join(' ')}"
{'fraction_non_alphanumeric': 0.10412328196584757, 'fraction_numerical': 0.009995835068721367, 'mean_word_length': 1.8325471698113207, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4922793', 'n_tokens_mistral': 733, 'n_tokens_neox': 692, 'n_words': 165}