defmastership 1.0.4 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.gitlab-ci.yml +0 -1
  4. data/.rubocop.yml +1 -1
  5. data/Rakefile +1 -2
  6. data/bin/defmastership +36 -24
  7. data/cucumber.yml +2 -0
  8. data/defmastership.gemspec +14 -8
  9. data/features/changeref.feature +82 -129
  10. data/features/definition_checksum.feature +298 -0
  11. data/features/definition_version.feature +24 -0
  12. data/features/export.feature +49 -31
  13. data/features/modify.feature +165 -0
  14. data/features/rename_included_files.feature +121 -0
  15. data/lib/defmastership.rb +14 -3
  16. data/lib/defmastership/batch_modifier.rb +35 -0
  17. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
  18. data/lib/defmastership/change_ref_modifier.rb +15 -0
  19. data/lib/defmastership/constants.rb +14 -1
  20. data/lib/defmastership/csv_formatter.rb +25 -19
  21. data/lib/defmastership/csv_formatter_body.rb +19 -11
  22. data/lib/defmastership/csv_formatter_header.rb +15 -10
  23. data/lib/defmastership/definition.rb +14 -3
  24. data/lib/defmastership/definition_parser.rb +46 -0
  25. data/lib/defmastership/document.rb +59 -85
  26. data/lib/defmastership/filters.rb +30 -0
  27. data/lib/defmastership/line_modifier_base.rb +29 -0
  28. data/lib/defmastership/modifier_base.rb +29 -0
  29. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  30. data/lib/defmastership/rename_included_files_modifier.rb +15 -0
  31. data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
  32. data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
  33. data/lib/defmastership/version.rb +1 -1
  34. data/spec/spec_helper.rb +1 -0
  35. data/spec/unit/defmastership/batch_modifier_spec.rb +123 -0
  36. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
  37. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  38. data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
  39. data/spec/unit/defmastership/csv_formatter_body_spec.rb +88 -82
  40. data/spec/unit/defmastership/csv_formatter_header_spec.rb +68 -22
  41. data/spec/unit/defmastership/csv_formatter_spec.rb +208 -110
  42. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  43. data/spec/unit/defmastership/definition_spec.rb +45 -4
  44. data/spec/unit/defmastership/document_spec.rb +236 -35
  45. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  46. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  47. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
  48. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
  49. metadata +47 -16
  50. data/Gemfile.lock +0 -140
  51. data/lib/defmastership/batch_changer.rb +0 -41
  52. data/lib/defmastership/project_ref_changer.rb +0 -28
  53. data/spec/unit/defmastership/batch_changer_spec.rb +0 -109
  54. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -80
