defmastership 1.0.7 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/bin/defmastership +1 -1
  4. data/features/changeref.feature +33 -0
  5. data/features/{checksum.feature → definition_checksum.feature} +85 -31
  6. data/features/definition_version.feature +204 -0
  7. data/features/export.feature +21 -21
  8. data/features/modify.feature +23 -1
  9. data/features/rename_included_files.feature +4 -0
  10. data/lib/defmastership.rb +3 -0
  11. data/lib/defmastership/batch_modifier.rb +2 -0
  12. data/lib/defmastership/change_ref_line_modifier.rb +2 -1
  13. data/lib/defmastership/constants.rb +4 -2
  14. data/lib/defmastership/csv_formatter.rb +12 -6
  15. data/lib/defmastership/csv_formatter_body.rb +8 -5
  16. data/lib/defmastership/csv_formatter_header.rb +5 -1
  17. data/lib/defmastership/definition.rb +4 -4
  18. data/lib/defmastership/document.rb +11 -15
  19. data/lib/defmastership/rename_included_files_line_modifier.rb +1 -1
  20. data/lib/defmastership/update_def_checksum_line_modifier.rb +2 -3
  21. data/lib/defmastership/update_def_checksum_modifier.rb +1 -1
  22. data/lib/defmastership/update_def_version_line_modifier.rb +58 -0
  23. data/lib/defmastership/update_def_version_modifier.rb +25 -0
  24. data/lib/defmastership/version.rb +1 -1
  25. data/spec/unit/defmastership/batch_modifier_spec.rb +8 -0
  26. data/spec/unit/defmastership/change_ref_line_modifier_spec.rb +15 -0
  27. data/spec/unit/defmastership/csv_formatter_body_spec.rb +42 -60
  28. data/spec/unit/defmastership/csv_formatter_header_spec.rb +23 -1
  29. data/spec/unit/defmastership/csv_formatter_spec.rb +204 -67
  30. data/spec/unit/defmastership/definition_spec.rb +19 -4
  31. data/spec/unit/defmastership/document_spec.rb +71 -4
  32. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +8 -8
  33. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +14 -4
  34. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
  35. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
  36. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0341f43f016456f897b3382a1a8356dd7dc5d35b37059bccfd254f5cd9ccf65d
4
- data.tar.gz: 442ebad69c76c21f8bfb972bd53d7ce83e6431795026f7b4abc760a70b450bf7
3
+ metadata.gz: 1a98ba2cd70decfd584d57f914d05bc31356cd53846fa13b01f3406ff41dc087
4
+ data.tar.gz: 999f28e56b654a6dd35d9da30a8701abd1121f62db4df730fcf903a255b34eff
5
5
  SHA512:
6
- metadata.gz: 7106dd56ff07b88ca64e67f3dbd62b46f09a078dff05a955f80a5a1473ca3ff918ff038346a9e598c8355de761e1e5dcc1270db811eadacb875d51de57032b09
7
- data.tar.gz: 719a47a9bb86aca473565693a645a85b72ade6036a2ed1ee47cdafc00c85640c52a747e2394d59e8f2ed08803406d49f03914a1b5d74026d20ae01de56b8c474
6
+ metadata.gz: 44bd90676d2ebd37cf47c0e6d9160340d1861497eb4a110e47e5b35c26cd23a28a1ddd24c93e489238520f916997fb2f45801ec1c74b84a7c44f16798b3c0eaf
7
+ data.tar.gz: 60d4904b54cbb6708ff1633ad0d01d9e43a97d0e4cb90c51126487de2eae477e81e670db38fc151784bde3bb59f1f473abf804f08f0968f06d99dbd58a32c3fa
data/.rubocop.yml CHANGED
@@ -62,3 +62,7 @@ RSpec/FilePath :
62
62
 
63
63
  RSpec/NestedGroups:
64
64
  Max: 4
65
+
66
+ Layout/RedundantLineBreak:
67
+ Enabled: false
68
+
data/bin/defmastership CHANGED
@@ -65,7 +65,7 @@ module DefMastership
65
65
  my_doc.definitions.each do |definition|
66
66
  next if definition.wrong_explicit_checksum.nil?
67
67
 
68
- warn("WARNING: #{definition.reference} has a wrong explicit checksum (should be #{definition.sha256})")
68
+ warn("warning: #{definition.reference} has a wrong explicit checksum (should be #{definition.sha256})")
69
69
  end
70
70
  exit 1 unless options[:"no-fail"]
71
71
  end
