<commit_before>(ns yada.resources.misc
  (:require
   [clj-time.core :refer [now]]
   [clj-time.coerce :refer [to-date]]
   [yada.protocols :as p]
   [yada.methods :refer [Get Put Post Delete Options]]))

(defrecord JustMethods []
  p/ResourceProperties
  (resource-properties [this]
    {:allowed-methods (keys this)
     :parameters (reduce-kv (fn [acc k v]
                              (assoc acc k (:parameters v))) {} this)
     :representations [{:media-type #{"text/plain"}}]})
  (resource-properties [_ ctx]
    {:last-modified (to-date (now))})

  Get
  (GET [this ctx]
    (get-in this [:get :response]))

  Put
  (PUT [this ctx]
    (get-in this [:put :response]))

  Post
  (POST [this ctx]
    (get-in this [:post :response]))

  Delete
  (DELETE [this ctx]
    (get-in this [:delete :response]))

  Options
  (OPTIONS [this ctx]
    (get-in this [:options :response])))

(defn just-methods [& {:as args}]
  (map->JustMethods args))<commit_msg>Only associate parameters when not nil<commit_after>(ns yada.resources.misc
  (:require
   [clj-time.core :refer [now]]
   [clj-time.coerce :refer [to-date]]
   [yada.protocols :as p]
   [yada.methods :refer [Get Put Post Delete Options]]))

(defrecord JustMethods []
  p/ResourceProperties
  (resource-properties [this]
    {:allowed-methods (keys this)
     :parameters (reduce-kv (fn [acc k v]
                              (cond-> acc (:parameters v)
                                      (assoc k (:parameters v))))
                            {} this)
     :representations [{:media-type #{"text/plain"}}]})
  (resource-properties [_ ctx]
    {:last-modified (to-date (now))})

  Get
  (GET [this ctx]
    (get-in this [:get :response]))

  Put
  (PUT [this ctx]
    (get-in this [:put :response]))

  Post
  (POST [this ctx]
    (get-in this [:post :response]))

  Delete
  (DELETE [this ctx]
    (get-in this [:delete :response]))

  Options
  (OPTIONS [this ctx]
    (get-in this [:options :response])))

(defn just-methods [& {:as args}]
  (map->JustMethods args))
{'fraction_non_alphanumeric': 0.16190944881889763, 'fraction_numerical': 0.0, 'mean_word_length': 2.6829710144927534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1655176', 'n_tokens_mistral': 707, 'n_tokens_neox': 686, 'n_words': 193}