-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
77 lines (68 loc) · 2.44 KB
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
(ns derivative.core
(:refer-clojure :exclude [derive])
(:require
[derivative.transformations.core :refer [apply-transformation]]
[derivative.transformations.find-and-replace]))
(defn derive [pipeline options]
(let [transformation (first pipeline)]
(apply-transformation transformation options)))
; validate configuration
; load tree of sources
; assemble plan of changes
; transform tree to targets
; write targets
; scope: file, line, word, character, ast, ...
; may help to optimise streaming nature
; terminology:
; definition - a type of operation to be performed
; type: the identifier for this definition
; scope: the unit to operate on,
; e.g., directory, file, line, word, character, ast
; configuration-spec: spec for the permitted configuration object
; transformation - an instance of a definition, concretely configured
; configuration:
; pipeline - a set of transformations to be applied sequentially
; steps:
; derivation - an application of a pipeline to a directory of files
; pipeline:
; source-directory:
; target-directory:
; variables
; should be able to provide variables for use in transformations
; find-and-replace
; acts on content of matching files
; looks for find, could be string or regex
; replaces with replace, can interpolate match groups
; limit to between points in file?
; allow replace to point to a file?
; replace in replace template?
; copy-files
; recursively copies files from source directory to target directory
; takes inclusion, exclusion paths / matchers, one or more
; able to transform names on the way
; move-files
; recursively moves files from source directory to target directory
; takes inclusion, exclusion paths / matchers, one or more
; able to transform names on the way
; insert-at-point
; delete-at-point
;
; insert-syntax
; delete-syntax
; potentially build an overlay filesystem
; overall we are transforming the file system
; multiple ways we can do this
; path-transformation:
; creating files/directories,
; deleting files/directories,
; copying files/directories,
; moving files/directories
; content-transformation:
; replacing or updating the contents of files
; stages:
; determine all paths affected by each transformation:
; not trivial as some transformations introduce new paths
; potentially each transformation can return the paths it:
; creates
; deletes
; modifies