string-text 0.1.0 → 0.2.0
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/TODO +12 -0
- data/lib/string-text/version.rb +1 -1
- data/lib/string-text.rb +17 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d954b59921214f791a82b0e1d07eb5ff770005d512fbdf231eb9e0d8c5ff7d3
|
4
|
+
data.tar.gz: 79350075e64dd1277b5a2b5610b8df9fb7c05a3e64ea90c1c4e5a6460e2f4471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18c9a7a0ed48c3ab51257983bb245a5087770594bbd9d20e283611846a6fce42f52af5976ef8157e572e0b6f772aa3746b321ea5d2968cfc28776775d77ae055
|
7
|
+
data.tar.gz: 037437d4642ac34a171127bce254162d230437047870847216322eed0be5b3269a6242a55f5cc00c0fe453cedb710a35874413693be8f22e8e1ff39da229075c
|
data/TODO
ADDED
data/lib/string-text/version.rb
CHANGED
data/lib/string-text.rb
CHANGED
@@ -6,7 +6,20 @@ module String::Text
|
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
8
|
refine String do
|
9
|
-
|
9
|
+
# Indent or outdent a block of text to the given column. It uses the indent
|
10
|
+
# of the non-empty line as the indent of the whole block that is then
|
11
|
+
# aligned as a whole (including internal indents) to the given column
|
12
|
+
#
|
13
|
+
# It is often handy when you're calling methods with a %(...) argument and
|
14
|
+
# don't want weird indentation in your output
|
15
|
+
#
|
16
|
+
# puts %(
|
17
|
+
# This line will start at column 1
|
18
|
+
# This line will start at column 3
|
19
|
+
# ).align
|
20
|
+
#
|
21
|
+
def align(column = 1)
|
22
|
+
column == 1 or raise NotImplementedError
|
10
23
|
lines = self.split(/\n/)
|
11
24
|
lines.shift while !lines.empty? && !(lines.first =~ /^(\s*)\S/)
|
12
25
|
return "" if lines.empty?
|
@@ -21,8 +34,9 @@ module String::Text
|
|
21
34
|
r.join("\n").chomp
|
22
35
|
end
|
23
36
|
|
24
|
-
# Converts a string to a boolean so that "true" becomes true and
|
25
|
-
# the empty string becomes false.
|
37
|
+
# Converts a string to a boolean so that "true" becomes true and that
|
38
|
+
# "false" and the empty string becomes false. Any other string is an error
|
39
|
+
#
|
26
40
|
def to_b
|
27
41
|
case self
|
28
42
|
when "true"; true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Gem string-text
|
14
14
|
email:
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- Gemfile
|
23
23
|
- README.md
|
24
24
|
- Rakefile
|
25
|
+
- TODO
|
25
26
|
- lib/string-text.rb
|
26
27
|
- lib/string-text/version.rb
|
27
28
|
- sig/string_text.rbs
|