cri 2.6.1 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +46 -21
- data/LICENSE +1 -1
- data/NEWS.md +12 -0
- data/README.adoc +1 -1
- data/Rakefile +7 -2
- data/cri.gemspec +5 -7
- data/lib/cri.rb +0 -2
- data/lib/cri/argument_array.rb +0 -4
- data/lib/cri/command.rb +31 -40
- data/lib/cri/command_dsl.rb +28 -18
- data/lib/cri/command_runner.rb +2 -6
- data/lib/cri/commands/basic_help.rb +2 -2
- data/lib/cri/commands/basic_root.rb +1 -1
- data/lib/cri/core_ext.rb +3 -1
- data/lib/cri/core_ext/string.rb +28 -30
- data/lib/cri/help_renderer.rb +105 -23
- data/lib/cri/option_parser.rb +13 -17
- data/lib/cri/platform.rb +1 -5
- data/lib/cri/string_formatter.rb +14 -9
- data/lib/cri/version.rb +1 -3
- data/test/helper.rb +38 -38
- data/test/test_argument_array.rb +7 -7
- data/test/test_base.rb +4 -4
- data/test/test_basic_help.rb +47 -47
- data/test/test_basic_root.rb +10 -10
- data/test/test_command.rb +424 -347
- data/test/test_command_dsl.rb +174 -150
- data/test/test_command_runner.rb +22 -23
- data/test/test_option_parser.rb +212 -224
- data/test/test_string_formatter.rb +97 -82
- metadata +3 -3
@@ -1,86 +1,101 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
3
|
+
module Cri
|
4
|
+
class CoreExtTestCase < Cri::TestCase
|
5
|
+
def formatter
|
6
|
+
Cri::StringFormatter.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_string_to_paragraphs
|
10
|
+
original = "Lorem ipsum dolor sit amet,\nconsectetur adipisicing.\n\n" \
|
11
|
+
"Sed do eiusmod\ntempor incididunt ut labore."
|
12
|
+
|
13
|
+
expected = ['Lorem ipsum dolor sit amet, consectetur adipisicing.',
|
14
|
+
'Sed do eiusmod tempor incididunt ut labore.']
|
15
|
+
|
16
|
+
actual = formatter.to_paragraphs(original)
|
17
|
+
assert_equal expected, actual
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_string_wrap_and_indent_without_indent
|
21
|
+
original = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' \
|
22
|
+
'sed do eiusmod tempor incididunt ut labore et dolore ' \
|
23
|
+
'magna aliqua.'
|
24
|
+
|
25
|
+
expected = "Lorem ipsum dolor sit amet, consectetur\n" \
|
26
|
+
"adipisicing elit, sed do eiusmod tempor\n" \
|
27
|
+
"incididunt ut labore et dolore magna\n" \
|
28
|
+
'aliqua.'
|
29
|
+
|
30
|
+
actual = formatter.wrap_and_indent(original, 40, 0)
|
31
|
+
assert_equal expected, actual
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_string_wrap_and_indent_with_indent
|
35
|
+
original = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' \
|
36
|
+
'sed do eiusmod tempor incididunt ut labore et dolore ' \
|
37
|
+
'magna aliqua.'
|
38
|
+
|
39
|
+
expected = " Lorem ipsum dolor sit amet,\n" \
|
40
|
+
" consectetur adipisicing elit,\n" \
|
41
|
+
" sed do eiusmod tempor\n" \
|
42
|
+
" incididunt ut labore et dolore\n" \
|
43
|
+
' magna aliqua.'
|
44
|
+
|
45
|
+
actual = formatter.wrap_and_indent(original, 36, 4)
|
46
|
+
assert_equal expected, actual
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_string_wrap_and_indent_excluding_first_line
|
50
|
+
original = 'Lorem ipsum dolor sit amet, consectetur adipisicing ' \
|
51
|
+
'elit, sed do eiusmod tempor incididunt ut labore et dolore ' \
|
52
|
+
'magna aliqua.'
|
53
|
+
|
54
|
+
expected = "Lorem ipsum dolor sit amet,\n" \
|
55
|
+
" consectetur adipisicing elit,\n" \
|
56
|
+
" sed do eiusmod tempor\n" \
|
57
|
+
" incididunt ut labore et dolore\n" \
|
58
|
+
' magna aliqua.'
|
59
|
+
|
60
|
+
actual = formatter.wrap_and_indent(original, 36, 4, true)
|
61
|
+
assert_equal expected, actual
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_string_wrap_and_indent_with_large_indent
|
65
|
+
original = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' \
|
66
|
+
'sed do eiusmod tempor incididunt ut labore et dolore ' \
|
67
|
+
'magna aliqua.'
|
68
|
+
|
69
|
+
expected = " Lorem ipsum\n" \
|
70
|
+
" dolor sit\n" \
|
71
|
+
" amet,\n" \
|
72
|
+
" consectetur\n" \
|
73
|
+
" adipisicing\n" \
|
74
|
+
" elit, sed do\n" \
|
75
|
+
" eiusmod\n" \
|
76
|
+
" tempor\n" \
|
77
|
+
" incididunt ut\n" \
|
78
|
+
" labore et\n" \
|
79
|
+
" dolore magna\n" \
|
80
|
+
' aliqua.'
|
81
|
+
|
82
|
+
actual = formatter.wrap_and_indent(original, 44, 30)
|
83
|
+
assert_equal expected, actual
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_string_wrap_and_indent_with_multiple_lines
|
87
|
+
original = "Lorem ipsum dolor sit\namet, consectetur adipisicing elit, " \
|
88
|
+
"sed do\neiusmod tempor incididunt ut\nlabore et dolore " \
|
89
|
+
"magna\naliqua."
|
90
|
+
|
91
|
+
expected = " Lorem ipsum dolor sit amet,\n" \
|
92
|
+
" consectetur adipisicing elit,\n" \
|
93
|
+
" sed do eiusmod tempor\n" \
|
94
|
+
" incididunt ut labore et dolore\n" \
|
95
|
+
' magna aliqua.'
|
96
|
+
|
97
|
+
actual = formatter.wrap_and_indent(original, 36, 4)
|
98
|
+
assert_equal expected, actual
|
99
|
+
end
|
69
100
|
end
|
70
|
-
|
71
|
-
def test_string_wrap_and_indent_with_multiple_lines
|
72
|
-
original = "Lorem ipsum dolor sit\namet, consectetur adipisicing elit, " +
|
73
|
-
"sed do\neiusmod tempor incididunt ut\nlabore et dolore " +
|
74
|
-
"magna\naliqua."
|
75
|
-
|
76
|
-
expected = " Lorem ipsum dolor sit amet,\n" +
|
77
|
-
" consectetur adipisicing elit,\n" +
|
78
|
-
" sed do eiusmod tempor\n" +
|
79
|
-
" incididunt ut labore et dolore\n" +
|
80
|
-
" magna aliqua."
|
81
|
-
|
82
|
-
actual = formatter.wrap_and_indent(original, 36, 4)
|
83
|
-
assert_equal expected, actual
|
84
|
-
end
|
85
|
-
|
86
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.4.6
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: a library for building easy-to-use commandline tools
|