defmastership 1.1.1 → 1.3.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/defmastership.gemspec +1 -1
- data/features/definition_checksum.feature +56 -0
- data/features/definition_version.feature +35 -0
- data/features/export.feature +55 -0
- data/lib/defmastership/definition.rb +6 -1
- data/lib/defmastership/document.rb +11 -1
- data/lib/defmastership/export/body_formatter.rb +9 -3
- data/lib/defmastership/export/csv/formatter.rb +35 -8
- data/lib/defmastership/export/header_formatter.rb +4 -3
- data/lib/defmastership/modifier/change_ref.rb +34 -4
- data/lib/defmastership/modifier/rename_included_files.rb +1 -2
- data/lib/defmastership/modifier/update_def_version.rb +1 -0
- data/lib/defmastership/version.rb +1 -1
- data/spec/unit/defmastership/definition_spec.rb +20 -0
- data/spec/unit/defmastership/document_spec.rb +83 -0
- data/spec/unit/defmastership/export/body_formatter_spec.rb +40 -6
- data/spec/unit/defmastership/export/csv/formatter_spec.rb +49 -8
- data/spec/unit/defmastership/export/header_formatter_spec.rb +18 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3101cc665380665519681d6644d3ba5bd818772542e2877305f94fabcc3b0d5b
|
4
|
+
data.tar.gz: 32a279c031db21c8bc9e58175c0842de490c922f8eb0538032bb8509ae39a3dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4029e2b886ba957c645381e00bd61007871075795a86c802bf618e0ca8f67609b62f16085e43ab7fcd54180d16474acfa72a1fc7effcf3c469995e9a7ed02be
|
7
|
+
data.tar.gz: fcd4f16c6fdcd001b02dc5378bce594a3df0be78a0fda6560c628be35a10d9ddccddea213152ceb0d514bc92eaf74cf90a836c6293e92b128f7f0d29175136f1
|
data/defmastership.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency('aasm', '~> 5')
|
35
35
|
spec.add_dependency('asciidoctor', '~> 2')
|
36
36
|
spec.add_dependency('csv', '~> 3')
|
37
|
-
spec.add_dependency('defmastership-core', '
|
37
|
+
spec.add_dependency('defmastership-core', '~> 1.4')
|
38
38
|
spec.add_dependency('git', '~> 1')
|
39
39
|
spec.add_dependency('gli', '~> 2')
|
40
40
|
spec.add_dependency('ostruct', '~> 0')
|
@@ -236,6 +236,62 @@ Feature: definition checksum
|
|
236
236
|
"""
|
237
237
|
And the stdout should not contain anything
|
238
238
|
|
239
|
+
Scenario: Checksum takes into account definition summary in ref modification
|
240
|
+
Given a file named "modifications.yml" with:
|
241
|
+
"""
|
242
|
+
---
|
243
|
+
:update_requirement_checksum:
|
244
|
+
:type: update_def_checksum
|
245
|
+
:config:
|
246
|
+
:def_type: requirement
|
247
|
+
"""
|
248
|
+
And a file named "thedoc.adoc" with:
|
249
|
+
"""
|
250
|
+
[define, requirement, TOTO-0001]
|
251
|
+
--
|
252
|
+
A nice summary
|
253
|
+
Exemple of multiline requirement.
|
254
|
+
Second line.
|
255
|
+
--
|
256
|
+
|
257
|
+
[define, requirement, TOTO-0002, A nice summary]
|
258
|
+
--
|
259
|
+
Exemple of multiline requirement.
|
260
|
+
Second line.
|
261
|
+
--
|
262
|
+
|
263
|
+
:a_variable: summary
|
264
|
+
[define, requirement, TOTO-0003, A nice {a_variable}]
|
265
|
+
--
|
266
|
+
Exemple of multiline requirement.
|
267
|
+
Second line.
|
268
|
+
--
|
269
|
+
"""
|
270
|
+
When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
|
271
|
+
Then the file "thedoc.adoc" should contain:
|
272
|
+
"""
|
273
|
+
[define, requirement, TOTO-0001(~f8092f4e)]
|
274
|
+
--
|
275
|
+
A nice summary
|
276
|
+
Exemple of multiline requirement.
|
277
|
+
Second line.
|
278
|
+
--
|
279
|
+
|
280
|
+
[define, requirement, TOTO-0002(~f8092f4e), A nice summary]
|
281
|
+
--
|
282
|
+
Exemple of multiline requirement.
|
283
|
+
Second line.
|
284
|
+
--
|
285
|
+
|
286
|
+
:a_variable: summary
|
287
|
+
[define, requirement, TOTO-0003(~f8092f4e), A nice {a_variable}]
|
288
|
+
--
|
289
|
+
Exemple of multiline requirement.
|
290
|
+
Second line.
|
291
|
+
--
|
292
|
+
"""
|
293
|
+
And the stdout should not contain anything
|
294
|
+
|
239
295
|
Scenario: Checksum does not take into account bad variables definition
|
240
296
|
Given a file named "modifications.yml" with:
|
241
297
|
"""
|
@@ -56,6 +56,41 @@ Feature: definitions version
|
|
56
56
|
--
|
57
57
|
"""
|
58
58
|
|
59
|
+
Scenario: Set initial explicit version when definition summary has changed
|
60
|
+
Given a file named "ref_doc.adoc" with:
|
61
|
+
"""
|
62
|
+
[define, requirement, TOTO-0001, a nice summary]
|
63
|
+
--
|
64
|
+
Some text.
|
65
|
+
--
|
66
|
+
"""
|
67
|
+
Given a file named "thedoc.adoc" with:
|
68
|
+
"""
|
69
|
+
[define, requirement, TOTO-0001(whatever), a really nice summary]
|
70
|
+
--
|
71
|
+
Some text.
|
72
|
+
--
|
73
|
+
"""
|
74
|
+
And a file named "modifications.yml" with:
|
75
|
+
"""
|
76
|
+
---
|
77
|
+
:update_requirement_version:
|
78
|
+
:type: update_def_version
|
79
|
+
:config:
|
80
|
+
:def_type: requirement
|
81
|
+
:first_version: a
|
82
|
+
:ref_document: ./ref_doc.adoc
|
83
|
+
"""
|
84
|
+
When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
|
85
|
+
And the stdout should not contain anything
|
86
|
+
Then the file "thedoc.adoc" should contain:
|
87
|
+
"""
|
88
|
+
[define, requirement, TOTO-0001(a), a really nice summary]
|
89
|
+
--
|
90
|
+
Some text.
|
91
|
+
--
|
92
|
+
"""
|
93
|
+
|
59
94
|
Scenario: Set initial explicit version when definition has changed with multiple ref_files
|
60
95
|
Given a file named "ref_doc1.adoc" with:
|
61
96
|
"""
|
data/features/export.feature
CHANGED
@@ -174,6 +174,61 @@ Feature: The extract command
|
|
174
174
|
"""
|
175
175
|
And the stdout should not contain anything
|
176
176
|
|
177
|
+
Scenario: Extract definition with summary
|
178
|
+
Given a file named "toto.adoc" with:
|
179
|
+
"""
|
180
|
+
[define, requirement, TOTO-0001, A nice summary]
|
181
|
+
--
|
182
|
+
Exemple of multiline requirement.
|
183
|
+
Second line.
|
184
|
+
--
|
185
|
+
"""
|
186
|
+
When I successfully run `defmastership export toto.adoc`
|
187
|
+
Then the file "toto.csv" should contain:
|
188
|
+
"""
|
189
|
+
Type,Reference,Summary,Value,Checksum
|
190
|
+
requirement,TOTO-0001,A nice summary,"Exemple of multiline requirement.
|
191
|
+
Second line.",~f8092f4e
|
192
|
+
"""
|
193
|
+
And the stdout should not contain anything
|
194
|
+
|
195
|
+
Scenario: Extract definition with summary with variable
|
196
|
+
Given a file named "toto.adoc" with:
|
197
|
+
"""
|
198
|
+
:a_variable: summary
|
199
|
+
[define, requirement, TOTO-0001, A nice {a_variable}]
|
200
|
+
--
|
201
|
+
Exemple of multiline requirement.
|
202
|
+
Second line.
|
203
|
+
--
|
204
|
+
"""
|
205
|
+
When I successfully run `defmastership export toto.adoc`
|
206
|
+
Then the file "toto.csv" should contain:
|
207
|
+
"""
|
208
|
+
Type,Reference,Summary,Value,Checksum
|
209
|
+
requirement,TOTO-0001,A nice summary,"Exemple of multiline requirement.
|
210
|
+
Second line.",~f8092f4e
|
211
|
+
"""
|
212
|
+
And the stdout should not contain anything
|
213
|
+
|
214
|
+
Scenario: Extract definition with summary including comma
|
215
|
+
Given a file named "toto.adoc" with:
|
216
|
+
"""
|
217
|
+
[define, requirement, TOTO-0001, " A nice, summary " ]
|
218
|
+
--
|
219
|
+
Exemple of multiline requirement.
|
220
|
+
Second line.
|
221
|
+
--
|
222
|
+
"""
|
223
|
+
When I successfully run `defmastership export toto.adoc`
|
224
|
+
Then the file "toto.csv" should contain:
|
225
|
+
"""
|
226
|
+
Type,Reference,Summary,Value,Checksum
|
227
|
+
requirement,TOTO-0001,"A nice, summary","Exemple of multiline requirement.
|
228
|
+
Second line.",~77a203d4
|
229
|
+
"""
|
230
|
+
And the stdout should not contain anything
|
231
|
+
|
177
232
|
Scenario: Extract definition with labels
|
178
233
|
Given a file named "toto.adoc" with:
|
179
234
|
"""
|
@@ -8,6 +8,7 @@ module Defmastership
|
|
8
8
|
BUILD_FROM_MATCH = {
|
9
9
|
type: ->(match) { match[:type] },
|
10
10
|
reference: ->(match) { match[:reference] },
|
11
|
+
summary: ->(match) { match[:summary] },
|
11
12
|
lines: ->(_) { [] },
|
12
13
|
labels: lambda do |match|
|
13
14
|
labels = Set.new
|
@@ -27,6 +28,7 @@ module Defmastership
|
|
27
28
|
DefinitionData = Struct.new(
|
28
29
|
:type,
|
29
30
|
:reference,
|
31
|
+
:summary,
|
30
32
|
:lines,
|
31
33
|
:labels,
|
32
34
|
:eref,
|
@@ -44,6 +46,7 @@ module Defmastership
|
|
44
46
|
def_delegators :@data,
|
45
47
|
:type,
|
46
48
|
:reference,
|
49
|
+
:summary,
|
47
50
|
:lines,
|
48
51
|
:labels,
|
49
52
|
:eref,
|
@@ -78,7 +81,9 @@ module Defmastership
|
|
78
81
|
|
79
82
|
# @return [String] short representation (8 last characters) of the sha256 of the definition's value
|
80
83
|
def sha256_short
|
81
|
-
"~#{Digest::SHA2.hexdigest(value).chars.last(8).join}"
|
84
|
+
return "~#{Digest::SHA2.hexdigest(value).chars.last(8).join}" unless summary
|
85
|
+
|
86
|
+
"~#{Digest::SHA2.hexdigest("#{summary}\n#{value}").chars.last(8).join}"
|
82
87
|
end
|
83
88
|
|
84
89
|
# @return [String] the explicit checsum if wrong or nil
|
@@ -22,7 +22,9 @@ module Defmastership
|
|
22
22
|
|
23
23
|
PARSER_ACTIONS = {
|
24
24
|
add_new_definition: lambda { |matching_line|
|
25
|
-
|
25
|
+
# rebuild the match to take into account eventual variable substitutions
|
26
|
+
match = matching_line.line.match(Core::DMRegexp::DEFINITION)
|
27
|
+
definition = Definition.new(match)
|
26
28
|
labels.merge(definition.labels)
|
27
29
|
definitions << definition
|
28
30
|
},
|
@@ -88,6 +90,13 @@ module Defmastership
|
|
88
90
|
do_parse(Asciidoctor.load_file(adoc_file, safe: :unsafe, parse: false).reader.read_lines)
|
89
91
|
end
|
90
92
|
|
93
|
+
# @return [Boolean] true if the document has definitions with summary
|
94
|
+
def summaries?
|
95
|
+
definitions.reduce(false) do |res, definition|
|
96
|
+
res || !!definition.summary
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
91
100
|
# @return [Boolean] true if the document has definitions with wrong explicit checksum
|
92
101
|
def wrong_explicit_checksum?
|
93
102
|
definitions.reduce(false) do |res, definition|
|
@@ -174,5 +183,6 @@ module Defmastership
|
|
174
183
|
end
|
175
184
|
end
|
176
185
|
end
|
186
|
+
private_constant :Helper
|
177
187
|
end
|
178
188
|
end
|
@@ -14,9 +14,15 @@ module Defmastership
|
|
14
14
|
@definition = definition
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
%i[type reference summary value].each do |method_symbol|
|
18
|
+
define_method(method_symbol) do
|
19
|
+
[@definition.public_send(method_symbol)]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Array<String>] checksum column value
|
24
|
+
def checksum
|
25
|
+
[@definition.sha256_short]
|
20
26
|
end
|
21
27
|
|
22
28
|
# @return [Array<String>] Optional wrong_explicit_checksum column value
|
@@ -32,6 +32,38 @@ module Defmastership
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
+
# Helper functions
|
36
|
+
module Helper
|
37
|
+
# @return [Array<Symbol>] the array of methods for columns inclusion
|
38
|
+
#
|
39
|
+
# @param column_spec [MethodSpec] the method to include or not with its guard
|
40
|
+
# @param doc [Document] the Document to export
|
41
|
+
def self.column_method(column_spec, doc)
|
42
|
+
column_spec.guard.call(doc) ? [column_spec.column_method] : []
|
43
|
+
end
|
44
|
+
|
45
|
+
# 2-uplet with one method to include or not depending of a lambda guard
|
46
|
+
MethodSpec = Struct.new(:column_method, :guard)
|
47
|
+
public_constant :MethodSpec
|
48
|
+
end
|
49
|
+
private_constant :Helper
|
50
|
+
|
51
|
+
COLUMNS_METHODS_SPECIFICATIONS =
|
52
|
+
[
|
53
|
+
Helper::MethodSpec.new(:type, ->(_) { true }),
|
54
|
+
Helper::MethodSpec.new(:reference, ->(_) { true }),
|
55
|
+
Helper::MethodSpec.new(:summary, lambda(&:summaries?)),
|
56
|
+
Helper::MethodSpec.new(:value, ->(_) { true }),
|
57
|
+
Helper::MethodSpec.new(:checksum, ->(_) { true }),
|
58
|
+
Helper::MethodSpec.new(:wrong_explicit_checksum, lambda(&:wrong_explicit_checksum?)),
|
59
|
+
Helper::MethodSpec.new(:explicit_version, lambda(&:explicit_version?)),
|
60
|
+
Helper::MethodSpec.new(:labels, ->(doc) { !doc.labels.empty? }),
|
61
|
+
Helper::MethodSpec.new(:eref, ->(doc) { !doc.eref.empty? }),
|
62
|
+
Helper::MethodSpec.new(:iref, lambda(&:iref)),
|
63
|
+
Helper::MethodSpec.new(:attributes, ->(doc) { !doc.attributes.empty? })
|
64
|
+
].freeze
|
65
|
+
private_constant :COLUMNS_METHODS_SPECIFICATIONS
|
66
|
+
|
35
67
|
def export_definitions_in(csv, column_list)
|
36
68
|
@doc.definitions.each { |definition| csv << body(definition, column_list) }
|
37
69
|
end
|
@@ -49,14 +81,9 @@ module Defmastership
|
|
49
81
|
end
|
50
82
|
|
51
83
|
def build_column_list
|
52
|
-
[
|
53
|
-
|
54
|
-
|
55
|
-
[:labels, !@doc.labels.empty?],
|
56
|
-
[:eref, !@doc.eref.empty?],
|
57
|
-
[:iref, @doc.iref],
|
58
|
-
[:attributes, !@doc.attributes.empty?]
|
59
|
-
].reduce([:fixed]) { |acc, elem| acc + (elem.fetch(1) ? [elem.first] : []) }
|
84
|
+
COLUMNS_METHODS_SPECIFICATIONS.reduce([]) do |acc, column|
|
85
|
+
acc + Helper.column_method(column, @doc)
|
86
|
+
end
|
60
87
|
end
|
61
88
|
end
|
62
89
|
end
|
@@ -12,9 +12,10 @@ module Defmastership
|
|
12
12
|
@doc = doc
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
%i[type reference summary value checksum].each do |method_symbol|
|
16
|
+
define_method(method_symbol) do
|
17
|
+
[method_symbol.to_s.capitalize]
|
18
|
+
end
|
18
19
|
end
|
19
20
|
|
20
21
|
# @return [Array<String>] Optional wrong_explicit_checksum column caption
|
@@ -11,14 +11,43 @@ module Defmastership
|
|
11
11
|
class ChangeRef
|
12
12
|
include ModifierCommon
|
13
13
|
|
14
|
+
# [Regexp] match all text before the definition's reference
|
15
|
+
DEF_BEFORE_REF = <<~"BEF"
|
16
|
+
^
|
17
|
+
\\s*
|
18
|
+
\\[
|
19
|
+
#{Core::DMRegexp::DEF_KEYWORD}
|
20
|
+
#{Core::DMRegexp::DEF_TYPE}
|
21
|
+
,
|
22
|
+
\\s*
|
23
|
+
BEF
|
24
|
+
private_constant :DEF_BEFORE_REF
|
25
|
+
|
26
|
+
# [Regexp] match all text after the definition's reference
|
27
|
+
DEF_AFTER_REF = <<~"AFT"
|
28
|
+
\\s*
|
29
|
+
#{Core::DMRegexp::DEF_SUMMARY}
|
30
|
+
#{Core::DMRegexp::DEF_LABELS}
|
31
|
+
\\s*
|
32
|
+
\\]
|
33
|
+
AFT
|
34
|
+
private_constant :DEF_AFTER_REF
|
35
|
+
|
36
|
+
# [Regexp] match the begining of an internal cross reference
|
37
|
+
IREF_DEF_BEF = 'defs:iref\[\s*'
|
38
|
+
private_constant :IREF_DEF_BEF
|
39
|
+
# [Regexp] match the end of an internal cross reference
|
40
|
+
IREF_DEF_AFT = '\s*\]'
|
41
|
+
private_constant :IREF_DEF_AFT
|
42
|
+
|
14
43
|
REGEXP_FROM = {
|
15
44
|
definition: {
|
16
|
-
before:
|
17
|
-
after:
|
45
|
+
before: DEF_BEFORE_REF,
|
46
|
+
after: DEF_AFTER_REF
|
18
47
|
},
|
19
48
|
iref: {
|
20
|
-
before:
|
21
|
-
after:
|
49
|
+
before: IREF_DEF_BEF,
|
50
|
+
after: IREF_DEF_AFT
|
22
51
|
}
|
23
52
|
}.freeze
|
24
53
|
|
@@ -112,6 +141,7 @@ module Defmastership
|
|
112
141
|
match[:before] + replacement + (match[:version_and_checksum] || '') + match[:after]
|
113
142
|
end
|
114
143
|
end
|
144
|
+
private_constant :Helper
|
115
145
|
end
|
116
146
|
end
|
117
147
|
end
|
@@ -108,8 +108,6 @@ module Defmastership
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def concerned_line?(line)
|
111
|
-
return false if line.commented?
|
112
|
-
|
113
111
|
parse(line)
|
114
112
|
|
115
113
|
return false if @definition_parser.idle?
|
@@ -218,6 +216,7 @@ module Defmastership
|
|
218
216
|
end
|
219
217
|
end
|
220
218
|
end
|
219
|
+
private_constant :Helper
|
221
220
|
end
|
222
221
|
end
|
223
222
|
end
|
@@ -112,6 +112,26 @@ RSpec.describe(Defmastership::Definition) do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
describe '#sha256_short' do
|
116
|
+
context 'when definition has no summary' do
|
117
|
+
subject(:definition) { described_class.new(type: 'req') }
|
118
|
+
|
119
|
+
it 'calculates sha256_short of value' do
|
120
|
+
definition << 'first line' << 'second line'
|
121
|
+
expect(definition.sha256_short).to(eq('~beb0535a'))
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when definition has a summary' do
|
126
|
+
subject(:definition) { described_class.new(type: 'req', summary: 'first line') }
|
127
|
+
|
128
|
+
it 'calculates sha256_short of value' do
|
129
|
+
definition << 'second line'
|
130
|
+
expect(definition.sha256_short).to(eq('~beb0535a'))
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
115
135
|
describe '#add_eref' do
|
116
136
|
subject(:definition) do
|
117
137
|
described_class.new(
|
@@ -475,6 +475,40 @@ RSpec.describe(Defmastership::Document) do
|
|
475
475
|
|
476
476
|
it { expect(definition).to(have_received(:<<).with('bef one two aft')) }
|
477
477
|
end
|
478
|
+
|
479
|
+
context 'when variable in definition summary' do
|
480
|
+
let(:input_lines) do
|
481
|
+
[
|
482
|
+
':one_variable: the substituted variable',
|
483
|
+
'[define, requirement, TOTO-0001, a summary with {one_variable}]'
|
484
|
+
]
|
485
|
+
end
|
486
|
+
|
487
|
+
it do
|
488
|
+
expect(Defmastership::Definition).to(
|
489
|
+
have_received(:new).with(
|
490
|
+
matchdata_including(summary: 'a summary with the substituted variable')
|
491
|
+
)
|
492
|
+
)
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
context 'when comma in definition summary' do
|
497
|
+
let(:input_lines) do
|
498
|
+
[
|
499
|
+
':one_variable: the substituted variable',
|
500
|
+
'[define, requirement, TOTO-0001, " a summary with a, comma "]'
|
501
|
+
]
|
502
|
+
end
|
503
|
+
|
504
|
+
it do
|
505
|
+
expect(Defmastership::Definition).to(
|
506
|
+
have_received(:new).with(
|
507
|
+
matchdata_including(summary: 'a summary with a, comma')
|
508
|
+
)
|
509
|
+
)
|
510
|
+
end
|
511
|
+
end
|
478
512
|
end
|
479
513
|
|
480
514
|
context 'with invalid definitions' do
|
@@ -557,6 +591,55 @@ RSpec.describe(Defmastership::Document) do
|
|
557
591
|
end
|
558
592
|
end
|
559
593
|
|
594
|
+
describe '#summaries?' do
|
595
|
+
let(:defs) do
|
596
|
+
[
|
597
|
+
instance_double(Defmastership::Definition, 'definition'),
|
598
|
+
instance_double(Defmastership::Definition, 'definition')
|
599
|
+
]
|
600
|
+
end
|
601
|
+
|
602
|
+
let(:input_lines) do
|
603
|
+
[
|
604
|
+
'[define, requirement, TOTO-0001]',
|
605
|
+
'def one',
|
606
|
+
'',
|
607
|
+
'[define, requirement, TOTO-0002]',
|
608
|
+
'def two'
|
609
|
+
]
|
610
|
+
end
|
611
|
+
|
612
|
+
before do
|
613
|
+
allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
|
614
|
+
defs.each do |definition|
|
615
|
+
allow(definition).to(receive(:labels)).and_return([])
|
616
|
+
allow(definition).to(receive(:<<)).and_return(definition)
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
context 'when no summary' do
|
621
|
+
before do
|
622
|
+
defs.each { |definition| allow(definition).to(receive(:summary)).and_return(nil) }
|
623
|
+
document.__send__(:do_parse, input_lines)
|
624
|
+
document.summaries?
|
625
|
+
end
|
626
|
+
|
627
|
+
it { expect(defs.first).to(have_received(:summary)) }
|
628
|
+
it { expect(defs[1]).to(have_received(:summary)) }
|
629
|
+
it { expect(document.summaries?).to(be(false)) }
|
630
|
+
end
|
631
|
+
|
632
|
+
context 'when at least one summary' do
|
633
|
+
before do
|
634
|
+
allow(defs.first).to(receive(:summary)).and_return('something')
|
635
|
+
allow(defs[1]).to(receive(:summary)).and_return(nil)
|
636
|
+
document.__send__(:do_parse, input_lines)
|
637
|
+
end
|
638
|
+
|
639
|
+
it { expect(document.summaries?).to(be(true)) }
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
560
643
|
describe '#wrong_explicit_checksum?' do
|
561
644
|
let(:defs) do
|
562
645
|
[
|
@@ -13,20 +13,54 @@ RSpec.describe(Defmastership::Export::BodyFormatter) do
|
|
13
13
|
it { is_expected.not_to(be_nil) }
|
14
14
|
end
|
15
15
|
|
16
|
-
describe '#
|
16
|
+
describe '#type' do
|
17
17
|
before do
|
18
18
|
allow(definition).to(receive(:type).with(no_args).and_return('a'))
|
19
|
-
|
20
|
-
allow(definition).to(receive(:value).with(no_args).and_return('c'))
|
21
|
-
allow(definition).to(receive(:sha256_short).with(no_args).and_return('d'))
|
22
|
-
formatter.fixed
|
19
|
+
formatter.type
|
23
20
|
end
|
24
21
|
|
25
22
|
it { expect(definition).to(have_received(:type).with(no_args)) }
|
23
|
+
it { expect(formatter.type).to(eq(['a'])) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#reference' do
|
27
|
+
before do
|
28
|
+
allow(definition).to(receive(:reference).with(no_args).and_return('b'))
|
29
|
+
formatter.reference
|
30
|
+
end
|
31
|
+
|
26
32
|
it { expect(definition).to(have_received(:reference).with(no_args)) }
|
33
|
+
it { expect(formatter.reference).to(eq(['b'])) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#summary' do
|
37
|
+
before do
|
38
|
+
allow(definition).to(receive(:summary).with(no_args).and_return('b'))
|
39
|
+
formatter.summary
|
40
|
+
end
|
41
|
+
|
42
|
+
it { expect(definition).to(have_received(:summary).with(no_args)) }
|
43
|
+
it { expect(formatter.summary).to(eq(['b'])) }
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#value' do
|
47
|
+
before do
|
48
|
+
allow(definition).to(receive(:value).with(no_args).and_return('c'))
|
49
|
+
formatter.value
|
50
|
+
end
|
51
|
+
|
27
52
|
it { expect(definition).to(have_received(:value).with(no_args)) }
|
53
|
+
it { expect(formatter.value).to(eq(['c'])) }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#checksum' do
|
57
|
+
before do
|
58
|
+
allow(definition).to(receive(:sha256_short).with(no_args).and_return('d'))
|
59
|
+
formatter.checksum
|
60
|
+
end
|
61
|
+
|
28
62
|
it { expect(definition).to(have_received(:sha256_short).with(no_args)) }
|
29
|
-
it { expect(formatter.
|
63
|
+
it { expect(formatter.checksum).to(eq(['d'])) }
|
30
64
|
end
|
31
65
|
|
32
66
|
describe '#wrong_explicit_checksum' do
|
@@ -37,6 +37,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
37
37
|
)
|
38
38
|
end
|
39
39
|
allow(document).to(receive(:definitions).and_return(%i[def0 def1]))
|
40
|
+
allow(document).to(receive(:summaries?).with(no_args).and_return(false))
|
40
41
|
allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
|
41
42
|
allow(document).to(receive(:explicit_version?).with(no_args).and_return(false))
|
42
43
|
allow(document).to(receive(:labels).with(no_args).and_return([]))
|
@@ -46,7 +47,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
46
47
|
end
|
47
48
|
|
48
49
|
context 'when no variable columns' do
|
49
|
-
methods = %i[
|
50
|
+
methods = %i[type reference value checksum]
|
50
51
|
|
51
52
|
before do
|
52
53
|
methods.each do |method|
|
@@ -73,8 +74,35 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
73
74
|
it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
|
74
75
|
end
|
75
76
|
|
77
|
+
context 'when summary' do
|
78
|
+
methods = %i[type reference summary value checksum]
|
79
|
+
|
80
|
+
before do
|
81
|
+
methods.each do |method|
|
82
|
+
allow(header).to(receive(method).with(no_args).and_return(["#{method} header"]))
|
83
|
+
bodies.each_with_index do |body, index|
|
84
|
+
allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
allow(document).to(receive(:summaries?).with(no_args).and_return([:whatever]))
|
88
|
+
formatter.export_to('whatever')
|
89
|
+
end
|
90
|
+
|
91
|
+
methods.each do |method|
|
92
|
+
it { expect(header).to(have_received(method).with(no_args)) }
|
93
|
+
|
94
|
+
2.times do |index|
|
95
|
+
it { expect(bodies[index]).to(have_received(method).with(no_args)) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} header" })) }
|
100
|
+
it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def0 body" })) }
|
101
|
+
it { expect(csv).to(have_received(:<<).with(methods.map { |method| "#{method} def1 body" })) }
|
102
|
+
end
|
103
|
+
|
76
104
|
context 'when wrong_explicit_checksum' do
|
77
|
-
methods = %i[
|
105
|
+
methods = %i[type reference value checksum wrong_explicit_checksum]
|
78
106
|
|
79
107
|
before do
|
80
108
|
methods.each do |method|
|
@@ -101,7 +129,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
101
129
|
end
|
102
130
|
|
103
131
|
context 'when explicit_version' do
|
104
|
-
methods = %i[
|
132
|
+
methods = %i[type reference value checksum explicit_version]
|
105
133
|
|
106
134
|
before do
|
107
135
|
methods.each do |method|
|
@@ -128,7 +156,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
128
156
|
end
|
129
157
|
|
130
158
|
context 'when labels' do
|
131
|
-
methods = %i[
|
159
|
+
methods = %i[type reference value checksum labels]
|
132
160
|
|
133
161
|
before do
|
134
162
|
methods.each do |method|
|
@@ -155,7 +183,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
155
183
|
end
|
156
184
|
|
157
185
|
context 'when eref' do
|
158
|
-
methods = %i[
|
186
|
+
methods = %i[type reference value checksum eref]
|
159
187
|
|
160
188
|
before do
|
161
189
|
methods.each do |method|
|
@@ -182,7 +210,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
182
210
|
end
|
183
211
|
|
184
212
|
context 'when iref' do
|
185
|
-
methods = %i[
|
213
|
+
methods = %i[type reference value checksum iref]
|
186
214
|
|
187
215
|
before do
|
188
216
|
methods.each do |method|
|
@@ -209,7 +237,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
209
237
|
end
|
210
238
|
|
211
239
|
context 'when attributes' do
|
212
|
-
methods = %i[
|
240
|
+
methods = %i[type reference value checksum attributes]
|
213
241
|
|
214
242
|
before do
|
215
243
|
methods.each do |method|
|
@@ -236,7 +264,19 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
236
264
|
end
|
237
265
|
|
238
266
|
context 'when every colums' do
|
239
|
-
methods = %i[
|
267
|
+
methods = %i[
|
268
|
+
type
|
269
|
+
reference
|
270
|
+
summary
|
271
|
+
value
|
272
|
+
checksum
|
273
|
+
wrong_explicit_checksum
|
274
|
+
explicit_version
|
275
|
+
labels
|
276
|
+
eref
|
277
|
+
iref
|
278
|
+
attributes
|
279
|
+
]
|
240
280
|
|
241
281
|
before do
|
242
282
|
methods.each do |method|
|
@@ -245,6 +285,7 @@ RSpec.describe(Defmastership::Export::CSV::Formatter) do
|
|
245
285
|
allow(body).to(receive(method).with(no_args).and_return(["#{method} def#{index} body"]))
|
246
286
|
end
|
247
287
|
end
|
288
|
+
allow(document).to(receive(:summaries?).with(no_args).and_return(true))
|
248
289
|
allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(true))
|
249
290
|
allow(document).to(receive(:explicit_version?).with(no_args).and_return(true))
|
250
291
|
allow(document).to(receive(:labels).with(no_args).and_return([:whatever]))
|
@@ -13,8 +13,24 @@ RSpec.describe(Defmastership::Export::HeaderFormatter) do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#header' do
|
16
|
-
describe '#
|
17
|
-
it { expect(formatter.
|
16
|
+
describe '#type' do
|
17
|
+
it { expect(formatter.type).to(eq(['Type'])) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#reference' do
|
21
|
+
it { expect(formatter.reference).to(eq(['Reference'])) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#summary' do
|
25
|
+
it { expect(formatter.summary).to(eq(['Summary'])) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#value' do
|
29
|
+
it { expect(formatter.value).to(eq(['Value'])) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#checksum' do
|
33
|
+
it { expect(formatter.checksum).to(eq(['Checksum'])) }
|
18
34
|
end
|
19
35
|
|
20
36
|
describe '#explicit_version' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defmastership
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jérôme Arbez-Gindre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aasm
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: defmastership-core
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: '1.4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: '1.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: git
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|