@@ -36,6 +36,39 @@ Feature: The changeref command
36
36
  [define, requirement, TOTO-0123]
37
37
  """
38
38
 
39
+ Scenario: Change a definition with explicit checksum and version
40
+ Given a file named "modifications.yml" with:
41
+ """
42
+ ---
43
+ :toto:
44
+ :type: change_ref
45
+ :config:
46
+ :from_regexp: TOTO-TEMP-[X\d]{4}
47
+ :to_template: TOTO-%<next_ref>04d
48
+ :next_ref: 123
49
+ """
50
+ And a file named "thedoc.adoc" with:
51
+ """
52
+ [define, requirement, TOTO-TEMP-XXX1(a~12345678)]
53
+ """
54
+ When I successfully run `defmastership modify --modifications toto thedoc.adoc`
55
+ Then the stdout should not contain anything
56
+ And the stderr should not contain anything
57
+ And the file "modifications.yml" should contain:
58
+ """
59
+ ---
60
+ :toto:
61
+ :type: change_ref
62
+ :config:
63
+ :from_regexp: TOTO-TEMP-[X\d]{4}
64
+ :to_template: TOTO-%<next_ref>04d
65
+ :next_ref: 124
66
+ """
67
+ And the file "thedoc.adoc" should contain:
68
+ """
69
+ [define, requirement, TOTO-0123(a~12345678)]
70
+ """
71
+
39
72
  Scenario: Change two definitions
40
73
  Given a file named "modifications.yml" with:
41
74
  """
@@ -1,4 +1,4 @@
1
- Feature: checksum
1
+ Feature: definition checksum
2
2
  As a Responsible of definitions for a given document
3
3
  In order to detect modifications of defintiions
4
4
  I want defmastership to export and update checksum in definitions
@@ -6,69 +6,69 @@ Feature: checksum
6
6
  Scenario: Extract one definition with WRONG explicit checksum to CSV
7
7
  Given a file named "thedoc.adoc" with:
8
8
  """
9
- [define, requirement, TOTO-0001(babe1234)]
9
+ [define, requirement, TOTO-0001(~babe1234)]
10
10
  def one
11
11
  """
12
12
  When I run `defmastership export thedoc.adoc`
13
13
  Then it should fail with:
14
14
  """
15
- WARNING: TOTO-0001 has a wrong explicit checksum (should be d27cb5c3)
15
+ warning: TOTO-0001 has a wrong explicit checksum (should be ~d27cb5c3)
16
16
  """
17
17
  And the file "thedoc.csv" should contain:
18
18
  """
19
- Type,Reference,Value,sha256,Wrong explicit checksum
20
- requirement,TOTO-0001,def one,d27cb5c3,babe1234
19
+ Type,Reference,Value,Checksum,Wrong explicit checksum
20
+ requirement,TOTO-0001,def one,~d27cb5c3,~babe1234
21
21
  """
22
22
  And the stdout should not contain anything
23
23
 
24
24
  Scenario: Extract two definitions with one WRONG explicit checksum to CSV
25
25
  Given a file named "thedoc.adoc" with:
26
26
  """
27
- [define, requirement, TOTO-0001(d27cb5c3)]
27
+ [define, requirement, TOTO-0001(~d27cb5c3)]
28
28
  def one
29
29
 
30
- [define, requirement, TOTO-0002(babe1234)]
30
+ [define, requirement, TOTO-0002(~babe1234)]
31
31
  def two
32
32
  """
33
33
  When I run `defmastership export thedoc.adoc`
34
34
  Then it should fail with:
35
35
  """
36
- WARNING: TOTO-0002 has a wrong explicit checksum (should be b80e1be5)
36
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
37
37
  """
38
38
  Then the file "thedoc.csv" should contain:
39
39
  """
40
- Type,Reference,Value,sha256,Wrong explicit checksum
41
- requirement,TOTO-0001,def one,d27cb5c3,\"\"
42
- requirement,TOTO-0002,def two,b80e1be5,babe1234
40
+ Type,Reference,Value,Checksum,Wrong explicit checksum
41
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
42
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
43
43
  """
44
44
  And the stdout should not contain anything
45
45
 
46
46
  Scenario: Export not failing even if WRONG explicit checksum
47
47
  Given a file named "thedoc.adoc" with:
48
48
  """
49
- [define, requirement, TOTO-0001(d27cb5c3)]
49
+ [define, requirement, TOTO-0001(~d27cb5c3)]
50
50
  def one
51
51
 
52
- [define, requirement, TOTO-0002(babe1234)]
52
+ [define, requirement, TOTO-0002(~babe1234)]
53
53
  def two
54
54
  """