@@ -0,0 +1,298 @@
1
+ Feature: definition checksum
2
+ As a Responsible of definitions for a given document
3
+ In order to detect modifications of defintiions
4
+ I want defmastership to export and update checksum in definitions
5
+
6
+ Scenario: Extract one definition with WRONG explicit checksum to CSV
7
+ Given a file named "thedoc.adoc" with:
8
+ """
9
+ [define, requirement, TOTO-0001(~babe1234)]
10
+ def one
11
+ """
12
+ When I run `defmastership export thedoc.adoc`
13
+ Then it should fail with:
14
+ """
15
+ warning: TOTO-0001 has a wrong explicit checksum (should be ~d27cb5c3)
16
+ """
17
+ And the file "thedoc.csv" should contain:
18
+ """
19
+ Type,Reference,Value,Checksum,Wrong explicit checksum
20
+ requirement,TOTO-0001,def one,~d27cb5c3,~babe1234
21
+ """
22
+ And the stdout should not contain anything
23
+
24
+ Scenario: Extract two definitions with one WRONG explicit checksum to CSV
25
+ Given a file named "thedoc.adoc" with:
26
+ """
27
+ [define, requirement, TOTO-0001(~d27cb5c3)]
28
+ def one
29
+
30
+ [define, requirement, TOTO-0002(~babe1234)]
31
+ def two
32
+ """
33
+ When I run `defmastership export thedoc.adoc`
34
+ Then it should fail with:
35
+ """
36
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
37
+ """
38
+ Then the file "thedoc.csv" should contain:
39
+ """
40
+ Type,Reference,Value,Checksum,Wrong explicit checksum
41
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
42
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
43
+ """
44
+ And the stdout should not contain anything
45
+
46
+ Scenario: Export not failing even if WRONG explicit checksum
47
+ Given a file named "thedoc.adoc" with:
48
+ """
49
+ [define, requirement, TOTO-0001(~d27cb5c3)]
50
+ def one
51
+
52
+ [define, requirement, TOTO-0002(~babe1234)]
53
+ def two
54
+ """
55
+ When I successfully run `defmastership export --no-fail thedoc.adoc`
56
+ Then the file "thedoc.csv" should contain:
57
+ """
58
+ Type,Reference,Value,Checksum,Wrong explicit checksum
59
+ requirement,TOTO-0001,def one,~d27cb5c3,\"\"
60
+ requirement,TOTO-0002,def two,~b80e1be5,~babe1234
61
+ """
62
+ And the stdout should not contain anything
63
+ And the stderr should contain:
64
+ """
65
+ warning: TOTO-0002 has a wrong explicit checksum (should be ~b80e1be5)
66
+ """
67
+
68
+ Scenario: Extract one definition with explicit checksum to CSV
69
+ Given a file named "thedoc.adoc" with:
70
+ """
71
+ [define, requirement, TOTO-0001(~b86dcbde)]
72
+ --
73
+ Exemple of multiline requirement.
74
+ Second line.
75
+ --
76
+ """
77
+ When I successfully run `defmastership export thedoc.adoc`
78
+ Then the file "thedoc.csv" should contain:
79
+ """
80
+ Type,Reference,Value,Checksum
81
+ requirement,TOTO-0001,"Exemple of multiline requirement.
82
+ Second line.",~b86dcbde
83
+ """
84
+ And the stdout should not contain anything
85
+ And the stderr should not contain anything
86
+
87
+ Scenario: Change one modifier
88
+ Given a file named "modifications.yml" with:
89
+ """
90
+ ---
91
+ :update_requirement_checksum:
92
+ :type: update_def_checksum
93
+ :config:
94
+ :def_type: requirement
95
+ """
96
+ And a file named "thedoc.adoc" with:
97
+ """
98
+ [define, requirement, TOTO-TEMP-XXX1]
99
+ --
100
+ the requirement value.
101
+ --
102
+ """
103
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
104
+ Then the stdout should not contain anything
105
+ And the stderr should not contain anything
106
+ And the file "thedoc.adoc" should contain:
107
+ """
108
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
109
+ --
110
+ the requirement value.
111
+ --
112
+ """
113
+
114
+ Scenario: Change one modifier with already set checksum
115
+ Given a file named "modifications.yml" with:
116
+ """
117
+ ---
118
+ :update_requirement_checksum:
119
+ :type: update_def_checksum
120
+ :config:
121
+ :def_type: requirement
122
+ """
123
+ And a file named "thedoc.adoc" with:
124
+ """
125
+ [define, requirement, TOTO-TEMP-XXX1(~abcd1234)]
126
+ --
127
+ the requirement value.
128
+ --
129
+ """
130
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
131
+ Then the stdout should not contain anything
132
+ And the stderr should not contain anything
133
+ And the file "thedoc.adoc" should contain:
134
+ """
135
+ [define, requirement, TOTO-TEMP-XXX1(~244eed18)]
136
+ --
137
+ the requirement value.
138
+ --
139
+ """
140
+
141
+ Scenario: Checksum is calculated on included file for export
142
+ Given a file named "thedoc.adoc" with:
143
+ """
144
+ [define, requirement, TOTO-0001]
145
+ --
146
+ include::included.txt[]
147
+ --
148
+ """
149
+ And a file named "included.txt" with:
150
+ """
151
+ Exemple of multiline requirement.
152
+ Second line.
153
+ """
154
+ When I successfully run `defmastership export thedoc.adoc`
155
+ Then the file "thedoc.csv" should contain:
156
+ """
157
+ Type,Reference,Value,Checksum
158
+ requirement,TOTO-0001,"Exemple of multiline requirement.
159
+ Second line.",~b86dcbde
160
+ """
161
+ And the stdout should not contain anything
162
+ And the stderr should not contain anything
163
+
164
+ Scenario: Checksum is calculated on included file in ref modification
165
+ Given a file named "modifications.yml" with:
166
+ """
167
+ ---
168
+ :update_requirement_checksum:
169
+ :type: update_def_checksum
170
+ :config:
171
+ :def_type: requirement
172
+ """
173
+ And a file named "thedoc.adoc" with:
174
+ """
175
+ [define, requirement, TOTO-0001]
176
+ --
177
+ include::included.txt[]
178
+ --
179
+ """
180
+ And a file named "included.txt" with:
181
+ """
182
+ Exemple of multiline requirement.
183
+ Second line.
184
+ """
185
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
186
+ Then the file "thedoc.adoc" should contain:
187
+ """
188
+ [define, requirement, TOTO-0001(~b86dcbde)]
189
+ --
190
+ include::included.txt[]
191
+ --
192
+ """
193
+ And the stdout should not contain anything
194
+ And the stderr should not contain anything
195
+
196
+ Scenario: Checksum take into account variables in CSV export
197
+ Given a file named "thedoc.adoc" with:
198
+ """
199
+ :variable: multiline
200
+ [define, requirement, TOTO-0001]
201
+ --
202
+ Exemple of {variable} requirement.
203
+ Second line.
204
+ --
205
+ """
206
+ When I successfully run `defmastership export thedoc.adoc`
207
+ Then the file "thedoc.csv" should contain:
208
+ """
209
+ Type,Reference,Value,Checksum
210
+ requirement,TOTO-0001,"Exemple of multiline requirement.
211
+ Second line.",~b86dcbde
212
+ """
213
+ And the stdout should not contain anything
214
+ And the stderr should not contain anything
215
+
216
+ Scenario: Checksum take into account variables in ref modification
217
+ Given a file named "modifications.yml" with:
218
+ """
219
+ ---
220
+ :update_requirement_checksum:
221
+ :type: update_def_checksum
222
+ :config:
223
+ :def_type: requirement
224
+ """
225
+ And a file named "thedoc.adoc" with:
226
+ """
227
+ :variable: multiline
228
+ [define, requirement, TOTO-0001]
229
+ --
230
+ Exemple of {variable} requirement.
231
+ Second line.
232
+ --
233
+ """
234
+ When I successfully run `defmastership modify --modifications update_requirement_checksum thedoc.adoc`
235
+ Then the file "thedoc.adoc" should contain:
236
+ """
237
+ [define, requirement, TOTO-0001(~b86dcbde)]
238
+ --
239
+ Exemple of {variable} requirement.
240
+ Second line.
241
+ --
242
+ """
243
+ And the stdout should not contain anything
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,24 @@
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
+
@@ -12,16 +12,33 @@ Feature: The extract command
12
12
  Second line.
