Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
updating def sources
Browse files Browse the repository at this point in the history
  • Loading branch information
rksm committed Mar 21, 2015
1 parent a90c7cd commit e321244
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/rksm/cloxp_source_reader/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,18 @@
; sym-fn (partial symbol ns-string)
; source-fn #(or (source-for-symbol (sym-fn (-> % :name str))) "")]
; (map #(assoc % :source (source-fn %)) intern-meta-data)))

; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

(defn updated-source
"Takes the new source for a def and produces a new version of the ns source,
with the new def code embedded. meta-info is a meta-data like structure."
[sym {:keys [line] :as meta-info} new-src-for-def old-src-for-def file-src]
(let [lines (s/split-lines file-src)
line (dec line)
before-lines (take line lines)
after-lines (-> old-src-for-def
s/trim-newline
s/split-lines count
(drop (drop line lines)))]
(str (s/join "\n" (concat before-lines [(s/trim-newline new-src-for-def)] after-lines)))))

0 comments on commit e321244

Please sign in to comment.