55
55
  When I successfully run `defmastership export --no-fail thedoc.adoc`
56
56
  Then the file "thedoc.csv" should contain:
57
57
  """
58
- Type,Reference,Value,sha256,Wrong explicit checksum
59
- requirement,TOTO-0001,def one,d27cb5c3,\"\"
60
- requirement,TOTO-0002,def two,b80e1be5,babe1234
58
+ Type,Reference,Value,Checksum,Wrong explicit checksum
59
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
60
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
61
61
  """
62
62
  And the stdout should not contain anything
63
63
  And the stderr should contain:
64
64
  """
65
- WARNING: TOTO-0002 has a wrong explicit checksum (should be b80e1be5)
65
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
66
66
  """
67
67
 
68
68
  Scenario: Extract one definition with explicit checksum to CSV
69
69
  Given a file named "thedoc.adoc" with:
70
70
  """
71
- [define, requirement, TOTO-0001(b86dcbde)]
71
+ [define, requirement, TOTO-0001(~b86dcbde)]
72
72
  --
73
73
  Exemple of multiline requirement.
74
74
  Second line.
@@ -77,9 +77,9 @@ Feature: checksum
77
77
  When I successfully run `defmastership export thedoc.adoc`
78
78
  Then the file "thedoc.csv" should contain:
79
79
  """
80
- Type,Reference,Value,sha256
80
+ Type,Reference,Value,Checksum
81
81
  requirement,TOTO-0001,"Exemple of multiline requirement.
82
- Second line.",b86dcbde
82
+ Second line.",~b86dcbde
83
83
  """
84
84
  And the stdout should not contain anything
85
85
  And the stderr should not contain anything
@@ -105,7 +105,7 @@ Feature: checksum
105
105
  And the stderr should not contain anything
106
106
  And the file "thedoc.adoc" should contain:
107
107
  """
108
- [define, requirement, TOTO-TEMP-XXX1(244eed18)]
108
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
109
109
  --
110
110
  the requirement value.
111
111
  --
@@ -122,7 +122,7 @@ Feature: checksum
122
122
  """
123
123
  And a file named "thedoc.adoc" with:
124
124
  """
125
- [define, requirement, TOTO-TEMP-XXX1(abcd1234)]
125
+ [define, requirement, TOTO-TEMP-XXX1(~abcd1234)]
126
126
  --
127
127
  the requirement value.
128
128
  --
@@ -132,7 +132,7 @@ Feature: checksum
132
132
  And the stderr should not contain anything
133
133
  And the file "thedoc.adoc" should contain:
134
134
  """
135
- [define, requirement, TOTO-TEMP-XXX1(244eed18)]
135
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
136
136
  --
137
137
  the requirement value.
138
138
  --
@@ -154,14 +154,14 @@ Feature: checksum
154
154
  When I successfully run `defmastership export thedoc.adoc`
155
155
  Then the file "thedoc.csv" should contain:
156
156
  """
157
- Type,Reference,Value,sha256
157
+ Type,Reference,Value,Checksum
158
158
  requirement,TOTO-0001,"Exemple of multiline requirement.
159
- Second line.",b86dcbde
159
+ Second line.",~b86dcbde
160
160
  """
161
161
  And the stdout should not contain anything
162
162
  And the stderr should not contain anything
163
163
 
164
- Scenario: Checksum is calculated on included file in ref modifcation
164
+ Scenario: Checksum is calculated on included file in ref modification
165
165
  Given a file named "modifications.yml" with:
166
166
  """
167
167
  ---
@@ -185,7 +185,7 @@ Feature: checksum
185
185
  When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
186
186
  Then the file "thedoc.adoc" should contain:
187
187
  """
188
- [define, requirement, TOTO-0001(b86dcbde)]
188
+ [define, requirement, TOTO-0001(~b86dcbde)]
189
189
  --
190
190
  include::included.txt[]
191
191
  --
@@ -206,14 +206,14 @@ Feature: checksum
206
206
  When I successfully run `defmastership export thedoc.adoc`
207
207
  Then the file "thedoc.csv" should contain:
208
208
  """
209
- Type,Reference,Value,sha256
209
+ Type,Reference,Value,Checksum
210
210
  requirement,TOTO-0001,"Exemple of multiline requirement.
