string-text 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/string-text/version.rb +1 -1
- data/lib/string-text.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5595a21634c9c54723c5e357e923e9c87c312a98005bb959dc98d8b69ad58480
|
4
|
+
data.tar.gz: 8da08b627f45ab3f25dbac74915c3a844b45270c5cfd3b742eb95b0287de0a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee0fdb300976264a9dd98dc25f1a73d9cd5f5258e1d272c327fd1bb51fe66d9c79d913192f3ac18a541972d5ba8469f2db62b6cea486babef8400a62b831800c
|
7
|
+
data.tar.gz: 64092e8dd171c15f40b202fd6849aed0b85ef1fa973f4257410a374bb0339ff29d546f54eb3b5021bd2aa223f0caa8f813e2f1d0926c1035d7d5afed3adf042b
|
data/lib/string-text/version.rb
CHANGED
data/lib/string-text.rb
CHANGED
@@ -58,12 +58,16 @@ module String::Text
|
|
58
58
|
lines.shift while !lines.empty? && !(lines.first =~ /^\s*\S/)
|
59
59
|
return "" if lines.empty?
|
60
60
|
|
61
|
+
# Only align to given column if first line is not indented
|
62
|
+
if String::Text.indentation(lines.first) == 0
|
63
|
+
return lines.map { |line| ' ' * (column-1) + line }.join("\n")
|
64
|
+
end
|
65
|
+
|
61
66
|
# Identation level of each line
|
62
67
|
indents = lines.map { String::Text.indentation(_1) }
|
63
68
|
|
64
|
-
# Find minimal indent
|
65
|
-
|
66
|
-
indent = String::Text.indentation(lines.first) == 0 ? 0 : indents.select { _1 > 0 }.min || 0
|
69
|
+
# Find minimal indent, ignoring unindented lines
|
70
|
+
indent = indents.select { _1 > 0 }.min || 0
|
67
71
|
|
68
72
|
first = true
|
69
73
|
lines.map.with_index { |line, i|
|