summaryrefslogtreecommitdiff
path: root/Resources/DefaultContent/Libraries/inspect/spec/unindent.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-26 11:32:46 +0800
committerchai <chaifix@163.com>2021-10-26 11:32:46 +0800
commit0549b1e5a8a3132005e275d6026db8003cb067d2 (patch)
treef0d7751ec32ecf5c4d23997fa0ffd3450a5a755a /Resources/DefaultContent/Libraries/inspect/spec/unindent.lua
parent32345800737b668011a87328cd3dcce59ec2934c (diff)
*rename folder
Diffstat (limited to 'Resources/DefaultContent/Libraries/inspect/spec/unindent.lua')
-rw-r--r--Resources/DefaultContent/Libraries/inspect/spec/unindent.lua39
1 files changed, 0 insertions, 39 deletions
diff --git a/Resources/DefaultContent/Libraries/inspect/spec/unindent.lua b/Resources/DefaultContent/Libraries/inspect/spec/unindent.lua
deleted file mode 100644
index 02324a1..0000000
--- a/Resources/DefaultContent/Libraries/inspect/spec/unindent.lua
+++ /dev/null
@@ -1,39 +0,0 @@
--- Unindenting transforms a string like this:
--- [[
--- {
--- foo = 1,
--- bar = 2
--- }
--- ]]
---
--- Into the same one without indentation, nor start/end newlines
---
--- [[{
--- foo = 1,
--- bar = 2
--- }]]
---
--- This makes the strings look and read better in the tests
---
-
-local getIndentPreffix = function(str)
- local level = math.huge
- local minPreffix = ""
- local len
- for preffix in str:gmatch("\n( +)") do
- len = #preffix
- if len < level then
- level = len
- minPreffix = preffix
- end
- end
- return minPreffix
-end
-
-local unindent = function(str)
- str = str:gsub(" +$", ""):gsub("^ +", "") -- remove spaces at start and end
- local preffix = getIndentPreffix(str)
- return (str:gsub("\n" .. preffix, "\n"):gsub("\n$", ""))
-end
-
-return unindent