211
- Second line.",b86dcbde
211
+ Second line.",~b86dcbde
212
212
  """
213
213
  And the stdout should not contain anything
214
214
  And the stderr should not contain anything
215
215
 
216
- Scenario: Checksum take into account variables in ref modifcation
216
+ Scenario: Checksum take into account variables in ref modification
217
217
  Given a file named "modifications.yml" with:
218
218
  """
219
219
  ---
@@ -234,7 +234,7 @@ Feature: checksum
234
234
  When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
235
235
  Then the file "thedoc.adoc" should contain:
236
236
  """
237
- [define, requirement, TOTO-0001(b86dcbde)]
237
+ [define, requirement, TOTO-0001(~b86dcbde)]
238
238
  --
239
239
  Exemple of {variable} requirement.
240
240
  Second line.
@@ -242,3 +242,57 @@ Feature: checksum
242
242
  """
243
243
  And the stdout should not contain anything
244
244
  And the stderr should not contain anything
245
+
246
+ Scenario: Checksum keep explicit version in ref modification
247
+ Given a file named "modifications.yml" with:
248
+ """
249
+ ---
250
+ :update_requirement_checksum:
251
+ :type: update_def_checksum
252
+ :config:
253
+ :def_type: requirement
254
+ """
255
+ And a file named "thedoc.adoc" with:
256
+ """
257
+ [define, requirement, TOTO-TEMP-XXX1(toto~abcd1234)]
258
+ --
259
+ the requirement value.
260
+ --
261
+ """
262
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
263
+ Then the stdout should not contain anything
264
+ And the stderr should not contain anything
265
+ And the file "thedoc.adoc" should contain:
266
+ """
267
+ [define, requirement, TOTO-TEMP-XXX1(toto~244eed18)]
268
+ --
269
+ the requirement value.
270
+ --
271
+ """
272
+
273
+ Scenario: Checksum keep explicit version in ref setting
274
+ Given a file named "modifications.yml" with:
275
+ """
276
+ ---
277
+ :update_requirement_checksum:
278
+ :type: update_def_checksum
279
+ :config:
280
+ :def_type: requirement
281
+ """
282
+ And a file named "thedoc.adoc" with:
283
+ """
284
+ [define, requirement, TOTO-TEMP-XXX1(toto)]
285
+ --
286
+ the requirement value.
287
+ --
288
+ """
289
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
290
+ Then the stdout should not contain anything
291
+ And the stderr should not contain anything
292
+ And the file "thedoc.adoc" should contain:
293
+ """
294
+ [define, requirement, TOTO-TEMP-XXX1(toto~244eed18)]
295
+ --
296
+ the requirement value.
297
+ --
298
+ """
@@ -0,0 +1,204 @@
1
+ Feature: definitions version
2
+ As a Responsible of definitions for a given document
3
+ In order to detect handle versions definitions
4
+ I want defmastership to export explicit versions in definitions
5
+
6
+ Scenario: Extract one definition with explicit version to CSV
7
+ Given a file named "thedoc.adoc" with:
8
+ """
9
+ [define, requirement, TOTO-0001(pouet)]
10
+ --
11
+ Exemple of multiline requirement.
12
+ Second line.
13
+ --
14
+ """
15
+ When I successfully run `defmastership export thedoc.adoc`
16
+ Then the file "thedoc.csv" should contain:
17
+ """
18
+ Type,Reference,Value,Checksum,Version
19
+ requirement,TOTO-0001,"Exemple of multiline requirement.
20
+ Second line.",~b86dcbde,pouet
21
+ """
22
+ And the stdout should not contain anything
23
+ And the stderr should not contain anything
24
+
25
+ Scenario: Set initial explicit version when definition has changed
26
+ Given a file named "ref_doc.adoc" with:
27
+ """
28
+ [define, requirement, TOTO-0001]
29
+ --
30
+ initial text.
31
+ --
32
+ """
33
+ Given a file named "thedoc.adoc" with:
34
+ """
35
+ [define, requirement, TOTO-0001(whatever)]
36
+ --
37
+ modified text.
38
+ --
39
+ """
40
+ And a file named "modifications.yml" with:
41
+ """
42
+ ---
43
+ :update_requirement_version:
44
+ :type: update_def_version
45
+ :config:
46
+ :def_type: requirement
47
+ :first_version: a
48
+ :ref_document: ./ref_doc.adoc
49
+ """
50
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
51
+ And the stdout should not contain anything
52
+ And the stderr should not contain anything
53
+ Then the file "thedoc.adoc" should contain:
54
+ """
55
+ [define, requirement, TOTO-0001(a)]
56
+ --
57
+ modified text.
58
+ --
59
+ """
60
+
61
+ Scenario: Do not set initial explicit version when definition has NOT changed
62
+ Given a file named "ref_doc.adoc" with:
63
+ """
64
+ [define, requirement, TOTO-0001]
65
+ --
66
+ initial text.
67
+ --
68
+ """
69
+ Given a file named "thedoc.adoc" with:
70
+ """
71
+ [define, requirement, TOTO-0001(whatever)]
72
+ --
73
+ initial text.
74
+ --
75
+ """
76
+ And a file named "modifications.yml" with:
77
+ """
78
+ ---
79
+ :update_requirement_version:
80
+ :type: update_def_version
81
+ :config:
82
+ :def_type: requirement
83
+ :first_version: a
84
+ :ref_document: ./ref_doc.adoc
85
+ """
86
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
87
+ And the stdout should not contain anything
88
+ And the stderr should not contain anything
89
+ Then the file "thedoc.adoc" should contain:
90
+ """
91
+ [define, requirement, TOTO-0001]
92
+ --
93
+ initial text.
94
+ --
95
+ """
96
+
97
+ Scenario: Set initial explicit version when definition has changed and ref is not an initial version
98
+ Given a file named "ref_doc.adoc" with:
99
+ """
100
+ [define, requirement, TOTO-0001(3)]
101
+ --
102
+ initial text.
103
+ --
104
+ """
105
+ Given a file named "thedoc.adoc" with:
106
+ """
107
+ [define, requirement, TOTO-0001(whatever)]
108
+ --
109
+ modified text.
110
+ --
111
+ """
112
+ And a file named "modifications.yml" with:
113
+ """
114
+ ---
115
+ :update_requirement_version:
116
+ :type: update_def_version
117
+ :config:
118
+ :def_type: requirement
119
+ :first_version: 1
120
+ :ref_document: ./ref_doc.adoc
121
+ """
122
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
123
+ And the stdout should not contain anything
124
+ And the stderr should not contain anything
125
+ Then the file "thedoc.adoc" should contain:
126
+ """
127
+ [define, requirement, TOTO-0001(4)]
128
+ --
129
+ modified text.
130
+ --
131
+ """
132
+
133
+ Scenario: No initial explicit version when definition is new
134
+ Given a file named "ref_doc.adoc" with:
135
+ """
136
+ [define, requirement, TOTO-0002]
137
+ --
138
+ initial text.
139
+ --
140
+ """
141
+ Given a file named "thedoc.adoc" with:
142
+ """
143
+ [define, requirement, TOTO-0001(whatever)]
144
+ --
145
+ modified text.
146
+ --
147
+ """
148
+ And a file named "modifications.yml" with:
149
+ """
150
+ ---
151
+ :update_requirement_version:
152
+ :type: update_def_version
153
+ :config:
154
+ :def_type: requirement
155
+ :first_version: 1
156
+ :ref_document: ./ref_doc.adoc
157
+ """
158
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
159
+ And the stdout should not contain anything
160
+ And the stderr should not contain anything
161
+ Then the file "thedoc.adoc" should contain:
162
+ """
163
+ [define, requirement, TOTO-0001]
164
+ --
165
+ modified text.
166
+ --
167
+ """
168
+
169
+ Scenario: update explicit version whith explicit checksum
170
+ Given a file named "ref_doc.adoc" with:
171
+ """
172
+ [define, requirement, TOTO-0001]
173
+ --
174
+ initial text.
175
+ --
176
+ """
177
+ Given a file named "thedoc.adoc" with:
178
+ """
179
+ [define, requirement, TOTO-0001(whatever~abcd1234)]
180
+ --
181
+ modified text.
182
+ --
183
+ """
184
+ And a file named "modifications.yml" with:
185
+ """
186
+ ---
187
+ :update_requirement_version:
188
+ :type: update_def_version
189
+ :config:
190
+ :def_type: requirement
191
+ :first_version: a
192
+ :ref_document: ./ref_doc.adoc
193
+ """
194
+ When I successfully run `defmastership modify --modifications update_requirement_version thedoc.adoc`
195
+ And the stdout should not contain anything
196
+ And the stderr should not contain anything
197
+ Then the file "thedoc.adoc" should contain:
198
+ """
199
+ [define, requirement, TOTO-0001(a~abcd1234)]
200
+ --
201
+ modified text.
202
+ --
203
+ """
204
+