13
13
  --
14
14
  """
15
- When I run `defmastership export toto.adoc`
15
+ When I successfully run `defmastership export toto.adoc`
16
16
  Then the file "toto.csv" should contain:
17
17
  """
18
- Type,Reference,Value
18
+ Type,Reference,Value,Checksum
19
19
  requirement,TOTO-0001,"Exemple of multiline requirement.
20
- Second line."
20
+ Second line.",~b86dcbde
21
21
  """
22
22
  And the stdout should not contain anything
23
23
  And the stderr should not contain anything
24
24
 
25
+ Scenario: Extract to CSV with alternative CSV separator
26
+ Given a file named "toto.adoc" with:
27
+ """
28
+ [define, requirement, TOTO-0001]
29
+ --
30
+ Exemple of multiline requirement.
31
+ Second line.
32
+ --
33
+ """
34
+ When I successfully run `defmastership export --separator=';' toto.adoc`
35
+ Then the file "toto.csv" should contain:
36
+ """
37
+ Type;Reference;Value;Checksum
38
+ requirement;TOTO-0001;"Exemple of multiline requirement.
39
+ Second line.";~b86dcbde
40
+ """
41
+
25
42
  Scenario: Extract one definition with variable to CSV
26
43
  Given a file named "toto.adoc" with:
27
44
  """
