cli-dispatcher 1.2.2 → 1.2.4
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/structured.rb +2 -2
- data/lib/texttools.rb +29 -7
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f480b01f8af6a9af5c131e3e25081edd7e69fff4caf3daa22ea10efbc49b4f4
|
4
|
+
data.tar.gz: 2eea3e4b6791f4babe182b56c15607b7fa5eb532106c00505fb26b8b0ee0f0d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ea432b818502f65c048a0911aef575b42ed17d2cff7e42f97382f5b3f6ce77e8cf52964f9ca43eb85b467c4f3a67bcc957a14d51b82b5fe37ff120524f03a9
|
7
|
+
data.tar.gz: 9e5dbff959cc60f44ebadf445cb3257fea82403c2db4f053a7f241deb0f7a290cc5b5f02e3810e8ca48ba5ea16893765cfbe8e73c8b7f73b12c7462004b56ef7
|
data/lib/structured.rb
CHANGED
@@ -561,7 +561,7 @@ module Structured
|
|
561
561
|
# returned, and processing should also stop.
|
562
562
|
#
|
563
563
|
def process_nil_val(val, data)
|
564
|
-
return [ val, false ]
|
564
|
+
return [ val, false ] unless val.nil?
|
565
565
|
unless data[:optional]
|
566
566
|
input_err("Required element is missing (or was deleted by a preproc)")
|
567
567
|
end
|
@@ -779,7 +779,7 @@ module Structured
|
|
779
779
|
# @param indent The indent string before new lines.
|
780
780
|
# @param sp Spacing after the colon, if any.
|
781
781
|
def template_type(type, indent, sp = ' ')
|
782
|
-
res = ''
|
782
|
+
res = String.new('')
|
783
783
|
case type
|
784
784
|
when :boolean
|
785
785
|
res << " true/false\n"
|
data/lib/texttools.rb
CHANGED
@@ -11,17 +11,41 @@ module TextTools
|
|
11
11
|
def line_break(
|
12
12
|
text, len: 80, prefix: '', first_prefix: nil, preserve_lines: false
|
13
13
|
)
|
14
|
-
res = ''
|
14
|
+
res = String.new('')
|
15
|
+
|
16
|
+
#
|
17
|
+
# Remove single paragraph breaks (unless preserve_lines is on). After this,
|
18
|
+
# every paragraph break should be preserved. Also remove trailing
|
19
|
+
# whitespace, which causes problems.
|
20
|
+
#
|
15
21
|
text = text.split(/\s*\n\s*\n\s*/).map { |para|
|
16
22
|
preserve_lines ? para : para.gsub(/\s*\n\s*/, " ")
|
17
|
-
}.join("\n\n")
|
23
|
+
}.join("\n\n").rstrip
|
18
24
|
|
19
25
|
cur_prefix = first_prefix || prefix
|
26
|
+
|
27
|
+
# Process each individual line separately.
|
28
|
+
while (line_match = /\s*\n\s*/.match(text))
|
29
|
+
res << one_line_break(line_match.pre_match, len, cur_prefix, prefix)
|
30
|
+
res << line_match[0].gsub(/[^\n]/, '')
|
31
|
+
cur_prefix = prefix
|
32
|
+
text = line_match.post_match
|
33
|
+
end
|
34
|
+
res << one_line_break(text, len, cur_prefix, prefix)
|
35
|
+
return res
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# Line break a text that is guaranteed not to have any line breaks within it.
|
41
|
+
#
|
42
|
+
def one_line_break(text, len, first_prefix, prefix)
|
43
|
+
res = String.new('')
|
44
|
+
cur_prefix = first_prefix
|
20
45
|
strlen = len - cur_prefix.length
|
21
46
|
while text.length > strlen
|
22
|
-
if (m = /\A(
|
23
|
-
res << cur_prefix + m[1]
|
24
|
-
res << (m[2].include?("\n") ? m[2].gsub(/[^\n]/, '') : "\n")
|
47
|
+
if (m = /\A(.{0,#{strlen}})(\s+)/.match(text))
|
48
|
+
res << cur_prefix + m[1] + "\n"
|
25
49
|
text = m.post_match
|
26
50
|
else
|
27
51
|
res << cur_prefix + text[0, strlen] + "\n"
|
@@ -31,8 +55,6 @@ module TextTools
|
|
31
55
|
strlen = len - cur_prefix.length
|
32
56
|
end
|
33
57
|
|
34
|
-
# If there's no text left, then there were trailing spaces and the final \n
|
35
|
-
# is superfluous.
|
36
58
|
if text.length > 0
|
37
59
|
res << cur_prefix + text
|
38
60
|
else
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cli-dispatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Duan
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-20 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: |
|
14
13
|
Library for creating command-line programs that accept commands. Also
|
@@ -29,7 +28,6 @@ licenses:
|
|
29
28
|
metadata:
|
30
29
|
source_code_uri: https://github.com/charlesduan/cli-dispatcher
|
31
30
|
documentation_uri: https://rubydoc.info/gems/cli-dispatcher/
|
32
|
-
post_install_message:
|
33
31
|
rdoc_options: []
|
34
32
|
require_paths:
|
35
33
|
- lib
|
@@ -44,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
42
|
- !ruby/object:Gem::Version
|
45
43
|
version: '0'
|
46
44
|
requirements: []
|
47
|
-
rubygems_version: 3.
|
48
|
-
signing_key:
|
45
|
+
rubygems_version: 3.6.9
|
49
46
|
specification_version: 4
|
50
47
|
summary: Command-line command dispatcher
|
51
48
|
test_files: []
|