format_engine 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/format_engine.gemspec +1 -1
- data/lib/format_engine/version.rb +1 -1
- data/tests/engine_base_tests.rb +1 -1
- data/tests/format_spec_tests.rb +207 -207
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae7c3a238d69ffcd6c837e0a65b19a75ae520c3b
|
4
|
+
data.tar.gz: fd92a7e85a1f5bd02ac6efaae01f5f3ab8894db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240907e0c92ad404a1a9955ec1a233060d3b233e7b35be132faac3545a57a9f5f22a47fc92eaab3052d22b71221b17af6c0d739732b957b77c9649a3be13969f
|
7
|
+
data.tar.gz: 402c7b85e92f63932190e5e3486423e562b82902841121174737f43488f4b9aa78bf9a54997226ada7a0acdb9a6dc8153538b06260627e540cf64d36bb69c5d7
|
data/README.md
CHANGED
@@ -304,3 +304,14 @@ fmt attribute, has itself, the following attributes:
|
|
304
304
|
|
305
305
|
Go to the GitHub repository and raise an issue calling attention to some
|
306
306
|
aspect that could use some TLC or a suggestion or idea.
|
307
|
+
|
308
|
+
## License
|
309
|
+
|
310
|
+
The gem is available as open source under the terms of the
|
311
|
+
[MIT License](./LICENSE.txt).
|
312
|
+
|
313
|
+
## Code of Conduct
|
314
|
+
|
315
|
+
Everyone interacting in the fully_freeze project’s codebases, issue trackers,
|
316
|
+
chat rooms and mailing lists is expected to follow the
|
317
|
+
[code of conduct](./CODE_OF_CONDUCT.md).
|
data/format_engine.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.required_ruby_version = '>= 1.9.3'
|
23
23
|
|
24
|
-
spec.add_development_dependency "rake", "
|
24
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
26
|
spec.add_development_dependency 'minitest', "~> 5.7"
|
27
27
|
spec.add_development_dependency 'minitest_visible', "~> 0.1"
|
data/tests/engine_base_tests.rb
CHANGED
@@ -12,7 +12,7 @@ class EngineBaseTester < Minitest::Test
|
|
12
12
|
test = FormatEngine::Engine.new({"%A" => 42})
|
13
13
|
|
14
14
|
assert_equal(42, test["%A"])
|
15
|
-
|
15
|
+
assert_nil(test["%B"])
|
16
16
|
assert(test[:before])
|
17
17
|
assert(test[:after])
|
18
18
|
assert_equal(3, test.library.length)
|
data/tests/format_spec_tests.rb
CHANGED
@@ -1,207 +1,207 @@
|
|
1
|
-
require_relative '../lib/format_engine'
|
2
|
-
gem 'minitest'
|
3
|
-
require 'minitest/autorun'
|
4
|
-
require 'minitest_visible'
|
5
|
-
|
6
|
-
class FormatSpecTester < Minitest::Test
|
7
|
-
|
8
|
-
#Track mini-test progress.
|
9
|
-
include MinitestVisible
|
10
|
-
|
11
|
-
def test_that_it_scans_literal_formats
|
12
|
-
test = FormatEngine::FormatSpec.new "ABCDEFG!"
|
13
|
-
assert_equal(Array, test.specs.class)
|
14
|
-
assert_equal(1, test.specs.length)
|
15
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
16
|
-
assert_equal("ABCDEFG!", test.specs[0].literal)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_that_backslash_quotes
|
20
|
-
test = FormatEngine::FormatSpec.new "ABC\\%DEFG!"
|
21
|
-
assert_equal(Array, test.specs.class)
|
22
|
-
assert_equal(1, test.specs.length)
|
23
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
24
|
-
assert_equal("ABC%DEFG!", test.specs[0].literal)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_that_it_scans_simple_variable_formats
|
28
|
-
test = FormatEngine::FormatSpec.new "%A"
|
29
|
-
assert_equal(Array, test.specs.class)
|
30
|
-
assert_equal(1, test.specs.length)
|
31
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
32
|
-
assert_equal("%A", test.specs[0].format)
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_that_it_scans_set_formats
|
37
|
-
test = FormatEngine::FormatSpec.new "%[A]"
|
38
|
-
assert_equal(Array, test.specs.class)
|
39
|
-
assert_equal(1, test.specs.length)
|
40
|
-
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
41
|
-
assert_equal("%[", test.specs[0].short_name)
|
42
|
-
assert_equal("%[A]", test.specs[0].long_name)
|
43
|
-
assert_equal(/[A]+/, test.specs[0].regex)
|
44
|
-
|
45
|
-
test = FormatEngine::FormatSpec.new "%*[A]"
|
46
|
-
assert_equal(Array, test.specs.class)
|
47
|
-
assert_equal(1, test.specs.length)
|
48
|
-
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
49
|
-
assert_equal("%*[", test.specs[0].short_name)
|
50
|
-
assert_equal("%*[A]", test.specs[0].long_name)
|
51
|
-
assert_equal(/[A]+/, test.specs[0].regex)
|
52
|
-
|
53
|
-
test = FormatEngine::FormatSpec.new "%7[A]"
|
54
|
-
assert_equal(Array, test.specs.class)
|
55
|
-
assert_equal(1, test.specs.length)
|
56
|
-
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
57
|
-
assert_equal("%[", test.specs[0].short_name)
|
58
|
-
assert_equal("%[A]", test.specs[0].long_name)
|
59
|
-
assert_equal(/[A]{1,7}/, test.specs[0].regex)
|
60
|
-
|
61
|
-
test = FormatEngine::FormatSpec.new "%*7[A]"
|
62
|
-
assert_equal(Array, test.specs.class)
|
63
|
-
assert_equal(1, test.specs.length)
|
64
|
-
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
65
|
-
assert_equal("%*[", test.specs[0].short_name)
|
66
|
-
assert_equal("%*[A]", test.specs[0].long_name)
|
67
|
-
assert_equal(/[A]{1,7}/, test.specs[0].regex)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_a_mixed_set
|
71
|
-
test = FormatEngine::FormatSpec.new "%f %l %[age] %a"
|
72
|
-
assert_equal(Array, test.specs.class)
|
73
|
-
assert_equal(7, test.specs.length)
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_that_it_scans_tab_seperators
|
78
|
-
test = FormatEngine::FormatSpec.new "%A\t%B"
|
79
|
-
assert_equal(Array, test.specs.class)
|
80
|
-
assert_equal(3, test.specs.length)
|
81
|
-
|
82
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
83
|
-
assert_equal("%A", test.specs[0].format)
|
84
|
-
|
85
|
-
|
86
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[1].class)
|
87
|
-
assert_equal("\t", test.specs[1].literal)
|
88
|
-
|
89
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[2].class)
|
90
|
-
assert_equal("%B", test.specs[2].format)
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_that_it_scans_option_variable_formats
|
95
|
-
"~@#&^&*-+=?_<>|".each_char do |char|
|
96
|
-
test = FormatEngine::FormatSpec.new "%#{char}A"
|
97
|
-
assert_equal(Array, test.specs.class)
|
98
|
-
assert_equal(1, test.specs.length)
|
99
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
100
|
-
assert_equal("%#{char}A", test.specs[0].format)
|
101
|
-
refute(test.specs[0].has_width?)
|
102
|
-
refute(test.specs[0].has_prec?)
|
103
|
-
assert_equal("", test.specs[0].width_str)
|
104
|
-
assert_equal("", test.specs[0].prec_str)
|
105
|
-
assert_equal("", test.specs[0].parm_str)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_that_it_scans_single_variable_formats
|
110
|
-
test = FormatEngine::FormatSpec.new "%123A"
|
111
|
-
assert_equal(Array, test.specs.class)
|
112
|
-
assert_equal(1, test.specs.length)
|
113
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
114
|
-
assert_equal("%A", test.specs[0].format)
|
115
|
-
|
116
|
-
assert_equal(Array, test.specs[0].parms.class)
|
117
|
-
assert_equal(1, test.specs[0].parms.length)
|
118
|
-
assert_equal("123", test.specs[0].parms[0])
|
119
|
-
assert(test.specs[0].has_width?)
|
120
|
-
refute(test.specs[0].has_prec?)
|
121
|
-
assert_equal("123", test.specs[0].width_str)
|
122
|
-
assert_equal("", test.specs[0].prec_str)
|
123
|
-
assert_equal("123", test.specs[0].parm_str)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_that_it_scans_double_variable_formats
|
127
|
-
test = FormatEngine::FormatSpec.new "%123.456A"
|
128
|
-
assert_equal(Array, test.specs.class)
|
129
|
-
assert_equal(1, test.specs.length)
|
130
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
131
|
-
assert_equal("%A", test.specs[0].format)
|
132
|
-
|
133
|
-
assert_equal(Array, test.specs[0].parms.class)
|
134
|
-
assert_equal(2, test.specs[0].parms.length)
|
135
|
-
assert_equal("123", test.specs[0].parms[0])
|
136
|
-
assert_equal("456", test.specs[0].parms[1])
|
137
|
-
assert(test.specs[0].has_width?)
|
138
|
-
assert(test.specs[0].has_prec?)
|
139
|
-
assert_equal("123", test.specs[0].width_str)
|
140
|
-
assert_equal("456", test.specs[0].prec_str)
|
141
|
-
assert_equal("123.456", test.specs[0].parm_str)
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_negative_variable_formats
|
145
|
-
test = FormatEngine::FormatSpec.new "%-123.456A"
|
146
|
-
assert_equal(Array, test.specs.class)
|
147
|
-
assert_equal(1, test.specs.length)
|
148
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
149
|
-
assert_equal("%A", test.specs[0].format)
|
150
|
-
|
151
|
-
assert_equal(Array, test.specs[0].parms.class)
|
152
|
-
assert_equal(2, test.specs[0].parms.length)
|
153
|
-
assert_equal("-123", test.specs[0].parms[0])
|
154
|
-
assert_equal("456", test.specs[0].parms[1])
|
155
|
-
assert(test.specs[0].has_width?)
|
156
|
-
assert(test.specs[0].has_prec?)
|
157
|
-
assert_equal("-123", test.specs[0].width_str)
|
158
|
-
assert_equal("456", test.specs[0].prec_str)
|
159
|
-
assert_equal("-123.456", test.specs[0].parm_str)
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_multipart_formats
|
163
|
-
test = FormatEngine::FormatSpec.new "T(%+02A:%3B:%4.1C)"
|
164
|
-
|
165
|
-
assert_equal(Array, test.specs.class)
|
166
|
-
assert_equal(7, test.specs.length)
|
167
|
-
|
168
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
169
|
-
assert_equal("T(", test.specs[0].literal)
|
170
|
-
|
171
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[1].class)
|
172
|
-
assert_equal("%A", test.specs[1].format)
|
173
|
-
assert_equal(1, test.specs[1].parms.length)
|
174
|
-
assert_equal("+02", test.specs[1].parms[0])
|
175
|
-
|
176
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[2].class)
|
177
|
-
assert_equal(":", test.specs[2].literal)
|
178
|
-
|
179
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[3].class)
|
180
|
-
assert_equal("%B", test.specs[3].format)
|
181
|
-
assert_equal(1, test.specs[3].parms.length)
|
182
|
-
assert_equal("3", test.specs[3].parms[0])
|
183
|
-
|
184
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[4].class)
|
185
|
-
assert_equal(":", test.specs[4].literal)
|
186
|
-
|
187
|
-
assert_equal(FormatEngine::FormatVariable, test.specs[5].class)
|
188
|
-
assert_equal("%C", test.specs[5].format)
|
189
|
-
assert_equal(2, test.specs[5].parms.length)
|
190
|
-
assert_equal("4", test.specs[5].parms[0])
|
191
|
-
assert_equal("1", test.specs[5].parms[1])
|
192
|
-
|
193
|
-
assert_equal(FormatEngine::FormatLiteral, test.specs[6].class)
|
194
|
-
assert_equal(")", test.specs[6].literal)
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_that_it_scans_regex_formats
|
198
|
-
test = FormatEngine::FormatSpec.new "%/ABC/"
|
199
|
-
assert_equal(Array, test.specs.class)
|
200
|
-
assert_equal(1, test.specs.length)
|
201
|
-
assert_equal(FormatEngine::FormatRgx, test.specs[0].class)
|
202
|
-
assert_equal(/ABC/, test.specs[0].regex)
|
203
|
-
end
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
end
|
1
|
+
require_relative '../lib/format_engine'
|
2
|
+
gem 'minitest'
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest_visible'
|
5
|
+
|
6
|
+
class FormatSpecTester < Minitest::Test
|
7
|
+
|
8
|
+
#Track mini-test progress.
|
9
|
+
include MinitestVisible
|
10
|
+
|
11
|
+
def test_that_it_scans_literal_formats
|
12
|
+
test = FormatEngine::FormatSpec.new "ABCDEFG!"
|
13
|
+
assert_equal(Array, test.specs.class)
|
14
|
+
assert_equal(1, test.specs.length)
|
15
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
16
|
+
assert_equal("ABCDEFG!", test.specs[0].literal)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_backslash_quotes
|
20
|
+
test = FormatEngine::FormatSpec.new "ABC\\%DEFG!"
|
21
|
+
assert_equal(Array, test.specs.class)
|
22
|
+
assert_equal(1, test.specs.length)
|
23
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
24
|
+
assert_equal("ABC%DEFG!", test.specs[0].literal)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_that_it_scans_simple_variable_formats
|
28
|
+
test = FormatEngine::FormatSpec.new "%A"
|
29
|
+
assert_equal(Array, test.specs.class)
|
30
|
+
assert_equal(1, test.specs.length)
|
31
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
32
|
+
assert_equal("%A", test.specs[0].format)
|
33
|
+
assert_nil(test.specs[0].parms)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_that_it_scans_set_formats
|
37
|
+
test = FormatEngine::FormatSpec.new "%[A]"
|
38
|
+
assert_equal(Array, test.specs.class)
|
39
|
+
assert_equal(1, test.specs.length)
|
40
|
+
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
41
|
+
assert_equal("%[", test.specs[0].short_name)
|
42
|
+
assert_equal("%[A]", test.specs[0].long_name)
|
43
|
+
assert_equal(/[A]+/, test.specs[0].regex)
|
44
|
+
|
45
|
+
test = FormatEngine::FormatSpec.new "%*[A]"
|
46
|
+
assert_equal(Array, test.specs.class)
|
47
|
+
assert_equal(1, test.specs.length)
|
48
|
+
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
49
|
+
assert_equal("%*[", test.specs[0].short_name)
|
50
|
+
assert_equal("%*[A]", test.specs[0].long_name)
|
51
|
+
assert_equal(/[A]+/, test.specs[0].regex)
|
52
|
+
|
53
|
+
test = FormatEngine::FormatSpec.new "%7[A]"
|
54
|
+
assert_equal(Array, test.specs.class)
|
55
|
+
assert_equal(1, test.specs.length)
|
56
|
+
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
57
|
+
assert_equal("%[", test.specs[0].short_name)
|
58
|
+
assert_equal("%[A]", test.specs[0].long_name)
|
59
|
+
assert_equal(/[A]{1,7}/, test.specs[0].regex)
|
60
|
+
|
61
|
+
test = FormatEngine::FormatSpec.new "%*7[A]"
|
62
|
+
assert_equal(Array, test.specs.class)
|
63
|
+
assert_equal(1, test.specs.length)
|
64
|
+
assert_equal(FormatEngine::FormatSet, test.specs[0].class)
|
65
|
+
assert_equal("%*[", test.specs[0].short_name)
|
66
|
+
assert_equal("%*[A]", test.specs[0].long_name)
|
67
|
+
assert_equal(/[A]{1,7}/, test.specs[0].regex)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_a_mixed_set
|
71
|
+
test = FormatEngine::FormatSpec.new "%f %l %[age] %a"
|
72
|
+
assert_equal(Array, test.specs.class)
|
73
|
+
assert_equal(7, test.specs.length)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_that_it_scans_tab_seperators
|
78
|
+
test = FormatEngine::FormatSpec.new "%A\t%B"
|
79
|
+
assert_equal(Array, test.specs.class)
|
80
|
+
assert_equal(3, test.specs.length)
|
81
|
+
|
82
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
83
|
+
assert_equal("%A", test.specs[0].format)
|
84
|
+
assert_nil(test.specs[0].parms)
|
85
|
+
|
86
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[1].class)
|
87
|
+
assert_equal("\t", test.specs[1].literal)
|
88
|
+
|
89
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[2].class)
|
90
|
+
assert_equal("%B", test.specs[2].format)
|
91
|
+
assert_nil(test.specs[2].parms)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_that_it_scans_option_variable_formats
|
95
|
+
"~@#&^&*-+=?_<>|".each_char do |char|
|
96
|
+
test = FormatEngine::FormatSpec.new "%#{char}A"
|
97
|
+
assert_equal(Array, test.specs.class)
|
98
|
+
assert_equal(1, test.specs.length)
|
99
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
100
|
+
assert_equal("%#{char}A", test.specs[0].format)
|
101
|
+
refute(test.specs[0].has_width?)
|
102
|
+
refute(test.specs[0].has_prec?)
|
103
|
+
assert_equal("", test.specs[0].width_str)
|
104
|
+
assert_equal("", test.specs[0].prec_str)
|
105
|
+
assert_equal("", test.specs[0].parm_str)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_that_it_scans_single_variable_formats
|
110
|
+
test = FormatEngine::FormatSpec.new "%123A"
|
111
|
+
assert_equal(Array, test.specs.class)
|
112
|
+
assert_equal(1, test.specs.length)
|
113
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
114
|
+
assert_equal("%A", test.specs[0].format)
|
115
|
+
|
116
|
+
assert_equal(Array, test.specs[0].parms.class)
|
117
|
+
assert_equal(1, test.specs[0].parms.length)
|
118
|
+
assert_equal("123", test.specs[0].parms[0])
|
119
|
+
assert(test.specs[0].has_width?)
|
120
|
+
refute(test.specs[0].has_prec?)
|
121
|
+
assert_equal("123", test.specs[0].width_str)
|
122
|
+
assert_equal("", test.specs[0].prec_str)
|
123
|
+
assert_equal("123", test.specs[0].parm_str)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_that_it_scans_double_variable_formats
|
127
|
+
test = FormatEngine::FormatSpec.new "%123.456A"
|
128
|
+
assert_equal(Array, test.specs.class)
|
129
|
+
assert_equal(1, test.specs.length)
|
130
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
131
|
+
assert_equal("%A", test.specs[0].format)
|
132
|
+
|
133
|
+
assert_equal(Array, test.specs[0].parms.class)
|
134
|
+
assert_equal(2, test.specs[0].parms.length)
|
135
|
+
assert_equal("123", test.specs[0].parms[0])
|
136
|
+
assert_equal("456", test.specs[0].parms[1])
|
137
|
+
assert(test.specs[0].has_width?)
|
138
|
+
assert(test.specs[0].has_prec?)
|
139
|
+
assert_equal("123", test.specs[0].width_str)
|
140
|
+
assert_equal("456", test.specs[0].prec_str)
|
141
|
+
assert_equal("123.456", test.specs[0].parm_str)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_negative_variable_formats
|
145
|
+
test = FormatEngine::FormatSpec.new "%-123.456A"
|
146
|
+
assert_equal(Array, test.specs.class)
|
147
|
+
assert_equal(1, test.specs.length)
|
148
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[0].class)
|
149
|
+
assert_equal("%A", test.specs[0].format)
|
150
|
+
|
151
|
+
assert_equal(Array, test.specs[0].parms.class)
|
152
|
+
assert_equal(2, test.specs[0].parms.length)
|
153
|
+
assert_equal("-123", test.specs[0].parms[0])
|
154
|
+
assert_equal("456", test.specs[0].parms[1])
|
155
|
+
assert(test.specs[0].has_width?)
|
156
|
+
assert(test.specs[0].has_prec?)
|
157
|
+
assert_equal("-123", test.specs[0].width_str)
|
158
|
+
assert_equal("456", test.specs[0].prec_str)
|
159
|
+
assert_equal("-123.456", test.specs[0].parm_str)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_multipart_formats
|
163
|
+
test = FormatEngine::FormatSpec.new "T(%+02A:%3B:%4.1C)"
|
164
|
+
|
165
|
+
assert_equal(Array, test.specs.class)
|
166
|
+
assert_equal(7, test.specs.length)
|
167
|
+
|
168
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[0].class)
|
169
|
+
assert_equal("T(", test.specs[0].literal)
|
170
|
+
|
171
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[1].class)
|
172
|
+
assert_equal("%A", test.specs[1].format)
|
173
|
+
assert_equal(1, test.specs[1].parms.length)
|
174
|
+
assert_equal("+02", test.specs[1].parms[0])
|
175
|
+
|
176
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[2].class)
|
177
|
+
assert_equal(":", test.specs[2].literal)
|
178
|
+
|
179
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[3].class)
|
180
|
+
assert_equal("%B", test.specs[3].format)
|
181
|
+
assert_equal(1, test.specs[3].parms.length)
|
182
|
+
assert_equal("3", test.specs[3].parms[0])
|
183
|
+
|
184
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[4].class)
|
185
|
+
assert_equal(":", test.specs[4].literal)
|
186
|
+
|
187
|
+
assert_equal(FormatEngine::FormatVariable, test.specs[5].class)
|
188
|
+
assert_equal("%C", test.specs[5].format)
|
189
|
+
assert_equal(2, test.specs[5].parms.length)
|
190
|
+
assert_equal("4", test.specs[5].parms[0])
|
191
|
+
assert_equal("1", test.specs[5].parms[1])
|
192
|
+
|
193
|
+
assert_equal(FormatEngine::FormatLiteral, test.specs[6].class)
|
194
|
+
assert_equal(")", test.specs[6].literal)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_that_it_scans_regex_formats
|
198
|
+
test = FormatEngine::FormatSpec.new "%/ABC/"
|
199
|
+
assert_equal(Array, test.specs.class)
|
200
|
+
assert_equal(1, test.specs.length)
|
201
|
+
assert_equal(FormatEngine::FormatRgx, test.specs[0].class)
|
202
|
+
assert_equal(/ABC/, test.specs[0].regex)
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 12.3.3
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 12.3.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,9 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.2
|
149
|
+
rubygems_version: 2.5.2
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: An engine for string formatting and parsing.
|
153
153
|
test_files: []
|
154
|
-
has_rdoc:
|