defmastership 1.0.18 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.gitlab-ci.yml +42 -1
  4. data/Gemfile +49 -18
  5. data/Guardfile +44 -0
  6. data/LICENSE +1 -1
  7. data/README.adoc +24 -0
  8. data/Rakefile +0 -1
  9. data/bin/defmastership +5 -5
  10. data/config/cucumber.yml +3 -0
  11. data/config/mutant.yml +22 -16
  12. data/config/reek.yml +129 -105
  13. data/config/rubocop.yml +67 -28
  14. data/defmastership.gemspec +8 -6
  15. data/features/changeref.feature +0 -8
  16. data/features/definition_checksum.feature +0 -10
  17. data/features/definition_version.feature +168 -10
  18. data/features/export.feature +23 -18
  19. data/features/modify.feature +1 -5
  20. data/features/rename_included_files.feature +0 -5
  21. data/features/step_definitions/git_steps.rb +19 -0
  22. data/lib/defmastership/batch_modifier.rb +23 -5
  23. data/lib/defmastership/comment_filter.rb +2 -1
  24. data/lib/defmastership/definition.rb +26 -6
  25. data/lib/defmastership/definition_parser.rb +2 -2
  26. data/lib/defmastership/document.rb +45 -33
  27. data/lib/defmastership/export/body_formatter.rb +55 -0
  28. data/lib/defmastership/export/csv/formatter.rb +64 -0
  29. data/lib/defmastership/export/header_formatter.rb +51 -0
  30. data/lib/defmastership/filters.rb +15 -12
  31. data/lib/defmastership/matching_line.rb +3 -2
  32. data/lib/defmastership/modifier/change_ref.rb +117 -0
  33. data/lib/defmastership/modifier/factory.rb +17 -0
  34. data/lib/defmastership/modifier/modifier_common.rb +71 -0
  35. data/lib/defmastership/modifier/rename_included_files.rb +223 -0
  36. data/lib/defmastership/modifier/update_def.rb +72 -0
  37. data/lib/defmastership/modifier/update_def_checksum.rb +17 -0
  38. data/lib/defmastership/modifier/update_def_version.rb +110 -0
  39. data/lib/defmastership/set_join_hack.rb +2 -0
  40. data/lib/defmastership/version.rb +3 -2
  41. data/lib/defmastership.rb +6 -8
  42. data/spec/unit/{def_mastership → defmastership}/batch_modifier_spec.rb +15 -13
  43. data/spec/unit/{def_mastership → defmastership}/definition_parser_spec.rb +1 -1
  44. data/spec/unit/{def_mastership → defmastership}/definition_spec.rb +1 -1
  45. data/spec/unit/{def_mastership → defmastership}/document_spec.rb +57 -57
  46. data/spec/unit/{def_mastership/csv_formatter_body_spec.rb → defmastership/export/body_formatter_spec.rb} +4 -4
  47. data/spec/unit/{def_mastership/csv_formatter_spec.rb → defmastership/export/csv/formatter_spec.rb} +13 -8
  48. data/spec/unit/{def_mastership/csv_formatter_header_spec.rb → defmastership/export/header_formatter_spec.rb} +3 -3
  49. data/spec/unit/{def_mastership → defmastership}/matching_line_spec.rb +1 -1
  50. data/spec/unit/{def_mastership/change_ref_modifier_spec.rb → defmastership/modifier/change_ref_spec.rb} +19 -44
  51. data/spec/unit/defmastership/modifier/factory_spec.rb +45 -0
  52. data/spec/unit/{def_mastership/modifier_spec.rb → defmastership/modifier/modifier_common_spec.rb} +11 -18
  53. data/spec/unit/{def_mastership/rename_included_files_modifier_spec.rb → defmastership/modifier/rename_included_files_spec.rb} +3 -3
  54. data/spec/unit/{def_mastership/update_def_checksum_modifier_spec.rb → defmastership/modifier/update_def_checksum_spec.rb} +10 -10
  55. data/spec/unit/{def_mastership/update_def_modifier_spec.rb → defmastership/modifier/update_def_spec.rb} +22 -18
  56. data/spec/unit/defmastership/modifier/update_def_version_spec.rb +351 -0
  57. data/spec/unit/{def_mastership_spec.rb → defmastership_spec.rb} +2 -2
  58. data/tasks/code_quality.rake +74 -0
  59. data/tasks/documentation.rake +19 -0
  60. data/tasks/package.rake +4 -0
  61. data/tasks/test.rake +6 -21
  62. metadata +96 -51
  63. data/.rubocop.yml +0 -76
  64. data/README.rdoc +0 -6
  65. data/config/devtools.yml +0 -2
  66. data/config/flay.yml +0 -3
  67. data/config/flog.yml +0 -2
  68. data/config/yardstick.yml +0 -2
  69. data/cucumber.yml +0 -2
  70. data/defmastership.rdoc +0 -5
  71. data/lib/defmastership/change_ref_modifier.rb +0 -99
  72. data/lib/defmastership/constants.rb +0 -89
  73. data/lib/defmastership/csv_formatter.rb +0 -53
  74. data/lib/defmastership/csv_formatter_body.rb +0 -46
  75. data/lib/defmastership/csv_formatter_header.rb +0 -41
  76. data/lib/defmastership/modifier.rb +0 -42
  77. data/lib/defmastership/modifier_factory.rb +0 -12
  78. data/lib/defmastership/parsing_state.rb +0 -31
  79. data/lib/defmastership/rename_included_files_modifier.rb +0 -182
  80. data/lib/defmastership/update_def_checksum_modifier.rb +0 -16
  81. data/lib/defmastership/update_def_modifier.rb +0 -49
  82. data/lib/defmastership/update_def_version_modifier.rb +0 -66
  83. data/spec/unit/def_mastership/modifier_factory_spec.rb +0 -37
  84. data/spec/unit/def_mastership/parsing_state_spec.rb +0 -62
  85. data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +0 -159
  86. data/tasks/package.task +0 -9
  87. data/tasks/smelling_code.rake +0 -38
  88. /data/{.rspec → config/rspec} +0 -0
  89. /data/spec/unit/{def_mastership → defmastership}/string_spec.rb +0 -0
@@ -3,17 +3,19 @@
3
3
 
4
4
  require('defmastership/batch_modifier')
5
5
 
6
- module DefMastership
7
- class TotoModifier
6
+ module Defmastership
7
+ # Modifier example
8
+ class Toto
8
9
  include Modifier
9
10
  end
10
11
 
11
- class TuTuModifier
12
+ # Modifier example
13
+ class TuTu
12
14
  include Modifier
13
15
  end
14
16
  end
15
17
 
16
- RSpec.describe(DefMastership::BatchModifier) do
18
+ RSpec.describe(Defmastership::BatchModifier) do
17
19
  subject(:batchmodifier) do
18
20
  described_class.new(config, adoc_sources)
19
21
  end
@@ -43,7 +45,7 @@ RSpec.describe(DefMastership::BatchModifier) do
43
45
 
44
46
  describe '#apply' do
45
47
  context 'with only one modification' do
46
- let(:toto1) { instance_double(DefMastership::TotoModifier, 'toto1') }
48
+ let(:toto1) { instance_double(Defmastership::Modifier::Toto, 'toto1') }
47
49
  let(:adoc_sources_modified) do
48
50
  {
49
51
  'file1.adoc' => 'some text modified',
@@ -60,7 +62,7 @@ RSpec.describe(DefMastership::BatchModifier) do
60
62
  end
61
63
 
62
64
  before do
63
- allow(DefMastership::TotoModifier).to(receive(:new).once.and_return(toto1))
65
+ allow(Defmastership::Modifier::Toto).to(receive(:new).once.and_return(toto1))
64
66
  allow(toto1).to(receive(:do_modifications).once.and_return(adoc_sources_modified))
65
67
  allow(toto1).to(receive(:config).once.and_return(p: 'modified_param'))
66
68
  allow(toto1).to(receive(:changes).once.and_return([%w[from1 to1], %w[from2 to2]]))
@@ -68,7 +70,7 @@ RSpec.describe(DefMastership::BatchModifier) do
68
70
  end
69
71
 
70
72
  it do
71
- expect(DefMastership::TotoModifier).to(have_received(:new).with(p: 1))
73
+ expect(Defmastership::Modifier::Toto).to(have_received(:new).with(p: 1))
72
74
  end
73
75
 
74
76
  it { expect(toto1).to(have_received(:do_modifications).with(adoc_sources)) }
@@ -80,8 +82,8 @@ RSpec.describe(DefMastership::BatchModifier) do
80
82
  end
81
83
 
82
84
  context 'with two modifications' do
83
- let(:toto2) { instance_double(DefMastership::TotoModifier, 'toto2') }
84
- let(:tutu3) { instance_double(DefMastership::TuTuModifier, 'tutu3') }
85
+ let(:toto2) { instance_double(Defmastership::Modifier::Toto, 'toto2') }
86
+ let(:tutu3) { instance_double(Defmastership::Modifier::TuTu, 'tutu3') }
85
87
 
86
88
  let(:config_modified) do
87
89
  {
@@ -92,10 +94,10 @@ RSpec.describe(DefMastership::BatchModifier) do
92
94
  end
93
95
 
94
96
  before do
95
- allow(DefMastership::TotoModifier).to(receive(:new).once.and_return(toto2))
97
+ allow(Defmastership::Modifier::Toto).to(receive(:new).once.and_return(toto2))
96
98
  allow(toto2).to(receive(:do_modifications).once.and_return(:adoc_sources_modified_mod2))
97
99
  allow(toto2).to(receive(:config).once.and_return(:whatever))
98
- allow(DefMastership::TuTuModifier).to(receive(:new).once.and_return(tutu3))
100
+ allow(Defmastership::Modifier::TuTu).to(receive(:new).once.and_return(tutu3))
99
101
  allow(tutu3).to(receive(:do_modifications).once.and_return(:adoc_sources_modified_mod3))
100
102
  allow(tutu3).to(receive(:config).once.and_return(:pouet))
101
103
  allow(toto2).to(receive(:changes).once.and_return([%w[from1 to1]]))
@@ -103,8 +105,8 @@ RSpec.describe(DefMastership::BatchModifier) do
103
105
  batchmodifier.apply(%i[modifier2 modifier3])
104
106
  end
105
107
 
106
- it { expect(DefMastership::TotoModifier).to(have_received(:new).with(p: 'whatever1')) }
107
- it { expect(DefMastership::TuTuModifier).to(have_received(:new).with(p1: 'whatever2', p2: 'whatever3')) }
108
+ it { expect(Defmastership::Modifier::Toto).to(have_received(:new).with(p: 'whatever1')) }
109
+ it { expect(Defmastership::Modifier::TuTu).to(have_received(:new).with(p1: 'whatever2', p2: 'whatever3')) }
108
110
  it { expect(toto2).to(have_received(:do_modifications).with(adoc_sources)) }
109
111
  it { expect(toto2).to(have_received(:config).with(no_args)) }
110
112
  it { expect(tutu3).to(have_received(:do_modifications).with(:adoc_sources_modified_mod2)) }
@@ -3,7 +3,7 @@
3
3
 
4
4
  require('defmastership/definition_parser')
5
5
 
6
- RSpec.describe(DefMastership::DefinitionParser) do
6
+ RSpec.describe(Defmastership::DefinitionParser) do
7
7
  subject(:parser) { described_class.new(callback_object) }
8
8
 
9
9
  let(:callback_object) { double }
@@ -3,7 +3,7 @@
3
3
 
4
4
  require('defmastership/definition')
5
5
 
6
- RSpec.describe(DefMastership::Definition) do
6
+ RSpec.describe(Defmastership::Definition) do
7
7
  describe '.new' do
8
8
  context 'when minimal' do
9
9
  subject do
@@ -3,7 +3,7 @@
3
3
 
4
4
  require('defmastership/document')
5
5
 
6
- RSpec.describe(DefMastership::Document) do
6
+ RSpec.describe(Defmastership::Document) do
7
7
  subject(:document) { described_class.new }
8
8
 
9
9
  describe '.new' do
@@ -27,12 +27,12 @@ RSpec.describe(DefMastership::Document) do
27
27
  it { expect(document.respond_to?(:not_implemented_random_method)).to(be(false)) }
28
28
  end
29
29
 
30
- describe '#parse' do
30
+ describe '#do_parse' do
31
31
  context 'with valid definitions' do
32
- let(:definition) { instance_double(DefMastership::Definition, 'definition') }
32
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
33
33
 
34
34
  before do
35
- allow(DefMastership::Definition).to(receive(:new).and_return(definition))
35
+ allow(Defmastership::Definition).to(receive(:new).and_return(definition))
36
36
  allow(definition).to(
37
37
  receive_messages(
38
38
  labels: Set.new,
@@ -47,16 +47,16 @@ RSpec.describe(DefMastership::Document) do
47
47
  let(:input_lines) { ['[define, requirement, TOTO-0001]'] }
48
48
 
49
49
  before do
50
- allow(DefMastership::Definition).to(
50
+ allow(Defmastership::Definition).to(
51
51
  receive(:new).with(
52
52
  matchdata_including(type: 'requirement', reference: 'TOTO-0001')
53
53
  ).and_return(definition)
54
54
  )
55
- document.parse(input_lines)
55
+ document.__send__(:do_parse, input_lines)
56
56
  end
57
57
 
58
58
  it do
59
- expect(DefMastership::Definition).to(
59
+ expect(Defmastership::Definition).to(
60
60
  have_received(:new).with(
61
61
  matchdata_including(type: 'requirement', reference: 'TOTO-0001')
62
62
  )
@@ -71,16 +71,16 @@ RSpec.describe(DefMastership::Document) do
71
71
  let(:input_lines) { ['[define, requirement, TOTO-0001(~ab12)]'] }
72
72
 
73
73
  before do
74
- allow(DefMastership::Definition).to(
74
+ allow(Defmastership::Definition).to(
75
75
  receive(:new).with(
76
76
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_checksum: '~ab12')
77
77
  ).and_return(definition)
78
78
  )
79
- document.parse(input_lines)
79
+ document.__send__(:do_parse, input_lines)
80
80
  end
81
81
 
82
82
  it do
83
- expect(DefMastership::Definition).to(
83
+ expect(Defmastership::Definition).to(
84
84
  have_received(:new).with(
85
85
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_checksum: '~ab12')
86
86
  )
@@ -92,16 +92,16 @@ RSpec.describe(DefMastership::Document) do
92
92
  let(:input_lines) { ['[define, requirement, TOTO-0001(pouet)]'] }
93
93
 
94
94
  before do
95
- allow(DefMastership::Definition).to(
95
+ allow(Defmastership::Definition).to(
96
96
  receive(:new).with(
97
97
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_version: 'pouet')
98
98
  ).and_return(definition)
99
99
  )
100
- document.parse(input_lines)
100
+ document.__send__(:do_parse, input_lines)
101
101
  end
102
102
 
103
103
  it do
104
- expect(DefMastership::Definition).to(
104
+ expect(Defmastership::Definition).to(
105
105
  have_received(:new).with(
106
106
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', explicit_version: 'pouet')
107
107
  )
@@ -123,7 +123,7 @@ RSpec.describe(DefMastership::Document) do
123
123
 
124
124
  before do
125
125
  allow(definition).to(receive(:<<).and_return(definition))
126
- document.parse(input_lines)
126
+ document.__send__(:do_parse, input_lines)
127
127
  end
128
128
 
129
129
  it { expect(definition).to(have_received(:<<).with('a')) }
@@ -147,7 +147,7 @@ RSpec.describe(DefMastership::Document) do
147
147
 
148
148
  before do
149
149
  allow(definition).to(receive(:<<).and_return(definition))
150
- document.parse(input_lines)
150
+ document.__send__(:do_parse, input_lines)
151
151
  end
152
152
 
153
153
  it { expect(definition).to(have_received(:<<).twice.with('----')) }
@@ -168,7 +168,7 @@ RSpec.describe(DefMastership::Document) do
168
168
 
169
169
  before do
170
170
  allow(definition).to(receive(:<<).and_return(definition))
171
- document.parse(input_lines)
171
+ document.__send__(:do_parse, input_lines)
172
172
  end
173
173
 
174
174
  it { expect(definition).to(have_received(:<<).with('// comment')) }
@@ -187,7 +187,7 @@ RSpec.describe(DefMastership::Document) do
187
187
 
188
188
  before do
189
189
  allow(definition).to(receive(:<<).and_return(definition))
190
- document.parse(input_lines)
190
+ document.__send__(:do_parse, input_lines)
191
191
  end
192
192
 
193
193
  it { expect(definition).to(have_received(:<<).with('one line')) }
@@ -207,7 +207,7 @@ RSpec.describe(DefMastership::Document) do
207
207
  ]
208
208
  end
209
209
 
210
- before { document.parse(input_lines) }
210
+ before { document.__send__(:do_parse, input_lines) }
211
211
 
212
212
  it { expect(definition).not_to(have_received(:<<).with('not included')) }
213
213
  end
@@ -216,7 +216,7 @@ RSpec.describe(DefMastership::Document) do
216
216
  let(:input_lines) { ['--', 'first line', '--'] }
217
217
 
218
218
  it do
219
- document.parse(input_lines)
219
+ document.__send__(:do_parse, input_lines)
220
220
  expect(document.definitions).to(eq([]))
221
221
  end
222
222
  end
@@ -232,11 +232,11 @@ RSpec.describe(DefMastership::Document) do
232
232
 
233
233
  before do
234
234
  allow(definition).to(receive(:labels).and_return(Set['bla1', 'bla2']))
235
- document.parse(input_lines)
235
+ document.__send__(:do_parse, input_lines)
236
236
  end
237
237
 
238
238
  it do
239
- expect(DefMastership::Definition).to(
239
+ expect(Defmastership::Definition).to(
240
240
  have_received(:new).with(
241
241
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', labels: 'label1, label2')
242
242
  )
@@ -257,11 +257,11 @@ RSpec.describe(DefMastership::Document) do
257
257
 
258
258
  before do
259
259
  allow(definition).to(receive(:labels).and_return(Set['bla1', 'bla2']))
260
- document.parse(input_lines)
260
+ document.__send__(:do_parse, input_lines)
261
261
  end
262
262
 
263
263
  it do
264
- expect(DefMastership::Definition).to(
264
+ expect(Defmastership::Definition).to(
265
265
  have_received(:new).with(
266
266
  matchdata_including(type: 'requirement', reference: 'TOTO-0001', labels: 'label1,label2')
267
267
  )
@@ -281,7 +281,7 @@ RSpec.describe(DefMastership::Document) do
281
281
  ]
282
282
  end
283
283
 
284
- before { document.parse(input_lines) }
284
+ before { document.__send__(:do_parse, input_lines) }
285
285
 
286
286
  it { expect(document.eref[:implements]).to(eq(prefix: 'Participate to:', url: './other_document.html')) }
287
287
  end
@@ -296,7 +296,7 @@ RSpec.describe(DefMastership::Document) do
296
296
  end
297
297
 
298
298
  it do
299
- document.parse(input_lines)
299
+ document.__send__(:do_parse, input_lines)
300
300
  expect(document.eref[:implements])
301
301
  .to(eq(prefix: 'Participate to:'))
302
302
  end
@@ -316,7 +316,7 @@ RSpec.describe(DefMastership::Document) do
316
316
  receive(:add_eref).with(:implements, 'SYSTEM-0012, SYSTEM-0014')
317
317
  .and_return(definition)
318
318
  )
319
- document.parse(input_lines)
319
+ document.__send__(:do_parse, input_lines)
320
320
  end
321
321
 
322
322
  it { expect(definition).to(have_received(:add_eref).with(:implements, 'SYSTEM-0012, SYSTEM-0014')) }
@@ -333,7 +333,7 @@ RSpec.describe(DefMastership::Document) do
333
333
 
334
334
  before do
335
335
  allow(definition).to(receive(:add_iref))
336
- document.parse(input_lines)
336
+ document.__send__(:do_parse, input_lines)
337
337
  end
338
338
 
339
339
  it { expect(definition).to(have_received(:add_iref).with('toto')) }
@@ -350,7 +350,7 @@ RSpec.describe(DefMastership::Document) do
350
350
  ]
351
351
  end
352
352
 
353
- before { document.parse(input_lines) }
353
+ before { document.__send__(:do_parse, input_lines) }
354
354
 
355
355
  it { expect(document.attributes).to(eq(myattribute: 'My attribute:', myotherone: 'My other attribute:')) }
356
356
  end
@@ -365,7 +365,7 @@ RSpec.describe(DefMastership::Document) do
365
365
 
366
366
  before do
367
367
  allow(definition).to(receive(:set_attribute).with(:myattribute, 'My value'))
368
- document.parse(input_lines)
368
+ document.__send__(:do_parse, input_lines)
369
369
  end
370
370
 
371
371
  it { expect(definition).to(have_received(:set_attribute).with(:myattribute, 'My value')) }
@@ -380,7 +380,7 @@ RSpec.describe(DefMastership::Document) do
380
380
  end
381
381
 
382
382
  it do
383
- document.parse(input_lines)
383
+ document.__send__(:do_parse, input_lines)
384
384
  expect(document.iref).to(be(false))
385
385
  end
386
386
  end
@@ -394,16 +394,16 @@ RSpec.describe(DefMastership::Document) do
394
394
  end
395
395
 
396
396
  before do
397
- allow(DefMastership::Definition).to(
397
+ allow(Defmastership::Definition).to(
398
398
  receive(:new).with(
399
399
  matchdata_including(type: 'requirement', reference: 'TOTO-0001')
400
400
  ).and_return(definition)
401
401
  )
402
- document.parse(input_lines)
402
+ document.__send__(:do_parse, input_lines)
403
403
  end
404
404
 
405
405
  it do
406
- expect(DefMastership::Definition).to(
406
+ expect(Defmastership::Definition).to(
407
407
  have_received(:new).with(
408
408
  matchdata_including(type: 'requirement', reference: 'TOTO-0001')
409
409
  )
@@ -413,17 +413,17 @@ RSpec.describe(DefMastership::Document) do
413
413
  end
414
414
 
415
415
  context 'when variables replacement' do
416
- let(:definition) { instance_double(DefMastership::Definition, 'definition') }
416
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
417
417
 
418
418
  before do
419
- allow(DefMastership::Definition).to(receive(:new).and_return(definition))
419
+ allow(Defmastership::Definition).to(receive(:new).and_return(definition))
420
420
  allow(definition).to(
421
421
  receive_messages(
422
422
  labels: Set.new,
423
423
  '<<': definition
424
424
  )
425
425
  )
426
- document.parse(input_lines)
426
+ document.__send__(:do_parse, input_lines)
427
427
  end
428
428
 
429
429
  context 'when defined variable' do
@@ -488,13 +488,13 @@ RSpec.describe(DefMastership::Document) do
488
488
  end
489
489
 
490
490
  before do
491
- allow(DefMastership::Definition).to(
491
+ allow(Defmastership::Definition).to(
492
492
  receive(:new).and_raise('not a valide definition')
493
493
  )
494
494
  end
495
495
 
496
496
  it do
497
- document.parse(input_lines)
497
+ document.__send__(:do_parse, input_lines)
498
498
  expect(document).to(have_attributes(definitions: []))
499
499
  end
500
500
  end
@@ -509,13 +509,13 @@ RSpec.describe(DefMastership::Document) do
509
509
  end
510
510
 
511
511
  before do
512
- allow(DefMastership::Definition).to(
512
+ allow(Defmastership::Definition).to(
513
513
  receive(:new).and_raise('not a valide definition')
514
514
  )
515
515
  end
516
516
 
517
517
  it do
518
- document.parse(input_lines)
518
+ document.__send__(:do_parse, input_lines)
519
519
  expect(document).to(have_attributes(definitions: []))
520
520
  end
521
521
  end
@@ -523,7 +523,7 @@ RSpec.describe(DefMastership::Document) do
523
523
  end
524
524
 
525
525
  describe '#parse_file_with_preprocessor' do
526
- let(:definition) { instance_double(DefMastership::Definition, 'definition') }
526
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
527
527
  let(:input_lines) { ['[define, requirement, TOTO-0001]'] }
528
528
  let(:adoc_doc) { instance_double(Asciidoctor::Document, 'adoc_doc') }
529
529
  let(:adoc_reader) { instance_double(Asciidoctor::Reader, 'adoc_reader') }
@@ -534,7 +534,7 @@ RSpec.describe(DefMastership::Document) do
534
534
  )
535
535
  allow(adoc_doc).to(receive(:reader).and_return(adoc_reader))
536
536
  allow(adoc_reader).to(receive(:read_lines).and_return(input_lines))
537
- allow(DefMastership::Definition).to(receive(:new).and_return(definition))
537
+ allow(Defmastership::Definition).to(receive(:new).and_return(definition))
538
538
  allow(definition).to(
539
539
  receive_messages(
540
540
  '<<': definition,
@@ -549,7 +549,7 @@ RSpec.describe(DefMastership::Document) do
549
549
  it { expect(adoc_reader).to(have_received(:read_lines).with(no_args)) }
550
550
 
551
551
  it do
552
- expect(DefMastership::Definition).to(
552
+ expect(Defmastership::Definition).to(
553
553
  have_received(:new).with(
554
554
  matchdata_including(type: 'requirement', reference: 'TOTO-0001')
555
555
  )
@@ -560,8 +560,8 @@ RSpec.describe(DefMastership::Document) do
560
560
  describe '#wrong_explicit_checksum?' do
561
561
  let(:defs) do
562
562
  [
563
- instance_double(DefMastership::Definition, 'definition'),
564
- instance_double(DefMastership::Definition, 'definition')
563
+ instance_double(Defmastership::Definition, 'definition'),
564
+ instance_double(Defmastership::Definition, 'definition')
565
565
  ]
566
566
  end
567
567
  let(:input_lines) do
@@ -575,7 +575,7 @@ RSpec.describe(DefMastership::Document) do
575
575
  end
576
576
 
577
577
  before do
578
- allow(DefMastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
578
+ allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
579
579
  defs.each do |definition|
580
580
  allow(definition).to(receive(:labels)).and_return([])
581
581
  allow(definition).to(receive(:<<)).and_return(definition)
@@ -585,7 +585,7 @@ RSpec.describe(DefMastership::Document) do
585
585
  context 'when no wrong explicit checksum' do
586
586
  before do
587
587
  defs.each { |definition| allow(definition).to(receive(:wrong_explicit_checksum)).and_return(nil) }
588
- document.parse(input_lines)
588
+ document.__send__(:do_parse, input_lines)
589
589
  document.wrong_explicit_checksum?
590
590
  end
591
591
 
@@ -598,7 +598,7 @@ RSpec.describe(DefMastership::Document) do
598
598
  before do
599
599
  allow(defs.first).to(receive(:wrong_explicit_checksum)).and_return('toto')
600
600
  allow(defs[1]).to(receive(:wrong_explicit_checksum)).and_return(nil)
601
- document.parse(input_lines)
601
+ document.__send__(:do_parse, input_lines)
602
602
  document.wrong_explicit_checksum?
603
603
  end
604
604
 
@@ -609,8 +609,8 @@ RSpec.describe(DefMastership::Document) do
609
609
  describe '#explicit_version?' do
610
610
  let(:defs) do
611
611
  [
612
- instance_double(DefMastership::Definition, 'definition'),
613
- instance_double(DefMastership::Definition, 'definition')
612
+ instance_double(Defmastership::Definition, 'definition'),
613
+ instance_double(Defmastership::Definition, 'definition')
614
614
  ]
615
615
  end
616
616
  let(:input_lines) do
@@ -624,7 +624,7 @@ RSpec.describe(DefMastership::Document) do
624
624
  end
625
625
 
626
626
  before do
627
- allow(DefMastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
627
+ allow(Defmastership::Definition).to(receive(:new).twice.and_return(defs.first, defs[1]))
628
628
  allow(defs.first).to(receive(:labels)).and_return([])
629
629
  allow(defs[1]).to(receive(:labels)).and_return([])
630
630
  allow(defs.first).to(receive(:<<).and_return(defs.first))
@@ -635,7 +635,7 @@ RSpec.describe(DefMastership::Document) do
635
635
  before do
636
636
  allow(defs.first).to(receive(:explicit_version)).and_return(nil)
637
637
  allow(defs[1]).to(receive(:explicit_version)).and_return(nil)
638
- document.parse(input_lines)
638
+ document.__send__(:do_parse, input_lines)
639
639
  document.explicit_version?
640
640
  end
641
641
 
@@ -648,7 +648,7 @@ RSpec.describe(DefMastership::Document) do
648
648
  before do
649
649
  allow(defs.first).to(receive(:explicit_version)).and_return('toto')
650
650
  allow(defs[1]).to(receive(:explicit_version)).and_return(nil)
651
- document.parse(input_lines)
651
+ document.__send__(:do_parse, input_lines)
652
652
  document.explicit_version?
653
653
  end
654
654
 
@@ -659,8 +659,8 @@ RSpec.describe(DefMastership::Document) do
659
659
  describe '#ref_to_def?' do
660
660
  let(:definitions) do
661
661
  [
662
- instance_double(DefMastership::Definition, 'def1'),
663
- instance_double(DefMastership::Definition, 'def2')
662
+ instance_double(Defmastership::Definition, 'def1'),
663
+ instance_double(Defmastership::Definition, 'def2')
664
664
  ]
665
665
  end
666
666
  let(:input_lines) do
@@ -674,7 +674,7 @@ RSpec.describe(DefMastership::Document) do
674
674
  end
675
675
 
676
676
  before do
677
- allow(DefMastership::Definition).to(receive(:new).twice.and_return(definitions.first, definitions[1]))
677
+ allow(Defmastership::Definition).to(receive(:new).twice.and_return(definitions.first, definitions[1]))
678
678
  allow(definitions.first).to(
679
679
  receive_messages(
680
680
  labels: [],
@@ -689,7 +689,7 @@ RSpec.describe(DefMastership::Document) do
689
689
  reference: 'TOTO-0002'
690
690
  )
691
691
  )
692
- document.parse(input_lines)
692
+ document.__send__(:do_parse, input_lines)
693
693
  end
694
694
 
695
695
  it { expect(document.ref_to_def('TOTO-0001')).to(eq(definitions.first)) }
@@ -1,13 +1,13 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('defmastership/csv_formatter_body')
4
+ require('defmastership/export/body_formatter')
5
5
 
6
- RSpec.describe(DefMastership::CSVFormatterBody) do
6
+ RSpec.describe(Defmastership::Export::BodyFormatter) do
7
7
  subject(:formatter) { described_class.new(document, definition) }
8
8
 
9
- let(:document) { instance_double(DefMastership::Document, 'document') }
10
- let(:definition) { instance_double(DefMastership::Definition, 'definition') }
9
+ let(:document) { instance_double(Defmastership::Document, 'document') }
10
+ let(:definition) { instance_double(Defmastership::Definition, 'definition') }
11
11
 
12
12
  describe '.new' do
13
13
  it { is_expected.not_to(be_nil) }
@@ -2,24 +2,24 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require('csv')
5
- require('defmastership/csv_formatter')
5
+ require('defmastership/export/csv/formatter')
6
6
  require('ostruct')
7
7
 
8
- RSpec.describe(DefMastership::CSVFormatter) do
8
+ RSpec.describe(Defmastership::Export::CSV::Formatter) do
9
9
  subject(:formatter) { described_class.new(document, ';') }
10
10
 
11
- let(:document) { instance_double(DefMastership::Document, 'document') }
11
+ let(:document) { instance_double(Defmastership::Document, 'document') }
12
12
 
13
13
  describe '.new' do
14
14
  it { is_expected.not_to(be_nil) }
15
15
  end
16
16
 
17
17
  describe '#export_to' do
18
- let(:header) { instance_double(DefMastership::CSVFormatterHeader, 'header') }
18
+ let(:header) { instance_double(Defmastership::Export::HeaderFormatter, 'header') }
19
19
  let(:bodies) do
20
20
  [
21
- instance_double(DefMastership::CSVFormatterBody, 'bodies[0]'),
22
- instance_double(DefMastership::CSVFormatterBody, 'bodies[1]')
21
+ instance_double(Defmastership::Export::BodyFormatter, 'bodies[0]'),
22
+ instance_double(Defmastership::Export::BodyFormatter, 'bodies[1]')
23
23
  ]
24
24
  end
25
25
  let(:csv) { instance_double(CSV, 'csv') }
@@ -27,9 +27,14 @@ RSpec.describe(DefMastership::CSVFormatter) do
27
27
  before do
28
28
  allow(CSV).to(receive(:open).with('whatever', 'w:ISO-8859-1', col_sep: ';').and_yield(csv))
29
29
  allow(csv).to(receive(:<<))
30
- allow(DefMastership::CSVFormatterHeader).to(receive(:new).with(document).and_return(header))
30
+ allow(Defmastership::Export::HeaderFormatter).to(receive(:new).with(document).and_return(header))
31
31
  bodies.each_with_index do |body, index|
32
- allow(DefMastership::CSVFormatterBody).to(receive(:new).with(document, :"def#{index}").and_return(body))
32
+ allow(Defmastership::Export::BodyFormatter).to(
33
+ receive(:new).with(
34
+ document,
35
+ :"def#{index}"
36
+ ).and_return(body)
37
+ )
33
38
  end
34
39
  allow(document).to(receive(:definitions).and_return(%i[def0 def1]))
35
40
  allow(document).to(receive(:wrong_explicit_checksum?).with(no_args).and_return(false))
@@ -1,12 +1,12 @@
1
1
  # Copyright (c) 2020 Jerome Arbez-Gindre
2
2
  # frozen_string_literal: true
3
3
 
4
- require('defmastership/csv_formatter_header')
4
+ require('defmastership/export/header_formatter')
5
5
 
6
- RSpec.describe(DefMastership::CSVFormatterHeader) do
6
+ RSpec.describe(Defmastership::Export::HeaderFormatter) do
7
7
  subject(:formatter) { described_class.new(document) }
8
8
 
9
- let(:document) { instance_double(DefMastership::Document, 'document') }
9
+ let(:document) { instance_double(Defmastership::Document, 'document') }
10
10
 
11
11
  describe '.new' do
12
12
  it { is_expected.not_to(be_nil) }
@@ -3,7 +3,7 @@
3
3
 
4
4
  require('defmastership/matching_line')
5
5
 
6
- RSpec.describe(DefMastership::MatchingLine) do
6
+ RSpec.describe(Defmastership::MatchingLine) do
7
7
  describe '.new' do
8
8
  subject(:matching_line) do
9
9
  described_class.new(:a_match, :a_line)