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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6c8858a8db9e8092584a772dfaf14f37ea992f5281a88419f42873f6ee2557
4
- data.tar.gz: 1e0e8b6db1a0b3184f1141dd38891fc2c628b28f53edfedd7013c84657bed6ce
3
+ metadata.gz: 5595a21634c9c54723c5e357e923e9c87c312a98005bb959dc98d8b69ad58480
4
+ data.tar.gz: 8da08b627f45ab3f25dbac74915c3a844b45270c5cfd3b742eb95b0287de0a50
5
5
  SHA512:
6
- metadata.gz: e2f147ba4df73785325b7f7f316cfc21419b2cd79cb4cf7daa3c58a2f909c5ada95d99c566b5d7759b50d518491b96d1389e2c5fde0e78b584932f6fab2c917b
7
- data.tar.gz: dab721a833b6afb441ec26ea881fed1975d65fd33a27843c9dbf236b6d1d2114ecccce1d1b848d01f0e03325352ed0b8819cd3b5612c72f2a4ca8a2a0619e8e2
6
+ metadata.gz: ee0fdb300976264a9dd98dc25f1a73d9cd5f5258e1d272c327fd1bb51fe66d9c79d913192f3ac18a541972d5ba8469f2db62b6cea486babef8400a62b831800c
7
+ data.tar.gz: 64092e8dd171c15f40b202fd6849aed0b85ef1fa973f4257410a374bb0339ff29d546f54eb3b5021bd2aa223f0caa8f813e2f1d0926c1035d7d5afed3adf042b
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module String::Text
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
5
5
  end
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. If the first line is not indented the minimal
65
- # indent is 0, otherwise the smallest non-zero indent used
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|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string-text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen