defmastership 1.0.5 → 1.0.10

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/.rubocop.yml +1 -1
  3. data/bin/defmastership +33 -22
  4. data/cucumber.yml +1 -1
  5. data/defmastership.gemspec +12 -6
  6. data/features/changeref.feature +82 -129
  7. data/features/definition_checksum.feature +298 -0
  8. data/features/definition_version.feature +204 -0
  9. data/features/export.feature +35 -34
  10. data/features/modify.feature +165 -0
  11. data/features/rename_included_files.feature +121 -0
  12. data/lib/defmastership.rb +17 -3
  13. data/lib/defmastership/batch_modifier.rb +35 -0
  14. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
  15. data/lib/defmastership/change_ref_modifier.rb +15 -0
  16. data/lib/defmastership/constants.rb +14 -1
  17. data/lib/defmastership/csv_formatter.rb +22 -17
  18. data/lib/defmastership/csv_formatter_body.rb +19 -11
  19. data/lib/defmastership/csv_formatter_header.rb +15 -10
  20. data/lib/defmastership/definition.rb +14 -3
  21. data/lib/defmastership/definition_parser.rb +46 -0
  22. data/lib/defmastership/document.rb +59 -85
  23. data/lib/defmastership/filters.rb +30 -0
  24. data/lib/defmastership/line_modifier_base.rb +29 -0
  25. data/lib/defmastership/modifier_base.rb +29 -0
  26. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  27. data/lib/defmastership/rename_included_files_modifier.rb +15 -0
  28. data/lib/defmastership/update_def_checksum_line_modifier.rb +38 -0
  29. data/lib/defmastership/update_def_checksum_modifier.rb +21 -0
  30. data/lib/defmastership/update_def_version_line_modifier.rb +58 -0
  31. data/lib/defmastership/update_def_version_modifier.rb +25 -0
  32. data/lib/defmastership/version.rb +1 -1
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/unit/defmastership/batch_modifier_spec.rb +123 -0
  35. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
  36. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  37. data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
  38. data/spec/unit/defmastership/csv_formatter_body_spec.rb +88 -82
  39. data/spec/unit/defmastership/csv_formatter_header_spec.rb +68 -22
  40. data/spec/unit/defmastership/csv_formatter_spec.rb +207 -109
  41. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  42. data/spec/unit/defmastership/definition_spec.rb +45 -4
  43. data/spec/unit/defmastership/document_spec.rb +236 -35
  44. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  45. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  46. data/spec/unit/defmastership/update_def_checksum_line_modifier_spec.rb +78 -0
  47. data/spec/unit/defmastership/update_def_checksum_modifier_spec.rb +75 -0
  48. data/spec/unit/defmastership/update_def_version_line_modifier_spec.rb +127 -0
  49. data/spec/unit/defmastership/update_def_version_modifier_spec.rb +80 -0
  50. metadata +44 -9
  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
@@ -12,12 +12,12 @@ 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
@@ -31,12 +31,12 @@ Feature: The extract command
31
31
  Second line.
32
32
  --
33
33
  """
34
- When I run `defmastership export --separator=';' toto.adoc`
34
+ When I successfully run `defmastership export --separator=';' toto.adoc`
35
35
  Then the file "toto.csv" should contain:
36
36
  """
37
- Type;Reference;Value
37
+ Type;Reference;Value;Checksum
38
38
  requirement;TOTO-0001;"Exemple of multiline requirement.
39
- Second line."
39
+ Second line.";~b86dcbde
40
40
  """
41
41
 
42
42
  Scenario: Extract one definition with variable to CSV
@@ -51,13 +51,13 @@ Feature: The extract command
51
51
  Third line with {not_defined_variable}.
52
52
  --
53
53
  """
54
- When I run `defmastership export toto.adoc`
54
+ When I successfully run `defmastership export toto.adoc`
55
55
  Then the file "toto.csv" should contain:
56
56
  """
57
- Type,Reference,Value
57
+ Type,Reference,Value,Checksum
58
58
  requirement,TOTO-0001,"Exemple of multiline requirement with variable: Variable content.
59
59
  Variable content : Variable content Toto.
60
- Third line with {not_defined_variable}."
60
+ Third line with {not_defined_variable}.",~3bf370ed
61
61
  """
62
62
  And the stdout should not contain anything
63
63
  And the stderr should not contain anything
@@ -79,13 +79,14 @@ Feature: The extract command
79
79
  Second line.
80
80
  --
81
81
  """
82
- When I run `defmastership export toto.adoc`
82
+ When I successfully run `defmastership export toto.adoc`
83
83
  Then the file "toto.csv" should contain:
84
84
  """
85
- Type,Reference,Value
85
+ Type,Reference,Value,Checksum
86
86
  requirement,TOTO-0001,"Exemple of multiline requirement.
87
- Second line."
88
- 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
89
90
  """
90
91
  And the file "toto.csv" should not contain:
91
92
  """
@@ -107,7 +108,7 @@ Feature: The extract command
107
108
  only one line
108
109
  ....
109
110
  """
110
- When I run `defmastership export toto.adoc`
111
+ When I successfully run `defmastership export toto.adoc`
111
112
  Then the file "toto.csv" should not contain:
112
113
  """
113
114
  something_else
@@ -128,7 +129,7 @@ Feature: The extract command
128
129
  only one line
129
130
  ////
130
131
  """
131
- When I run `defmastership export toto.adoc`
132
+ When I successfully run `defmastership export toto.adoc`
132
133
  Then the file "toto.csv" should not contain:
133
134
  """
134
135
  something_else
@@ -151,7 +152,7 @@ Feature: The extract command
151
152
  ////
152
153
  [define, something_else, TOTO-0003]
153
154
  """
154
- When I run `defmastership export toto.adoc`
155
+ When I successfully run `defmastership export toto.adoc`
155
156
  Then the file "toto.csv" should contain:
156
157
  """
157
158
  something_else
@@ -168,12 +169,12 @@ Feature: The extract command
168
169
  Second line.
169
170
  --
170
171
  """
171
- When I run `defmastership export toto.adoc`
172
+ When I successfully run `defmastership export toto.adoc`
172
173
  Then the file "toto.csv" should contain:
173
174
  """
174
- Type,Reference,Value,Labels
175
+ Type,Reference,Value,Checksum,Labels
175
176
  requirement,TOTO-0001,"Exemple of multiline requirement.
176
- Second line.","label1
177
+ Second line.",~b86dcbde,"label1
177
178
  label2"
178
179
  """
179
180
  And the stdout should not contain anything
@@ -191,12 +192,12 @@ Feature: The extract command
191
192
  --
192
193
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
193
194
  """
194
- When I run `defmastership export toto.adoc`
195
+ When I successfully run `defmastership export toto.adoc`
195
196
  Then the file "toto.csv" should contain:
196
197
  """
197
- Type,Reference,Value,Participate to: ./the_other_document.html
198
+ Type,Reference,Value,Checksum,Participate to:
198
199
  requirement,TOTO-0001,"Exemple of multiline requirement.
199
- Second line.","SYSTEM-0012
200
+ Second line.",~b86dcbde,"SYSTEM-0012
200
201
  SYSTEM-0014"
201
202
  """
202
203
  And the stdout should not contain anything
@@ -214,12 +215,12 @@ Feature: The extract command
214
215
  --
215
216
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
216
217
  """
217
- When I run `defmastership export toto.adoc`
218
+ When I successfully run `defmastership export toto.adoc`
218
219
  Then the file "toto.csv" should contain:
219
220
  """
220
- Type,Reference,Value,Participate to:
221
+ Type,Reference,Value,Checksum,Participate to:
221
222
  requirement,TOTO-0001,"Exemple of multiline requirement.
222
- Second line.","SYSTEM-0012
223
+ Second line.",~b86dcbde,"SYSTEM-0012
223
224
  SYSTEM-0014"
224
225
  """
225
226
  And the stdout should not contain anything
@@ -236,14 +237,14 @@ Feature: The extract command
236
237
  --
237
238
  defs:eref[implements, [SYSTEM-0012, SYSTEM-0014]]
238
239
  """
239
- When I run `defmastership export toto.adoc`
240
+ When I successfully run `defmastership export toto.adoc`
240
241
  Then the stdout should not contain anything
241
242
  And the stderr should not contain anything
242
243
  And the file "toto.csv" should contain:
243
244
  """
244
- Type,Reference,Value,Participate to:
245
+ Type,Reference,Value,Checksum,Participate to:
245
246
  requirement,TOTO-0001,"Exemple of multiline requirement.
246
- Second line.","SYSTEM-0012
247
+ Second line.",~b86dcbde,"SYSTEM-0012
247
248
  SYSTEM-0014"
248
249
  """
249
250
 
@@ -257,12 +258,12 @@ Feature: The extract command
257
258
  --
258
259
  please see defs:iref[TOTO-0002]
259
260
  """
260
- When I run `defmastership export toto.adoc`
261
+ When I successfully run `defmastership export toto.adoc`
261
262
  Then the file "toto.csv" should contain:
262
263
  """
263
- Type,Reference,Value,Internal links
264
+ Type,Reference,Value,Checksum,Internal links
264
265
  requirement,TOTO-0001,"Exemple of multiline requirement.
265
- 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
266
267
  TOTO-0123
267
268
  TOTO-0002"
268
269
  """
@@ -281,12 +282,12 @@ Feature: The extract command
281
282
  defs:attribute[verifiedby, Beautiful Test]
282
283
  defs:attribute[criticity, Very cool]
283
284
  """
284
- When I run `defmastership export toto.adoc`
285
+ When I successfully run `defmastership export toto.adoc`
285
286
  And the stdout should not contain anything
286
287
  Then the file "toto.csv" should contain:
287
288
  """
288
- Type,Reference,Value,Verified by:,Criticity:
289
- 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
290
291
  """
291
292
  And the stdout should not contain anything
292
293
  And the stderr should not contain anything
@@ -0,0 +1,165 @@
1
+ Feature: The modify command
2
+ As a Responsible of definitions for a given document
3
+ In order to manage to applu predefined modifications
4
+ I want defmastership to apply automatic modifications
5
+
6
+ Scenario: Changes with one modifier
7
+ Given a file named "modifications.yml" with:
8
+ """
9
+ ---
10
+ :temp-references:
11
+ :type: change_ref
12
+ :config:
13
+ :from_regexp: TOTO-TEMP-[X\d]{4}
14
+ :to_template: TOTO-%<next_ref>04d
15
+ :next_ref: 123
16
+ """
17
+ And a file named "thedoc.adoc" with:
18
+ """
19
+ [define, requirement, TOTO-TEMP-XXX1]
20
+ """
21
+ When I successfully run `defmastership modify --modifications temp-references thedoc.adoc`
22
+ Then the stdout should not contain anything
23
+ And the stderr should not contain anything
24
+ And the file "modifications.yml" should contain:
25
+ """
26
+ ---
27
+ :temp-references:
28
+ :type: change_ref
29
+ :config:
30
+ :from_regexp: TOTO-TEMP-[X\d]{4}
31
+ :to_template: TOTO-%<next_ref>04d
32
+ :next_ref: 124
33
+ """
34
+ And the file "thedoc.adoc" should contain:
35
+ """
36
+ [define, requirement, TOTO-0123]
37
+ """
38
+
39
+
40
+ Scenario: Change with wrong modifier
41
+ Given a file named "modifications.yml" with:
42
+ """
43
+ ---
44
+ :temp-references:
45
+ :type: change_ref
46
+ :config:
47
+ :from_regexp: TOTO-TEMP-[X\d]{4}
48
+ :to_template: TOTO-%<next_ref>04d
49
+ :next_ref: 123
50
+ """
51
+ And a file named "thedoc.adoc" with:
52
+ """
53
+ [define, requirement, TOTO-TEMP-XXX1]
54
+ """
55
+ When I run `defmastership modify --modifications wrong-modification thedoc.adoc`
56
+ Then it should fail with:
57
+ """
58
+ error: wrong-modification is not a known modification
59
+ """
60
+
61
+ Scenario: Make modifications with yaml file parameter
62
+ Given a file named "pouet.yml" with:
63
+ """
64
+ ---
65
+ :toto:
66
+ :type: change_ref
67
+ :config:
68
+ :from_regexp: TOTO-TEMP-[X\d]{4}
69
+ :to_template: TOTO-%<next_ref>04d
70
+ :next_ref: 123
71
+ """
72
+ And a file named "thedoc.adoc" with:
73
+ """
74
+ [define, requirement, TOTO-TEMP-XXX1]
75
+ """
76
+ When I successfully run `defmastership modify --modifications-file=pouet.yml --modifications toto thedoc.adoc`
77
+ Then the stdout should not contain anything
78
+ And the stderr should not contain anything
79
+ And the file "pouet.yml" should contain:
80
+ """
81
+ ---
82
+ :toto:
83
+ :type: change_ref
84
+ :config:
85
+ :from_regexp: TOTO-TEMP-[X\d]{4}
86
+ :to_template: TOTO-%<next_ref>04d
87
+ :next_ref: 124
88
+ """
89
+ And the file "thedoc.adoc" should contain:
90
+ """
91
+ [define, requirement, TOTO-0123]
92
+ """
93
+
94
+ Scenario: Generate a table with changes
95
+ Given a file named "modifications.yml" with:
96
+ """
97
+ ---
98
+ :temp-references:
99
+ :type: change_ref
100
+ :config:
101
+ :from_regexp: TOTO-TEMP-[X\d]{4}
102
+ :to_template: TOTO-%<next_ref>04d
103
+ :next_ref: 123
104
+ """
105
+ And a file named "thedoc.adoc" with:
106
+ """
107
+ [define, requirement, TOTO-TEMP-XXX1]
108
+ [define, requirement, TOTO-TEMP-XXX2]
109
+ """
110
+ When I successfully run `defmastership modify --modifications temp-references --changes-summary=changes.csv thedoc.adoc`
111
+ Then the stderr should not contain anything
112
+ And the stdout should not contain anything
113
+ And the file "changes.csv" should contain:
114
+ """
115
+ Modifier,Was,Becomes
116
+ temp-references,TOTO-TEMP-XXX1,TOTO-0123
117
+ temp-references,TOTO-TEMP-XXX2,TOTO-0124
118
+ """
119
+
120
+ Scenario: Apply two modifcations
121
+ Given a file named "modifications.yml" with:
122
+ """
123
+ ---
124
+ :temp-references:
125
+ :type: change_ref
126
+ :config:
127
+ :from_regexp: TOTO-TEMP-[X\d]{4}
128
+ :to_template: TOTO-%<next_ref>04d
129
+ :next_ref: 123
130
+ :tata_or_titi:
131
+ :type: change_ref
132
+ :config:
133
+ :from_regexp: "(?<tata_or_titi>TATA|TITI)-TEMP-[X\\d]{4}"
134
+ :to_template: "%<tata_or_titi>s-%<next_ref>07d"
135
+ :next_ref: 432
136
+ """
137
+ And a file named "thedoc.adoc" with:
138
+ """
139
+ [define, requirement, TOTO-TEMP-XXX1]
140
+ [define, requirement, TITI-TEMP-XXX2]
141
+ """
142
+ When I successfully run `defmastership modify --modifications temp-references,tata_or_titi --changes-summary=changes.csv thedoc.adoc`
143
+ Then the stdout should not contain anything
144
+ And the stderr should not contain anything
145
+ And the file "modifications.yml" should contain:
146
+ """
147
+ ---
148
+ :temp-references:
149
+ :type: change_ref
150
+ :config:
151
+ :from_regexp: TOTO-TEMP-[X\d]{4}
152
+ :to_template: TOTO-%<next_ref>04d
153
+ :next_ref: 124
154
+ :tata_or_titi:
155
+ :type: change_ref
156
+ :config:
157
+ :from_regexp: "(?<tata_or_titi>TATA|TITI)-TEMP-[X\\d]{4}"
158
+ :to_template: "%<tata_or_titi>s-%<next_ref>07d"
159
+ :next_ref: 433
160
+ """
161
+ And the file "thedoc.adoc" should contain:
162
+ """
163
+ [define, requirement, TOTO-0123]
164
+ [define, requirement, TITI-0000432]
165
+ """
@@ -0,0 +1,121 @@
1
+
2
+ Feature: The rename_included_files command
3
+ As a Responsible of definitions for a given document.
4
+ In order to easy traceability with included files,
5
+ I want defmastership to change filename of included files to reflect
6
+ reference.
7
+
8
+ Scenario: do NOT change the filename of a file NOT included in a definition
9
+ Given a file named "modifications.yml" with:
10
+ """
11
+ ---
12
+ :rename_included_png:
13
+ :type: rename_included_files
14
+ :config:
15
+ :from_regexp: (?<origin>.*\.png)
16
+ :to_template: "%<reference>s_%<origin>s"
17
+ """
18
+ And a file named "thedoc.adoc" with:
19
+ """
20
+ include::any_path/one_file.png[]
21
+ """
22
+ And a directory named "any_path"
23
+ And an empty file named "any_path/one_file.png"
24
+ When I successfully run `defmastership modify --modifications rename_included_png thedoc.adoc`
25
+ Then the stdout should not contain anything
26
+ And the stderr should not contain anything
27
+ And the file "thedoc.adoc" should contain:
28
+ """
29
+ include::any_path/one_file.png[]
30
+ """
31
+ And the file "any_path/one_file.png" should exist
32
+
33
+ Scenario: change the filename of a file included in a definition
34
+ Given a file named "modifications.yml" with:
35
+ """
36
+ ---
37
+ :rename_included_png:
38
+ :type: rename_included_files
39
+ :config:
40
+ :from_regexp: (?<origin>.*\.png)
41
+ :to_template: "%<reference>s_%<origin>s"
42
+ """
43
+ And a file named "thedoc.adoc" with:
44
+ """
45
+ [define, requirement, TOTO-WHATEVER-123]
46
+ include::any_path/one_file.png[]
47
+ """
48
+ And a directory named "any_path"
49
+ And an empty file named "any_path/one_file.png"
50
+ When I successfully run `defmastership modify --modifications rename_included_png thedoc.adoc`
51
+ Then the stdout should not contain anything
52
+ And the stderr should not contain anything
53
+ And the file "thedoc.adoc" should contain:
54
+ """
55
+ [define, requirement, TOTO-WHATEVER-123]
56
+ include::any_path/TOTO-WHATEVER-123_one_file.png[]
57
+ """
58
+ And the file "any_path/one_file.png" should not exist
59
+ And the file "any_path/TOTO-WHATEVER-123_one_file.png" should exist
60
+
61
+ Scenario: change the filename with variable in path
62
+ Given a file named "modifications.yml" with:
63
+ """
64
+ ---
65
+ :rename_included_png:
66
+ :type: rename_included_files
67
+ :config:
68
+ :from_regexp: (?<origin>.*\.png)
69
+ :to_template: "%<reference>s_%<origin>s"
70
+ """
71
+ And a file named "thedoc.adoc" with:
72
+ """
73
+ :any: one
74
+ :path: two
75
+ [define, requirement, TOTO-WHATEVER-123]
76
+ include::{any}_{path}/one_file.png[]
77
+ """
78
+ And a directory named "one_two"
79
+ And an empty file named "one_two/one_file.png"
80
+ When I successfully run `defmastership modify --modifications rename_included_png thedoc.adoc`
81
+ Then the stdout should not contain anything
82
+ And the stderr should not contain anything
83
+ And the file "thedoc.adoc" should contain:
84
+ """
85
+ :any: one
86
+ :path: two
87
+ [define, requirement, TOTO-WHATEVER-123]
88
+ include::{any}_{path}/TOTO-WHATEVER-123_one_file.png[]
89
+ """
90
+ And the file "one_two/one_file.png" should not exist
91
+ And the file "one_two/TOTO-WHATEVER-123_one_file.png" should exist
92
+
93
+ Scenario: DO NOT change the filename again and again
94
+ Given a file named "modifications.yml" with:
95
+ """
96
+ ---
97
+ :rename_included_png:
98
+ :type: rename_included_files
99
+ :config:
100
+ :from_regexp: (?<origin>.*\.png)
101
+ :cancel_if_match: TOTO-WHATEVER
102
+ :to_template: "%<reference>s_%<origin>s"
103
+ """
104
+ And a file named "thedoc.adoc" with:
105
+ """
106
+ [define, requirement, TOTO-WHATEVER-123]
107
+ include::any_path/TOTO-WHATEVER-123_one_file.png[]
108
+ """
109
+ And a directory named "any_path"
110
+ And an empty file named "any_path/TOTO-WHATEVER-123_one_file.png"
111
+ When I successfully run `defmastership modify --modifications rename_included_png thedoc.adoc`
112
+ Then the stdout should not contain anything
113
+ And the stderr should not contain anything
114
+ And the file "thedoc.adoc" should contain:
115
+ """
116
+ [define, requirement, TOTO-WHATEVER-123]
117
+ include::any_path/TOTO-WHATEVER-123_one_file.png[]
118
+ """
119
+ And the file "any_path/one_file.png" should not exist
120
+ And the file "any_path/TOTO-WHATEVER-123_one_file.png" should exist
121
+