<commit_before>(ns adzerk.boot-reload.server
  (:require
   [clojure.java.io    :as io]
   [boot.util          :as util]
   [org.httpkit.server :as http]
   [clojure.string     :as string])
  (:import
   [java.io IOException]))

(def options (atom {:open-file nil}))
(def clients (atom {}))

(defn set-options [opts]
  (reset! options opts))

(defn web-path
  ([rel-path] (web-path {} rel-path))
  ([opts rel-path]
   ; windows fix, convert \ characters to / in rel-path
   (let [rel-path (string/replace rel-path #"\\" "/")
         {:keys [protocol target-path asset-path cljs-asset-path]} opts]
     (if (= "file:" protocol)
       (.getCanonicalPath (io/file target-path rel-path))
       (str
        (if cljs-asset-path (str cljs-asset-path "/") "")
        (string/replace rel-path
                        (re-pattern (str "^" (string/replace (or asset-path "") #"^/" "") "/"))
                        ""))))))

(defn send-visual! [messages]
  (doseq [[channel _] @clients]
    (http/send! channel (pr-str (merge {:type :visual}
                                       messages)))))

(defn send-changed!
  ([changed] (send-changed! {} changed))
  ([opts changed]
   (doseq [[channel {:keys [protocol]}] @clients]
     (http/send! channel
                 (pr-str {:type :reload
                          :files (map #(web-path (assoc opts :protocol protocol) %) changed)})))))

(defmulti handle-message (fn [channel message] (:type message)))
<commit_msg>make sure slash is present by default<commit_after>(ns adzerk.boot-reload.server
  (:require
   [clojure.java.io    :as io]
   [boot.util          :as util]
   [org.httpkit.server :as http]
   [clojure.string     :as string])
  (:import
   [java.io IOException]))

(def options (atom {:open-file nil}))
(def clients (atom {}))

(defn set-options [opts]
  (reset! options opts))

(defn web-path
  ([rel-path] (web-path {} rel-path))
  ([opts rel-path]
   ; windows fix, convert \ characters to / in rel-path
   (let [rel-path (string/replace rel-path #"\\" "/")
         {:keys [protocol target-path asset-path cljs-asset-path]} opts]
     (if (= "file:" protocol)
       (.getCanonicalPath (io/file target-path rel-path))
       (str
        cljs-asset-path "/"
        (string/replace rel-path
                        (re-pattern (str "^" (string/replace (or asset-path "") #"^/" "") "/"))
                        ""))))))

(defn send-visual! [messages]
  (doseq [[channel _] @clients]
    (http/send! channel (pr-str (merge {:type :visual}
                                       messages)))))

(defn send-changed!
  ([changed] (send-changed! {} changed))
  ([opts changed]
   (doseq [[channel {:keys [protocol]}] @clients]
     (http/send! channel
                 (pr-str {:type :reload
                          :files (map #(web-path (assoc opts :protocol protocol) %) changed)})))))

(defmulti handle-message (fn [channel message] (:type message)))

{'fraction_non_alphanumeric': 0.17421124828532236, 'fraction_numerical': 0.0, 'mean_word_length': 2.3185437997724687, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4420046', 'n_tokens_mistral': 975, 'n_tokens_neox': 925, 'n_words': 243}