@@ -34,13 +51,13 @@ Feature: The extract command
34
51
  Third line with {not_defined_variable}.
35
52
  --
36
53
  """
37
- When I run `defmastership export toto.adoc`
54
+ When I successfully run `defmastership export toto.adoc`
38
55
  Then the file "toto.csv" should contain:
39
56
  """
40
- Type,Reference,Value
57
+ Type,Reference,Value,Checksum
41
58
  requirement,TOTO-0001,"Exemple of multiline requirement with variable: Variable content.
42
59
  Variable content : Variable content Toto.
43
- Third line with {not_defined_variable}."
60
+ Third line with {not_defined_variable}.",~3bf370ed
44
61
  """
45
62
  And the stdout should not contain anything
46
63
  And the stderr should not contain anything
@@ -62,13 +79,14 @@ Feature: The extract command
62
79
  Second line.
63
80
  --
64
81
  """
65
- When I run `defmastership export toto.adoc`
82
+ When I successfully run `defmastership export toto.adoc`
66
83
  Then the file "toto.csv" should contain:
67
84
  """
68
- Type,Reference,Value
85
+ Type,Reference,Value,Checksum
69
86
  requirement,TOTO-0001,"Exemple of multiline requirement.
70
- Second line."
71
- something_else,TOTO-0003,"only one paragraphe.\nwith two sentences."
87
+ Second line.",~b86dcbde
88
+ something_else,TOTO-0003,"only one paragraphe.
89
+ with two sentences.",~4761e172
72
90
  """
73
91
  And the file "toto.csv" should not contain:
74
92
  """
@@ -90,7 +108,7 @@ Feature: The extract command
90
108
  only one line
91
109
  ....
92
110
  """
93
- When I run `defmastership export toto.adoc`
111
+ When I successfully run `defmastership export toto.adoc`
94
112
  Then the file "toto.csv" should not contain:
95
113
  """
96
114
  something_else
@@ -111,7 +129,7 @@ Feature: The extract command
111
129
  only one line
112
130
  ////
113
131
  """
114
- When I run `defmastership export toto.adoc`
132
+ When I successfully run `defmastership export toto.adoc`
115
133
  Then the file "toto.csv" should not contain:
116
134
  """
117
135
  something_else
@@ -134,7 +152,7 @@ Feature: The extract command
134
152
  ////
135
153
  [define, something_else, TOTO-0003]
136
154
  """
137
- When I run `defmastership export toto.adoc`
155
+ When I successfully run `defmastership export toto.adoc`
138
156
  Then the file "toto.csv" should contain:
139
157
  """
140
158
  something_else
@@ -151,12 +169,12 @@ Feature: The extract command
151
169
  Second line.
152
170
  --
153
171
  """
154
- When I run `defmastership export toto.adoc`
172
+ When I successfully run `defmastership export toto.adoc`
155
173
  Then the file "toto.csv" should contain:
156
174
  """
157
- Type,Reference,Value,Labels
175
+ Type,Reference,Value,Checksum,Labels
158
176
  requirement,TOTO-0001,"Exemple of multiline requirement.
159
- Second line.","label1
177
+ Second line.",~b86dcbde,"label1
160
178
  label2"
161
179
  """
162
180
  And the stdout should not contain anything
@@ -174,12 +192,12 @@ Feature: The extract command
174
192
  --
175
193
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
176
194
  """
177
- When I run `defmastership export toto.adoc`
195
+ When I successfully run `defmastership export toto.adoc`
178
196
  Then the file "toto.csv" should contain:
179
197
  """
180
- Type,Reference,Value,Participate to: ./the_other_document.html
198
+ Type,Reference,Value,Checksum,Participate to:
181
199
  requirement,TOTO-0001,"Exemple of multiline requirement.
182
- Second line.","SYSTEM-0012
200
+ Second line.",~b86dcbde,"SYSTEM-0012
183
201
  SYSTEM-0014"
184
202
  """
185
203
  And the stdout should not contain anything
@@ -197,12 +215,12 @@ Feature: The extract command
197
215
  --
198
216
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
199
217
  """
200
- When I run `defmastership export toto.adoc`
218
+ When I successfully run `defmastership export toto.adoc`
201
219
  Then the file "toto.csv" should contain:
202
220
  """
203
- Type,Reference,Value,Participate to:
221
+ Type,Reference,Value,Checksum,Participate to:
204
222
  requirement,TOTO-0001,"Exemple of multiline requirement.
205
- Second line.","SYSTEM-0012
223
+ Second line.",~b86dcbde,"SYSTEM-0012
206
224
  SYSTEM-0014"
207
225
  """
208
226
  And the stdout should not contain anything
@@ -219,14 +237,14 @@ Feature: The extract command
219
237
  --
220
238
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
221
239
  """
222
- When I run `defmastership export toto.adoc`
240
+ When I successfully run `defmastership export toto.adoc`
223
241
  Then the stdout should not contain anything
224
242
  And the stderr should not contain anything
225
243
  And the file "toto.csv" should contain:
226
244
  """
227
- Type,Reference,Value,Participate to:
245
+ Type,Reference,Value,Checksum,Participate to:
228
246
  requirement,TOTO-0001,"Exemple of multiline requirement.
229
- Second line.","SYSTEM-0012
247
+ Second line.",~b86dcbde,"SYSTEM-0012
230
248
  SYSTEM-0014"
231
249
  """
232
250
 
@@ -240,12 +258,12 @@ Feature: The extract command
240
258
  --
241
259
  please see defs:iref[TOTO-0002]
242
260
  """
243
- When I run `defmastership export toto.adoc`
261
+ When I successfully run `defmastership export toto.adoc`
244
262
  Then the file "toto.csv" should contain:
245
263
  """
246
- Type,Reference,Value,Internal links
264
+ Type,Reference,Value,Checksum,Internal links
247
265
  requirement,TOTO-0001,"Exemple of multiline requirement.
248
- Second line: defs:iref[TOTO-0001], defs:iref[TOTO-0123].","TOTO-0001
266
+ Second line: defs:iref[TOTO-0001], defs:iref[TOTO-0123].",~059b7188,"TOTO-0001
249
267
  TOTO-0123
250
268
  TOTO-0002"
251
269
  """
@@ -264,12 +282,12 @@ Feature: The extract command
264
282
  defs:attribute[verifiedby, Beautiful Test]
265
283
  defs:attribute[criticity, Very cool]
266
284
  """
267
- When I run `defmastership export toto.adoc`
285
+ When I successfully run `defmastership export toto.adoc`
268
286
  And the stdout should not contain anything
269
287
  Then the file "toto.csv" should contain:
270
288
  """
271
- Type,Reference,Value,Verified by:,Criticity:
272
- requirement,TOTO-0001,One single line.,Beautiful Test,Very cool
289
+ Type,Reference,Value,Checksum,Verified by:,Criticity:
290
+ requirement,TOTO-0001,One single line.,~554b0ff5,Beautiful Test,Very cool
273
291
  """
274
292
  And the stdout should not contain anything
275
293
  And the stderr should not contain anything